修复SPC采集配置列表和按钮显示
This commit is contained in:
@@ -4,7 +4,7 @@ const BASE = 'production_configuration/spc_configuration/binding_scada_node/'
|
|||||||
|
|
||||||
function apiParams (method, data = {}) {
|
function apiParams (method, data = {}) {
|
||||||
return {
|
return {
|
||||||
method: `production_master_data_spc_configuration_data_collection_configuration_${method}`,
|
method: `production_configuration_spc_configuration_binding_scada_node_${method}`,
|
||||||
platform: 'background',
|
platform: 'background',
|
||||||
...data
|
...data
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -681,6 +681,28 @@
|
|||||||
"confirm_delete": "Are you sure to delete this SPC collection configuration?",
|
"confirm_delete": "Are you sure to delete this SPC collection configuration?",
|
||||||
"validation_fail": "Validation failed",
|
"validation_fail": "Validation failed",
|
||||||
"please_enter": "Please enter {name}",
|
"please_enter": "Please enter {name}",
|
||||||
|
"result_param": "Result Parameter",
|
||||||
|
"result_param_code": "Result Parameter Code",
|
||||||
|
"result_param_name": "Result Parameter Name",
|
||||||
|
"enter_result_param_code": "Please enter result parameter code",
|
||||||
|
"enter_result_param_name": "Please enter result parameter name",
|
||||||
|
"scada_node_code": "SCADA Node Code",
|
||||||
|
"scada_node_name": "SCADA Node Name",
|
||||||
|
"enter_scada_node_code": "Please enter SCADA node code",
|
||||||
|
"enter_scada_node_name": "Please enter SCADA node name",
|
||||||
|
"working_subclass": "Process Step",
|
||||||
|
"select_working_subclass": "Please select process step",
|
||||||
|
"category": "Category",
|
||||||
|
"select_data_type": "Please select data type",
|
||||||
|
"select_result_param": "Please select result parameter",
|
||||||
|
"select_scada_node": "Please select SCADA node",
|
||||||
|
"result_param_type": "Result Parameter Type",
|
||||||
|
"process_inspection": "Process Inspection",
|
||||||
|
"result_data": "Result Data",
|
||||||
|
"measurement_type": "Measurement Type",
|
||||||
|
"count_type": "Count Type",
|
||||||
|
"create_time": "Created Time",
|
||||||
|
"update_data": "Updated Time",
|
||||||
"help": "Configure SPC data collection parameters and bind SCADA nodes"
|
"help": "Configure SPC data collection parameters and bind SCADA nodes"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -681,6 +681,28 @@
|
|||||||
"confirm_delete": "确定要删除该SPC采集配置吗?",
|
"confirm_delete": "确定要删除该SPC采集配置吗?",
|
||||||
"validation_fail": "校验失败",
|
"validation_fail": "校验失败",
|
||||||
"please_enter": "请输入{name}",
|
"please_enter": "请输入{name}",
|
||||||
|
"result_param": "结果参数",
|
||||||
|
"result_param_code": "结果参数编码",
|
||||||
|
"result_param_name": "结果参数名称",
|
||||||
|
"enter_result_param_code": "请输入结果参数编码",
|
||||||
|
"enter_result_param_name": "请输入结果参数名称",
|
||||||
|
"scada_node_code": "SCADA节点编码",
|
||||||
|
"scada_node_name": "SCADA节点名称",
|
||||||
|
"enter_scada_node_code": "请输入SCADA节点编码",
|
||||||
|
"enter_scada_node_name": "请输入SCADA节点名称",
|
||||||
|
"working_subclass": "工序",
|
||||||
|
"select_working_subclass": "请选择工序",
|
||||||
|
"category": "类别",
|
||||||
|
"select_data_type": "请选择数据类型",
|
||||||
|
"select_result_param": "请选择结果参数",
|
||||||
|
"select_scada_node": "请选择SCADA节点",
|
||||||
|
"result_param_type": "结果参数类型",
|
||||||
|
"process_inspection": "过程检验",
|
||||||
|
"result_data": "结果数据",
|
||||||
|
"measurement_type": "计量型",
|
||||||
|
"count_type": "计数型",
|
||||||
|
"create_time": "创建时间",
|
||||||
|
"update_data": "更新时间",
|
||||||
"help": "配置SPC数据采集参数,绑定SCADA节点"
|
"help": "配置SPC数据采集参数,绑定SCADA节点"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -3,43 +3,41 @@
|
|||||||
<template #header>
|
<template #header>
|
||||||
<div class="search-bar">
|
<div class="search-bar">
|
||||||
<el-form :inline="true" size="mini">
|
<el-form :inline="true" size="mini">
|
||||||
<el-form-item :label="$t(key('code'))">
|
<el-form-item :label="$t(key('result_param_code'))">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="search.code"
|
v-model="search.result_param_code"
|
||||||
:placeholder="$t(key('enter_code'))"
|
:placeholder="$t(key('enter_result_param_code'))"
|
||||||
clearable
|
clearable
|
||||||
style="width:200px"
|
style="width:200px"
|
||||||
@keyup.enter.native="onSearch"
|
@keyup.enter.native="onSearch"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t(key('name'))">
|
<el-form-item :label="$t(key('result_param_name'))">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="search.name"
|
v-model="search.result_param_name"
|
||||||
:placeholder="$t(key('enter_name'))"
|
:placeholder="$t(key('enter_result_param_name'))"
|
||||||
clearable
|
clearable
|
||||||
style="width:200px"
|
style="width:200px"
|
||||||
@keyup.enter.native="onSearch"
|
@keyup.enter.native="onSearch"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t(key('scada_node'))">
|
<el-form-item :label="$t(key('scada_node_code'))">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="search.scada_node"
|
v-model="search.scada_node_code"
|
||||||
:placeholder="$t(key('enter_scada_node'))"
|
:placeholder="$t(key('enter_scada_node_code'))"
|
||||||
clearable
|
clearable
|
||||||
style="width:200px"
|
style="width:200px"
|
||||||
@keyup.enter.native="onSearch"
|
@keyup.enter.native="onSearch"
|
||||||
/>
|
/>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item :label="$t(key('status'))">
|
<el-form-item :label="$t(key('scada_node_name'))">
|
||||||
<el-select
|
<el-input
|
||||||
v-model="search.status"
|
v-model="search.scada_node_name"
|
||||||
:placeholder="$t(key('select_status'))"
|
:placeholder="$t(key('enter_scada_node_name'))"
|
||||||
clearable
|
clearable
|
||||||
style="width:140px"
|
style="width:200px"
|
||||||
>
|
@keyup.enter.native="onSearch"
|
||||||
<el-option :value="1" :label="$t(key('enable'))" />
|
/>
|
||||||
<el-option :value="0" :label="$t(key('disable'))" />
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-button type="primary" icon="el-icon-search" @click="onSearch">
|
<el-button type="primary" icon="el-icon-search" @click="onSearch">
|
||||||
@@ -67,8 +65,8 @@
|
|||||||
@page-change="onPageChange"
|
@page-change="onPageChange"
|
||||||
@selection-change="onSelect"
|
@selection-change="onSelect"
|
||||||
>
|
>
|
||||||
<template #col-status_name="{ row }">
|
<template #col-category="{ row }">
|
||||||
<span>{{ row.status_name || statusText(row.status) }}</span>
|
<span>{{ categoryText(row.category) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</page-table>
|
</page-table>
|
||||||
|
|
||||||
@@ -101,6 +99,9 @@ import {
|
|||||||
editDataCollectionConfig,
|
editDataCollectionConfig,
|
||||||
deleteDataCollectionConfig
|
deleteDataCollectionConfig
|
||||||
} from '@/api/production-master-data/data-collection-configuration'
|
} 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 PageTable from '@/components/page-table'
|
||||||
import PageDialogForm from '@/components/page-dialog-form'
|
import PageDialogForm from '@/components/page-dialog-form'
|
||||||
|
|
||||||
@@ -121,140 +122,57 @@ export default {
|
|||||||
dialogTitle: '',
|
dialogTitle: '',
|
||||||
editId: '',
|
editId: '',
|
||||||
handleType: 'create',
|
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 },
|
pagination: { current: 1, size: 10, total: 0 },
|
||||||
|
workingSubclassOptions: [],
|
||||||
|
workingSubclassRawData: [],
|
||||||
|
resultParamOptions: [],
|
||||||
|
scadaNodeOptions: [],
|
||||||
formData: {
|
formData: {
|
||||||
code: '',
|
working_subclass_id: undefined,
|
||||||
name: '',
|
category: undefined,
|
||||||
scada_node: '',
|
result_param_code: undefined,
|
||||||
collect_type: '',
|
scada_node_code: undefined,
|
||||||
interval: 1,
|
result_param_type: 1
|
||||||
status: 1,
|
|
||||||
remark: ''
|
|
||||||
},
|
},
|
||||||
rules: {
|
rules: {
|
||||||
code: [
|
working_subclass_id: [
|
||||||
{ required: true, message: this.key('enter_code'), trigger: 'blur' },
|
{ required: true, message: this.key('select_working_subclass'), trigger: 'change' }
|
||||||
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
|
|
||||||
],
|
],
|
||||||
name: [
|
category: [
|
||||||
{ required: true, message: this.key('enter_name'), trigger: 'blur' },
|
{ required: true, message: this.key('select_data_type'), trigger: 'change' }
|
||||||
{ min: 1, max: 100, message: this.key('remark_length'), trigger: 'blur' }
|
|
||||||
],
|
],
|
||||||
scada_node: [
|
result_param_code: [
|
||||||
{ required: true, message: this.key('enter_scada_node'), trigger: 'blur' }
|
{ required: true, message: this.key('select_result_param'), trigger: 'change' }
|
||||||
],
|
],
|
||||||
collect_type: [
|
scada_node_code: [
|
||||||
{ required: true, message: this.key('select_collect_type'), trigger: 'change' }
|
{ required: true, message: this.key('select_scada_node'), trigger: 'change' }
|
||||||
],
|
],
|
||||||
interval: [
|
result_param_type: [
|
||||||
{ required: true, message: this.key('enter_interval'), trigger: 'blur' }
|
{ required: true, message: this.key('select_data_type'), trigger: 'change' }
|
||||||
],
|
|
||||||
status: [
|
|
||||||
{ required: true, message: this.key('select_status'), trigger: 'change' }
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
columns: [],
|
columns: [],
|
||||||
toolbarButtons: [],
|
toolbarButtons: [],
|
||||||
rowButtons: [],
|
rowButtons: [],
|
||||||
formCols: [
|
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%' }
|
|
||||||
}
|
|
||||||
]
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
this.columns = useTableColumns([
|
this.columns = useTableColumns([
|
||||||
{ prop: 'sort', label: this.key('sort'), width: 80 },
|
{ prop: 'working_subclass', label: this.key('working_subclass'), minWidth: 140 },
|
||||||
{ prop: 'code', label: this.key('code'), minWidth: 120 },
|
{ prop: 'result_param_name', label: this.key('result_param_name'), minWidth: 160 },
|
||||||
{ prop: 'name', label: this.key('name'), minWidth: 140 },
|
{ prop: 'result_param_code', label: this.key('result_param_code'), minWidth: 160 },
|
||||||
{ prop: 'scada_node', label: this.key('scada_node'), minWidth: 140 },
|
{ prop: 'scada_node_name', label: this.key('scada_node_name'), minWidth: 160 },
|
||||||
{ prop: 'collect_type_name', label: this.key('collect_type'), minWidth: 120 },
|
{ prop: 'scada_node_code', label: this.key('scada_node_code'), minWidth: 160 },
|
||||||
{ prop: 'interval', label: this.key('interval'), width: 100 },
|
{ prop: 'category', label: this.key('category'), minWidth: 140, slot: 'category' },
|
||||||
{ prop: 'status_name', label: this.key('status'), width: 100, slot: true },
|
{ prop: 'create_time', label: this.key('create_time'), minWidth: 160 },
|
||||||
{ prop: 'remark', label: this.key('remark'), minWidth: 120 },
|
{ prop: 'update_data', label: this.key('update_data'), minWidth: 160 },
|
||||||
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
|
{ prop: '_actions', label: this.key('operation'), width: 160, fixed: 'right' }
|
||||||
])
|
])
|
||||||
const btns = useTableButtons({
|
const btns = useTableButtons({
|
||||||
@@ -264,7 +182,7 @@ export default {
|
|||||||
label: this.key('add'),
|
label: this.key('add'),
|
||||||
icon: 'el-icon-plus',
|
icon: 'el-icon-plus',
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
auth: '/production_configuration/spc_configuration/binding_scada_node/create',
|
auth: '/production_configuration/matetial_model/bom/create',
|
||||||
onClick: this.openAdd
|
onClick: this.openAdd
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
@@ -273,7 +191,7 @@ export default {
|
|||||||
key: 'edit',
|
key: 'edit',
|
||||||
label: this.key('edit'),
|
label: this.key('edit'),
|
||||||
icon: 'el-icon-edit',
|
icon: 'el-icon-edit',
|
||||||
auth: '/production_configuration/spc_configuration/binding_scada_node/edit',
|
auth: '/production_configuration/matetial_model/bom/edit',
|
||||||
onClick: this.openEdit
|
onClick: this.openEdit
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -281,13 +199,15 @@ export default {
|
|||||||
label: this.key('delete'),
|
label: this.key('delete'),
|
||||||
icon: 'el-icon-delete',
|
icon: 'el-icon-delete',
|
||||||
color: 'danger',
|
color: 'danger',
|
||||||
auth: '/production_configuration/spc_configuration/binding_scada_node/delete',
|
auth: '/production_configuration/matetial_model/bom/delete',
|
||||||
onClick: this.handleDelete
|
onClick: this.handleDelete
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}, this.$permission)
|
}, this.$permission)
|
||||||
this.toolbarButtons = btns.toolbarButtons
|
this.toolbarButtons = btns.toolbarButtons
|
||||||
this.rowButtons = btns.rowButtons
|
this.rowButtons = btns.rowButtons
|
||||||
|
this.formCols = this.makeFormCols()
|
||||||
|
this.loadWorkingSubclassOptions()
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@@ -324,7 +244,7 @@ export default {
|
|||||||
total: this.getTotal(res, item.length)
|
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)) {
|
if (Array.isArray(list)) {
|
||||||
return {
|
return {
|
||||||
list,
|
list,
|
||||||
@@ -351,86 +271,168 @@ export default {
|
|||||||
}
|
}
|
||||||
return defaultValue
|
return defaultValue
|
||||||
},
|
},
|
||||||
normalizeCollectType (value) {
|
makeFormCols () {
|
||||||
const text = String(value || '').toLowerCase()
|
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 = {
|
const map = {
|
||||||
realtime: 'real_time',
|
PROCESS_INSPECTION: this.key('process_inspection'),
|
||||||
real_time: 'real_time',
|
RESULT_DATA: this.key('result_data')
|
||||||
real: 'real_time',
|
|
||||||
periodic: 'periodic',
|
|
||||||
period: 'periodic',
|
|
||||||
cycle: 'periodic',
|
|
||||||
trigger: 'trigger',
|
|
||||||
event: 'trigger'
|
|
||||||
}
|
}
|
||||||
return map[text] || value || ''
|
return map[value] ? this.$t(map[value]) : (value || '')
|
||||||
},
|
},
|
||||||
collectTypeText (value) {
|
async loadWorkingSubclassOptions () {
|
||||||
const type = this.normalizeCollectType(value)
|
try {
|
||||||
const map = {
|
const res = await getWorkingsubclassAll()
|
||||||
real_time: this.key('real_time'),
|
const list = this.normalizeList(res)
|
||||||
periodic: this.key('periodic'),
|
this.workingSubclassRawData = list
|
||||||
trigger: this.key('trigger')
|
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) {
|
findWorkingSubclassById (id) {
|
||||||
const status = this.firstValue(row, ['status', 'enable', 'enabled', 'is_enable', 'active'], '')
|
return this.workingSubclassRawData.find(item => item.id === id)
|
||||||
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
|
|
||||||
},
|
},
|
||||||
statusText (status) {
|
async onWorkingSubclassChange (value) {
|
||||||
if (status === 1 || status === '1') return this.$t(this.key('enable'))
|
this.formData.result_param_code = undefined
|
||||||
if (status === 0 || status === '0') return this.$t(this.key('disable'))
|
this.formData.scada_node_code = undefined
|
||||||
return status || ''
|
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) {
|
async loadResultParamOptions (workingsubclassId) {
|
||||||
const sortIndex = typeof index === 'number' ? index + 1 : ''
|
try {
|
||||||
const collectType = this.normalizeCollectType(this.firstValue(row, [
|
const res = await getOptionalParamsList({
|
||||||
'collect_type',
|
workingsubclass_id: workingsubclassId,
|
||||||
'collection_type',
|
page_no: 1,
|
||||||
'type',
|
page_size: 10000
|
||||||
'category'
|
})
|
||||||
], ''))
|
this.resultParamOptions = this.normalizeList(res).map(item => ({
|
||||||
const status = this.normalizeStatus(row)
|
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 {
|
return {
|
||||||
...row,
|
...row,
|
||||||
id: this.firstValue(row, ['id', 'binding_scada_node_id', 'config_id']),
|
id: this.firstValue(row, ['id', 'binding_scada_node_id', 'config_id']),
|
||||||
sort: this.firstValue(row, ['sort', 'order_no', 'sequence', 'seq'], sortIndex),
|
working_subclass: this.firstValue(row, ['working_subclass', 'working_subclass_code', 'workingsubclass_code']),
|
||||||
code: this.firstValue(row, ['code', 'node_code', 'scada_code', 'binding_code', 'number']),
|
working_subclass_id: this.firstValue(row, ['working_subclass_id', 'workingsubclass_id']),
|
||||||
name: this.firstValue(row, ['name', 'node_name', 'scada_name', 'binding_name', 'label']),
|
result_param_name: this.firstValue(row, ['result_param_name', 'param_name', 'name']),
|
||||||
scada_node: this.firstValue(row, [
|
result_param_code: this.firstValue(row, ['result_param_code', 'param_code', 'code']),
|
||||||
'scada_node',
|
scada_node_name: this.firstValue(row, ['scada_node_name', 'node_name']),
|
||||||
'scada_node_name',
|
scada_node_code: this.firstValue(row, ['scada_node_code', 'node_code']),
|
||||||
'scadaNode',
|
category: this.firstValue(row, ['category', 'data_category']),
|
||||||
'node',
|
create_time: this.firstValue(row, ['create_time', 'created_at']),
|
||||||
'node_name',
|
update_data: this.firstValue(row, ['update_data', 'update_time', 'updated_at'])
|
||||||
'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'])
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onSearch () {
|
onSearch () {
|
||||||
@@ -438,7 +440,12 @@ export default {
|
|||||||
this.fetchData()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
onReset () {
|
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.pagination.current = 1
|
||||||
this.fetchData()
|
this.fetchData()
|
||||||
},
|
},
|
||||||
@@ -452,14 +459,15 @@ export default {
|
|||||||
},
|
},
|
||||||
resetForm () {
|
resetForm () {
|
||||||
this.formData = {
|
this.formData = {
|
||||||
code: '',
|
working_subclass_id: undefined,
|
||||||
name: '',
|
category: undefined,
|
||||||
scada_node: '',
|
result_param_code: undefined,
|
||||||
collect_type: '',
|
scada_node_code: undefined,
|
||||||
interval: 1,
|
result_param_type: 1
|
||||||
status: 1,
|
|
||||||
remark: ''
|
|
||||||
}
|
}
|
||||||
|
this.resultParamOptions = []
|
||||||
|
this.scadaNodeOptions = []
|
||||||
|
this.formCols = this.makeFormCols()
|
||||||
this.editId = ''
|
this.editId = ''
|
||||||
},
|
},
|
||||||
openAdd () {
|
openAdd () {
|
||||||
@@ -471,29 +479,64 @@ export default {
|
|||||||
this.dialogVisible = true
|
this.dialogVisible = true
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
openEdit (row) {
|
async openEdit (row) {
|
||||||
|
if (!this.workingSubclassRawData.length) {
|
||||||
|
await this.loadWorkingSubclassOptions()
|
||||||
|
}
|
||||||
const record = this.normalizeRow(row)
|
const record = this.normalizeRow(row)
|
||||||
this.handleType = 'edit'
|
this.handleType = 'edit'
|
||||||
this.dialogTitle = this.key('edit_title')
|
this.dialogTitle = this.key('edit_title')
|
||||||
this.editId = record.id
|
this.editId = record.id
|
||||||
|
const workingSubclassId = record.working_subclass_id || this.getWorkingSubclassIdByCode(record.working_subclass)
|
||||||
this.formData = {
|
this.formData = {
|
||||||
code: record.code,
|
working_subclass_id: workingSubclassId,
|
||||||
name: record.name,
|
category: record.category,
|
||||||
scada_node: record.scada_node || '',
|
result_param_code: record.result_param_code,
|
||||||
collect_type: record.collect_type || '',
|
scada_node_code: record.scada_node_code,
|
||||||
interval: record.interval || 1,
|
result_param_type: record.result_param_type || 1
|
||||||
status: typeof record.status === 'number' ? record.status : 1,
|
}
|
||||||
remark: record.remark || ''
|
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 () {
|
async onDialogSubmit () {
|
||||||
this.submitting = true
|
this.submitting = true
|
||||||
try {
|
try {
|
||||||
|
const submitData = this.buildSubmitData()
|
||||||
if (this.handleType === 'create') {
|
if (this.handleType === 'create') {
|
||||||
await createDataCollectionConfig(this.formData)
|
await createDataCollectionConfig(submitData)
|
||||||
} else {
|
} else {
|
||||||
await editDataCollectionConfig({ ...this.formData, id: this.editId })
|
await editDataCollectionConfig({ ...submitData, id: this.editId })
|
||||||
}
|
}
|
||||||
this.$message.success(this.$t(this.key('operation_success')))
|
this.$message.success(this.$t(this.key('operation_success')))
|
||||||
this.dialogVisible = false
|
this.dialogVisible = false
|
||||||
|
|||||||
Reference in New Issue
Block a user