feat(mmsmapping): 添加ICD索引配置人工确认功能
- 新增IndexConfirmTarget、IndexConfirmLabelItem、IndexConfirmGroup等接口定义 - 添加buildIndexConfirmDataApi和buildIndexSelectionApi两个API方法 - 实现MappingConfirmDialog组件用于人工确认索引配置 - 将解析ICD流程分为候选数据获取和人工确认两个步骤 - 添加确认弹窗的验证逻辑和状态管理 - 更新页面重置逻辑以清除确认相关状态 - 修改请求配置面板显示确认按钮和相应操作 - 移除原有的自动生成默认索引选择的工具函数
This commit is contained in:
@@ -29,3 +29,13 @@ export const getIcdMmsJsonApi = (params: MmsMapping.GetIcdMmsJsonParams) => {
|
||||
headers: { 'Content-Type': 'multipart/form-data' }
|
||||
})
|
||||
}
|
||||
|
||||
export const buildIndexConfirmDataApi = (params: MmsMapping.IndexCandidateGroup[]) => {
|
||||
// 关键业务节点:ICD 候选数据需要先转换成前端确认弹窗模型,后续人工确认才能继续生成正式索引配置。
|
||||
return http.post<MmsMapping.IndexConfirmGroup[]>('/api/mms-mapping/build-index-confirm-data', params)
|
||||
}
|
||||
|
||||
export const buildIndexSelectionApi = (params: MmsMapping.BuildIndexSelectionRequest) => {
|
||||
// 关键业务节点:人工确认完成后,必须把 confirmData 和 confirmedData 一并提交给后端生成正式 request.indexSelection。
|
||||
return http.post<MmsMapping.IndexSelectionGroup[]>('/api/mms-mapping/build-index-selection', params)
|
||||
}
|
||||
|
||||
@@ -3,6 +3,39 @@ export namespace MmsMapping {
|
||||
icdFile: File
|
||||
}
|
||||
|
||||
export interface IndexConfirmTarget {
|
||||
reportName?: string
|
||||
dataSetName?: string
|
||||
reportDesc?: string
|
||||
availableLnInstValues?: string[]
|
||||
}
|
||||
|
||||
export interface IndexConfirmLabelItem {
|
||||
label?: string
|
||||
required?: boolean
|
||||
configurableOnce?: boolean
|
||||
defaultLnInst?: string
|
||||
commonLnInstValues?: string[]
|
||||
targets?: IndexConfirmTarget[]
|
||||
}
|
||||
|
||||
export interface IndexConfirmGroup {
|
||||
groupKey?: string
|
||||
groupDesc?: string
|
||||
labelItems?: IndexConfirmLabelItem[]
|
||||
}
|
||||
|
||||
export interface ConfirmedIndexLabelItem {
|
||||
label: string
|
||||
enabled: boolean
|
||||
lnInst: string
|
||||
}
|
||||
|
||||
export interface ConfirmedIndexGroup {
|
||||
groupKey: string
|
||||
labelItems: ConfirmedIndexLabelItem[]
|
||||
}
|
||||
|
||||
export interface IndexSelectionBinding {
|
||||
reportName: string
|
||||
dataSetName: string
|
||||
@@ -30,6 +63,11 @@ export namespace MmsMapping {
|
||||
request: GetIcdMmsJsonRequestPayload
|
||||
}
|
||||
|
||||
export interface BuildIndexSelectionRequest {
|
||||
confirmData: IndexConfirmGroup[]
|
||||
confirmedData: ConfirmedIndexGroup[]
|
||||
}
|
||||
|
||||
export interface IcdDocument {
|
||||
[key: string]: unknown
|
||||
}
|
||||
|
||||
@@ -0,0 +1,533 @@
|
||||
<template>
|
||||
<el-dialog
|
||||
:model-value="visible"
|
||||
title="人工确认索引配置"
|
||||
width="960px"
|
||||
destroy-on-close
|
||||
top="6vh"
|
||||
class="mapping-confirm-dialog"
|
||||
@close="emit('update:visible', false)"
|
||||
>
|
||||
<div class="dialog-description">
|
||||
这里展示 ICD 候选索引的人工确认结果。请按分组确认每个标签是否启用,并为已启用标签选择合法的
|
||||
lnInst,确认后会自动回填到 request.indexSelection。
|
||||
</div>
|
||||
|
||||
<el-empty v-if="!draftGroups.length" description="当前没有可确认的索引分组。" />
|
||||
|
||||
<div v-else class="dialog-content">
|
||||
<section v-for="group in draftGroups" :key="group.groupKey" class="group-card">
|
||||
<div class="group-header">
|
||||
<div>
|
||||
<h3 class="group-title">{{ group.groupDesc || group.groupKey }}</h3>
|
||||
<p class="group-key">{{ group.groupKey }}</p>
|
||||
</div>
|
||||
<el-tag type="info" effect="light">{{ group.labelItems.length }} 个标签</el-tag>
|
||||
</div>
|
||||
|
||||
<div class="label-list">
|
||||
<article v-for="item in group.labelItems" :key="`${group.groupKey}-${item.label}`" class="label-card">
|
||||
<div class="label-main">
|
||||
<div class="label-meta">
|
||||
<div class="label-title-row">
|
||||
<span class="label-title">{{ item.label }}</span>
|
||||
<el-tag v-if="item.required" type="danger" effect="light" size="small">必选</el-tag>
|
||||
<el-tag v-if="item.configurableOnce" type="success" effect="light" size="small">
|
||||
共享 lnInst
|
||||
</el-tag>
|
||||
</div>
|
||||
<div class="label-options">
|
||||
<span class="label-hint">共同可选值</span>
|
||||
<template v-if="item.commonLnInstValues.length">
|
||||
<el-tag
|
||||
v-for="value in item.commonLnInstValues"
|
||||
:key="`${item.label}-${value}`"
|
||||
size="small"
|
||||
effect="plain"
|
||||
>
|
||||
{{ value }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<span v-else class="label-hint">当前没有共同 lnInst</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="label-actions">
|
||||
<el-switch
|
||||
v-model="item.enabled"
|
||||
:disabled="item.required"
|
||||
inline-prompt
|
||||
active-text="启用"
|
||||
inactive-text="停用"
|
||||
/>
|
||||
<el-select
|
||||
v-model="item.lnInst"
|
||||
class="lninst-select"
|
||||
placeholder="请选择 lnInst"
|
||||
clearable
|
||||
:disabled="!item.enabled || !item.commonLnInstValues.length"
|
||||
>
|
||||
<el-option
|
||||
v-for="value in item.commonLnInstValues"
|
||||
:key="`${item.label}-option-${value}`"
|
||||
:label="value"
|
||||
:value="value"
|
||||
/>
|
||||
</el-select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<el-alert
|
||||
v-if="item.enabled && !item.lnInst"
|
||||
title="已启用的标签必须选择 lnInst"
|
||||
type="warning"
|
||||
:closable="false"
|
||||
class="label-alert"
|
||||
/>
|
||||
|
||||
<div class="target-list">
|
||||
<div v-for="target in item.targets" :key="`${target.reportName}-${target.dataSetName}`" class="target-item">
|
||||
<div class="target-name-row">
|
||||
<span class="target-name">{{ target.reportDesc || target.reportName || '--' }}</span>
|
||||
<span class="target-code">{{ target.reportName || '--' }} / {{ target.dataSetName || '--' }}</span>
|
||||
</div>
|
||||
<div class="target-lninst-row">
|
||||
<span class="label-hint">目标报告可选值</span>
|
||||
<template v-if="target.availableLnInstValues.length">
|
||||
<el-tag
|
||||
v-for="value in target.availableLnInstValues"
|
||||
:key="`${target.reportName}-${target.dataSetName}-${value}`"
|
||||
size="small"
|
||||
effect="plain"
|
||||
>
|
||||
{{ value }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<span v-else class="label-hint">当前没有可用 lnInst</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<div v-if="validationMessage" class="footer-message">{{ validationMessage }}</div>
|
||||
<div class="footer-actions">
|
||||
<el-button :disabled="submitting" @click="emit('update:visible', false)">取消</el-button>
|
||||
<el-button type="primary" :loading="submitting" :disabled="Boolean(validationMessage)" @click="handleConfirm">
|
||||
确认并生成索引配置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue'
|
||||
import type { MmsMapping } from '@/api/tools/mmsmapping/interface'
|
||||
|
||||
defineOptions({
|
||||
name: 'MappingConfirmDialog'
|
||||
})
|
||||
|
||||
interface ConfirmDialogDraftTarget {
|
||||
reportName: string
|
||||
dataSetName: string
|
||||
reportDesc: string
|
||||
availableLnInstValues: string[]
|
||||
}
|
||||
|
||||
interface ConfirmDialogDraftLabelItem {
|
||||
label: string
|
||||
required: boolean
|
||||
configurableOnce: boolean
|
||||
enabled: boolean
|
||||
lnInst: string
|
||||
commonLnInstValues: string[]
|
||||
targets: ConfirmDialogDraftTarget[]
|
||||
}
|
||||
|
||||
interface ConfirmDialogDraftGroup {
|
||||
groupKey: string
|
||||
groupDesc: string
|
||||
labelItems: ConfirmDialogDraftLabelItem[]
|
||||
}
|
||||
|
||||
interface PreparedConfirmDialogDraftLabelItem {
|
||||
label: string
|
||||
required: boolean
|
||||
configurableOnce: boolean
|
||||
commonLnInstValues: string[]
|
||||
targets: ConfirmDialogDraftTarget[]
|
||||
}
|
||||
|
||||
const props = defineProps<{
|
||||
visible: boolean
|
||||
submitting: boolean
|
||||
confirmData: MmsMapping.IndexConfirmGroup[]
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:visible', value: boolean): void
|
||||
(event: 'confirm', value: MmsMapping.ConfirmedIndexGroup[]): void
|
||||
}>()
|
||||
|
||||
const normalizeStringArray = (values?: string[]) => (values || []).map(value => value?.trim() || '').filter(Boolean)
|
||||
|
||||
const sortLnInstValues = (values: string[]) =>
|
||||
[...values].sort((left, right) => {
|
||||
const leftNumber = Number(left)
|
||||
const rightNumber = Number(right)
|
||||
const bothNumeric = !Number.isNaN(leftNumber) && !Number.isNaN(rightNumber)
|
||||
|
||||
if (bothNumeric && leftNumber !== rightNumber) {
|
||||
return leftNumber - rightNumber
|
||||
}
|
||||
|
||||
return left.localeCompare(right, 'zh-CN', { numeric: true })
|
||||
})
|
||||
|
||||
const buildLnInstCluster = (items: PreparedConfirmDialogDraftLabelItem[]) => {
|
||||
const clusters: PreparedConfirmDialogDraftLabelItem[][] = []
|
||||
|
||||
items.forEach(item => {
|
||||
const itemValueSet = new Set(item.commonLnInstValues)
|
||||
const matchedCluster = clusters.find(cluster =>
|
||||
cluster.some(clusterItem => clusterItem.commonLnInstValues.some(value => itemValueSet.has(value)))
|
||||
)
|
||||
|
||||
if (matchedCluster) {
|
||||
matchedCluster.push(item)
|
||||
return
|
||||
}
|
||||
|
||||
clusters.push([item])
|
||||
})
|
||||
|
||||
return clusters
|
||||
}
|
||||
|
||||
const resolveDefaultLnInst = (commonLnInstValues: string[], expectedLnInst: string) => {
|
||||
if (!commonLnInstValues.length) return ''
|
||||
if (!expectedLnInst) return ''
|
||||
if (!commonLnInstValues.includes(expectedLnInst)) return ''
|
||||
return expectedLnInst
|
||||
}
|
||||
|
||||
const buildInitialDraftGroups = (groups: MmsMapping.IndexConfirmGroup[]): ConfirmDialogDraftGroup[] =>
|
||||
groups
|
||||
.map(group => {
|
||||
const preparedItems = (group.labelItems || [])
|
||||
.map<PreparedConfirmDialogDraftLabelItem | null>(item => {
|
||||
const commonLnInstValues = sortLnInstValues(normalizeStringArray(item.commonLnInstValues))
|
||||
|
||||
return {
|
||||
label: item.label?.trim() || '',
|
||||
required: Boolean(item.required),
|
||||
configurableOnce: Boolean(item.configurableOnce),
|
||||
commonLnInstValues,
|
||||
targets: (item.targets || []).map(target => ({
|
||||
reportName: target.reportName?.trim() || '',
|
||||
dataSetName: target.dataSetName?.trim() || '',
|
||||
reportDesc: target.reportDesc?.trim() || '',
|
||||
availableLnInstValues: sortLnInstValues(normalizeStringArray(target.availableLnInstValues))
|
||||
}))
|
||||
}
|
||||
})
|
||||
.filter((item): item is PreparedConfirmDialogDraftLabelItem => Boolean(item?.label))
|
||||
|
||||
const clusters = buildLnInstCluster(preparedItems)
|
||||
const defaultStateMap = new Map<
|
||||
string,
|
||||
{
|
||||
enabled: boolean
|
||||
lnInst: string
|
||||
}
|
||||
>()
|
||||
|
||||
clusters.forEach(cluster => {
|
||||
const clusterValues = sortLnInstValues(
|
||||
Array.from(new Set(cluster.flatMap(item => item.commonLnInstValues)))
|
||||
)
|
||||
|
||||
cluster.forEach((item, index) => {
|
||||
const expectedLnInst = index < clusterValues.length ? clusterValues[index] : ''
|
||||
const defaultLnInst = resolveDefaultLnInst(item.commonLnInstValues, expectedLnInst)
|
||||
const enabled = Boolean(defaultLnInst)
|
||||
|
||||
defaultStateMap.set(item.label, {
|
||||
enabled,
|
||||
lnInst: defaultLnInst
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
return {
|
||||
groupKey: group.groupKey?.trim() || '',
|
||||
groupDesc: group.groupDesc?.trim() || '',
|
||||
labelItems: preparedItems.map(item => {
|
||||
const defaultState = defaultStateMap.get(item.label) || {
|
||||
enabled: false,
|
||||
lnInst: ''
|
||||
}
|
||||
|
||||
return {
|
||||
label: item.label,
|
||||
required: item.required,
|
||||
configurableOnce: item.configurableOnce,
|
||||
enabled: defaultState.enabled,
|
||||
lnInst: defaultState.lnInst,
|
||||
commonLnInstValues: item.commonLnInstValues,
|
||||
targets: item.targets
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
.filter(group => group.groupKey)
|
||||
|
||||
const draftGroups = ref<ConfirmDialogDraftGroup[]>([])
|
||||
|
||||
watch(
|
||||
() => [props.confirmData, props.visible] as const,
|
||||
([confirmData, visible]) => {
|
||||
if (!visible) return
|
||||
// 关键业务节点:弹窗每次打开都基于最新 confirmData 重新生成草稿,避免不同 ICD 的确认状态串用。
|
||||
draftGroups.value = buildInitialDraftGroups(confirmData)
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
const validationMessage = computed(() => {
|
||||
for (const group of draftGroups.value) {
|
||||
for (const item of group.labelItems) {
|
||||
if (!item.enabled) continue
|
||||
if (!item.lnInst) return `分组“${group.groupDesc || group.groupKey}”中的标签“${item.label}”必须选择 lnInst`
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
})
|
||||
|
||||
const buildConfirmedGroups = (): MmsMapping.ConfirmedIndexGroup[] =>
|
||||
draftGroups.value.map(group => ({
|
||||
groupKey: group.groupKey,
|
||||
labelItems: group.labelItems.map(item => ({
|
||||
label: item.label,
|
||||
enabled: item.enabled,
|
||||
lnInst: item.enabled ? item.lnInst : ''
|
||||
}))
|
||||
}))
|
||||
|
||||
const handleConfirm = () => {
|
||||
if (validationMessage.value) return
|
||||
emit('confirm', buildConfirmedGroups())
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
.dialog-description {
|
||||
margin-bottom: 16px;
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
color: #4b5563;
|
||||
}
|
||||
|
||||
.dialog-content {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 16px;
|
||||
max-height: 68vh;
|
||||
padding-right: 4px;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.group-card {
|
||||
padding: 20px;
|
||||
border: 1px solid #dbe3f0;
|
||||
border-radius: 14px;
|
||||
background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
|
||||
}
|
||||
|
||||
.group-header {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.group-title {
|
||||
margin: 0;
|
||||
font-size: 18px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.group-key {
|
||||
margin: 6px 0 0;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: #64748b;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.label-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.label-card {
|
||||
padding: 16px;
|
||||
border: 1px solid #e5e7eb;
|
||||
border-radius: 12px;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.label-main {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.label-meta,
|
||||
.label-actions,
|
||||
.target-list {
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.label-meta {
|
||||
display: flex;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.label-title-row,
|
||||
.label-options,
|
||||
.target-lninst-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.label-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
line-height: 1.5;
|
||||
color: #111827;
|
||||
}
|
||||
|
||||
.label-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.lninst-select {
|
||||
width: 180px;
|
||||
}
|
||||
|
||||
.label-hint {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #64748b;
|
||||
}
|
||||
|
||||
.label-alert {
|
||||
margin-top: 12px;
|
||||
}
|
||||
|
||||
.target-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
margin-top: 16px;
|
||||
}
|
||||
|
||||
.target-item {
|
||||
padding: 12px;
|
||||
border-radius: 10px;
|
||||
background: #f8fafc;
|
||||
}
|
||||
|
||||
.target-name-row {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.target-name {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
line-height: 1.6;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.target-code {
|
||||
font-family: Consolas, 'Courier New', monospace;
|
||||
font-size: 12px;
|
||||
line-height: 1.6;
|
||||
color: #64748b;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.footer-message {
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
color: #d97706;
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.footer-actions {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.dialog-content {
|
||||
max-height: 62vh;
|
||||
}
|
||||
|
||||
.group-card,
|
||||
.label-card {
|
||||
padding: 14px;
|
||||
}
|
||||
|
||||
.group-header,
|
||||
.label-main,
|
||||
.dialog-footer {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.label-actions,
|
||||
.footer-actions {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.lninst-select {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -8,7 +8,7 @@
|
||||
:icd-file-accept="icdFileAccept"
|
||||
:request-status-text="requestStatusText"
|
||||
:request-status-tag-type="requestStatusTagType"
|
||||
:can-reset="Boolean(selectedIcdFile || responsePayload || indexSelectionJsonText.trim())"
|
||||
:can-reset="canResetPage"
|
||||
@file-change="handleIcdFileChange"
|
||||
@parse="handleParseIcd"
|
||||
@reset="resetPage"
|
||||
@@ -21,8 +21,12 @@
|
||||
:can-generate="canGenerate"
|
||||
:json-error="indexSelectionError"
|
||||
:show-generate-button="showGenerateButton"
|
||||
:show-confirm-button="Boolean(confirmData.length)"
|
||||
:confirm-button-text="indexSelectionJsonText.trim() ? '重新确认' : '人工确认'"
|
||||
:can-confirm="!isSubmitting"
|
||||
:has-default-json="Boolean(indexSelectionJsonText.trim())"
|
||||
:empty-description="configEmptyDescription"
|
||||
@confirm-config="confirmDialogVisible = true"
|
||||
@generate="handleGenerateMapping"
|
||||
/>
|
||||
</div>
|
||||
@@ -40,6 +44,14 @@
|
||||
@export-mapping="handleExportMapping"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<MappingConfirmDialog
|
||||
:visible="confirmDialogVisible"
|
||||
:submitting="isConfirmingSelection"
|
||||
:confirm-data="confirmData"
|
||||
@update:visible="confirmDialogVisible = $event"
|
||||
@confirm="handleConfirmIndexSelection"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -47,12 +59,18 @@
|
||||
import { computed, ref } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import type { ResultData } from '@/api/interface'
|
||||
import { getIcdApi, getIcdMmsJsonApi } from '@/api/tools/mmsmapping'
|
||||
import {
|
||||
buildIndexConfirmDataApi,
|
||||
buildIndexSelectionApi,
|
||||
getIcdApi,
|
||||
getIcdMmsJsonApi
|
||||
} from '@/api/tools/mmsmapping'
|
||||
import type { MmsMapping } from '@/api/tools/mmsmapping/interface'
|
||||
import MappingRequestPanel from './components/MappingRequestPanel.vue'
|
||||
import MappingResultPanel from './components/MappingResultPanel.vue'
|
||||
import MappingConfigPanel from './components/MappingConfigPanel.vue'
|
||||
import { buildDefaultIndexSelection, formatIndexSelectionJson, parseIndexSelectionJson } from './utils/indexSelection'
|
||||
import MappingConfirmDialog from './components/MappingConfirmDialog.vue'
|
||||
import { formatIndexSelectionJson, parseIndexSelectionJson } from './utils/indexSelection'
|
||||
import { createBaseRequestPayload } from './utils/requestPayload'
|
||||
|
||||
defineOptions({
|
||||
@@ -71,8 +89,11 @@ const selectedIcdFile = ref<File | null>(null)
|
||||
const responsePayload = ref<MmsMapping.MappingTaskResponse | null>(null)
|
||||
const activeResultTab = ref<ResultTab>('mapping')
|
||||
const parsedCandidates = ref<MmsMapping.IndexCandidateGroup[]>([])
|
||||
const confirmData = ref<MmsMapping.IndexConfirmGroup[]>([])
|
||||
const indexSelectionJsonText = ref('')
|
||||
const confirmDialogVisible = ref(false)
|
||||
const isParsing = ref(false)
|
||||
const isConfirmingSelection = ref(false)
|
||||
const isGenerating = ref(false)
|
||||
const icdFileAccept = '.icd,.cid,.scd,.xml'
|
||||
const problemEmptyText = '当前返回未包含 problems'
|
||||
@@ -86,7 +107,7 @@ function unwrapApiPayload<T>(response: ResultData<T> | T): T {
|
||||
}
|
||||
|
||||
const getErrorMessage = (error: unknown) => {
|
||||
if (error instanceof Error) return error.message
|
||||
if (error instanceof Error && error.message) return error.message
|
||||
return '接口调用失败,请检查后端服务和请求参数'
|
||||
}
|
||||
|
||||
@@ -100,7 +121,7 @@ const parsedIndexSelectionState = computed(() => {
|
||||
if (!source) {
|
||||
return {
|
||||
value: [] as MmsMapping.IndexSelectionGroup[],
|
||||
error: parsedCandidates.value.length ? 'request.indexSelection 不能为空' : ''
|
||||
error: ''
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,31 +138,45 @@ const parsedIndexSelectionState = computed(() => {
|
||||
}
|
||||
})
|
||||
|
||||
const isSubmitting = computed(() => isParsing.value || isGenerating.value)
|
||||
const isSubmitting = computed(() => isParsing.value || isConfirmingSelection.value || isGenerating.value)
|
||||
const canResetPage = computed(() =>
|
||||
Boolean(
|
||||
selectedIcdFile.value || responsePayload.value || confirmData.value.length || indexSelectionJsonText.value.trim()
|
||||
)
|
||||
)
|
||||
const indexSelectionError = computed(() => parsedIndexSelectionState.value.error)
|
||||
const canGenerate = computed(
|
||||
() => Boolean(selectedIcdFile.value && indexSelectionJsonText.value.trim() && !indexSelectionError.value)
|
||||
)
|
||||
// 关键业务节点:请求配置区只在用户已经选择 ICD 后展示,避免初始态暴露无效的 JSON 编辑区和按钮。
|
||||
// 关键业务节点:请求配置区只在用户已经选择 ICD 后展示,避免初始态暴露无效的请求编辑区。
|
||||
const showConfigPanel = computed(() => Boolean(selectedIcdFile.value))
|
||||
const showGenerateButton = computed(() => Boolean(selectedIcdFile.value))
|
||||
const selectedIcdFileName = computed(() => selectedIcdFile.value?.name || '')
|
||||
|
||||
const configEmptyDescription = computed(() => {
|
||||
if (isParsing.value) return '正在根据当前 ICD 生成 request.indexSelection,请稍候。'
|
||||
if (selectedIcdFile.value) return '已选择 ICD 文件,请先点击“解析 ICD”生成 request.indexSelection。'
|
||||
if (isParsing.value) return '正在获取 ICD 候选数据并准备人工确认,请稍候。'
|
||||
if (isConfirmingSelection.value) return '正在根据人工确认结果生成 request.indexSelection,请稍候。'
|
||||
if (confirmDialogVisible.value || confirmData.value.length) {
|
||||
return '请先在弹窗中完成人工确认,确认后会自动回填 request.indexSelection。'
|
||||
}
|
||||
if (selectedIcdFile.value) return '已选择 ICD 文件,请先点击“解析 ICD”进入人工确认流程。'
|
||||
return '当前 ICD 暂未生成可编辑的 request.indexSelection。'
|
||||
})
|
||||
const selectedIcdFileName = computed(() => selectedIcdFile.value?.name || '')
|
||||
|
||||
const requestStatusText = computed(() => {
|
||||
if (isParsing.value) return '解析中'
|
||||
if (isConfirmingSelection.value) return '确认中'
|
||||
if (isGenerating.value) return '生成中'
|
||||
if (selectedIcdFile.value && indexSelectionJsonText.value.trim()) return '已生成默认配置'
|
||||
if (confirmDialogVisible.value) return '待人工确认'
|
||||
if (selectedIcdFile.value && indexSelectionJsonText.value.trim()) return '已确认'
|
||||
if (selectedIcdFile.value && parsedCandidates.value.length) return '待确认'
|
||||
if (selectedIcdFile.value) return '待解析'
|
||||
return '未选择文件'
|
||||
})
|
||||
|
||||
const requestStatusTagType = computed<TagType>(() => {
|
||||
if (isParsing.value || isGenerating.value) return 'warning'
|
||||
if (isParsing.value || isConfirmingSelection.value || isGenerating.value) return 'warning'
|
||||
if (confirmDialogVisible.value) return 'primary'
|
||||
if (selectedIcdFile.value && indexSelectionJsonText.value.trim()) return 'success'
|
||||
if (selectedIcdFile.value) return 'primary'
|
||||
return 'info'
|
||||
@@ -191,7 +226,7 @@ const resolveResultTab = (payload: MmsMapping.MappingTaskResponse | null): Resul
|
||||
}
|
||||
|
||||
const stripProblemsFromIcdPayload = (payload: MmsMapping.MappingTaskResponse): MmsMapping.MappingTaskResponse => {
|
||||
// 关键业务节点:解析 ICD 只消费候选数据和文档结构,不把后端返回的 problems 绑定到结果区。
|
||||
// 关键业务节点:解析 ICD 阶段只消费候选数据和文档结构,不把后端问题列表直接绑定到结果区。
|
||||
const sanitizedPayload = { ...payload }
|
||||
|
||||
delete sanitizedPayload.problems
|
||||
@@ -202,7 +237,9 @@ const stripProblemsFromIcdPayload = (payload: MmsMapping.MappingTaskResponse): M
|
||||
const resetParsedState = () => {
|
||||
responsePayload.value = null
|
||||
parsedCandidates.value = []
|
||||
confirmData.value = []
|
||||
indexSelectionJsonText.value = ''
|
||||
confirmDialogVisible.value = false
|
||||
activeResultTab.value = 'mapping'
|
||||
}
|
||||
|
||||
@@ -217,7 +254,7 @@ const handleIcdFileChange = (event: Event) => {
|
||||
return
|
||||
}
|
||||
|
||||
// 关键业务节点:切换 ICD 文件后先只清空旧解析结果,等用户明确点击“解析 ICD”后再请求后台。
|
||||
// 关键业务节点:切换 ICD 文件后立即清空旧确认结果和旧请求配置,避免不同文件的索引配置串用。
|
||||
selectedIcdFile.value = file
|
||||
resetParsedState()
|
||||
input.value = ''
|
||||
@@ -231,9 +268,11 @@ const handleParseIcd = async () => {
|
||||
|
||||
isParsing.value = true
|
||||
responsePayload.value = null
|
||||
confirmDialogVisible.value = false
|
||||
confirmData.value = []
|
||||
indexSelectionJsonText.value = ''
|
||||
|
||||
try {
|
||||
// 关键业务节点:解析 ICD 时先走 get-icd,拿到当前文件的候选数据后再生成默认 request.indexSelection。
|
||||
const response = await getIcdApi({
|
||||
icdFile: selectedIcdFile.value
|
||||
})
|
||||
@@ -247,14 +286,26 @@ const handleParseIcd = async () => {
|
||||
|
||||
if (payload.status === 'FAILED') {
|
||||
parsedCandidates.value = []
|
||||
indexSelectionJsonText.value = ''
|
||||
ElMessage.error(payload.message || 'ICD 解析失败')
|
||||
return
|
||||
}
|
||||
|
||||
parsedCandidates.value = candidateGroups
|
||||
indexSelectionJsonText.value = formatIndexSelectionJson(buildDefaultIndexSelection(candidateGroups))
|
||||
ElMessage.success(payload.message || 'ICD 解析完成,已生成 request.indexSelection')
|
||||
|
||||
// 关键业务节点:拿到 ICD 候选结果后必须先走 buildIndexConfirmData,生成人工确认弹窗所需模型。
|
||||
const confirmResponse = await buildIndexConfirmDataApi(candidateGroups)
|
||||
const confirmGroups = unwrapApiPayload<MmsMapping.IndexConfirmGroup[]>(confirmResponse) || []
|
||||
|
||||
confirmData.value = confirmGroups
|
||||
|
||||
if (!confirmGroups.length) {
|
||||
indexSelectionJsonText.value = formatIndexSelectionJson([])
|
||||
ElMessage.success(payload.message || 'ICD 解析完成,当前没有待确认的索引配置')
|
||||
return
|
||||
}
|
||||
|
||||
confirmDialogVisible.value = true
|
||||
ElMessage.success(payload.message || 'ICD 解析完成,请在弹窗中完成人工确认')
|
||||
} catch (error) {
|
||||
resetParsedState()
|
||||
ElMessage.error(getErrorMessage(error))
|
||||
@@ -263,6 +314,32 @@ const handleParseIcd = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
const handleConfirmIndexSelection = async (confirmedData: MmsMapping.ConfirmedIndexGroup[]) => {
|
||||
if (!confirmData.value.length) {
|
||||
ElMessage.warning('当前没有可确认的索引配置')
|
||||
return
|
||||
}
|
||||
|
||||
isConfirmingSelection.value = true
|
||||
|
||||
try {
|
||||
const response = await buildIndexSelectionApi({
|
||||
confirmData: confirmData.value,
|
||||
confirmedData
|
||||
})
|
||||
const indexSelection = unwrapApiPayload<MmsMapping.IndexSelectionGroup[]>(response) || []
|
||||
|
||||
// 关键业务节点:只有 buildIndexSelection 返回的正式结果才能进入请求配置区,避免前端自行拼装绑定关系。
|
||||
indexSelectionJsonText.value = formatIndexSelectionJson(indexSelection)
|
||||
confirmDialogVisible.value = false
|
||||
ElMessage.success('人工确认完成,已回填 request.indexSelection')
|
||||
} catch (error) {
|
||||
ElMessage.error(getErrorMessage(error))
|
||||
} finally {
|
||||
isConfirmingSelection.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleGenerateMapping = async () => {
|
||||
if (!selectedIcdFile.value) {
|
||||
ElMessage.warning('请先选择 ICD 文件')
|
||||
@@ -270,7 +347,12 @@ const handleGenerateMapping = async () => {
|
||||
}
|
||||
|
||||
if (!indexSelectionJsonText.value.trim()) {
|
||||
ElMessage.warning('请先解析 ICD,系统会自动生成 request.indexSelection')
|
||||
if (confirmData.value.length) {
|
||||
ElMessage.warning('请先完成人工确认并生成 request.indexSelection')
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.warning('请先解析 ICD,并在弹窗中完成人工确认')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -290,7 +372,7 @@ const handleGenerateMapping = async () => {
|
||||
responsePayload.value = null
|
||||
|
||||
try {
|
||||
// 关键业务节点:正式生成阶段只消费当前编辑区里的 request.indexSelection,确保导出的映射与页面编辑态一致。
|
||||
// 关键业务节点:正式生成阶段只消费当前请求配置区里的 request.indexSelection,确保导出的映射与最终确认结果一致。
|
||||
const response = await getIcdMmsJsonApi({
|
||||
icdFile: selectedIcdFile.value,
|
||||
request: {
|
||||
|
||||
@@ -3,18 +3,29 @@
|
||||
<div class="panel-header">
|
||||
<div>
|
||||
<h2 class="panel-title">请求配置</h2>
|
||||
<p class="panel-description">这里直接编辑 request.indexSelection,默认值会在选择 ICD 文件后自动生成。</p>
|
||||
<p class="panel-description">这里展示并可继续编辑经人工确认后生成的 request.indexSelection。</p>
|
||||
</div>
|
||||
<div class="panel-actions">
|
||||
<el-button
|
||||
v-if="showConfirmButton"
|
||||
type="primary"
|
||||
plain
|
||||
:disabled="!canConfirm"
|
||||
@click="emit('confirm-config')"
|
||||
>
|
||||
{{ confirmButtonText }}
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="showGenerateButton"
|
||||
type="primary"
|
||||
:icon="Connection"
|
||||
:loading="isSubmitting"
|
||||
:disabled="!canGenerate"
|
||||
@click="emit('generate')"
|
||||
>
|
||||
生成映射
|
||||
</el-button>
|
||||
</div>
|
||||
<el-button
|
||||
v-if="showGenerateButton"
|
||||
type="primary"
|
||||
:icon="Connection"
|
||||
:loading="isSubmitting"
|
||||
:disabled="!canGenerate"
|
||||
@click="emit('generate')"
|
||||
>
|
||||
生成映射
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<div class="panel-content">
|
||||
@@ -28,7 +39,7 @@
|
||||
:disabled="isSubmitting"
|
||||
:rows="18"
|
||||
resize="none"
|
||||
placeholder="ICD 解析完成后,这里会自动填充 request.indexSelection,可继续直接编辑。"
|
||||
placeholder="人工确认完成后,这里会自动回填 request.indexSelection,仍可继续直接编辑。"
|
||||
@update:model-value="value => emit('update:indexSelectionJson', String(value || ''))"
|
||||
/>
|
||||
</div>
|
||||
@@ -51,12 +62,16 @@ defineProps<{
|
||||
canGenerate: boolean
|
||||
jsonError: string
|
||||
showGenerateButton: boolean
|
||||
showConfirmButton: boolean
|
||||
confirmButtonText: string
|
||||
canConfirm: boolean
|
||||
hasDefaultJson: boolean
|
||||
emptyDescription: string
|
||||
}>()
|
||||
|
||||
const emit = defineEmits<{
|
||||
(event: 'update:indexSelectionJson', value: string): void
|
||||
(event: 'confirm-config'): void
|
||||
(event: 'generate'): void
|
||||
}>()
|
||||
</script>
|
||||
@@ -86,6 +101,12 @@ const emit = defineEmits<{
|
||||
gap: 16px;
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 12px;
|
||||
}
|
||||
|
||||
.panel-title {
|
||||
margin: 0;
|
||||
font-size: 22px;
|
||||
@@ -156,5 +177,9 @@ const emit = defineEmits<{
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -44,32 +44,6 @@ const normalizeBindings = (value: unknown, groupIndex: number): MmsMapping.Index
|
||||
})
|
||||
}
|
||||
|
||||
export const buildDefaultIndexSelection = (
|
||||
candidateGroups: MmsMapping.IndexCandidateGroup[]
|
||||
): MmsMapping.IndexSelectionGroup[] =>
|
||||
candidateGroups
|
||||
.filter(candidate => candidate.groupKey?.trim())
|
||||
.map(candidate => {
|
||||
const defaultReport = (candidate.reports || []).find(
|
||||
report => report.reportName?.trim() && report.dataSetName?.trim()
|
||||
)
|
||||
const defaultLnInst = (defaultReport?.availableLnInstValues || []).find(item => item?.trim())?.trim() || ''
|
||||
|
||||
return {
|
||||
groupKey: candidate.groupKey!.trim(),
|
||||
groupDesc: candidate.groupDesc?.trim() || '',
|
||||
bindings: (candidate.templateLabels || [])
|
||||
.map(label => label?.trim() || '')
|
||||
.filter(Boolean)
|
||||
.map(label => ({
|
||||
reportName: defaultReport?.reportName?.trim() || '',
|
||||
dataSetName: defaultReport?.dataSetName?.trim() || '',
|
||||
label,
|
||||
lnInst: defaultLnInst
|
||||
}))
|
||||
}
|
||||
})
|
||||
|
||||
export const formatIndexSelectionJson = (value: MmsMapping.IndexSelectionGroup[]) => JSON.stringify(value, null, 4)
|
||||
|
||||
export const parseIndexSelectionJson = (source: string): MmsMapping.IndexSelectionGroup[] => {
|
||||
|
||||
Reference in New Issue
Block a user