Commit 29792f1cb73f73e7f5a2eb195c227e75b0ec244b

Authored by fengtao
1 parent 99c1ff47

fix:修复场景联动新增触发器无设备问题

... ... @@ -3,17 +3,17 @@ import { FormSchema } from '/@/components/Form';
3 3 import { BasicColumn } from '/@/components/Table';
4 4 import { DeviceTypeEnum } from '/@/api/device/model/deviceModel';
5 5 import { getCustomerList } from '/@/api/device/deviceManager';
6   -import moment from 'moment';
  6 +import dayjs from 'moment';
7 7 export const columns: BasicColumn[] = [
8 8 {
9 9 title: '设备名称',
10 10 dataIndex: 'name',
11   - width: 160,
  11 + width: 120,
12 12 },
13 13 {
14 14 title: '设备标签',
15 15 dataIndex: 'label',
16   - width: 160,
  16 + width: 100,
17 17 },
18 18 {
19 19 title: '设备配置',
... ... @@ -34,7 +34,7 @@ export const columns: BasicColumn[] = [
34 34 {
35 35 title: '描述',
36 36 dataIndex: 'description',
37   - width: 160,
  37 + width: 180,
38 38 },
39 39 ];
40 40 // 实时数据表格
... ... @@ -100,7 +100,7 @@ export const alarmSearchSchemas: FormSchema[] = [
100 100 component: 'DatePicker',
101 101 componentProps: {
102 102 valueFormat: 'x',
103   - showTime: { defaultValue: moment('23:59:59', 'HH:mm:ss') },
  103 + showTime: { defaultValue: dayjs('23:59:59', 'HH:mm:ss') },
104 104 },
105 105 colProps: { span: 6 },
106 106 },
... ... @@ -216,22 +216,16 @@ export const alarmSchemasForm: FormSchema[] = [
216 216 // 子设备
217 217 export const childDeviceSchemas: FormSchema[] = [
218 218 {
219   - field: 'deviceState',
220   - label: '设备状态',
221   - colProps: { span: 6 },
  219 + field: 'icon',
  220 + label: '设备配置',
222 221 component: 'Select',
  222 + colProps: { span: 6 },
223 223 componentProps: {
224   - size: 'small',
225 224 maxLength: 255,
226   - options: [
227   - { label: '待激活', value: 'INACTIVE' },
228   - { label: '在线', value: 'ONLINE' },
229   - { label: '离线', value: 'OFFLINE' },
230   - ],
231 225 },
232 226 },
233 227 {
234   - field: 'name',
  228 + field: 'icon',
235 229 label: '设备名称',
236 230 component: 'Input',
237 231 colProps: { span: 6 },
... ... @@ -244,30 +238,32 @@ export const childDeviceSchemas: FormSchema[] = [
244 238 export const childDeviceColumns: BasicColumn[] = [
245 239 {
246 240 title: '名称',
247   - dataIndex: 'tbDeviceName',
  241 + dataIndex: 'name',
248 242 width: 120,
249 243 },
250 244 {
251   - title: '标签',
  245 + title: '设备配置',
252 246 dataIndex: 'label',
  247 + width: 100,
  248 + },
  249 + {
  250 + title: '标签',
  251 + dataIndex: 'aaa',
253 252 width: 160,
254 253 },
255 254 {
256 255 title: '状态',
257   - dataIndex: 'deviceState',
258   - slots: { customRender: 'deviceState' },
  256 + dataIndex: 'bbb',
259 257 width: 160,
260 258 },
261 259 {
262 260 title: '最后连接时间',
263   - dataIndex: 'lastOnlineTime',
264   - format: (text) => formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'),
  261 + dataIndex: 'ccc',
265 262 width: 160,
266 263 },
267 264 {
268   - title: '更新时间',
269   - dataIndex: 'createdTime',
270   - format: (text) => formatToDateTime(text, 'YYYY-MM-DD HH:mm:ss'),
  265 + title: '创建时间',
  266 + dataIndex: 'ddd',
271 267 width: 160,
272 268 },
273 269 ];
... ...
... ... @@ -7,7 +7,7 @@
7 7 centered
8 8 @ok="dispatchCustomer"
9 9 @cancel="resetFields"
10   - :minHeight="100"
  10 + :minHeight="150"
11 11 okText="分配"
12 12 >
13 13 <BasicForm @register="registerForm" />
... ...
... ... @@ -17,8 +17,8 @@
17 17 /></TabPane>
18 18 <TabPane key="3" tab="告警"><Alarm :id="deviceDetail.id" /></TabPane>
19 19 <TabPane key="4" tab="子设备" v-if="deviceDetail?.deviceType === 'GATEWAY'"
20   - ><ChildDevice :fromId="deviceDetail?.tbDeviceId" />
21   - </TabPane>
  20 + ><ChildDevice
  21 + /></TabPane>
22 22 </Tabs>
23 23 </BasicDrawer>
24 24 </template>
... ... @@ -61,7 +61,6 @@
61 61 deviceDetailRef.value.initMap(longitude, latitude, address);
62 62 }
63 63 });
64   -
65 64 const closeDrawer = () => {
66 65 activeKey.value = '1';
67 66 };
... ...
... ... @@ -10,9 +10,9 @@
10 10 centered
11 11 >
12 12 <div class="step-form-form">
13   - <Steps :current="current" v-if="!isUpdate">
14   - <Step title="填写设备信息" />
15   - <Step title="添加设备凭证" />
  13 + <Steps :current="current">
  14 + <Step title="填写设备信息" v-if="!isUpdate" />
  15 + <Step title="添加设备凭证" v-if="!isUpdate" />
16 16 </Steps>
17 17 </div>
18 18 <div class="mt-5">
... ...
... ... @@ -6,7 +6,6 @@
6 6 @cancel="handleCancel"
7 7 @ok="handleOk"
8 8 centered
9   - :canFullscreen="false"
10 9 >
11 10 <BasicForm @register="registerForm" />
12 11 </BasicModal>
... ...
1 1 <template>
2   - <BasicTable @register="registerTable">
3   - <template #deviceState="{ record }">
4   - <Tag
5   - :color="
6   - record.deviceState == DeviceState.INACTIVE
7   - ? 'warning'
8   - : record.deviceState == DeviceState.ONLINE
9   - ? 'success'
10   - : 'error'
11   - "
12   - class="ml-2"
13   - >
14   - {{
15   - record.deviceState == DeviceState.INACTIVE
16   - ? '待激活'
17   - : record.deviceState == DeviceState.ONLINE
18   - ? '在线'
19   - : '离线'
20   - }}
21   - </Tag>
22   - </template>
23   - </BasicTable>
  2 + <BasicTable @register="registerTable" />
24 3 </template>
25 4 <script lang="ts">
26   - import { defineComponent, onMounted } from 'vue';
27   - import { Tag } from 'ant-design-vue';
28   - import { DeviceState } from '/@/api/device/model/deviceModel';
  5 + import { defineComponent } from 'vue';
29 6 import { BasicTable, useTable } from '/@/components/Table';
30 7 import { childDeviceColumns, childDeviceSchemas } from '../../config/detail.config';
31   - import { getChildDevicePage } from '/@/api/device/deviceManager.ts';
  8 +
32 9 export default defineComponent({
33 10 name: 'DeviceManagement',
34 11 components: {
35 12 BasicTable,
36   - Tag,
37   - },
38   - props: {
39   - fromId: {
40   - type: String,
41   - required: true,
42   - },
43 13 },
44   - setup(props) {
45   - console.log(123);
46   - onMounted(() => {
47   - console.log(props.fromId);
48   - });
  14 + setup(_) {
49 15 const [registerTable] = useTable({
50   - api: getChildDevicePage,
51 16 columns: childDeviceColumns,
52 17 formConfig: {
53 18 labelWidth: 120,
54 19 schemas: childDeviceSchemas,
55 20 },
56   - beforeFetch: (data) => {
57   - console.log(props.fromId);
58   - Reflect.set(data, 'fromId', props.fromId);
59   - },
60 21 useSearchForm: true,
61 22 showTableSetting: true,
62 23 bordered: true,
... ... @@ -65,7 +26,6 @@
65 26
66 27 return {
67 28 registerTable,
68   - DeviceState,
69 29 };
70 30 },
71 31 });
... ...
... ... @@ -23,7 +23,7 @@
23 23 </div>
24 24 <div v-if="deviceDetail?.deviceInfo?.address" class="mt-4">
25 25 <p>设备位置</p>
26   - <div ref="wrapRef" style="height: 550px; width: 100%"></div>
  26 + <div ref="wrapRef" style="height: 400px; width: 100%"></div>
27 27 </div>
28 28 </div>
29 29 </template>
... ... @@ -38,8 +38,6 @@
38 38 import { useModal } from '/@/components/Modal';
39 39 import ManageDeviceTokenModal from '../modal/ManageDeviceTokenModal.vue';
40 40 import { getDeviceToken } from '/@/api/device/deviceManager';
41   - import wz from '/@/assets/images/wz.png';
42   -
43 41 export default defineComponent({
44 42 components: {
45 43 Image,
... ... @@ -64,7 +62,7 @@
64 62 const BMap = (window as any).BMap;
65 63 if (!wrapEl) return;
66 64 const map = new BMap.Map(wrapEl);
67   - let myIcon = new BMap.Icon(wz, new BMap.Size(20, 30));
  65 + let myIcon = new BMap.Icon('/src/assets/images/wz.png', new BMap.Size(20, 30));
68 66
69 67 const point = new BMap.Point(Number(longitude), Number(latitude));
70 68 var content = `我在 ${address}`;
... ...
... ... @@ -207,7 +207,7 @@
207 207 }
208 208
209 209 function handleDelete(record: Recordable) {
210   - const ids = [record.id];
  210 + let ids = [record.id];
211 211 deleteDevice(ids).then(() => {
212 212 createMessage.success('删除设备成功');
213 213 handleSuccess();
... ...
  1 +{
  2 + "id": "",
  3 + "name": "6",
  4 + "transportType": "DEFAULT",
  5 + "profileData": {
  6 + "alarms": [
  7 + {
  8 + "id": "05f99082-3941-467d-999a-7ab5eb7bac46",
  9 + "alarmType": "6",
  10 + "propagate": true,
  11 + "propagateRelationTypes": ["6"],
  12 + "createRules": {
  13 + "MAJOR": {
  14 + "alarmDetails": "CO2过高",
  15 + "schedule": {
  16 + "type": "ANY_TIME",
  17 + "timezone": "Asia/Shanghai (UTC+08:00)"
  18 + },
  19 + "condition": [
  20 + {
  21 + "key": {
  22 + "type": "TIME_SERIES",
  23 + "key": "100"
  24 + },
  25 + "valueType": "NUMERIC",
  26 + "value": "100",
  27 + "predicate": {
  28 + "type": "NUMERIC",
  29 + "operation": "NOT_EQUAL",
  30 + "value": {
  31 + "defaultValue": "100"
  32 + }
  33 + }
  34 + }
  35 + ]
  36 + },
  37 + "MINOR": {
  38 + "alarmDetails": "CO过高",
  39 + "schedule": {
  40 + "type": "ANY_TIME",
  41 + "timezone": "Asia/Shanghai (UTC+08:00)"
  42 + },
  43 + "condition": [
  44 + {
  45 + "key": {
  46 + "type": "TIME_SERIES",
  47 + "key": "2000"
  48 + },
  49 + "valueType": "NUMERIC",
  50 + "value": "2000",
  51 + "predicate": {
  52 + "type": "NUMERIC",
  53 + "operation": "EQUAL",
  54 + "value": {
  55 + "defaultValue": "2000"
  56 + }
  57 + }
  58 + }
  59 + ]
  60 + }
  61 + },
  62 + "clearRule": {
  63 + "schedule": {
  64 + "type": "ANY_TIME",
  65 + "timezone": "Asia/Shanghai (UTC+08:00)"
  66 + },
  67 + "condition": [
  68 + {
  69 + "key": {
  70 + "type": "TIME_SERIES",
  71 + "key": "123"
  72 + },
  73 + "valueType": "NUMERIC",
  74 + "value": "123",
  75 + "predicate": {
  76 + "type": "NUMERIC",
  77 + "operation": "GREATER_OR_EQUAL",
  78 + "value": {
  79 + "defaultValue": "123"
  80 + }
  81 + }
  82 + },
  83 + {
  84 + "key": {
  85 + "type": "TIME_SERIES",
  86 + "key": "456"
  87 + },
  88 + "valueType": "NUMERIC",
  89 + "value": "456",
  90 + "predicate": {
  91 + "type": "NUMERIC",
  92 + "operation": "LESS",
  93 + "value": {
  94 + "defaultValue": "456"
  95 + }
  96 + }
  97 + }
  98 + ],
  99 + "alarmDetails": "CO3过低"
  100 + }
  101 + }
  102 + ]
  103 + },
  104 + "alarmProfile": {
  105 + "alarmContactId": "224a312c-4f52-41ef-9dce-2aac69ec2e85,8aff39c6-af9c-416a-b110-601183e39da0",
  106 + "messageMode": "EMAIL_MESSAGE"
  107 + }
  108 +}
... ...
  1 +{
  2 + "id": "5445f670-8946-11ec-ac19-e398562c8b61",
  3 + "name": "一氧化碳检测",
  4 + "enabled": false,
  5 + "description": "针对一氧化碳有害气体检测",
  6 + "tenantId": "de10f9e0-8892-11ec-ac19-e398562c8b61",
  7 + "profileData": {
  8 + "configuration": {
  9 + "type": "DEFAULT"
  10 + },
  11 + "transportConfiguration": {
  12 + "type": "DEFAULT"
  13 + },
  14 + "provisionConfiguration": {
  15 + "type": "DISABLED",
  16 + "provisionDeviceSecret": null
  17 + },
  18 + "alarms": [
  19 + {
  20 + "id": "5d11af7e-71ce-44ef-b34b-6b1a2425f25c",
  21 + "alarmType": "气体浓度告警",
  22 + "createRules": {
  23 + "MAJOR": {
  24 + "condition": {
  25 + "condition": [
  26 + {
  27 + "key": {
  28 + "type": "TIME_SERIES",
  29 + "key": "CO"
  30 + },
  31 + "valueType": "NUMERIC",
  32 + "value": null,
  33 + "predicate": {
  34 + "type": "NUMERIC",
  35 + "operation": "GREATER",
  36 + "value": {
  37 + "defaultValue": 100,
  38 + "userValue": null,
  39 + "dynamicValue": null
  40 + }
  41 + }
  42 + }
  43 + ],
  44 + "spec": {
  45 + "type": "SIMPLE"
  46 + }
  47 + },
  48 + "schedule": {
  49 + "type": "ANY_TIME"
  50 + },
  51 + "alarmDetails": "告警",
  52 + "dashboardId": null
  53 + },
  54 + "MINOR": {
  55 + "condition": {
  56 + "condition": [
  57 + {
  58 + "key": {
  59 + "type": "TIME_SERIES",
  60 + "key": "CO"
  61 + },
  62 + "valueType": "NUMERIC",
  63 + "value": null,
  64 + "predicate": {
  65 + "type": "NUMERIC",
  66 + "operation": "GREATER",
  67 + "value": {
  68 + "defaultValue": 100,
  69 + "userValue": null,
  70 + "dynamicValue": null
  71 + }
  72 + }
  73 + }
  74 + ],
  75 + "spec": {
  76 + "type": "SIMPLE"
  77 + }
  78 + },
  79 + "schedule": {
  80 + "type": "ANY_TIME"
  81 + },
  82 + "alarmDetails": "告警",
  83 + "dashboardId": null
  84 + }
  85 + },
  86 + "clearRule": {
  87 + "condition": {
  88 + "condition": [
  89 + {
  90 + "key": {
  91 + "type": "TIME_SERIES",
  92 + "key": "CO"
  93 + },
  94 + "valueType": "NUMERIC",
  95 + "value": null,
  96 + "predicate": {
  97 + "type": "NUMERIC",
  98 + "operation": "LESS_OR_EQUAL",
  99 + "value": {
  100 + "defaultValue": 100,
  101 + "userValue": null,
  102 + "dynamicValue": null
  103 + }
  104 + }
  105 + }
  106 + ],
  107 + "spec": {
  108 + "type": "SIMPLE"
  109 + }
  110 + },
  111 + "schedule": {
  112 + "type": "ANY_TIME"
  113 + },
  114 + "alarmDetails": "清除告警",
  115 + "dashboardId": null
  116 + },
  117 + "propagate": true,
  118 + "propagateRelationTypes": ["CO"]
  119 + }
  120 + ]
  121 + },
  122 + "defaultRuleChainId": "de8bf640-8892-11ec-ac19-e398562c8b61",
  123 + "alarmProfile": {
  124 + "id": "e822cccb-7f00-487e-9ece-790f4d145947",
  125 + "creator": "b75f1c80-0f94-4a06-84ef-253962bbfe9e",
  126 + "createTime": "2022-02-09 09:19:29",
  127 + "enabled": false,
  128 + "tenantId": "de10f9e0-8892-11ec-ac19-e398562c8b61",
  129 + "alarmContactId": "8aff39c6-af9c-416a-b110-601183e39da0",
  130 + "deviceProfileId": "5445f670-8946-11ec-ac19-e398562c8b61",
  131 + "messageMode": "PHONE_MESSAGE"
  132 + },
  133 + "defaultQueueName": "Main"
  134 +}
... ...
... ... @@ -8,7 +8,7 @@
8 8 @cancel="handleCancel"
9 9 >
10 10 <div class="step-form-form">
11   - <a-steps :current="current">
  11 + <a-steps :current="current" @change="handleChange">
12 12 <a-step title="设备配置" />
13 13 <a-step title="传输配置" />
14 14 <a-step title="告警配置" />
... ... @@ -79,6 +79,7 @@
79 79 const DeviceProfileStep3Ref = ref(null);
80 80 const DeviceProfileStep4Ref = ref(null);
81 81 const { createMessage } = useMessage();
  82 + // const getStepData = ref(null);
82 83 const { proxy } = getCurrentInstance();
83 84 const postDeviceConfogData: any = ref({});
84 85 const getStepOneData: any = ref({});
... ... @@ -90,8 +91,10 @@
90 91 const postEditId = ref('');
91 92 const current = ref(0);
92 93 const isUpdate = ref(true);
93   -
94 94 const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置'));
  95 + const handleChange = (v) => {
  96 + console.log(v);
  97 + };
95 98 const [register, { closeModal }] = useModalInner(async (data) => {
96 99 isUpdate.value = !!data?.isUpdate;
97 100 if (!unref(isUpdate)) {
... ... @@ -287,7 +290,8 @@
287 290 createMessage.success('新增设备配置成功');
288 291 closeModal();
289 292 emit('success');
290   - } else {
  293 + }
  294 + if (unref(isUpdate)) {
291 295 postDeviceConfogData.value.id = postEditId.value;
292 296 isGetStepThreeData.value.profileData = getStepThreeData.value;
293 297 alarmProfileData.value.alarmProfile =
... ... @@ -309,11 +313,13 @@
309 313 closeModal();
310 314 };
311 315 return {
  316 + handleChange,
312 317 DeviceProfileStep2Ref,
313 318 DeviceProfileStep3Ref,
314 319 DeviceProfileStep4Ref,
315 320 DeviceProfileStep1Ref,
316 321 editEchoData,
  322 + // getStepData,
317 323 handleStep3Next,
318 324 handleSubmit,
319 325 handleCancel,
... ...
... ... @@ -223,7 +223,7 @@
223 223 function handleSuccess() {
224 224 reload();
225 225 }
226   - return {
  226 + return {
227 227 deviceDetailRef,
228 228 setRowClassName,
229 229 registerModalDetail,
... ...
... ... @@ -207,7 +207,7 @@
207 207
208 208 <script lang="ts">
209 209 import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue';
210   - import type { IProfileData } from './index.t';
  210 + import type { IProfileData } from '../types/index';
211 211 import { CollapseContainer } from '/@/components/Container/index';
212 212 import { BasicForm, useForm } from '/@/components/Form';
213 213 import {
... ...
1 1 <template>
2 2 <div class="step-4">
  3 + <!-- <span>请选择告警通知联系人:</span> -->
  4 + <!-- <Tag v-for="(item, index) in 15" closable :key="index"> 冯涛+{{ item }}</Tag> -->
3 5 <BasicForm :showSubmitButton="false" @register="register" />
4 6 </div>
5 7 </template>
6 8 <script lang="ts">
7 9 import { defineComponent, ref } from 'vue';
  10 + // import { Tag } from 'ant-design-vue';
8 11 import { BasicForm, useForm } from '/@/components/Form/index';
9 12 import { alertContactsSchemas } from '../cpns/config';
10 13
... ...
... ... @@ -26,7 +26,6 @@ interface IAlarms {
26 26 id: string;
27 27 alarmType: string;
28 28 createRules: ICreateRule;
29   - // clearRule?: IClearRule[];
30 29 propagate: boolean;
31 30 propagateRelationTypes: string[];
32 31 }
... ... @@ -38,3 +37,12 @@ export interface IProfileData {
38 37 alarms?: IAlarms[];
39 38 clearRule?: IClearRule[];
40 39 }
  40 +
  41 +export interface IAddAlarms {
  42 + id: string;
  43 + alarmType: string;
  44 + createRules: [];
  45 + clearRule: {};
  46 + propagate: boolean;
  47 + propagateRelationTypes: string[];
  48 +}
... ...
  1 +interface IConfiguration {
  2 + type?: string;
  3 +}
  4 +interface ITansportConfiguration {
  5 + type?: string;
  6 +}
  7 +interface provisionConfigurationD {
  8 + provisionDeviceSecret?: string;
  9 +}
  10 +type ICreateRule = {};
  11 +type IClearRule = {
  12 + id: string;
  13 + alarmDetails: string;
  14 + dashboardId: {
  15 + id: string;
  16 + entityType: string;
  17 + };
  18 + propagate: string;
  19 + propagateRelationTypes: string[];
  20 + schedule: {
  21 + type: string;
  22 + };
  23 + condition: object;
  24 +};
  25 +interface IAlarms {
  26 + id: string;
  27 + alarmType: string;
  28 + createRules: ICreateRule;
  29 + // clearRule?: IClearRule[];
  30 + propagate: boolean;
  31 + propagateRelationTypes: string[];
  32 +}
  33 +
  34 +export interface IProfileData {
  35 + configuration?: IConfiguration;
  36 + transportConfiguration?: ITansportConfiguration;
  37 + provisionConfiguration?: provisionConfigurationD;
  38 + alarms?: IAlarms[];
  39 + clearRule?: IClearRule[];
  40 +}
... ...
... ... @@ -21,19 +21,23 @@
21 21
22 22 export default defineComponent({
23 23 components: { CollapseContainer, BasicForm, [Input.name]: Input },
24   - props: ['deviceInfo1'],
  24 + props: ['deviceInfo1', 'editconditionFather', 'newConditionMapFather'],
25 25
26 26 setup(props) {
27 27 const fieldValue: any = ref({});
28   - const [registerCondition, { getFieldsValue, updateSchema }] = useForm({
29   - labelWidth: 100,
30   - schemas: useConditionDrawerSchema,
31   - actionColOptions: { span: 24 },
32   - });
  28 + const [registerCondition, { setFieldsValue, getFieldsValue, updateSchema, resetFields }] =
  29 + useForm({
  30 + labelWidth: 100,
  31 + schemas: useConditionDrawerSchema,
  32 + actionColOptions: { span: 24 },
  33 + });
33 34 const getFieldsValueFunc = () => {
34 35 fieldValue.value = getFieldsValue();
35 36 return fieldValue.value;
36 37 };
  38 + const resetFieldsValueFunc = () => {
  39 + resetFields();
  40 + };
37 41 watch(
38 42 () => props.deviceInfo1,
39 43 async (newV) => {
... ... @@ -49,6 +53,29 @@
49 53 });
50 54 }
51 55 );
  56 +
  57 + //回显数据
  58 + const setFieldsFormValueFun = () => {
  59 + if (props.editconditionFather !== 1) {
  60 + setTimeout(() => {
  61 + setFieldsValue(props.editconditionFather);
  62 + }, 100);
  63 + }
  64 + };
  65 + setFieldsFormValueFun();
  66 + const editSelectDevice = () => {
  67 + if (props.newConditionMapFather !== 1) {
  68 + setTimeout(() => {
  69 + updateSchema({
  70 + field: 'deviceId',
  71 + componentProps: {
  72 + options: props.newConditionMapFather,
  73 + },
  74 + });
  75 + }, 100);
  76 + }
  77 + };
  78 + editSelectDevice();
52 79 //新增清空设备选择
53 80 const clearSelectDevice = () => {
54 81 updateSchema({
... ... @@ -58,15 +85,16 @@
58 85 },
59 86 });
60 87 };
61   - const editSelectDevice = (v) => {
62   - updateSchema({
63   - field: 'deviceId',
64   - componentProps: {
65   - options: v,
66   - },
67   - });
68   - };
  88 + // const editSelectDevice = (v) => {
  89 + // updateSchema({
  90 + // field: 'deviceId',
  91 + // componentProps: {
  92 + // options: v,
  93 + // },
  94 + // });
  95 + // };
69 96 return {
  97 + resetFieldsValueFunc,
70 98 clearSelectDevice,
71 99 editSelectDevice,
72 100 getFieldsValueFunc,
... ...
... ... @@ -21,15 +21,16 @@
21 21
22 22 export default defineComponent({
23 23 components: { CollapseContainer, BasicForm, [Input.name]: Input },
24   - props: ['deviceInfo2'],
  24 + props: ['deviceInfo2', 'editActionFather', 'newActionMapFather'],
25 25
26 26 setup(props) {
27 27 const fieldValue: any = ref({});
28   - const [registerAction, { getFieldsValue, resetFields, updateSchema }] = useForm({
29   - labelWidth: 100,
30   - schemas: useActionDrawerSchema,
31   - actionColOptions: { span: 24 },
32   - });
  28 + const [registerAction, { setFieldsValue, getFieldsValue, resetFields, updateSchema }] =
  29 + useForm({
  30 + labelWidth: 100,
  31 + schemas: useActionDrawerSchema,
  32 + actionColOptions: { span: 24 },
  33 + });
33 34 const getFieldsValueFunc = () => {
34 35 fieldValue.value = getFieldsValue();
35 36 return fieldValue.value;
... ... @@ -52,6 +53,29 @@
52 53 });
53 54 }
54 55 );
  56 +
  57 + //回显数据
  58 + const setFieldsFormValueFun = () => {
  59 + if (props.editActionFather !== 1) {
  60 + setTimeout(() => {
  61 + setFieldsValue(props.editActionFather);
  62 + }, 100);
  63 + }
  64 + };
  65 + setFieldsFormValueFun();
  66 + const editSelectDevice = () => {
  67 + if (props.newActionMapFather !== 1) {
  68 + setTimeout(() => {
  69 + updateSchema({
  70 + field: 'deviceId',
  71 + componentProps: {
  72 + options: props.newActionMapFather,
  73 + },
  74 + });
  75 + }, 100);
  76 + }
  77 + };
  78 + editSelectDevice();
55 79 //新增清空设备选择
56 80 const clearSelectDevice = () => {
57 81 updateSchema({
... ... @@ -61,14 +85,14 @@
61 85 },
62 86 });
63 87 };
64   - const editSelectDevice = (v) => {
65   - updateSchema({
66   - field: 'deviceId',
67   - componentProps: {
68   - options: v,
69   - },
70   - });
71   - };
  88 + // const editSelectDevice = (v) => {
  89 + // updateSchema({
  90 + // field: 'deviceId',
  91 + // componentProps: {
  92 + // options: v,
  93 + // },
  94 + // });
  95 + // };
72 96 return {
73 97 clearSelectDevice,
74 98 editSelectDevice,
... ...
... ... @@ -26,11 +26,12 @@
26 26 props: ['deviceInfo', 'editTriggerFather', 'newFilterMapFather'],
27 27 setup(props) {
28 28 const fieldValue: any = ref({});
29   - const [registerTrigger, { setFieldsValue, getFieldsValue, updateSchema }] = useForm({
30   - labelWidth: 100,
31   - schemas: useTriggerDrawerSchema,
32   - actionColOptions: { span: 24 },
33   - });
  29 + const [registerTrigger, { resetFields, setFieldsValue, getFieldsValue, updateSchema }] =
  30 + useForm({
  31 + labelWidth: 100,
  32 + schemas: useTriggerDrawerSchema,
  33 + actionColOptions: { span: 24 },
  34 + });
34 35 const getFieldsValueFunc = () => {
35 36 fieldValue.value = getFieldsValue();
36 37 return fieldValue.value;
... ... @@ -42,21 +43,34 @@
42 43 options.items.forEach((v) => {
43 44 return (v.value = v.id), (v.label = v.name);
44 45 });
  46 + updateFieldDeviceId(options.items);
  47 + }
  48 + );
  49 + const updateFieldDeviceId = (v) => {
  50 + setTimeout(() => {
45 51 updateSchema({
46 52 field: 'deviceId',
47 53 componentProps: {
48   - options: options.items,
  54 + options: v,
49 55 },
50 56 });
51   - }
52   - );
  57 + }, 10);
  58 + };
  59 + const resetFieldsValueFunc = () => {
  60 + setTimeout(() => {
  61 + resetFields();
  62 + }, 100);
  63 + };
53 64
54 65 //回显数据
55 66 const setFieldsFormValueFun = () => {
56   - setTimeout(() => {
57   - setFieldsValue(props.editTriggerFather);
58   - }, 100);
  67 + if (props.editTriggerFather != 1) {
  68 + setTimeout(() => {
  69 + setFieldsValue(props.editTriggerFather);
  70 + }, 100);
  71 + }
59 72 };
  73 +
60 74 setFieldsFormValueFun();
61 75 //新增清空设备选择
62 76 const clearSelectDevice = () => {
... ... @@ -68,14 +82,16 @@
68 82 });
69 83 };
70 84 const editSelectDevice = () => {
71   - setTimeout(() => {
72   - updateSchema({
73   - field: 'deviceId',
74   - componentProps: {
75   - options: props.newFilterMapFather,
76   - },
77   - });
78   - }, 100);
  85 + if (props.newFilterMapFather != 1) {
  86 + setTimeout(() => {
  87 + updateSchema({
  88 + field: 'deviceId',
  89 + componentProps: {
  90 + options: props.newFilterMapFather,
  91 + },
  92 + });
  93 + }, 100);
  94 + }
79 95 };
80 96 editSelectDevice();
81 97 //新增清空场景触发器选择
... ... @@ -96,6 +112,8 @@
96 112 });
97 113 };
98 114 return {
  115 + updateFieldDeviceId,
  116 + resetFieldsValueFunc,
99 117 clearSelectScene,
100 118 editSelectScene,
101 119 clearSelectDevice,
... ...
... ... @@ -90,6 +90,10 @@
90 90 function handleAdd() {
91 91 try {
92 92 proxy.$refs.sceneLinkAgeDrawerRef.clearAllArrayFunc();
  93 + setTimeout(() => {
  94 + proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger();
  95 + }, 10);
  96 + proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition();
93 97 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction();
94 98 proxy.$refs.sceneLinkAgeDrawerRef.resetActionsAllArrayFunc();
95 99 proxy.$refs.sceneLinkAgeDrawerRef.clearActionsAllDevice();
... ...
... ... @@ -16,11 +16,11 @@
16 16 :key="index"
17 17 >
18 18 <span style="display: none">{{ item + index }}</span>
19   - <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器{{ index + 1 }}</span>
20   - <div>
  19 + <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器 {{ index + 1 }}</span>
  20 + <div style="display: block">
21 21 <AddTriggerForm
22   - :editTriggerFather="isUpdate == false ? null : item"
23   - :newFilterMapFather="isUpdate == false ? null : newFilterMap"
  22 + :editTriggerFather="isUpdate == false ? 1 : item"
  23 + :newFilterMapFather="isUpdate == false ? 1 : newFilterMap"
24 24 :deviceInfo="getDeviceInfo"
25 25 ref="refTriggerChild"
26 26 />
... ... @@ -57,12 +57,20 @@
57 57 <div style="height: 5vh"></div>
58 58 <!-- 执行条件 -->
59 59 <div>
60   - <template v-for="(item, index) in addConditionPushData" :key="index">
  60 + <template
  61 + v-for="(item, index) in isUpdate == false ? addConditionPushData : editConditionPushData"
  62 + :key="index"
  63 + >
61 64 <span style="display: none">{{ item + index }}</span>
62   - <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件{{ index + 1 }}</span>
  65 + <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件 {{ index + 1 }}</span>
63 66
64 67 <div>
65   - <AddConditiForm :deviceInfo1="getDeviceInfo1" ref="refConditionChild" />
  68 + <AddConditiForm
  69 + :editConditionFather="isUpdate == false ? 1 : item"
  70 + :newConditionMapFather="isUpdate == false ? 1 : newConditionFilterMap"
  71 + :deviceInfo1="getDeviceInfo1"
  72 + ref="refConditionChild"
  73 + />
66 74 </div>
67 75 <div style="height: 3vh"></div>
68 76 </template>
... ... @@ -82,7 +90,7 @@
82 90 </div>
83 91 <div style="display: flex; width: 4vw; height: 4vh">
84 92 <Button
85   - v-if="addConditionPushData.length != 0"
  93 + v-if="addConditionPushData.length != 0 || addConditionPushData.length != 0"
86 94 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
87 95 type="default"
88 96 class="mt-5"
... ... @@ -96,12 +104,20 @@
96 104 <!-- 执行动作 -->
97 105 <div style="height: 5vh"></div>
98 106 <div>
99   - <template v-for="(item, index) in addActionPushData" :key="index">
  107 + <template
  108 + v-for="(item, index) in isUpdate == false ? addActionPushData : editActionPushData"
  109 + :key="index"
  110 + >
100 111 <span style="display: none">{{ item + index }}</span>
101   - <span style="position: relative; top: 4.2vh; left: 0.65vw">执行动作{{ index + 1 }}</span>
  112 + <span style="position: relative; top: 4.2vh; left: 0.65vw">执行动作 {{ index + 1 }}</span>
102 113
103 114 <div>
104   - <AddActionForm :deviceInfo2="getDeviceInfo2" ref="refActionChild" />
  115 + <AddActionForm
  116 + :editActionFather="isUpdate == false ? 1 : item"
  117 + :newActionMapFather="isUpdate == false ? 1 : newActionFilterMap"
  118 + :deviceInfo2="getDeviceInfo2"
  119 + ref="refActionChild"
  120 + />
105 121 </div>
106 122 <div style="height: 3vh"></div>
107 123 </template>
... ... @@ -121,7 +137,7 @@
121 137 </div>
122 138 <div style="display: flex; width: 4vw; height: 4vh">
123 139 <Button
124   - v-if="addActionPushData.length > 0"
  140 + v-if="addActionPushData.length > 0 || addActionPushData.length > 0"
125 141 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
126 142 type="default"
127 143 class="mt-5"
... ... @@ -168,6 +184,8 @@
168 184 const { proxy } = getCurrentInstance();
169 185 const lastRefTriggerChildDataArray = ref<[]>([]);
170 186 const lastEditRefTriggerChildDataArray = ref<[]>([]);
  187 + const lastEditRefConditionChildDataArray = ref<[]>([]);
  188 + const lastEditRefActionChildDataArray = ref<[]>([]);
171 189 const lastRefConditionChildDataArray = ref<[]>([]);
172 190 const lastRefActionChildDataArray = ref<[]>([]);
173 191 const lastRefTriggerChildData: any = ref({});
... ... @@ -207,6 +225,8 @@
207 225 const addActionPushData = ref<[]>([]);
208 226 //edit data
209 227 const editTriggerPushData = ref<[]>([]);
  228 + const editConditionPushData = ref<[]>([]);
  229 + const editActionPushData = ref<[]>([]);
210 230 const getChildData = ref(null);
211 231 const refTriggerChild = ref(null);
212 232 const refConditionChild = ref(null);
... ... @@ -222,6 +242,8 @@
222 242 const getDeviceInfo1 = ref(null);
223 243 const getDeviceInfo2 = ref(null);
224 244 const newFilterMap = ref<[]>([]);
  245 + const newConditionFilterMap = ref<[]>([]);
  246 + const newActionFilterMap = ref<[]>([]);
225 247
226 248 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
227 249 labelWidth: 120,
... ... @@ -234,18 +256,26 @@
234 256 setDrawerProps({ confirmLoading: false });
235 257 isUpdate.value = !!data?.isUpdate;
236 258 if (!unref(isUpdate)) {
  259 + editTriggerPushData.value = [];
  260 + editTriggerPushData.value.length = 0;
237 261 try {
238   - proxy.$refs.refTriggerChild.clearSelectDevice();
239   - proxy.$refs.refTriggerChild.clearSelectScene();
240   - proxy.$refs.refConditionChild.clearSelectDevice();
241   - proxy.$refs.refActionChild.clearSelectDevice();
  262 + setTimeout(() => {
  263 + // proxy.$refs.refTriggerChild.resetFieldsValueFunc();
  264 + proxy.$refs.refConditionChild.resetFieldsValueFunc();
  265 + proxy.$refs.refActionChild.resetFieldsValueFunc();
  266 + }, 50);
242 267 } catch (e) {
243 268 return e;
244 269 }
245 270 } else {
246 271 newFilterMap.value = [];
  272 + newConditionFilterMap.value = [];
  273 + newActionFilterMap.value = [];
247 274 clearAllArrayFunc();
248 275 editTriggerPushData.value = [];
  276 + editTriggerPushData.value.length = 0;
  277 + editConditionPushData.value = [];
  278 + editActionPushData.value = [];
249 279 lastEditRefTriggerChildDataArray.value = [];
250 280 getId.value = data.record.id;
251 281 getTenantId.value = data.record.tenantId;
... ... @@ -253,19 +283,52 @@
253 283 ...data.record,
254 284 });
255 285 editTriggerPushData.value = data.record.triggers;
  286 + editTriggerPushData.value.forEach((f) => {
  287 + if (f?.id.length == 18) {
  288 + editTriggerPushData.value.pop();
  289 + if (editTriggerPushData.value.length) {
  290 + editTriggerPushData.value.length = editTriggerPushData.value.length;
  291 + }
  292 + }
  293 + });
  294 + editConditionPushData.value = data.record.doConditions;
  295 + editActionPushData.value = data.record.doActions;
256 296 const options = await screenLinkPageByDeptIdGetDevice({
257 297 organizationId: data.record.organizationId,
258 298 });
259   - data.record.triggers.forEach((f1) => {
260   - options.items.forEach((f2) => {
261   - if (f2.id == f1.deviceId) {
262   - newFilterMap.value.push({
263   - value: f2.id,
264   - label: f2.name,
265   - });
266   - }
  299 + try {
  300 + data.record.triggers.forEach((f1) => {
  301 + options.items?.forEach((f2) => {
  302 + if (f2.id == f1.deviceId) {
  303 + newFilterMap.value.push({
  304 + value: f2.id,
  305 + label: f2.name,
  306 + });
  307 + }
  308 + });
267 309 });
268   - });
  310 +
  311 + data.record.doConditions.forEach((f1) => {
  312 + options.items?.forEach((f2) => {
  313 + if (f2.id == f1.deviceId) {
  314 + newConditionFilterMap.value.push({
  315 + value: f2.id,
  316 + label: f2.name,
  317 + });
  318 + }
  319 + });
  320 + });
  321 + data.record.doActions.forEach((f1) => {
  322 + options.items?.forEach((f2) => {
  323 + if (f2.id == f1.deviceId) {
  324 + newActionFilterMap.value.push({
  325 + value: f2.id,
  326 + label: f2.name,
  327 + });
  328 + }
  329 + });
  330 + });
  331 + } catch (e) {}
269 332 }
270 333 });
271 334 const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
... ... @@ -353,6 +416,8 @@
353 416 refConditionChildDataFunc();
354 417 refActionChildDataFunc();
355 418 lastEditRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
  419 + lastEditRefConditionChildDataArray.value.push(refConditionChildData.value as never);
  420 + lastEditRefActionChildDataArray.value.push(refActionChildData.value as never);
356 421 lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
357 422 lastRefActionChildDataArray.value.push(refActionChildData.value as never);
358 423 const triggersObj = {
... ... @@ -365,6 +430,7 @@
365 430 doActions: lastRefActionChildDataArray.value,
366 431 };
367 432 Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
  433 + console.log(getAllFormData);
368 434 }
369 435 };
370 436
... ... @@ -381,7 +447,6 @@
381 447 } else {
382 448 getDefaultValue();
383 449 getValuesFormData = await validateFields();
384   - if (!getValuesFormData) return;
385 450 Object.assign(getAllFormData, getValuesFormData);
386 451 getAllFormData.id = getId.value;
387 452 getAllFormData.tenantId = getTenantId.value;
... ... @@ -391,6 +456,13 @@
391 456 emit('success');
392 457 }
393 458 };
  459 + const defaultAddTrigger = () => {
  460 + if (unref(addTriggerPushData).length == 0) {
  461 + setTimeout(() => {
  462 + addTrigger();
  463 + }, 10);
  464 + }
  465 + };
394 466
395 467 //新增触发器
396 468 const addTrigger = () => {
... ... @@ -426,6 +498,21 @@
426 498
427 499 //新增执行条件
428 500 const addCondition = () => {
  501 + // if (!unref(isUpdate)) {
  502 + // console.log('add');
  503 + // unref(addConditionPushData).push(addConditionData as never);
  504 + // refConditionChildDataFunc();
  505 + // lastRefConditionChildData.value = refConditionChildData.value;
  506 + // lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
  507 + // } else {
  508 + // console.log('edit');
  509 +
  510 + // unref(editConditionPushData).push(addConditionData as never);
  511 + // console.log(unref(editConditionPushData));
  512 + // refConditionChildDataFunc();
  513 + // lastRefConditionChildData.value = refConditionChildData.value;
  514 + // lastEditRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
  515 + // }
429 516 unref(addConditionPushData).push(addConditionData as never);
430 517 refConditionChildDataFunc();
431 518 lastRefConditionChildData.value = refConditionChildData.value;
... ... @@ -446,7 +533,24 @@
446 533 addAction();
447 534 }
448 535 };
  536 +
  537 + const defaultAddCondition = () => {
  538 + if (unref(addConditionPushData).length == 0) {
  539 + addCondition();
  540 + }
  541 + };
449 542 const addAction = () => {
  543 + // if (!unref(isUpdate)) {
  544 + // unref(addActionPushData).push(addActionData as never);
  545 + // refActionChildDataFunc();
  546 + // lastRefActionChildData.value = refActionChildData.value;
  547 + // lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
  548 + // } else {
  549 + // unref(editActionPushData).push(addActionData as never);
  550 + // refActionChildDataFunc();
  551 + // lastRefActionChildData.value = refActionChildData.value;
  552 + // lastEditRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
  553 + // }
450 554 unref(addActionPushData).push(addActionData as never);
451 555 refActionChildDataFunc();
452 556 lastRefActionChildData.value = refActionChildData.value;
... ... @@ -462,8 +566,14 @@
462 566 };
463 567
464 568 return {
  569 + defaultAddTrigger,
  570 + defaultAddCondition,
465 571 newFilterMap,
  572 + newConditionFilterMap,
  573 + newActionFilterMap,
466 574 editTriggerPushData,
  575 + editConditionPushData,
  576 + editActionPushData,
467 577 isUpdate,
468 578 clearActionsAllDevice,
469 579 getDeviceInfo,
... ...