From 7a11f50e390a74163937acf13b58ebd32264c511 Mon Sep 17 00:00:00 2001
From: sheng <905537351@qq.com>
Date: Wed, 24 Jun 2026 16:52:40 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=BC=82=E5=B8=B8=E4=B8=8D?=
=?UTF-8?q?=E8=89=AF=E7=AE=A1=E7=90=86=E5=88=97=E8=A1=A8=E5=92=8C=E8=A1=A8?=
=?UTF-8?q?=E5=8D=95=E9=97=AE=E9=A2=98?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../product-model/product-ng-info/index.vue | 88 +++++++++++++------
1 file changed, 62 insertions(+), 26 deletions(-)
diff --git a/src/views/production-master-data/product-model/product-ng-info/index.vue b/src/views/production-master-data/product-model/product-ng-info/index.vue
index 05887f05..43e50955 100644
--- a/src/views/production-master-data/product-model/product-ng-info/index.vue
+++ b/src/views/production-master-data/product-model/product-ng-info/index.vue
@@ -14,9 +14,9 @@
>
@@ -74,7 +74,11 @@
auto-height
@page-change="onPageChange"
@selection-change="onSelect"
- />
+ >
+
+ {{ typeText(row.type) }}
+
+
{
+ this.fetchData()
+ })
},
methods: {
+ normalizeResponse (res) {
+ const root = res || {}
+ const data = res && res.data !== undefined ? res.data : res
+ if (Array.isArray(data)) return { list: data, total: Number(root.count || root.total || data.length) }
+ if (data && Array.isArray(data.list)) return { list: data.list, total: Number(root.count || root.total || data.count || data.total || data.list.length) }
+ if (data && Array.isArray(data.rows)) return { list: data.rows, total: Number(root.count || root.total || data.count || data.total || data.rows.length) }
+ if (data && Array.isArray(data.records)) return { list: data.records, total: Number(root.count || root.total || data.count || data.total || data.records.length) }
+ if (data && Array.isArray(data.data)) return { list: data.data, total: Number(root.count || root.total || data.count || data.total || data.data.length) }
+ if (data && data.data && Array.isArray(data.data.data)) return { list: data.data.data, total: Number(root.count || root.total || data.count || data.total || data.data.count || data.data.total || data.data.data.length) }
+ if (data && data.data && Array.isArray(data.data.list)) return { list: data.data.list, total: Number(root.count || root.total || data.count || data.total || data.data.count || data.data.total || data.data.list.length) }
+ return { list: [], total: 0 }
+ },
+ normalizeRow (row) {
+ const deviceCategory = typeof row.device_category === 'object'
+ ? row.device_category
+ : (typeof row.category === 'object' ? row.category : {})
+ const option = this.deviceCategoryOptions.find(item => String(item.value) === String(row.device_category_id || deviceCategory.id || ''))
+ return {
+ ...row,
+ device_category_id: row.device_category_id || deviceCategory.id || '',
+ device_category_name: row.device_category_name || deviceCategory.name || row.category_name || (option && option.label) || (typeof row.device_category === 'string' ? row.device_category : '')
+ }
+ },
+ normalizeOptions (res) {
+ return this.normalizeResponse(res).list.map(item => ({
+ label: item.name || item.label || item.code || item.id,
+ value: item.id !== undefined ? item.id : item.value
+ })).filter(item => item.value !== undefined && item.value !== null && item.value !== '')
+ },
+ typeText (type) {
+ if (type === 'ERR') return this.$t(this.key('type_error'))
+ if (type === 'NG') return this.$t(this.key('type_ng'))
+ return type
+ },
async fetchData () {
this.loading = true
try {
@@ -297,11 +334,9 @@ export default {
page_no: this.pagination.current,
page_size: this.pagination.size
})
- const data = Array.isArray(res) ? res : (res.data || {})
- const list = Array.isArray(data) ? data : (data.data || [])
- const total = Array.isArray(data) ? data.length : (data.count || 0)
- this.tableData = list
- this.pagination.total = total
+ const data = this.normalizeResponse(res)
+ this.tableData = data.list.map(this.normalizeRow)
+ this.pagination.total = data.total
} finally {
this.loading = false
}
@@ -327,8 +362,7 @@ export default {
if (this.deviceCategoryOptions.length) return
try {
const res = await getDeviceCategoryAll({})
- const list = Array.isArray(res) ? res : (res.data || [])
- this.deviceCategoryOptions = Array.isArray(list) ? list : []
+ this.deviceCategoryOptions = this.normalizeOptions(res)
this.searchFormDeviceCategoryUpdate()
} catch { /* ignore */ }
},
@@ -349,18 +383,18 @@ export default {
openAdd () {
this.handleType = 'create'
this.dialogTitle = this.key('add_exception_ng_category')
- this.loadDeviceCategories()
- this.$nextTick(() => {
- this.$refs.dialogForm && this.$refs.dialogForm.reset()
- this.resetForm()
- this.dialogVisible = true
+ this.loadDeviceCategories().then(() => {
+ this.$nextTick(() => {
+ this.$refs.dialogForm && this.$refs.dialogForm.reset()
+ this.resetForm()
+ this.dialogVisible = true
+ })
})
},
openEdit (row) {
this.handleType = 'edit'
this.dialogTitle = this.key('edit_exception_ng_category')
this.editId = row.id
- this.loadDeviceCategories()
this.formData = {
device_category_id: row.device_category_id || '',
type: row.type || '',
@@ -368,7 +402,9 @@ export default {
explain: row.explain || '',
note: row.note || ''
}
- this.dialogVisible = true
+ this.loadDeviceCategories().then(() => {
+ this.dialogVisible = true
+ })
},
async onDialogSubmit () {
this.submitting = true