diff --git a/src/views/iot/devicemodel/components/ModelAttributeList.vue b/src/views/iot/devicemodel/components/ModelAttributeList.vue index deac1c1a..420ffc1f 100644 --- a/src/views/iot/devicemodel/components/ModelAttributeList.vue +++ b/src/views/iot/devicemodel/components/ModelAttributeList.vue @@ -147,6 +147,7 @@ import { DeviceModelAttributeApi, DeviceModelAttributeVO } from '@/api/iot/devic import DeviceModelAttributeForm from './DeviceModelAttributeForm.vue' import { DeviceAttributeTypeApi, DeviceAttributeTypeVO } from '@/api/iot/deviceattributetype' import { getAccessToken, getTenantId } from '@/utils/auth' +import { ElMessageBox } from 'element-plus' const props = defineProps<{ id?: number // id(主表的关联字段) @@ -189,6 +190,15 @@ const uploadHeaders = ref() const importFileList = ref([]) const updateSupport = ref(0) +const escapeHtml = (value: unknown) => { + return String(value ?? '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') +} + const selectedIds = ref([]) const handleSelectionChange = (rows: any[]) => { selectedIds.value = rows?.map((row) => row.id).filter((id) => id !== undefined) ?? [] @@ -318,13 +328,29 @@ const submitImport = async () => { uploadRef.value?.submit() } -const handleImportSuccess = (response: any) => { +const handleImportSuccess = async (response: any) => { if (!response || response.code !== 0) { message.error(response?.msg || '导入失败') importLoading.value = false return } - message.success('导入成功') + const failureCodes = response?.data?.failureCodes + if (failureCodes && typeof failureCodes === 'object') { + const entries = Object.entries(failureCodes).filter(([key]) => String(key).trim() !== '') + if (entries.length > 0) { + const detail = entries + .map(([code, err], index) => `${index + 1}. ${escapeHtml(code)}:${escapeHtml(err)}`) + .join('
') + await ElMessageBox.alert(`以下点位编码导入失败:
${detail}`, t('common.confirmTitle'), { + type: 'error', + dangerouslyUseHTMLString: true, + }) + } else { + message.success('导入成功') + } + } else { + message.success('导入成功') + } importLoading.value = false importDialogVisible.value = false getList() diff --git a/src/views/mes/criticalComponent/index.vue b/src/views/mes/criticalComponent/index.vue index 5df85d23..4250d619 100644 --- a/src/views/mes/criticalComponent/index.vue +++ b/src/views/mes/criticalComponent/index.vue @@ -145,6 +145,7 @@ import download from '@/utils/download' import { CriticalComponentApi, CriticalComponentVO } from '@/api/mes/criticalComponent' import { getAccessToken, getTenantId } from '@/utils/auth' import CriticalComponentForm from './CriticalComponentForm.vue' +import { ElMessageBox } from 'element-plus' defineOptions({ name: 'CriticalComponent' }) @@ -178,6 +179,15 @@ const uploadHeaders = ref() const importFileList = ref([]) const updateSupport = ref(0) +const escapeHtml = (value: unknown) => { + return String(value ?? '') + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, ''') +} + const getList = async () => { loading.value = true try { @@ -267,13 +277,29 @@ const submitImport = async () => { uploadRef.value?.submit() } -const handleImportSuccess = (response: any) => { +const handleImportSuccess = async (response: any) => { if (!response || response.code !== 0) { message.error(response?.msg || '导入失败') importLoading.value = false return } - message.success('导入成功') + const failureCodes = response?.data?.failureCodes + if (failureCodes && typeof failureCodes === 'object') { + const entries = Object.entries(failureCodes).filter(([key]) => String(key).trim() !== '') + if (entries.length > 0) { + const detail = entries + .map(([code, err], index) => `${index + 1}. ${escapeHtml(code)}:${escapeHtml(err)}`) + .join('
') + await ElMessageBox.alert(`以下编码导入失败:
${detail}`, t('common.confirmTitle'), { + type: 'error', + dangerouslyUseHTMLString: true, + }) + } else { + message.success('导入成功') + } + } else { + message.success('导入成功') + } importLoading.value = false importDialogVisible.value = false getList()