diff --git a/packages/api/src/core/metadata-instances.ts b/packages/api/src/core/metadata-instances.ts index 4e57c2235..4a9282bf2 100644 --- a/packages/api/src/core/metadata-instances.ts +++ b/packages/api/src/core/metadata-instances.ts @@ -345,6 +345,7 @@ export interface CompareResultStatistics { MissingApply: 0 DifferentApply: 0 Different: 0 + PrimaryKeyInconsistency: 0 } } diff --git a/packages/dag/src/components/form/compare-schema/index.tsx b/packages/dag/src/components/form/compare-schema/index.tsx index 499e21be6..dae04eca1 100644 --- a/packages/dag/src/components/form/compare-schema/index.tsx +++ b/packages/dag/src/components/form/compare-schema/index.tsx @@ -67,7 +67,10 @@ const CompareSchema = defineComponent({ const details = [] const total = - (map.CannotWrite || 0) + (map.Missing || 0) + (map.Different || 0) + (map.CannotWrite || 0) + + (map.Missing || 0) + + (map.Different || 0) + + (map.PrimaryKeyInconsistency || 0) const resolved = (map.CannotWriteApply || 0) + (map.MissingApply || 0) + @@ -135,15 +138,26 @@ const CompareSchema = defineComponent({ ) } + if (map.PrimaryKeyInconsistency) { + details.push( + t('packages_dag_compare_result_detail_primary_key_inconsistency', { + primaryKeyInconsistency: map.PrimaryKeyInconsistency, + }), + ) + } + return { type, title: t('packages_dag_compare_result_alert', { time1, time2, - result: t('packages_dag_compare_result_with_diff', { - count: total, - details: `(${details.join(',')})`, - }), + result: + details.length > 1 + ? t('packages_dag_compare_result_with_diff', { + count: total, + details: `(${details.join(',')})`, + }) + : details[0], }), } }) diff --git a/packages/dag/src/components/form/field-inference/CompareResultDialog.vue b/packages/dag/src/components/form/field-inference/CompareResultDialog.vue index 4a7eef918..681757a90 100644 --- a/packages/dag/src/components/form/field-inference/CompareResultDialog.vue +++ b/packages/dag/src/components/form/field-inference/CompareResultDialog.vue @@ -43,6 +43,7 @@ type TableItem = { additionalNum: number missingNum: number cannotWriteNum: number + primaryKeyInconsistencyNum: number } const { t } = useI18n() @@ -60,61 +61,73 @@ const invalidApplyNum = ref(0) const pageSize = ref(10) const currentPage = ref(1) const applyCompareRules = ref(props.rules) -const filterType = ref(['Different', 'Missing', 'CannotWrite']) +const filterType = ref([ + 'PrimaryKeyInconsistency', + 'Different', + 'Missing', + 'CannotWrite', +]) -const typeMap = { - Different: { - text: t('packages_dag_compare_different'), +const filterOptions = ref([ + { + label: t('packages_dag_compare_primary_key_inconsistency'), + value: 'PrimaryKeyInconsistency', type: 'warning', - doneText: 'packages_dag_compare_done_modify', - btnText: t('public_button_revise'), - numKey: 'differentNum', - }, - Missing: { - text: t('packages_dag_compare_missing'), - type: 'danger', - doneText: 'packages_dag_compare_done_delete', - btnText: t('public_button_delete'), - numKey: 'missingNum', - }, - CannotWrite: { - text: t('packages_dag_compare_cannot_write'), - type: 'danger', - doneText: 'packages_dag_compare_done_delete', - btnText: t('public_button_delete'), - numKey: 'cannotWriteNum', + numKey: 'primaryKeyInconsistencyNum', }, -} - -const filterOptions = ref([ { label: t('packages_dag_compare_different'), value: 'Different', + type: 'warning', + numKey: 'differentNum', + doneText: 'packages_dag_compare_done_modify', + actionText: t('public_button_update'), }, { label: t('packages_dag_compare_missing'), value: 'Missing', + type: 'danger', + numKey: 'missingNum', + doneText: 'packages_dag_compare_done_delete', + actionText: t('public_button_delete'), }, { label: t('packages_dag_compare_cannot_write'), value: 'CannotWrite', + type: 'danger', + numKey: 'cannotWriteNum', + doneText: 'packages_dag_compare_done_delete', + actionText: t('public_button_delete'), }, { label: t('packages_dag_compare_missing_source'), value: 'Additional', + type: 'info', }, { label: t('packages_dag_compare_precision'), value: 'Precision', + type: 'info', + doneText: 'packages_dag_compare_done_modify', + actionText: t('public_button_update'), }, ]) const ruleOptions = filterOptions.value.filter((item) => { - return item.value !== 'Additional' + return !!item.actionText }) const totalMap = ref>({}) +const typeMap = filterOptions.value.reduce((acc: Record, item) => { + acc[item.value] = item + return acc +}, {}) + +const importantOptions = filterOptions.value.filter((item) => { + return ['warning', 'danger'].includes(item.type) +}) + const isLoading = computed(() => { return compareResultLoading.value || compareStatus.value === 'running' }) @@ -179,25 +192,29 @@ const { Additional: 0, Missing: 0, CannotWrite: 0, + PrimaryKeyInconsistency: 0, } const fields: TableItem['fields'] = [] item.differenceFieldList.forEach((field) => { - if (!field.applyType) totalMap[field.type as keyof typeof totalMap]++ + if (!field.applyType) { + totalMap[field.type as keyof typeof totalMap]++ + if (field.type !== 'PrimaryKeyInconsistency' && field.isPrimaryKey) { + // 只要是主键,其他差异也需要算进来 + totalMap.PrimaryKeyInconsistency++ + } + } let fieldType - let isPrimaryKey let isNullable let icon if (field.sourceField) { fieldType = field.sourceField.data_type - isPrimaryKey = field.sourceField.primary_key_position > 0 isNullable = field.sourceField.is_nullable icon = getFieldIcon(field.sourceField.tapType) } else { fieldType = field.targetField.data_type - isPrimaryKey = field.targetField.primary_key_position > 0 isNullable = field.targetField.is_nullable icon = getFieldIcon(field.targetField.tapType) } @@ -212,9 +229,11 @@ const { field.sourceField?.data_type, field.targetField?.data_type, ), + sourcePrimaryKey: field.sourceField?.primaryKey, + targetPrimaryKey: field.targetField?.primaryKey, fieldType, icon, - isPrimaryKey, + isPrimaryKey: field.isPrimaryKey, isNullable, }) }) @@ -227,6 +246,7 @@ const { additionalNum: totalMap.Additional, missingNum: totalMap.Missing, cannotWriteNum: totalMap.CannotWrite, + primaryKeyInconsistencyNum: totalMap.PrimaryKeyInconsistency, } }) @@ -294,10 +314,6 @@ const handleApplyTable = () => { ]) } -const handleApplyAll = () => { - saveApply(true) -} - const handleUndo = (item: Partial) => { deleteApply(false, [ { @@ -316,10 +332,6 @@ const handleUndoTable = () => { ]) } -const handleUndoAll = () => { - deleteApply(true) -} - let unwatch: () => void const handleCompareTargetModel = async () => { @@ -468,6 +480,8 @@ onBeforeUnmount(() => { width="60%" class="p-0 overflow-hidden compare-result-dialog" :show-close="false" + :close-on-click-modal="false" + :close-on-press-escape="false" @open="onOpen" @close="onClose" > @@ -561,7 +575,7 @@ onBeforeUnmount(() => { @@ -603,19 +617,11 @@ onBeforeUnmount(() => { :label="item.label" :value="item.value" > - + {{ item.label }} - {{ - item.value === 'Different' || item.value === 'Precision' - ? $t('public_button_update') - : $t('public_button_delete') - }} + {{ item.actionText }} @@ -716,15 +722,18 @@ onBeforeUnmount(() => { >
-