新建监控功能

This commit is contained in:
2026-04-23 11:09:06 +08:00
parent 7dee9092dc
commit 287de846a6
28 changed files with 6263 additions and 703 deletions

View File

@@ -0,0 +1,160 @@
<template>
<div class="icd-document-tree">
<el-tree
v-if="treeNodes.length"
:data="treeNodes"
node-key="key"
:indent="18"
:default-expanded-keys="defaultExpandedKeys"
:expand-on-click-node="false"
class="icd-tree"
>
<template #default="{ data }">
<div class="icd-tree-node">
<span class="icd-tree-node__label">{{ data.label }}</span>
<span v-if="data.value !== undefined" class="icd-tree-node__value">{{ data.value }}</span>
<span v-else class="icd-tree-node__summary">{{ data.summary }}</span>
</div>
</template>
</el-tree>
<div v-else class="icd-tree-empty">接口返回 `icdDocument` 会在这里以层级结构展示文档内容</div>
</div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import type { MmsMapping } from '@/api/tools/mmsmapping/interface'
defineOptions({
name: 'IcdDocumentTree'
})
interface DocumentTreeNode {
key: string
label: string
value?: string
summary?: string
children?: DocumentTreeNode[]
}
const props = defineProps<{
document: MmsMapping.IcdDocument | null
}>()
const treeNodes = computed<DocumentTreeNode[]>(() => {
if (!props.document) return []
return [buildTreeNode('icdDocument', props.document, 'icdDocument')]
})
const defaultExpandedKeys = computed(() => {
const rootNode = treeNodes.value[0]
if (!rootNode) return []
return [rootNode.key, ...(rootNode.children?.map(child => child.key) || [])]
})
// 业务展示要求:按接口原始层级渲染 icdDocument避免左侧信息再次退化成平铺文本。
const buildTreeNode = (label: string, source: unknown, path: string): DocumentTreeNode => {
if (Array.isArray(source)) {
return {
key: path,
label,
summary: `数组(${source.length})`,
children: source.map((item, index) => buildTreeNode(`[${index}]`, item, `${path}.${index}`))
}
}
if (source && typeof source === 'object') {
const entries = Object.entries(source as Record<string, unknown>).filter(([, value]) => value !== undefined)
return {
key: path,
label,
summary: `对象(${entries.length})`,
children: entries.map(([key, value]) => buildTreeNode(key, value, `${path}.${key}`))
}
}
return {
key: path,
label,
value: formatNodeValue(source)
}
}
const formatNodeValue = (source: unknown) => {
if (source === null) return 'null'
if (typeof source === 'string') return source || '""'
return String(source)
}
</script>
<style scoped lang="scss">
.icd-document-tree {
min-height: 100%;
}
.icd-tree {
padding: 4px 0;
background: transparent;
}
.icd-tree-node {
display: flex;
flex-wrap: wrap;
gap: 8px;
align-items: center;
min-width: 0;
padding: 2px 0;
line-height: 1.7;
}
.icd-tree-node__label {
font-size: 13px;
font-weight: 600;
color: #172033;
word-break: break-word;
}
.icd-tree-node__summary,
.icd-tree-node__value {
font-size: 13px;
color: #4b5563;
word-break: break-word;
}
.icd-tree-node__value {
padding: 2px 8px;
border-radius: 999px;
background: #f1f5f9;
font-family: Consolas, 'Courier New', monospace;
}
.icd-tree-empty {
font-size: 14px;
line-height: 1.7;
color: #64748b;
}
:deep(.icd-tree .el-tree-node__content) {
min-height: 32px;
height: auto;
padding: 4px 0;
align-items: flex-start;
background: transparent;
}
:deep(.icd-tree .el-tree-node__expand-icon) {
margin-top: 7px;
color: #64748b;
}
:deep(.icd-tree .el-tree-node:focus > .el-tree-node__content),
:deep(.icd-tree .el-tree-node__content:hover) {
background: #eef6ff;
}
:deep(.icd-tree .el-tree-node__children) {
overflow: visible;
}
</style>

View File

