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" /> - - -