-
+
-
+
-
+
-
-
+
-
-
-
+ style="width:200px"
+ @keyup.enter.native="onSearch"
+ />
@@ -67,8 +65,8 @@
@page-change="onPageChange"
@selection-change="onSelect"
>
-
- {{ row.status_name || statusText(row.status) }}
+
+ {{ categoryText(row.category) }}
@@ -101,6 +99,9 @@ import {
editDataCollectionConfig,
deleteDataCollectionConfig
} from '@/api/production-master-data/data-collection-configuration'
+import { getOptionalParamsList } from '@/api/production-master-data/optional-params'
+import { getWorkingsubclassAll } from '@/api/production-master-data/process-step'
+import { getQueryCodes } from '@/api/scada-manage/edge-manager'
import PageTable from '@/components/page-table'
import PageDialogForm from '@/components/page-dialog-form'
@@ -121,140 +122,57 @@ export default {
dialogTitle: '',
editId: '',
handleType: 'create',
- search: { code: '', name: '', scada_node: '', status: '' },
+ search: {
+ result_param_code: undefined,
+ result_param_name: undefined,
+ scada_node_code: undefined,
+ scada_node_name: undefined
+ },
pagination: { current: 1, size: 10, total: 0 },
+ workingSubclassOptions: [],
+ workingSubclassRawData: [],
+ resultParamOptions: [],
+ scadaNodeOptions: [],
formData: {
- code: '',
- name: '',
- scada_node: '',
- collect_type: '',
- interval: 1,
- status: 1,
- remark: ''
+ working_subclass_id: undefined,
+ category: undefined,
+ result_param_code: undefined,
+ scada_node_code: undefined,
+ result_param_type: 1
},
rules: {
- code: [
- { required: true, message: this.key('enter_code'), trigger: 'blur' },
- { min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
+ working_subclass_id: [
+ { required: true, message: this.key('select_working_subclass'), trigger: 'change' }
],
- name: [
- { required: true, message: this.key('enter_name'), trigger: 'blur' },
- { min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
+ category: [
+ { required: true, message: this.key('select_data_type'), trigger: 'change' }
],
- scada_node: [
- { required: true, message: this.key('enter_scada_node'), trigger: 'blur' }
+ result_param_code: [
+ { required: true, message: this.key('select_result_param'), trigger: 'change' }
],
- collect_type: [
- { required: true, message: this.key('select_collect_type'), trigger: 'change' }
+ scada_node_code: [
+ { required: true, message: this.key('select_scada_node'), trigger: 'change' }
],
- interval: [
- { required: true, message: this.key('enter_interval'), trigger: 'blur' }
- ],
- status: [
- { required: true, message: this.key('select_status'), trigger: 'change' }
+ result_param_type: [
+ { required: true, message: this.key('select_data_type'), trigger: 'change' }
]
},
columns: [],
toolbarButtons: [],
rowButtons: [],
- formCols: [
- [
- {
- type: 'input',
- prop: 'code',
- label: this.key('code'),
- placeholder: this.key('enter_code'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'name',
- label: this.key('name'),
- placeholder: this.key('enter_name'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'input',
- prop: 'scada_node',
- label: this.key('scada_node'),
- placeholder: this.key('enter_scada_node'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'select',
- prop: 'collect_type',
- label: this.key('collect_type'),
- placeholder: this.key('select_collect_type'),
- clearable: true,
- filterable: true,
- style: { width: '90%' },
- options: [
- { label: this.key('real_time'), value: 'real_time' },
- { label: this.key('periodic'), value: 'periodic' },
- { label: this.key('trigger'), value: 'trigger' }
- ]
- }
- ],
- [
- {
- type: 'input',
- prop: 'interval',
- inputType: 'number',
- label: this.key('interval'),
- placeholder: this.key('enter_interval'),
- clearable: true,
- style: { width: '90%' }
- }
- ],
- [
- {
- type: 'select',
- prop: 'status',
- label: this.key('status'),
- placeholder: this.key('select_status'),
- clearable: true,
- filterable: true,
- style: { width: '90%' },
- options: [
- { label: this.key('enable'), value: 1 },
- { label: this.key('disable'), value: 0 }
- ]
- }
- ],
- [
- {
- type: 'input',
- prop: 'remark',
- inputType: 'textarea',
- autosize: { minRows: 2, maxRows: 6 },
- label: this.key('remark'),
- placeholder: this.key('enter_remark'),
- clearable: true,
- style: { width: '90%' }
- }
- ]
- ]
+ formCols: []
}
},
created () {
this.columns = useTableColumns([
- { prop: 'sort', label: this.key('sort'), width: 80 },
- { prop: 'code', label: this.key('code'), minWidth: 120 },
- { prop: 'name', label: this.key('name'), minWidth: 140 },
- { prop: 'scada_node', label: this.key('scada_node'), minWidth: 140 },
- { prop: 'collect_type_name', label: this.key('collect_type'), minWidth: 120 },
- { prop: 'interval', label: this.key('interval'), width: 100 },
- { prop: 'status_name', label: this.key('status'), width: 100, slot: true },
- { prop: 'remark', label: this.key('remark'), minWidth: 120 },
+ { prop: 'working_subclass', label: this.key('working_subclass'), minWidth: 140 },
+ { prop: 'result_param_name', label: this.key('result_param_name'), minWidth: 160 },
+ { prop: 'result_param_code', label: this.key('result_param_code'), minWidth: 160 },
+ { prop: 'scada_node_name', label: this.key('scada_node_name'), minWidth: 160 },
+ { prop: 'scada_node_code', label: this.key('scada_node_code'), minWidth: 160 },
+ { prop: 'category', label: this.key('category'), minWidth: 140, slot: 'category' },
+ { prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
+ { prop: 'update_data', label: this.key('update_data'), minWidth: 160 },
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
])
const btns = useTableButtons({
@@ -264,7 +182,7 @@ export default {
label: this.key('add'),
icon: 'el-icon-plus',
type: 'primary',
- auth: '/production_configuration/spc_configuration/binding_scada_node/create',
+ auth: '/production_configuration/matetial_model/bom/create',
onClick: this.openAdd
}
],
@@ -273,7 +191,7 @@ export default {
key: 'edit',
label: this.key('edit'),
icon: 'el-icon-edit',
- auth: '/production_configuration/spc_configuration/binding_scada_node/edit',
+ auth: '/production_configuration/matetial_model/bom/edit',
onClick: this.openEdit
},
{
@@ -281,13 +199,15 @@ export default {
label: this.key('delete'),
icon: 'el-icon-delete',
color: 'danger',
- auth: '/production_configuration/spc_configuration/binding_scada_node/delete',
+ auth: '/production_configuration/matetial_model/bom/delete',
onClick: this.handleDelete
}
]
}, this.$permission)
this.toolbarButtons = btns.toolbarButtons
this.rowButtons = btns.rowButtons
+ this.formCols = this.makeFormCols()
+ this.loadWorkingSubclassOptions()
this.fetchData()
},
methods: {
@@ -324,7 +244,7 @@ export default {
total: this.getTotal(res, item.length)
}
}
- const list = item.list || item.rows || item.records || item.results || item.items
+ const list = item.data || item.list || item.rows || item.records || item.results || item.items
if (Array.isArray(list)) {
return {
list,
@@ -351,86 +271,168 @@ export default {
}
return defaultValue
},
- normalizeCollectType (value) {
- const text = String(value || '').toLowerCase()
+ makeFormCols () {
+ return [
+ [
+ {
+ type: 'select',
+ prop: 'working_subclass_id',
+ label: this.key('working_subclass'),
+ placeholder: this.key('select_working_subclass'),
+ clearable: true,
+ filterable: true,
+ style: { width: '90%' },
+ options: this.workingSubclassOptions,
+ onChange: this.onWorkingSubclassChange
+ }
+ ],
+ [
+ {
+ type: 'select',
+ prop: 'category',
+ label: this.key('category'),
+ placeholder: this.key('select_data_type'),
+ clearable: true,
+ filterable: true,
+ style: { width: '90%' },
+ options: [
+ { label: this.$t(this.key('process_inspection')), value: 'PROCESS_INSPECTION' },
+ { label: this.$t(this.key('result_data')), value: 'RESULT_DATA' }
+ ]
+ }
+ ],
+ [
+ {
+ type: 'select',
+ prop: 'result_param_code',
+ label: this.key('result_param'),
+ placeholder: this.key('select_result_param'),
+ clearable: true,
+ filterable: true,
+ style: { width: '90%' },
+ options: this.resultParamOptions
+ }
+ ],
+ [
+ {
+ type: 'select',
+ prop: 'scada_node_code',
+ label: this.key('scada_node'),
+ placeholder: this.key('select_scada_node'),
+ clearable: true,
+ filterable: true,
+ style: { width: '90%' },
+ options: this.scadaNodeOptions
+ }
+ ],
+ [
+ {
+ type: 'select',
+ prop: 'result_param_type',
+ label: this.key('result_param_type'),
+ placeholder: this.key('select_data_type'),
+ clearable: true,
+ filterable: true,
+ style: { width: '90%' },
+ options: [
+ { label: this.$t(this.key('measurement_type')), value: 1 },
+ { label: this.$t(this.key('count_type')), value: 2 }
+ ]
+ }
+ ]
+ ]
+ },
+ normalizeList (res) {
+ return this.normalizeResponse(res).list
+ },
+ categoryText (value) {
const map = {
- realtime: 'real_time',
- real_time: 'real_time',
- real: 'real_time',
- periodic: 'periodic',
- period: 'periodic',
- cycle: 'periodic',
- trigger: 'trigger',
- event: 'trigger'
+ PROCESS_INSPECTION: this.key('process_inspection'),
+ RESULT_DATA: this.key('result_data')
}
- return map[text] || value || ''
+ return map[value] ? this.$t(map[value]) : (value || '')
},
- collectTypeText (value) {
- const type = this.normalizeCollectType(value)
- const map = {
- real_time: this.key('real_time'),
- periodic: this.key('periodic'),
- trigger: this.key('trigger')
+ async loadWorkingSubclassOptions () {
+ try {
+ const res = await getWorkingsubclassAll()
+ const list = this.normalizeList(res)
+ this.workingSubclassRawData = list
+ this.workingSubclassOptions = list.map(item => ({
+ label: item.name || item.working_subclass_name || item.code,
+ value: item.id
+ }))
+ this.formCols = this.makeFormCols()
+ } catch (e) {
+ this.formCols = this.makeFormCols()
}
- return map[type] ? this.$t(map[type]) : (value || '')
},
- normalizeStatus (row) {
- const status = this.firstValue(row, ['status', 'enable', 'enabled', 'is_enable', 'active'], '')
- if (typeof status === 'boolean') return status ? 1 : 0
- if (typeof status === 'number') return status
- const text = String(status).toLowerCase()
- if (['1', 'true', 'enable', 'enabled', 'active', 'yes'].includes(text)) return 1
- if (['0', 'false', 'disable', 'disabled', 'inactive', 'no'].includes(text)) return 0
- return status
+ findWorkingSubclassById (id) {
+ return this.workingSubclassRawData.find(item => item.id === id)
},
- statusText (status) {
- if (status === 1 || status === '1') return this.$t(this.key('enable'))
- if (status === 0 || status === '0') return this.$t(this.key('disable'))
- return status || ''
+ async onWorkingSubclassChange (value) {
+ this.formData.result_param_code = undefined
+ this.formData.scada_node_code = undefined
+ this.resultParamOptions = []
+ this.scadaNodeOptions = []
+ const workingSubclass = this.findWorkingSubclassById(value)
+ if (!workingSubclass) {
+ this.formCols = this.makeFormCols()
+ return
+ }
+ const code = workingSubclass.code || workingSubclass.working_subclass
+ await Promise.all([
+ this.loadResultParamOptions(value),
+ this.loadScadaNodeOptions(code)
+ ])
+ this.formCols = this.makeFormCols()
},
- normalizeRow (row, index) {
- const sortIndex = typeof index === 'number' ? index + 1 : ''
- const collectType = this.normalizeCollectType(this.firstValue(row, [
- 'collect_type',
- 'collection_type',
- 'type',
- 'category'
- ], ''))
- const status = this.normalizeStatus(row)
-
+ async loadResultParamOptions (workingsubclassId) {
+ try {
+ const res = await getOptionalParamsList({
+ workingsubclass_id: workingsubclassId,
+ page_no: 1,
+ page_size: 10000
+ })
+ this.resultParamOptions = this.normalizeList(res).map(item => ({
+ label: item.name || item.result_param_name || item.code,
+ value: item.code || item.result_param_code
+ }))
+ } catch (e) {
+ this.resultParamOptions = []
+ }
+ },
+ normalizeScadaNodeList (res, workingSubclassCode) {
+ const data = res && res.data ? res.data : res
+ if (Array.isArray(data)) return data
+ if (data && Array.isArray(data[workingSubclassCode])) return data[workingSubclassCode]
+ if (data && Array.isArray(data.data)) return data.data
+ return []
+ },
+ async loadScadaNodeOptions (workingSubclassCode) {
+ try {
+ const res = await getQueryCodes(workingSubclassCode)
+ const list = this.normalizeScadaNodeList(res, workingSubclassCode)
+ this.scadaNodeOptions = list.map(item => ({
+ label: item.name || item.scada_node_name || item.code,
+ value: item.code || item.scada_node_code
+ }))
+ } catch (e) {
+ this.scadaNodeOptions = []
+ }
+ },
+ normalizeRow (row) {
return {
...row,
id: this.firstValue(row, ['id', 'binding_scada_node_id', 'config_id']),
- sort: this.firstValue(row, ['sort', 'order_no', 'sequence', 'seq'], sortIndex),
- code: this.firstValue(row, ['code', 'node_code', 'scada_code', 'binding_code', 'number']),
- name: this.firstValue(row, ['name', 'node_name', 'scada_name', 'binding_name', 'label']),
- scada_node: this.firstValue(row, [
- 'scada_node',
- 'scada_node_name',
- 'scadaNode',
- 'node',
- 'node_name',
- 'node_code',
- 'device_node',
- 'bind_scada_node'
- ]),
- collect_type: collectType,
- collect_type_name: this.firstValue(row, [
- 'collect_type_name',
- 'collection_type_name',
- 'type_name',
- 'category_name'
- ], this.collectTypeText(collectType)),
- interval: this.firstValue(row, [
- 'interval',
- 'collect_interval',
- 'collection_interval',
- 'period',
- 'refresh_interval'
- ]),
- status,
- status_name: this.firstValue(row, ['status_name', 'enable_name', 'enabled_name'], this.statusText(status)),
- remark: this.firstValue(row, ['remark', 'note', 'description'])
+ working_subclass: this.firstValue(row, ['working_subclass', 'working_subclass_code', 'workingsubclass_code']),
+ working_subclass_id: this.firstValue(row, ['working_subclass_id', 'workingsubclass_id']),
+ result_param_name: this.firstValue(row, ['result_param_name', 'param_name', 'name']),
+ result_param_code: this.firstValue(row, ['result_param_code', 'param_code', 'code']),
+ scada_node_name: this.firstValue(row, ['scada_node_name', 'node_name']),
+ scada_node_code: this.firstValue(row, ['scada_node_code', 'node_code']),
+ category: this.firstValue(row, ['category', 'data_category']),
+ create_time: this.firstValue(row, ['create_time', 'created_at']),
+ update_data: this.firstValue(row, ['update_data', 'update_time', 'updated_at'])
}
},
onSearch () {
@@ -438,7 +440,12 @@ export default {
this.fetchData()
},
onReset () {
- this.search = { code: '', name: '', scada_node: '', status: '' }
+ this.search = {
+ result_param_code: undefined,
+ result_param_name: undefined,
+ scada_node_code: undefined,
+ scada_node_name: undefined
+ }
this.pagination.current = 1
this.fetchData()
},
@@ -452,14 +459,15 @@ export default {
},
resetForm () {
this.formData = {
- code: '',
- name: '',
- scada_node: '',
- collect_type: '',
- interval: 1,
- status: 1,
- remark: ''
+ working_subclass_id: undefined,
+ category: undefined,
+ result_param_code: undefined,
+ scada_node_code: undefined,
+ result_param_type: 1
}
+ this.resultParamOptions = []
+ this.scadaNodeOptions = []
+ this.formCols = this.makeFormCols()
this.editId = ''
},
openAdd () {
@@ -471,29 +479,64 @@ export default {
this.dialogVisible = true
})
},
- openEdit (row) {
+ async openEdit (row) {
+ if (!this.workingSubclassRawData.length) {
+ await this.loadWorkingSubclassOptions()
+ }
const record = this.normalizeRow(row)
this.handleType = 'edit'
this.dialogTitle = this.key('edit_title')
this.editId = record.id
+ const workingSubclassId = record.working_subclass_id || this.getWorkingSubclassIdByCode(record.working_subclass)
this.formData = {
- code: record.code,
- name: record.name,
- scada_node: record.scada_node || '',
- collect_type: record.collect_type || '',
- interval: record.interval || 1,
- status: typeof record.status === 'number' ? record.status : 1,
- remark: record.remark || ''
+ working_subclass_id: workingSubclassId,
+ category: record.category,
+ result_param_code: record.result_param_code,
+ scada_node_code: record.scada_node_code,
+ result_param_type: record.result_param_type || 1
+ }
+ this.prepareEditOptions(workingSubclassId, record).finally(() => {
+ this.dialogVisible = true
+ })
+ },
+ getWorkingSubclassIdByCode (code) {
+ const target = this.workingSubclassRawData.find(item => item.code === code || item.working_subclass === code)
+ return target && target.id
+ },
+ async prepareEditOptions (workingSubclassId, record) {
+ const workingSubclass = this.findWorkingSubclassById(workingSubclassId)
+ if (workingSubclass) {
+ await Promise.all([
+ this.loadResultParamOptions(workingSubclassId),
+ this.loadScadaNodeOptions(workingSubclass.code || workingSubclass.working_subclass)
+ ])
+ }
+ if (record.result_param_code && !this.resultParamOptions.some(item => item.value === record.result_param_code)) {
+ this.resultParamOptions.push({ label: record.result_param_name || record.result_param_code, value: record.result_param_code })
+ }
+ if (record.scada_node_code && !this.scadaNodeOptions.some(item => item.value === record.scada_node_code)) {
+ this.scadaNodeOptions.push({ label: record.scada_node_name || record.scada_node_code, value: record.scada_node_code })
+ }
+ this.formCols = this.makeFormCols()
+ },
+ buildSubmitData () {
+ const workingSubclass = this.findWorkingSubclassById(this.formData.working_subclass_id)
+ const workingSubclassCode = workingSubclass && (workingSubclass.code || workingSubclass.working_subclass)
+ const scadaNode = this.scadaNodeOptions.find(item => item.value === this.formData.scada_node_code)
+ return {
+ ...this.formData,
+ working_subclass: workingSubclassCode,
+ scada_node_name: scadaNode ? scadaNode.label : undefined
}
- this.dialogVisible = true
},
async onDialogSubmit () {
this.submitting = true
try {
+ const submitData = this.buildSubmitData()
if (this.handleType === 'create') {
- await createDataCollectionConfig(this.formData)
+ await createDataCollectionConfig(submitData)
} else {
- await editDataCollectionConfig({ ...this.formData, id: this.editId })
+ await editDataCollectionConfig({ ...submitData, id: this.editId })
}
this.$message.success(this.$t(this.key('operation_success')))
this.dialogVisible = false
From 4f83f95362249e8fe94dbb4e1799f6c2bbbfbe5b Mon Sep 17 00:00:00 2001
From: sheng <905537351@qq.com>
Date: Wed, 24 Jun 2026 22:47:34 +0800
Subject: [PATCH 11/12] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=B7=A5=E8=89=BA?=
=?UTF-8?q?=E6=A8=A1=E5=9E=8B=E8=A1=A8=E6=A0=BC=E5=BA=8F=E5=8F=B7=E5=88=97?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../process-model/process-category/index.vue | 1 -
.../process-model/process-routing-card/index.vue | 1 -
.../process-model/process-routing/index.vue | 1 -
.../production-master-data/process-model/process-step/index.vue | 1 -
4 files changed, 4 deletions(-)
diff --git a/src/views/production-master-data/process-model/process-category/index.vue b/src/views/production-master-data/process-model/process-category/index.vue
index 3b19420c..503b6e70 100644
--- a/src/views/production-master-data/process-model/process-category/index.vue
+++ b/src/views/production-master-data/process-model/process-category/index.vue
@@ -148,7 +148,6 @@ export default {
},
created () {
this.columns = useTableColumns([
- { prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('code'), minWidth: 120 },
{ prop: 'name', label: this.key('name'), minWidth: 120 },
{ prop: 'remark', label: this.key('remark') },
diff --git a/src/views/production-master-data/process-model/process-routing-card/index.vue b/src/views/production-master-data/process-model/process-routing-card/index.vue
index 67da6cae..a7a417a6 100644
--- a/src/views/production-master-data/process-model/process-routing-card/index.vue
+++ b/src/views/production-master-data/process-model/process-routing-card/index.vue
@@ -314,7 +314,6 @@ export default {
this.columns = useTableColumns([
{ prop: 'up', label: '', slot: 'up', width: 40 },
{ prop: 'down', label: '', slot: 'down', width: 40 },
- { prop: 'sort', label: this.key('sort'), slot: 'sort', width: 80 },
{ prop: 'code', label: this.key('step_code'), minWidth: 120 },
{ prop: 'name', label: this.key('step_name'), minWidth: 140 },
{ prop: 'workingsubclass_name', label: this.key('process_unit_name'), minWidth: 140 },
diff --git a/src/views/production-master-data/process-model/process-routing/index.vue b/src/views/production-master-data/process-model/process-routing/index.vue
index 1202e3f6..1486c053 100644
--- a/src/views/production-master-data/process-model/process-routing/index.vue
+++ b/src/views/production-master-data/process-model/process-routing/index.vue
@@ -228,7 +228,6 @@ export default {
},
created () {
this.columns = useTableColumns([
- { prop: 'sort', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('code'), minWidth: 120 },
{ prop: 'name', label: this.key('name'), minWidth: 140 },
{ prop: 'flow_category_name', label: this.key('category'), minWidth: 120 },
diff --git a/src/views/production-master-data/process-model/process-step/index.vue b/src/views/production-master-data/process-model/process-step/index.vue
index 0d3ebe70..f076be97 100644
--- a/src/views/production-master-data/process-model/process-step/index.vue
+++ b/src/views/production-master-data/process-model/process-step/index.vue
@@ -195,7 +195,6 @@ export default {
},
created () {
this.columns = useTableColumns([
- { prop: 'sort ', label: this.key('sort'), width: 80 },
{ prop: 'code', label: this.key('process_unit_code'), minWidth: 120 },
{ prop: 'name', label: this.key('process_unit_name'), minWidth: 120 },
{ prop: 'device_category_name', label: this.key('device_category'), minWidth: 120 },
From cab65fb3807f35bcfb1764956de53ba515ec997c Mon Sep 17 00:00:00 2001
From: sheng <905537351@qq.com>
Date: Wed, 24 Jun 2026 23:14:34 +0800
Subject: [PATCH 12/12] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?=
=?UTF-8?q?=E4=BA=A7=E7=BA=BF=E5=92=8C=E5=B7=A5=E5=8E=82=E5=8C=BA=E5=9F=9F?=
=?UTF-8?q?=E5=88=86=E9=A1=B5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../production-master-data/factory-area.js | 2 +-
.../production-master-data/production-line.js | 2 +-
.../factory-model/factory-area/index.vue | 40 +++++++++++++++----
.../factory-model/production-line/index.vue | 21 +++++++---
.../user-management/user/index.vue | 21 +++++++---
5 files changed, 67 insertions(+), 19 deletions(-)
diff --git a/src/api/production-master-data/factory-area.js b/src/api/production-master-data/factory-area.js
index 18fa5981..57141320 100644
--- a/src/api/production-master-data/factory-area.js
+++ b/src/api/production-master-data/factory-area.js
@@ -4,7 +4,7 @@ const BASE = 'production_configuration/factory_model/factory_area/'
function apiParams (method, data = {}) {
return {
- method: `production_master_data_factory_model_factory_area_${method}`,
+ method: `production_configuration_factory_model_factory_area_${method}`,
platform: 'background',
...data
}
diff --git a/src/api/production-master-data/production-line.js b/src/api/production-master-data/production-line.js
index 2c7acd82..3864b2cb 100644
--- a/src/api/production-master-data/production-line.js
+++ b/src/api/production-master-data/production-line.js
@@ -4,7 +4,7 @@ const BASE = 'production_configuration/factory_model/factory_line/'
function apiParams (method, data = {}) {
return {
- method: `production_master_data_factory_model_factory_line_${method}`,
+ method: `production_configuration_factory_model_factory_line_${method}`,
platform: 'background',
...data
}
diff --git a/src/views/production-master-data/factory-model/factory-area/index.vue b/src/views/production-master-data/factory-model/factory-area/index.vue
index 2751f1f6..468605f0 100644
--- a/src/views/production-master-data/factory-model/factory-area/index.vue
+++ b/src/views/production-master-data/factory-model/factory-area/index.vue
@@ -25,11 +25,12 @@
:loading="loading"
:toolbar-buttons="toolbarButtons"
:row-buttons="rowButtons"
- :pagination="null"
+ :pagination="pagination"
:table-attrs="tableAttrs"
help-url="/help/factory-area"
:help-text="$t(ckey('help'))"
auto-height
+ @page-change="onPageChange"
@selection-change="onSelect"
>
@@ -82,6 +83,7 @@ export default {
editId: '',
handleType: 'create',
search: { code: '', name: '' },
+ pagination: { current: 1, size: 10, total: 0 },
tableAttrs: { defaultExpandAll: true, treeProps: { children: 'children', hasChildren: 'hasChildren' } },
formData: { code: '', name: '', parent_id: '', remark: '' },
rules: {
@@ -138,11 +140,22 @@ export default {
return ''
},
normalizeResponse (res) {
- const data = res && res.data !== undefined ? res.data : res
- if (Array.isArray(data)) return { list: data, total: data.length }
- if (data && Array.isArray(data.list)) return { list: data.list, total: Number(data.count || data.total || data.list.length) }
- if (data && Array.isArray(data.data)) return { list: data.data, total: Number(data.count || data.total || data.data.length) }
- if (data && data.data && Array.isArray(data.data.data)) return { list: data.data.data, total: Number(data.data.count || data.data.total || data.data.data.length) }
+ const getTotal = (source, fallback) => {
+ if (!source) return fallback
+ const total = source.count ?? source.total ?? source.total_count ?? source.record_count
+ const value = Number(total)
+ return Number.isNaN(value) ? fallback : value
+ }
+ const containers = [res, res && res.data, res && res.data && res.data.data].filter(Boolean)
+ for (const item of containers) {
+ if (Array.isArray(item)) {
+ return { list: item, total: getTotal(res, item.length) }
+ }
+ const list = item.data || item.list || item.rows || item.records || item.items
+ if (Array.isArray(list)) {
+ return { list, total: getTotal(item, getTotal(res, list.length)) }
+ }
+ }
return { list: [], total: 0 }
},
normalizeNode (row, level = 0) {
@@ -185,19 +198,31 @@ export default {
async fetchData () {
this.loading = true
try {
- const res = await getFactoryAreaList({ ...this.search, page_no: 1, page_size: 10000 })
+ const res = await getFactoryAreaList({
+ ...this.search,
+ page_no: this.pagination.current,
+ page_size: this.pagination.size
+ })
const data = this.normalizeResponse(res)
this.rawAreaData = data.list
this.tableData = this.buildTree(data.list)
+ this.pagination.total = data.total
} finally {
this.loading = false
}
},
onSearch () {
+ this.pagination.current = 1
this.fetchData()
},
onReset () {
this.search = { code: '', name: '' }
+ this.pagination.current = 1
+ this.fetchData()
+ },
+ onPageChange (page) {
+ this.pagination.current = page.current
+ this.pagination.size = page.size
this.fetchData()
},
onSelect (rows) {
@@ -251,6 +276,7 @@ export default {
const ok = await this.confirmAction(this.key('confirm_delete'), () => deleteFactoryArea({ id: [this.getId(row)] }))
if (!ok) return
this.$message.success(this.$t(this.key('operation_success')))
+ this.pagination.current = Math.min(this.pagination.current, Math.ceil((this.pagination.total - 1) / this.pagination.size) || 1)
this.fetchData()
},
async handleExport () {
diff --git a/src/views/production-master-data/factory-model/production-line/index.vue b/src/views/production-master-data/factory-model/production-line/index.vue
index 932d5684..5e04e05a 100644
--- a/src/views/production-master-data/factory-model/production-line/index.vue
+++ b/src/views/production-master-data/factory-model/production-line/index.vue
@@ -176,11 +176,22 @@ export default {
},
methods: {
normalizeResponse (res) {
- const data = res && res.data !== undefined ? res.data : res
- if (Array.isArray(data)) return { list: data, total: data.length }
- if (data && Array.isArray(data.list)) return { list: data.list, total: Number(data.count || data.total || data.list.length) }
- if (data && Array.isArray(data.data)) return { list: data.data, total: Number(data.count || data.total || data.data.length) }
- if (data && data.data && Array.isArray(data.data.data)) return { list: data.data.data, total: Number(data.data.count || data.data.total || data.data.data.length) }
+ const getTotal = (source, fallback) => {
+ if (!source) return fallback
+ const total = source.count ?? source.total ?? source.total_count ?? source.record_count
+ const value = Number(total)
+ return Number.isNaN(value) ? fallback : value
+ }
+ const containers = [res, res && res.data, res && res.data && res.data.data].filter(Boolean)
+ for (const item of containers) {
+ if (Array.isArray(item)) {
+ return { list: item, total: getTotal(res, item.length) }
+ }
+ const list = item.data || item.list || item.rows || item.records || item.items
+ if (Array.isArray(list)) {
+ return { list, total: getTotal(item, getTotal(res, list.length)) }
+ }
+ }
return { list: [], total: 0 }
},
async initAreaOptions () {
diff --git a/src/views/system-administration/user-management/user/index.vue b/src/views/system-administration/user-management/user/index.vue
index 034097eb..91fa80d6 100644
--- a/src/views/system-administration/user-management/user/index.vue
+++ b/src/views/system-administration/user-management/user/index.vue
@@ -319,11 +319,22 @@ export default {
} catch { /* 忽略 */ }
},
normalizeResponse (res) {
- const data = res && res.data !== undefined ? res.data : res
- if (Array.isArray(data)) return { list: data, total: data.length }
- if (data && Array.isArray(data.list)) return { list: data.list, total: Number(data.count || data.total || data.list.length) }
- if (data && Array.isArray(data.data)) return { list: data.data, total: Number(data.count || data.total || data.data.length) }
- if (data && data.data && Array.isArray(data.data.data)) return { list: data.data.data, total: Number(data.data.count || data.data.total || data.data.data.length) }
+ const getTotal = (source, fallback) => {
+ if (!source) return fallback
+ const total = source.count ?? source.total ?? source.total_count ?? source.record_count
+ const value = Number(total)
+ return Number.isNaN(value) ? fallback : value
+ }
+ const containers = [res, res && res.data, res && res.data && res.data.data].filter(Boolean)
+ for (const item of containers) {
+ if (Array.isArray(item)) {
+ return { list: item, total: getTotal(res, item.length) }
+ }
+ const list = item.data || item.list || item.rows || item.records || item.items
+ if (Array.isArray(list)) {
+ return { list, total: getTotal(item, getTotal(res, list.length)) }
+ }
+ }
return { list: [], total: 0 }
},
async fetchData () {