@@ -0,0 +1,160 @@
<template>
<section class="mapping-panel config-panel">
<div class="panel-header">
<div>
<h2 class="panel-title">请求配置</h2>
<p class="panel-description">这里直接编辑 request.indexSelection默认值会在选择 ICD 文件后自动生成</p>
</div>
<el-button
v-if="showGenerateButton"
type="primary"
:icon="Connection"
:loading="isSubmitting"
:disabled="!canGenerate"
@click="emit('generate')"
>
生成映射
</el-button>
</div>
<div class="panel-content">
<div class="panel-section result-card">
<el-alert v-if="jsonError" :title="jsonError" type="error" :closable="false" class="json-alert" />
<el-input
type="textarea"
class="index-selection-textarea"
:model-value="indexSelectionJson"
:disabled="isSubmitting"
:rows="18"
resize="none"
placeholder="ICD 解析完成后,这里会自动填充 request.indexSelection可继续直接编辑。"
@update:model-value="value => emit('update:indexSelectionJson', String(value || ''))"
/>
</div>
<el-empty v-if="!hasDefaultJson" :description="emptyDescription" />
</div>
</section>
</template>
<script setup lang="ts">
import { Connection } from '@element-plus/icons-vue'
defineOptions({
name: 'MappingConfigPanel'
})
defineProps<{
indexSelectionJson: string
isSubmitting: boolean
canGenerate: boolean
jsonError: string
showGenerateButton: boolean
hasDefaultJson: boolean
emptyDescription: string
}>()
const emit = defineEmits<{
(event: 'update:indexSelectionJson', value: string): void
(event: 'generate'): void
}>()
</script>
<style scoped lang="scss">
.mapping-panel {
display: flex;
flex-direction: column;
gap: 16px;
min-height: 0;
padding: 24px;
border: 1px solid #e5e7eb;
border-radius: 12px;
background: #ffffff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
overflow: hidden;
}
.config-panel {
min-height: 0;
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.panel-title {
margin: 0;
font-size: 22px;
font-weight: 600;
line-height: 1.4;
color: #1f2937;
}
.panel-description {
margin: 8px 0 0;
font-size: 14px;
line-height: 1.7;
color: #4b5563;
}
.panel-content {
display: flex;
flex: 1;
flex-direction: column;
gap: 16px;
min-height: 0;
overflow: hidden;
}
.panel-section {
border: 1px solid #e5e7eb;
border-radius: 12px;
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.result-card {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
padding: 16px;
overflow: hidden;
}
.index-selection-textarea {
flex: 1;
min-height: 0;
margin-top: 16px;
}
.index-selection-textarea :deep(.el-textarea) {
width: 100%;
height: 100%;
}
.index-selection-textarea :deep(.el-textarea__inner) {
height: 100%;
font-family: Consolas, 'Courier New', monospace;
line-height: 1.6;
overflow-y: auto;
}
.json-alert {
margin: 16px 0 0;
}
@media (max-width: 768px) {
.mapping-panel {
padding: 20px;
}
.panel-header {
flex-direction: column;
align-items: flex-start;
}
}
</style>

View File

@@ -0,0 +1,173 @@
<template>
<section class="mapping-panel">
<div class="panel-header">
<div>
<h2 class="panel-title">ICD 解析</h2>
<p class="panel-description">选择 ICD 文件后仅保存当前文件点击解析 ICD后才会向后台请求候选数据</p>
</div>
<el-tag :type="requestStatusTagType" effect="light">{{ requestStatusText }}</el-tag>
</div>
<div class="panel-content">
<div class="panel-section file-action-row">
<div class="file-select-row">
<el-input
:model-value="selectedIcdFileName"
readonly
placeholder="请选择 `.icd`、`.cid`、`.scd` 或 `.xml` 文件"
class="file-input"
/>
<el-button type="primary" :icon="FolderOpened" :loading="isSubmitting" @click="openIcdFilePicker">
选择 ICD
</el-button>
<input
ref="icdFileInputRef"
class="hidden-file-input"
type="file"
:accept="icdFileAccept"
@change="event => emit('file-change', event)"
/>
</div>
<el-button
type="primary"
plain
:icon="Search"
:loading="isSubmitting"
:disabled="!selectedIcdFileName"
@click="emit('parse')"
>
解析 ICD
</el-button>
<el-button :icon="Delete" :disabled="!canReset" @click="emit('reset')">清空</el-button>
</div>
</div>
</section>
</template>
<script setup lang="ts">
import { Delete, FolderOpened, Search } from '@element-plus/icons-vue'
import { ref } from 'vue'
defineOptions({
name: 'MappingRequestPanel'
})
type TagType = 'success' | 'warning' | 'info' | 'primary' | 'danger'
defineProps<{
selectedIcdFileName: string
isSubmitting: boolean
icdFileAccept: string
requestStatusText: string
requestStatusTagType: TagType
canReset: boolean
}>()
const emit = defineEmits<{
(event: 'file-change', value: Event): void
(event: 'parse'): void
(event: 'reset'): void
}>()
const icdFileInputRef = ref<HTMLInputElement | null>(null)
const openIcdFilePicker = () => {
icdFileInputRef.value?.click()
}
</script>
<style scoped lang="scss">
.mapping-panel {
display: flex;
flex-direction: column;
gap: 16px;
min-height: 0;
padding: 24px;
border: 1px solid #e5e7eb;
border-radius: 12px;
background: #ffffff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
overflow: hidden;
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.panel-title {
margin: 0;
font-size: 22px;
font-weight: 600;
line-height: 1.4;
color: #1f2937;
}
.panel-description {
margin: 8px 0 0;
font-size: 14px;
line-height: 1.7;
color: #4b5563;
}
.panel-content {
display: flex;
flex: 1;
flex-direction: column;
gap: 16px;
min-height: 0;
}
.panel-section {
border: 1px solid #e5e7eb;
border-radius: 12px;
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.file-action-row {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 12px;
padding: 16px;
}
.file-select-row {
display: flex;
gap: 12px;
align-items: center;
min-width: 0;
flex: 1;
}
.file-input {
width: 360px;
max-width: 100%;
}
.hidden-file-input {
display: none;
}
@media (max-width: 768px) {
.mapping-panel {
padding: 20px;
}
.panel-header {
flex-direction: column;
align-items: flex-start;
}
.file-select-row {
width: 100%;
}
.file-input {
width: 100%;
max-width: none;
}
}
</style>

View File

@@ -0,0 +1,282 @@
<template>
<section class="mapping-panel">
<div class="panel-header">
<div>
<h2 class="panel-title">调试输出</h2>
<p class="panel-description">右侧展示最近一次接口返回的 mappingJson problems并支持导出当前映射摘要</p>
</div>
<div class="panel-actions">
<el-button plain :icon="Download" :disabled="!canExportMapping" @click="emit('export-mapping')">
导出映射文件
</el-button>
<el-tag :type="responseStatusTagType" effect="light">{{ responseStatusText }}</el-tag>
</div>
</div>
<div class="panel-content panel-content--fixed">
<div class="panel-section result-card grow-card preview-tab-section">
<el-tabs v-model="activeTabProxy" class="preview-tabs">
<el-tab-pane label="映射摘要" name="mapping">
<div class="preview-header preview-header--compact">
<div class="preview-meta">{{ mappingMetaText }}</div>
</div>
<div class="mapping-json-scroll">
<pre v-if="mappingJsonPreview" class="mapping-json-text">{{ mappingJsonPreview }}</pre>
<el-empty v-else description="当前返回未包含 mappingJson" />
</div>
</el-tab-pane>
<el-tab-pane :label="problemTabLabel" name="problem">
<div class="problem-section">
<div v-if="problemList.length" class="problem-list">
<div v-for="(problem, index) in problemList" :key="`${index}-${problem}`" class="problem-item">
<span class="problem-index">{{ index + 1 }}</span>
<span class="problem-text">{{ problem }}</span>
</div>
</div>
<el-empty v-else :description="problemEmptyText" />
</div>
</el-tab-pane>
</el-tabs>
</div>
</div>
</section>
</template>
<script setup lang="ts">
import { Download } from '@element-plus/icons-vue'
import { computed } from 'vue'
defineOptions({
name: 'MappingResultPanel'
})
type TagType = 'success' | 'warning' | 'info' | 'primary' | 'danger'
const props = defineProps<{
responseStatusText: string
responseStatusTagType: TagType
activeResultTab: 'mapping' | 'problem'
mappingMetaText: string
mappingJsonPreview: string
problemTabLabel: string
problemList: string[]
problemEmptyText: string
canExportMapping: boolean
}>()
const emit = defineEmits<{
(event: 'update:activeResultTab', value: 'mapping' | 'problem'): void
(event: 'export-mapping'): void
}>()
const activeTabProxy = computed({
get: () => props.activeResultTab,
set: value => emit('update:activeResultTab', value)
})
</script>
<style scoped lang="scss">
.mapping-panel {
display: flex;
flex-direction: column;
gap: 16px;
min-height: 0;
padding: 24px;
border: 1px solid #e5e7eb;
border-radius: 12px;
background: #ffffff;
box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
overflow: hidden;
}
.panel-header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 16px;
}
.panel-actions {
display: flex;
align-items: center;
gap: 12px;
}
.panel-title {
margin: 0;
font-size: 22px;
font-weight: 600;
line-height: 1.4;
color: #1f2937;
}
.panel-description {
margin: 8px 0 0;
font-size: 14px;
line-height: 1.7;
color: #4b5563;
}
.panel-content {
display: flex;
flex: 1;
flex-direction: column;
gap: 16px;
min-height: 0;
overflow: auto;
}
.panel-content--fixed {
overflow: hidden;
}
.panel-section {
border: 1px solid #e5e7eb;
border-radius: 12px;
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
}
.result-card {
padding: 16px;
}
.grow-card {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
}
.preview-tab-section {
overflow: hidden;
}
.preview-tabs {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
}
.preview-tabs :deep(.el-tabs__header) {
margin-bottom: 16px;
}
.preview-tabs :deep(.el-tabs__nav-wrap::after) {
background-color: #e5e7eb;
}
.preview-tabs :deep(.el-tabs__item) {
height: 36px;
font-size: 15px;
font-weight: 600;
color: #4b5563;
}
.preview-tabs :deep(.el-tabs__item.is-active) {
color: #2563eb;
}
.preview-tabs :deep(.el-tabs__content) {
flex: 1;
min-height: 0;
}
.preview-tabs :deep(.el-tab-pane) {
display: flex;
flex-direction: column;
height: 100%;
min-height: 0;
}
.preview-header {
display: flex;
align-items: center;
justify-content: space-between;
gap: 16px;
margin-bottom: 16px;
}
.preview-header--compact {
margin-bottom: 12px;
}
.preview-meta {
font-size: 13px;
color: #64748b;
}
.mapping-json-scroll,
.problem-section {
display: flex;
flex: 1;
flex-direction: column;
min-height: 0;
overflow: auto;
}
.mapping-json-text {
margin: 0;
padding: 16px;
border: 1px solid #dbe3f0;
border-radius: 10px;
background: #ffffff;
font-family: Consolas, 'Courier New', monospace;
font-size: 13px;
line-height: 1.7;
color: #172033;
white-space: pre-wrap;
word-break: break-word;
}
.problem-list {
display: flex;
flex-direction: column;
gap: 12px;
}
.problem-item {
display: flex;
align-items: flex-start;
gap: 12px;
padding: 14px 16px;
border: 1px solid #f3d19e;
border-radius: 10px;
background: #fff7ed;
}
.problem-index {
display: inline-flex;
align-items: center;
justify-content: center;
flex: 0 0 24px;
width: 24px;
height: 24px;
border-radius: 999px;
background: #f97316;
font-size: 12px;
font-weight: 600;
color: #ffffff;
}
.problem-text {
flex: 1;
font-size: 14px;
line-height: 1.7;
color: #7c2d12;
word-break: break-word;
}
@media (max-width: 768px) {
.mapping-panel {
padding: 20px;
}
.panel-header,
.panel-actions,
.preview-header {
flex-direction: column;
align-items: flex-start;
}
}
</style>