From 992e9a0aabbd4621501d8b03bc5fa603a40973f6 Mon Sep 17 00:00:00 2001 From: XieYongHong <18010623010@163.com> Date: Tue, 25 Jul 2023 19:50:58 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BC=98=E5=8C=96gateway=E7=9A=84?= =?UTF-8?q?=E9=87=87=E9=9B=86=E5=99=A8=E6=96=B0=E5=A2=9E=EF=BC=8C=E7=82=B9?= =?UTF-8?q?=E4=BD=8D=E6=96=B0=E5=A2=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/data-collect/collector.ts | 1 + .../Collector/Point/Save/SaveModBus.vue | 49 ++- .../DataCollect/Collector/Tree/Save/index.vue | 291 +++++++++--------- .../Detail/components/EditTable/index.vue | 10 +- src/views/link/AccessConfig/Detail/index.vue | 2 +- src/views/link/AccessConfig/data.ts | 1 + vite.config.ts | 2 +- 7 files changed, 192 insertions(+), 164 deletions(-) diff --git a/src/api/data-collect/collector.ts b/src/api/data-collect/collector.ts index 53304ef6..ce1c8e5f 100644 --- a/src/api/data-collect/collector.ts +++ b/src/api/data-collect/collector.ts @@ -61,3 +61,4 @@ export const scanOpcUAList = (data: any) => export const queryTypeList = () => server.get(`/data-collect/opc/data-types`); +export const getProviders = () => server.get('/data-collect/channel/gateway/codec/providers') \ No newline at end of file diff --git a/src/views/DataCollect/Collector/Point/Save/SaveModBus.vue b/src/views/DataCollect/Collector/Point/Save/SaveModBus.vue index 5ddbdfd5..9d40ba15 100644 --- a/src/views/DataCollect/Collector/Point/Save/SaveModBus.vue +++ b/src/views/DataCollect/Collector/Point/Save/SaveModBus.vue @@ -271,7 +271,7 @@ import { import { ModBusRules, checkProviderData } from '../../data.ts'; import type { FormInstance } from 'ant-design-vue'; import type { Rule } from 'ant-design-vue/lib/form'; -import { cloneDeep } from 'lodash-es'; +import {cloneDeep, omit} from 'lodash-es'; const props = defineProps({ data: { @@ -343,10 +343,18 @@ const handleOk = async () => { // address是多余字段,但是react版本上使用到了这个字段 params.configuration.parameter = { - ...params.configuration.parameter, - address: data?.pointKey, + ...params.configuration.parameter, + address: data?.pointKey, }; + if (props.data.provider === 'GATEWAY') { + const configuration = cloneDeep(params.configuration) + params.configuration = { + configuration: configuration, + interval: params.interval + } + } + loading.value = true; const response = !id ? await savePointBatch(params).catch(() => {}) @@ -439,22 +447,31 @@ watch( watch( () => props.data, (value) => { - if (value.id && value.provider === 'MODBUS_TCP') { + if (value.id && ['MODBUS_TCP', 'GATEWAY'].includes(value.provider)) { const _value: any = cloneDeep(value); const { writeByteCount, byteCount } = - _value.configuration.parameter; + props.data.provider === 'GATEWAY' ? _value.configuration.configuration.parameter: _value.configuration.parameter; + + if (props.data.provider === 'GATEWAY') { + formData.value = { + ...omit(_value, ['configuration']), + ..._value.configuration, + } + } else { formData.value = _value; - if (!!_value.accessModes[0]?.value) { - formData.value.accessModes = value.accessModes.map( - (i: any) => i.value, - ); - } - if (!!_value.features[0]?.value) { - formData.value.features = value.features.map( - (i: any) => i.value, - ); - } - formData.value.nspwc = !!writeByteCount || !!byteCount; + } + + if (!!_value.accessModes[0]?.value) { + formData.value.accessModes = value.accessModes.map( + (i: any) => i.value, + ); + } + if (!!_value.features[0]?.value) { + formData.value.features = value.features.map( + (i: any) => i.value, + ); + } + formData.value.nspwc = !!writeByteCount || !!byteCount; } }, { immediate: true, deep: true }, diff --git a/src/views/DataCollect/Collector/Tree/Save/index.vue b/src/views/DataCollect/Collector/Tree/Save/index.vue index c4c9f1a6..f869e77f 100644 --- a/src/views/DataCollect/Collector/Tree/Save/index.vue +++ b/src/views/DataCollect/Collector/Tree/Save/index.vue @@ -40,114 +40,111 @@ v-model:value="formData.name" /> - - -