|
@@ -228,9 +228,11 @@ const groupingList = ref<GroupingList[]>([
|
|
|
},
|
|
|
]);
|
|
|
|
|
|
-const deviceParamGroups: DeviceParamGroups[] = [];
|
|
|
-const deviceGateways: DeviceGateways[] = [];
|
|
|
-const deviceParamGroupRels: DeviceParamGroupRels[] = [];
|
|
|
+const groupingDisplayList = ref<GroupingList[]>([]);
|
|
|
+
|
|
|
+const deviceParamGroups = ref<DeviceParamGroups[]>([]);
|
|
|
+const deviceGateways = ref<DeviceGateways[]>([]);
|
|
|
+const deviceParamGroupRels = ref<DeviceParamGroupRels[]>([]);
|
|
|
const customizationData = ref<CustomizationData[]>([]);
|
|
|
|
|
|
const { handleRequest } = useRequest();
|
|
@@ -254,7 +256,7 @@ let linkId: number;
|
|
|
|
|
|
const deviceId = props.form.devId;
|
|
|
|
|
|
-const customParameters: CustomParameters[] = [];
|
|
|
+const customParameters = ref<CustomParameters[]>([]);
|
|
|
|
|
|
const agreementKey = ref<string>('monitoring');
|
|
|
const agreementListKey = ref<string>('monitoring');
|
|
@@ -447,6 +449,8 @@ const addGateway = () => {
|
|
|
const { links, id, snCode, modelName } = serialNumberItem.value[0];
|
|
|
const { linkId: physicalId } = links[0];
|
|
|
linkId = physicalId;
|
|
|
+
|
|
|
+ gatewayId = id;
|
|
|
gatewayList.value.push({
|
|
|
snCode,
|
|
|
modelName,
|
|
@@ -522,8 +526,9 @@ const obtainParamValueListAutomatic = (linkId: number) => {
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-const linkSwitch = (value: SelectValue, option: DefaultOptionType, index: number) => {
|
|
|
+const linkSwitch = (value: SelectValue, option: DefaultOptionType, index: number, divId: number) => {
|
|
|
linkId = option.linkId;
|
|
|
+ gatewayId = divId;
|
|
|
gatewayList.value[index].linkId = option.linkId;
|
|
|
gatewayList.value[index].modelNameShow = false;
|
|
|
obtainParamValueListAutomatic(option.linkId);
|
|
@@ -610,9 +615,55 @@ const arrayIdFiltering = (a: Key[], b: ListEquipmentParametersItem[]) => {
|
|
|
return a.filter((item) => !idsToRemove.includes(Number(item)));
|
|
|
};
|
|
|
|
|
|
+const validateParams = () => {
|
|
|
+ const errors: string[] = [];
|
|
|
+ const codes = new Set<string>();
|
|
|
+ const names = new Set<string>();
|
|
|
+ const dataList = [
|
|
|
+ ...monitorAssociationGatewayList.value,
|
|
|
+ ...controlAssociationGatewayList.value,
|
|
|
+ ...customizationData.value,
|
|
|
+ ];
|
|
|
+
|
|
|
+ dataList.forEach((param) => {
|
|
|
+ if (codes.has(param.deviceParamCode)) {
|
|
|
+ errors.push(`设备参数编码:" ${param.deviceParamCode} "重复`);
|
|
|
+ }
|
|
|
+ if (names.has(param.deviceParamName)) {
|
|
|
+ errors.push(`设备参数名称:" ${param.deviceParamName} "重复`);
|
|
|
+ }
|
|
|
+ codes.add(param.deviceParamCode);
|
|
|
+ names.add(param.deviceParamName);
|
|
|
+ });
|
|
|
+
|
|
|
+ return errors;
|
|
|
+};
|
|
|
+
|
|
|
const finish = async () => {
|
|
|
+ const dataList = [
|
|
|
+ ...monitorAssociationGatewayList.value,
|
|
|
+ ...controlAssociationGatewayList.value,
|
|
|
+ ...customizationData.value,
|
|
|
+ ];
|
|
|
+
|
|
|
+ if (dataList.some((item) => item.deviceParamCode == '')) {
|
|
|
+ throw new Error('设备参数编码不能为空!');
|
|
|
+ }
|
|
|
+ if (dataList.some((item) => item.deviceParamName == '')) {
|
|
|
+ throw new Error('设备参数名称不能为空!');
|
|
|
+ }
|
|
|
+ const valueList = validateParams();
|
|
|
+ if (valueList.length) {
|
|
|
+ throw new Error('设备参数名称或设备参数编码存在重复项!');
|
|
|
+ }
|
|
|
+
|
|
|
+ deviceParamGroups.value = [];
|
|
|
+ customParameters.value = [];
|
|
|
+ deviceGateways.value = [];
|
|
|
+ deviceParamGroupRels.value = [];
|
|
|
+
|
|
|
groupingList.value.forEach((item) => {
|
|
|
- deviceParamGroups.push({
|
|
|
+ deviceParamGroups.value.push({
|
|
|
groupName: item.groupName,
|
|
|
deviceId,
|
|
|
});
|
|
@@ -628,7 +679,7 @@ const finish = async () => {
|
|
|
deviceParamCode,
|
|
|
paramGroupName,
|
|
|
} = item;
|
|
|
- customParameters.push({
|
|
|
+ customParameters.value.push({
|
|
|
customFormula,
|
|
|
unit,
|
|
|
decimalDigits,
|
|
@@ -644,13 +695,13 @@ const finish = async () => {
|
|
|
|
|
|
[...monitorAssociationGatewayList.value, ...controlAssociationGatewayList.value].forEach((item) => {
|
|
|
const { id, gatewayId, linkId, groupName, deviceParamCode, deviceParamName, isProcessData, unit } = item;
|
|
|
- deviceGateways.push({
|
|
|
+ deviceGateways.value.push({
|
|
|
deviceId,
|
|
|
gatewayId,
|
|
|
gatewayProtocolId: id,
|
|
|
linkId,
|
|
|
});
|
|
|
- deviceParamGroupRels.push({
|
|
|
+ deviceParamGroupRels.value.push({
|
|
|
deviceId,
|
|
|
protocolParamId: id,
|
|
|
paramGroupName: groupName,
|
|
@@ -663,10 +714,10 @@ const finish = async () => {
|
|
|
});
|
|
|
|
|
|
await addDeviceBind({
|
|
|
- deviceParamGroups,
|
|
|
- deviceGateways,
|
|
|
- deviceParamGroupRels,
|
|
|
- protocolParamCustomDevDTOS: customParameters,
|
|
|
+ deviceParamGroups: deviceParamGroups.value,
|
|
|
+ deviceGateways: deviceGateways.value,
|
|
|
+ deviceParamGroupRels: deviceParamGroupRels.value,
|
|
|
+ protocolParamCustomDevDTOS: customParameters.value,
|
|
|
});
|
|
|
};
|
|
|
|
|
@@ -675,21 +726,29 @@ defineExpose<UseGuideStepItemExpose>({
|
|
|
});
|
|
|
|
|
|
const groupSettings = () => {
|
|
|
+ groupingDisplayList.value = JSON.parse(JSON.stringify(groupingList.value));
|
|
|
open1.value = true;
|
|
|
};
|
|
|
|
|
|
const addGroupingList = () => {
|
|
|
- groupingList.value.push({
|
|
|
+ groupingDisplayList.value.push({
|
|
|
groupName: '',
|
|
|
serialNum: undefined,
|
|
|
});
|
|
|
};
|
|
|
|
|
|
const deleteGroupingList = (index: number) => {
|
|
|
- groupingList.value.splice(index, 1);
|
|
|
+ groupingDisplayList.value.splice(index, 1);
|
|
|
};
|
|
|
|
|
|
const handleOk1 = () => {
|
|
|
+ if (groupingDisplayList.value.some((item) => item.groupName == '')) {
|
|
|
+ return message.warning('分组名称不能为空!');
|
|
|
+ }
|
|
|
+ if (new Set(groupingDisplayList.value.map((item) => item.groupName)).size !== groupingDisplayList.value.length) {
|
|
|
+ return message.warning('分组名称不能重复!');
|
|
|
+ }
|
|
|
+ groupingList.value = groupingDisplayList.value;
|
|
|
open1.value = false;
|
|
|
};
|
|
|
|
|
@@ -887,7 +946,7 @@ onMounted(() => {
|
|
|
:show-arrow="record.modelNameShow"
|
|
|
:options="record.links"
|
|
|
:field-names="{ label: 'linkName', value: 'linkId' }"
|
|
|
- @change="(value, option) => linkSwitch(value, option, index)"
|
|
|
+ @change="(value, option) => linkSwitch(value, option, index, record.divId)"
|
|
|
/>
|
|
|
</template>
|
|
|
|
|
@@ -1266,10 +1325,11 @@ onMounted(() => {
|
|
|
width="460px"
|
|
|
:mask-closable="false"
|
|
|
:keyboard="false"
|
|
|
+ :ok-text="$t('common.save')"
|
|
|
>
|
|
|
<br />
|
|
|
|
|
|
- <ATable :columns="groupingColumns" :data-source="groupingList" :pagination="false">
|
|
|
+ <ATable :columns="groupingColumns" :data-source="groupingDisplayList" :pagination="false">
|
|
|
<template #bodyCell="{ column, record, index }">
|
|
|
<template v-if="column.key === 'groupName'">
|
|
|
<AInput v-model:value="record.groupName" />
|