From d99a461d79cb84ef2cf9f88b622c05e5b726f4d1 Mon Sep 17 00:00:00 2001 From: hwj Date: Wed, 25 Feb 2026 17:41:15 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E8=AE=BE=E5=A4=87=E5=85=B3?= =?UTF-8?q?=E9=94=AE=E4=BB=B6/=E9=87=87=E9=9B=86=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E6=A8=A1=E5=9E=8B-=E5=AF=BC=E5=85=A5=E6=8C=89=E9=92=AE?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=8A=A5=E9=94=99=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/ModelAttributeList.vue | 30 +++++++++++++++++-- src/views/mes/criticalComponent/index.vue | 30 +++++++++++++++++-- 2 files changed, 56 insertions(+), 4 deletions(-) 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()