fix: 优化gateway的采集器新增,点位新增
This commit is contained in:
parent
ccbdef9f3c
commit
992e9a0aab
|
@ -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')
|
|
@ -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: {
|
||||
|
@ -347,6 +347,14 @@ const handleOk = async () => {
|
|||
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,11 +447,20 @@ 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,
|
||||
|
|
|
@ -40,16 +40,15 @@
|
|||
v-model:value="formData.name"
|
||||
/>
|
||||
</j-form-item>
|
||||
|
||||
<template v-if="provider === 'GATEWAY'">
|
||||
<j-form-item
|
||||
v-if="provider === 'GATEWAY'"
|
||||
label="通讯协议"
|
||||
:name="['configuration', 'collectorProvider']"
|
||||
:name="['collectorProvider']"
|
||||
:rules="[{ required: true, message: '请选择通讯协议' }]"
|
||||
>
|
||||
<j-select
|
||||
style="width: 100%"
|
||||
v-model:value="formData.configuration.collectorProvider"
|
||||
v-model:value="formData.collectorProvider"
|
||||
:options="providerListItems"
|
||||
placeholder="请选择通讯协议"
|
||||
allowClear
|
||||
|
@ -58,8 +57,6 @@
|
|||
:disabled="!!id"
|
||||
/>
|
||||
</j-form-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<j-form-item
|
||||
v-if="visibleUnitId"
|
||||
:name="['configuration', 'unitId']"
|
||||
|
@ -75,6 +72,7 @@
|
|||
/>
|
||||
</j-form-item>
|
||||
<j-form-item
|
||||
v-if="provider !== 'GATEWAY'"
|
||||
:name="['configuration', 'inheritBreakerSpec', 'type']"
|
||||
:rules="LeftTreeRules.type"
|
||||
label="点位熔断处理"
|
||||
|
@ -90,7 +88,7 @@
|
|||
@change="changeCardSelectType"
|
||||
/>
|
||||
</j-form-item>
|
||||
<p style="color: #616161">
|
||||
<p style="color: #616161" v-if="provider !== 'GATEWAY'">
|
||||
{{ getTypeTooltip(formData.configuration.inheritBreakerSpec.type) }}
|
||||
</p>
|
||||
<j-form-item
|
||||
|
@ -147,7 +145,6 @@
|
|||
:min="1"
|
||||
/>
|
||||
</j-form-item>
|
||||
</template>
|
||||
<j-form-item label="说明" name="description">
|
||||
<j-textarea
|
||||
placeholder="请输入说明"
|
||||
|
@ -176,11 +173,10 @@
|
|||
</j-modal>
|
||||
</template>
|
||||
<script lang="ts" name="CollectorTreeSave" setup>
|
||||
import { save, update } from '@/api/data-collect/collector';
|
||||
import { save, update, getProviders } from '@/api/data-collect/collector';
|
||||
import { LeftTreeRules } from '../../data';
|
||||
import type { FormInstance } from 'ant-design-vue';
|
||||
import {cloneDeep} from "lodash-es";
|
||||
import {getProviders} from "@/api/data-collect/channel";
|
||||
import {cloneDeep, omit} from "lodash-es";
|
||||
import {protocolList} from "@/utils/consts";
|
||||
|
||||
const loading = ref(false);
|
||||
|
@ -208,13 +204,7 @@ const providerListItems = ref()
|
|||
const geyProviderList = async () => {
|
||||
const resp: any = await getProviders();
|
||||
if (resp.success) {
|
||||
const arr = resp.result.filter(
|
||||
(item: any) => ['collector-gateway', 'modbus-tcp', 'opc-ua'].includes(item.id),
|
||||
).map((it: any) => it.id);
|
||||
console.log(arr, protocolList)
|
||||
providerListItems.value = protocolList.filter((item: any) =>
|
||||
arr.includes(item.alias),
|
||||
);
|
||||
providerListItems.value = resp.result.map((item: any) => ({ label: item.name, value: item.id }))
|
||||
} else {
|
||||
providerListItems.value = []
|
||||
}
|
||||
|
@ -255,12 +245,12 @@ const endianData = computed(() => {
|
|||
const formData = ref({
|
||||
channelId: undefined,
|
||||
name: '',
|
||||
collectorProvider: undefined,
|
||||
configuration: {
|
||||
unitId: '',
|
||||
type: 'LowerFrequency',
|
||||
endian: 'BIG',
|
||||
endianIn: 'BIG',
|
||||
collectorProvider: undefined,
|
||||
requsetTimeout: 2000,
|
||||
inheritBreakerSpec: {
|
||||
type: 'LowerFrequency',
|
||||
|
@ -274,20 +264,32 @@ const formData = ref({
|
|||
});
|
||||
|
||||
const handleOk = async () => {
|
||||
const data = await formRef.value?.validate();
|
||||
|
||||
|
||||
const _data: any = await formRef.value?.validate();
|
||||
|
||||
if (_data) {
|
||||
const { name } = _channelListAll.value.find(
|
||||
(item: any) => item.id === formData.value.channelId,
|
||||
);
|
||||
|
||||
if (['GATEWAY'].includes(data?.provider)) {
|
||||
data.configuration.inheritBreakerSpec.type = 'Ignore'
|
||||
let _copyData = _data
|
||||
|
||||
if (['GATEWAY'].includes(provider.value)) {
|
||||
const copyData = cloneDeep(_data)
|
||||
_copyData = omit(copyData, ['configuration', 'collectorProvider'])
|
||||
|
||||
_copyData.configuration = {
|
||||
configuration: {
|
||||
..._data.configuration,
|
||||
inheritBreakerSpec: {
|
||||
type: 'Ignore'
|
||||
}
|
||||
},
|
||||
collectorProvider: _data.collectorProvider
|
||||
}
|
||||
}
|
||||
|
||||
const params = {
|
||||
...data,
|
||||
..._copyData,
|
||||
provider: provider.value,
|
||||
channelName: name,
|
||||
circuitBreaker: {
|
||||
|
@ -296,13 +298,19 @@ const handleOk = async () => {
|
|||
};
|
||||
|
||||
loading.value = true;
|
||||
|
||||
try {
|
||||
const response = !id
|
||||
? await save(params).catch(() => { success: false })
|
||||
: await update(id, { ...props.data, ...params }).catch(() => { success: false });
|
||||
? await save(params)
|
||||
: await update(id, { ...props.data, ...params })
|
||||
loading.value = false;
|
||||
if (response.success) {
|
||||
emit('change', true);
|
||||
}
|
||||
} catch (e) {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const getTypeTooltip = (value: string) => {
|
||||
|
@ -337,7 +345,7 @@ watch(
|
|||
(value) => {
|
||||
const dt = _channelListAll.value.find((item) => item.id === value);
|
||||
visibleUnitId.value = visibleEndian.value =
|
||||
dt?.provider && dt?.provider === 'MODBUS_TCP';
|
||||
dt?.provider && ['MODBUS_TCP', 'GATEWAY'].includes(dt?.provider);
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
@ -347,7 +355,7 @@ watch(
|
|||
(value) => {
|
||||
if (value.id) {
|
||||
let copyValue = cloneDeep(value)
|
||||
if (!copyValue?.configuration?.inheritBreakerSpec) {
|
||||
if (!copyValue?.configuration?.inheritBreakerSpec && copyValue.provider !== 'GATEWAY') {
|
||||
copyValue.configuration = {
|
||||
...copyValue.configuration,
|
||||
inheritBreakerSpec: {
|
||||
|
@ -356,12 +364,17 @@ watch(
|
|||
}
|
||||
copyValue.circuitBreaker.type = 'Ignore'
|
||||
}
|
||||
formData.value = copyValue
|
||||
|
||||
const item = props.channelListAll.find(
|
||||
(item: any) => item.id === formData.value.channelId,
|
||||
);
|
||||
provider.value = item?.provider
|
||||
if (copyValue.provider === 'GATEWAY') {
|
||||
formData.value = {
|
||||
...omit(copyValue, ['configuration']),
|
||||
...copyValue.configuration,
|
||||
}
|
||||
} else {
|
||||
formData.value = copyValue
|
||||
}
|
||||
|
||||
provider.value = copyValue?.provider
|
||||
};
|
||||
},
|
||||
{ immediate: true, deep: true },
|
||||
|
|
|
@ -28,13 +28,8 @@
|
|||
placeholder="请选择"
|
||||
allowClear
|
||||
:filter-option="filterOption"
|
||||
>
|
||||
<j-select-option
|
||||
v-for="item in channelList"
|
||||
:key="item.value"
|
||||
:value="item.value"
|
||||
:label="item.label"
|
||||
>{{ item.label }}</j-select-option
|
||||
:options="channelList"
|
||||
@select="(_, option) => { record.provider = option.provider }"
|
||||
>
|
||||
</j-select>
|
||||
</j-form-item>
|
||||
|
@ -269,6 +264,7 @@ const onSave = () => {
|
|||
(i: any) => i.channelId,
|
||||
);
|
||||
if (arr && arr.length !== 0) {
|
||||
console.log(arr)
|
||||
const resp = await saveMapping(
|
||||
instanceStore.current.id,
|
||||
props.provider,
|
||||
|
|
|
@ -139,7 +139,7 @@ const getTypeList = (result: Record<string, any>) => {
|
|||
} else if (item.id === 'OneNet' || item.id === 'Ctwing') {
|
||||
item.type = 'cloud';
|
||||
cloud.push(item);
|
||||
} else if (item.id === 'modbus-tcp' || item.id === 'opc-ua') {
|
||||
} else if (item.id === 'modbus-tcp' || item.id === 'opc-ua' || item.id === 'collector-gateway') {
|
||||
item.type = 'channel';
|
||||
channel.push(item);
|
||||
} else if (
|
||||
|
|
|
@ -45,6 +45,7 @@ BackMap.set('gb28181-2016', getImage('/access/gb28181.png'));
|
|||
BackMap.set('mqtt-client-gateway', getImage('/access/mqtt-broke.png'));
|
||||
BackMap.set('edge-child-device', getImage('/access/child-device.png'));
|
||||
BackMap.set('official-edge-gateway', getImage('/access/edge.png'));
|
||||
BackMap.set('collector-gateway', getImage('/access/collector-gateway.png'));
|
||||
|
||||
const descriptionList = {
|
||||
'udp-device-gateway':
|
||||
|
|
Loading…
Reference in New Issue