|
|
|
|
@ -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, '"')
|
|
|
|
|
.replace(/'/g, ''')
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const selectedIds = ref<number[]>([])
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
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('<br />')
|
|
|
|
|
await ElMessageBox.alert(`以下点位编码导入失败:<br />${detail}`, t('common.confirmTitle'), {
|
|
|
|
|
type: 'error',
|
|
|
|
|
dangerouslyUseHTMLString: true,
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
message.success('导入成功')
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
message.success('导入成功')
|
|
|
|
|
}
|
|
|
|
|
importLoading.value = false
|
|
|
|
|
importDialogVisible.value = false
|
|
|
|
|
getList()
|
|
|
|
|
|