|
|
|
|
@@ -3,43 +3,41 @@
|
|
|
|
|
<template #header>
|
|
|
|
|
<div class="search-bar">
|
|
|
|
|
<el-form :inline="true" size="mini">
|
|
|
|
|
<el-form-item :label="$t(key('code'))">
|
|
|
|
|
<el-form-item :label="$t(key('result_param_code'))">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="search.code"
|
|
|
|
|
:placeholder="$t(key('enter_code'))"
|
|
|
|
|
v-model="search.result_param_code"
|
|
|
|
|
:placeholder="$t(key('enter_result_param_code'))"
|
|
|
|
|
clearable
|
|
|
|
|
style="width:200px"
|
|
|
|
|
@keyup.enter.native="onSearch"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t(key('name'))">
|
|
|
|
|
<el-form-item :label="$t(key('result_param_name'))">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="search.name"
|
|
|
|
|
:placeholder="$t(key('enter_name'))"
|
|
|
|
|
v-model="search.result_param_name"
|
|
|
|
|
:placeholder="$t(key('enter_result_param_name'))"
|
|
|
|
|
clearable
|
|
|
|
|
style="width:200px"
|
|
|
|
|
@keyup.enter.native="onSearch"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t(key('scada_node'))">
|
|
|
|
|
<el-form-item :label="$t(key('scada_node_code'))">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="search.scada_node"
|
|
|
|
|
:placeholder="$t(key('enter_scada_node'))"
|
|
|
|
|
v-model="search.scada_node_code"
|
|
|
|
|
:placeholder="$t(key('enter_scada_node_code'))"
|
|
|
|
|
clearable
|
|
|
|
|
style="width:200px"
|
|
|
|
|
@keyup.enter.native="onSearch"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item :label="$t(key('status'))">
|
|
|
|
|
<el-select
|
|
|
|
|
v-model="search.status"
|
|
|
|
|
:placeholder="$t(key('select_status'))"
|
|
|
|
|
<el-form-item :label="$t(key('scada_node_name'))">
|
|
|
|
|
<el-input
|
|
|
|
|
v-model="search.scada_node_name"
|
|
|
|
|
:placeholder="$t(key('enter_scada_node_name'))"
|
|
|
|
|
clearable
|
|
|
|
|
style="width:140px"
|
|
|
|
|
>
|
|
|
|
|
<el-option :value="1" :label="$t(key('enable'))" />
|
|
|
|
|
<el-option :value="0" :label="$t(key('disable'))" />
|
|
|
|
|
</el-select>
|
|
|
|
|
style="width:200px"
|
|
|
|
|
@keyup.enter.native="onSearch"
|
|
|
|
|
/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item>
|
|
|
|
|
<el-button type="primary" icon="el-icon-search" @click="onSearch">
|
|
|
|
|
@@ -67,8 +65,8 @@
|
|
|
|
|
@page-change="onPageChange"
|
|
|
|
|
@selection-change="onSelect"
|
|
|
|
|
>
|
|
|
|
|
<template #col-status_name="{ row }">
|
|
|
|
|
<span>{{ row.status_name || statusText(row.status) }}</span>
|
|
|
|
|
<template #col-category="{ row }">
|
|
|
|
|
<span>{{ categoryText(row.category) }}</span>
|
|
|
|
|
</template>
|
|
|
|
|
</page-table>
|
|
|
|
|
|
|
|
|
|
@@ -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()
|
|
|
|
|
const map = {
|
|
|
|
|
realtime: 'real_time',
|
|
|
|
|
real_time: 'real_time',
|
|
|
|
|
real: 'real_time',
|
|
|
|
|
periodic: 'periodic',
|
|
|
|
|
period: 'periodic',
|
|
|
|
|
cycle: 'periodic',
|
|
|
|
|
trigger: 'trigger',
|
|
|
|
|
event: 'trigger'
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
return map[text] || value || ''
|
|
|
|
|
},
|
|
|
|
|
collectTypeText (value) {
|
|
|
|
|
const type = this.normalizeCollectType(value)
|
|
|
|
|
const map = {
|
|
|
|
|
real_time: this.key('real_time'),
|
|
|
|
|
periodic: this.key('periodic'),
|
|
|
|
|
trigger: this.key('trigger')
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
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' }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
return map[type] ? this.$t(map[type]) : (value || '')
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
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 }
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
|
normalizeList (res) {
|
|
|
|
|
return this.normalizeResponse(res).list
|
|
|
|
|
},
|
|
|
|
|
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 || ''
|
|
|
|
|
categoryText (value) {
|
|
|
|
|
const map = {
|
|
|
|
|
PROCESS_INSPECTION: this.key('process_inspection'),
|
|
|
|
|
RESULT_DATA: this.key('result_data')
|
|
|
|
|
}
|
|
|
|
|
return map[value] ? this.$t(map[value]) : (value || '')
|
|
|
|
|
},
|
|
|
|
|
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 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()
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
findWorkingSubclassById (id) {
|
|
|
|
|
return this.workingSubclassRawData.find(item => item.id === id)
|
|
|
|
|
},
|
|
|
|
|
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()
|
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
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
|
|
|
|
|
|