Commit 3202c87d8f42f9a8ae643080d81643b577527c84

Authored by xp.Huang
2 parents be4fb905 82f14b79

Merge branch 'ft-dev' into 'main'

fix:修改场景联动触发器新增触发器设备不显示问题,refractor:重构部分设备配置代码

See merge request huang/yun-teng-iot-front!109
... ... @@ -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="告警配置" />
... ... @@ -41,7 +41,7 @@
41 41 </BasicModal>
42 42 </template>
43 43 <script lang="ts">
44   - import { defineComponent, ref, computed, unref, getCurrentInstance } from 'vue';
  44 + import { defineComponent, ref, computed, unref, getCurrentInstance, reactive } from 'vue';
45 45 import { BasicModal, useModalInner } from '/@/components/Modal';
46 46 import DeviceProfileStep1 from '/@/views/device/profile/step/DeviceProfileStep1.vue';
47 47 import DeviceProfileStep2 from '/@/views/device/profile/step/DeviceProfileStep2.vue';
... ... @@ -79,19 +79,26 @@
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({});
85 86 const getStepTwoData: any = ref({});
86   - const getStepThreeData: any = ref({});
  87 + const getStepThreeData = ref([]);
87 88 const editEchoData: any = ref(null);
88 89 const alarmProfileData: any = ref({});
89   - const isGetStepThreeData: any = ref({});
  90 + const isGetStepThreeData = reactive({
  91 + profileData: {
  92 + alarms: [],
  93 + },
  94 + });
90 95 const postEditId = ref('');
91 96 const current = ref(0);
92 97 const isUpdate = ref(true);
93   -
94 98 const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置'));
  99 + const handleChange = (v) => {
  100 + console.log(v);
  101 + };
95 102 const [register, { closeModal }] = useModalInner(async (data) => {
96 103 isUpdate.value = !!data?.isUpdate;
97 104 if (!unref(isUpdate)) {
... ... @@ -246,7 +253,7 @@
246 253 if (unref(isUpdate)) {
247 254 try {
248 255 proxy.$refs.DeviceProfileStep4Ref.resetFieldsFunc({
249   - alarmContactId: editEchoData.value.alarmProfile.alarmContactId,
  256 + id: editEchoData.value.alarmProfile.id,
250 257 messageMode: editEchoData.value.alarmProfile.messageMode,
251 258 });
252 259 } catch (e) {
... ... @@ -255,7 +262,7 @@
255 262 } else {
256 263 try {
257 264 proxy.$refs.DeviceProfileStep4Ref.resetFieldsFunc({
258   - alarmContactId: '',
  265 + id: '',
259 266 messageMode: '',
260 267 });
261 268 } catch (e) {
... ... @@ -271,7 +278,7 @@
271 278 }
272 279 const handleSubmit = async () => {
273 280 if (!unref(isUpdate)) {
274   - isGetStepThreeData.value.profileData = getStepThreeData.value;
  281 + isGetStepThreeData.profileData.alarms = getStepThreeData.value;
275 282 alarmProfileData.value.alarmProfile =
276 283 await proxy.$refs.DeviceProfileStep4Ref.getAllFields();
277 284 alarmProfileData.value.alarmProfile.alarmContactId.shift();
... ... @@ -280,16 +287,18 @@
280 287 postDeviceConfogData.value,
281 288 getStepOneData.value,
282 289 getStepTwoData.value,
283   - isGetStepThreeData.value,
  290 + isGetStepThreeData,
284 291 alarmProfileData.value
285 292 );
286 293 await deviceConfigAddOrEdit(postDeviceConfogData.value);
287 294 createMessage.success('新增设备配置成功');
288 295 closeModal();
289 296 emit('success');
290   - } else {
  297 + }
  298 + if (unref(isUpdate)) {
291 299 postDeviceConfogData.value.id = postEditId.value;
292   - isGetStepThreeData.value.profileData = getStepThreeData.value;
  300 + isGetStepThreeData.profileData.alarms = getStepThreeData.value;
  301 +
293 302 alarmProfileData.value.alarmProfile =
294 303 await proxy.$refs.DeviceProfileStep4Ref.getAllFields();
295 304 Object.assign(
... ... @@ -297,7 +306,7 @@
297 306 getStepOneData.value,
298 307 getStepTwoData.value,
299 308 alarmProfileData.value,
300   - isGetStepThreeData.value
  309 + isGetStepThreeData
301 310 );
302 311 await deviceConfigAddOrEdit(postDeviceConfogData.value);
303 312 createMessage.success('编辑设备配置成功');
... ... @@ -309,11 +318,13 @@
309 318 closeModal();
310 319 };
311 320 return {
  321 + handleChange,
312 322 DeviceProfileStep2Ref,
313 323 DeviceProfileStep3Ref,
314 324 DeviceProfileStep4Ref,
315 325 DeviceProfileStep1Ref,
316 326 editEchoData,
  327 + // getStepData,
317 328 handleStep3Next,
318 329 handleSubmit,
319 330 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,
... ...
  1 +{
  2 + "name": "2",
  3 + "icon": "",
  4 + "transportType": "DEFAULT",
  5 + "profileData": {
  6 + "alarms": [
  7 + {
  8 + "createRules": {
  9 + "MAJOR": {
  10 + "alarmDetails": "2",
  11 + "schedule": {
  12 + "type": "ANY_TIME",
  13 + "timezone": "Asia/Shanghai (UTC+08:00)"
  14 + },
  15 + "condition": {
  16 + "type": "TIME_SERIES",
  17 + "key1": "2",
  18 + "type1": "NUMERIC",
  19 + "id": 2
  20 + }
  21 + },
  22 + "WARNING": {
  23 + "alarmDetails": "3",
  24 + "schedule": {
  25 + "type": "ANY_TIME",
  26 + "timezone": "Asia/Shanghai (UTC+08:00)"
  27 + },
  28 + "condition": {
  29 + "type": "TIME_SERIES",
  30 + "key1": "3",
  31 + "type1": "NUMERIC",
  32 + "operation": "LESS",
  33 + "value1": "3",
  34 + "id": 2
  35 + }
  36 + }
  37 + },
  38 + "clearRule": {
  39 + "schedule": {
  40 + "type": "ANY_TIME",
  41 + "timezone": "Asia/Shanghai (UTC+08:00)"
  42 + },
  43 + "condition": {
  44 + "type": "TIME_SERIES",
  45 + "key1": "4",
  46 + "type1": "NUMERIC",
  47 + "operation": "GREATER_OR_EQUAL",
  48 + "value1": "4",
  49 + "id": 2
  50 + },
  51 + "alarmDetails": "4"
  52 + },
  53 + "id": "d8dbd518-5c72-4a2e-ab27-56fca5f6fa8d",
  54 + "alarmType": "2",
  55 + "propagate": true,
  56 + "propagateRelationTypes": [
  57 + "2"
  58 + ]
  59 + }
  60 + ]
  61 + },
  62 + "alarmProfile": {
  63 + "alarmContactId": [],
  64 + "messageMode": [
  65 + "PHONE_MESSAGE"
  66 + ]
  67 + }
  68 +}
\ No newline at end of file
... ...
1 1 <template>
2   - <div class="step3" style="background-color: #f6f8f9">
3   - <template v-for="(item, index) in profileData" :key="item.id">
4   - <CollapseContainer class="border mb-1" :canExpan="false">
5   - <template #action>
6   - <div class="cursor-pointer">
7   - <img
8   - style="cursor: pointer"
9   - @click="deleteAlarmRule(index)"
10   - alt="移除"
11   - src="../../../../assets/images/delete.png"
12   - />
13   - </div>
14   - </template>
15   - <div style="margin-top: -15px; margin-left: 10px">
16   - <div class="alert-type" style="margin-left: -50px; margin-top: -10px">
17   - <BasicForm @register="registerForm"
18   - /></div>
19   - <div style="margin-top: -15px">
20   - <div style="margin-left: -8px; margin-top: -10px">
21   - <BasicForm
22   - @register="registerFormHighSetting"
23   - style="margin-left: 12px; margin-top: -10px"
24   - >
25   - <template #checkBox="{ model, field }">
26   - <Checkbox v-model:checked="model[field]">传递报警</Checkbox>
27   - </template>
28   - </BasicForm>
  2 + <div>
  3 + <div class="step3" style="background-color: #f6f8f9">
  4 + <template v-for="(item, index) in profileData" :key="item.id">
  5 + <CollapseContainer class="border mb-1" :canExpan="false">
  6 + <!-- 移除按钮 -->
  7 + <template #action>
  8 + <div class="cursor-pointer">
  9 + <img
  10 + style="cursor: pointer"
  11 + @click="deleteAlarmRule(index)"
  12 + alt="移除"
  13 + src="../../../../assets/images/delete.png"
  14 + />
  15 + </div>
  16 + </template>
  17 + <!-- 移除按钮 -->
  18 + <!-- 传递报警和报警类型 -->
  19 + <div style="margin-top: -15px; margin-left: 10px">
  20 + <div class="alert-type" style="margin-left: -50px; margin-top: -10px">
  21 + <BasicForm @register="registerForm"
  22 + /></div>
  23 + <div style="margin-top: -15px">
  24 + <div style="margin-left: -8px; margin-top: -10px">
  25 + <BasicForm
  26 + @register="registerFormHighSetting"
  27 + style="margin-left: 12px; margin-top: -10px"
  28 + >
  29 + <template #checkBox="{ model, field }">
  30 + <Checkbox v-model:checked="model[field]">传递报警</Checkbox>
  31 + </template>
  32 + </BasicForm>
  33 + </div>
29 34 </div>
30 35 </div>
31   - </div>
32   - <div style="margin-top: -57px">
33   - <p style="margin-left: 10px">创建报警规则</p>
34   - <template v-for="(childItem, createIndex) in item.alarms" :key="childItem.id">
35   - <div class="aic" style="border: 1px solid #bfbfbf">
36   - <div class="w-3/4" style="margin-left: 40px">
37   - <div style="margin-left: 10px; margin-top: 20px"
38   - ><BasicForm @register="registerFormCreateAlarm" />
39   - </div>
40   - <div style="margin-left: 5px; margin-top: -50px">
41   - <div style="color: #f5594e" class="ml-4"
42   - >报警规则条件:
43   - <Button
44   - style="margin-left: 4px"
45   - size="small"
46   - type="primary"
47   - @click="handleOpenAlaramRuleConditions"
48   - >添加</Button
49   - >
50   - <p>{{ ruleTemplateData }}</p>
  36 + <!-- 传递报警和报警类型 -->
  37 + <!-- 创建报警规则 -->
  38 + <div style="margin-top: -57px">
  39 + <p style="margin-left: 10px; font-size: medium">创建报警规则</p>
  40 + <template v-for="(childItem, createIndex) in item.alarms" :key="childItem.id">
  41 + <span style="display: none">{{ childItem }}</span>
  42 + <!-- 报警添加条件 -->
  43 + <div>
  44 + <!-- 报警启用规则 -->
  45 + <EnableRule
  46 + v-if="isRuleAlarmRuleConditions === 2"
  47 + ref="getChildData2"
  48 + @getAllFieldsEnab="getAllFieldsEnabFunc"
  49 + @register="registerModal2"
  50 + />
  51 + <!-- 报警规则条件 -->
  52 + <AlarmRuleConditions
  53 + v-if="isRuleAlarmRuleConditions === 3"
  54 + ref="getChildData3"
  55 + @getAllFieldsRule="getAllFieldsRuleFunc"
  56 + @register="registerModal3"
  57 + />
  58 + </div>
  59 + <!-- 添加条件按钮 -->
  60 + <div class="aic" style="border: 1px solid #bfbfbf">
  61 + <div class="w-3/4" style="margin-left: 40px">
  62 + <!-- 报警严重程度 -->
  63 + <div style="margin-left: 10px; margin-top: 20px"
  64 + ><BasicForm @register="registerFormCreateAlarm" />
51 65 </div>
52   - <div style="white-space: wrap; margin-top: 25px" class="mt-4 ml-4"
53   - >报警启用规则:
54   - <Button
55   - style="margin-left: 4px"
56   - size="small"
57   - type="primary"
58   - @click="handleOpenEnableRule"
59   - >添加</Button
60   - >
61   - <p>{{ enableTemplateData }}</p>
62   - <div
63   - class="mt-4 ml-4"
64   - style="margin-left: 0px; position: relative; margin-top: 25px"
65   - >报警详情模板:
66   - <div style="position: absolute; top: -5px; left: 106px; width: 581px">
67   - <BasicForm @register="registerFormChangeDetail" />
68   - </div>
69   - <!-- <Button size="small" type="primary" @click="handleOpenDetailTemplate"
  66 + <!-- 报警严重程度 -->
  67 +
  68 + <div style="margin-left: 5px; margin-top: -50px">
  69 + <div style="color: #f5594e" class="ml-4"
  70 + >报警规则条件:
  71 + <Button
  72 + style="margin-left: 4px"
  73 + size="small"
  74 + type="primary"
  75 + @click="handleOpenAlaramRuleConditions"
70 76 >添加</Button
71   - > -->
  77 + >
  78 + <!-- <p>{{ ruleTemplateData }}</p> -->
72 79 </div>
73   - <div style="margin-top: 25px; position: relative">
74   - <div style="margin-left: -14px">
75   - <BasicForm @register="dashboardForm" />
  80 + <div style="white-space: wrap; margin-top: 25px" class="mt-4 ml-4"
  81 + >报警启用规则:
  82 + <Button
  83 + style="margin-left: 4px"
  84 + size="small"
  85 + type="primary"
  86 + @click="handleOpenEnableRule"
  87 + >添加</Button
  88 + >
  89 + <!-- <p>{{ enableTemplateData }}</p> -->
  90 + <div
  91 + class="mt-4 ml-4"
  92 + style="margin-left: 0px; position: relative; margin-top: 25px"
  93 + >报警详情模板:
  94 + <div style="position: absolute; top: -5px; left: 106px; width: 581px">
  95 + <BasicForm @register="registerFormChangeDetail" />
  96 + </div>
  97 + </div>
  98 + <div style="margin-top: 25px; position: relative">
  99 + <div style="margin-left: -14px">
  100 + <BasicForm @register="dashboardForm" />
  101 + </div>
76 102 </div>
77 103 </div>
78 104 </div>
79   - </div>
80   - <div
81   - class="remove-type"
82   - style="display: inline-block; position: relative; top: -257px; left: 757px"
83   - >
84   - <img
85   - style="cursor: pointer"
86   - @click="deleteCondition(index, createIndex)"
87   - alt="移除"
88   - src="../../../../assets/images/close.png"
89   - />
  105 + <div
  106 + class="remove-type"
  107 + style="display: inline-block; position: relative; top: -257px; left: 757px"
  108 + >
  109 + <img
  110 + style="cursor: pointer"
  111 + @click="deleteCondition(index, createIndex)"
  112 + alt="移除"
  113 + src="../../../../assets/images/close.png"
  114 + />
  115 + </div>
90 116 </div>
91 117 </div>
  118 + </template>
  119 + <div>
  120 + <a-button style="border-radius: 10px" class="mt-5" @click="addCreateRole(index)"
  121 + ><PlusCircleOutlined />添加创建条件</a-button
  122 + >
92 123 </div>
93   - </template>
94   - <a-button style="border-radius: 10px" class="mt-5" @click="addCreateRole(index)"
95   - ><PlusCircleOutlined />添加创建条件</a-button
96   - >
97   - </div>
98   - <div style="height: 20px"></div>
99   - <div>
100   - <p style="margin-left: 10px">清除报警规则</p>
101   - <template
102   - v-for="(childClearItem, clearIndexItem) in item.clearRule"
103   - :key="childClearItem.id"
104   - >
105   - <div class="aic mb-1" style="border: 1px solid #bfbfbf">
106   - <div class="w-3/4" style="margin-left: 40px">
107   - <div style="margin-left: 5px">
108   - <div style="color: #f5594e" class="mt-4 ml-4"
109   - >报警规则条件:
110   - <Button
111   - style="margin-left: 2px"
112   - size="small"
113   - type="primary"
114   - @click="handleOpenClearAlaramRuleConditions"
115   - >添加</Button
116   - >
117   - <p>{{ ruleClearTemplateData }}</p>
118   - </div>
119   - <div style="white-space: wrap; margin-top: 25px" class="mt-4 ml-4"
120   - >报警启用规则:
121   - <Button
122   - style="margin-left: 2px"
123   - size="small"
124   - type="primary"
125   - @click="handleOpenClearEnableRule"
126   - >添加</Button
127   - >
128   - <p>{{ enableClearTemplateData }}</p>
129   - <div
130   - class="mt-4 ml-4"
131   - style="margin-left: 0px; position: relative; margin-top: 25px"
132   - >报警详情模板:
133   - <div style="position: absolute; top: -5px; left: 106px; width: 581px">
134   - <BasicForm @register="registerFormChangeClearDetail" />
135   - </div>
136   - <!-- <Button size="small" type="primary" @click="handleOpenClearDetailTemplate"
  124 + </div>
  125 + <!-- 创建报警规则 -->
  126 + <div style="height: 20px"></div>
  127 + <!-- 清除报警规则 -->
  128 + <div>
  129 + <p style="margin-left: 10px; font-size: medium">清除报警规则</p>
  130 + <template
  131 + v-for="(childClearItem, clearIndexItem) in item.clearRule"
  132 + :key="childClearItem.id"
  133 + >
  134 + <span style="display: none">{{ childClearItem }}</span>
  135 + <span style="display: none">{{ clearIndexItem }}</span>
  136 + <div>
  137 + <!-- 报警启用规则 -->
  138 + <EnableRule
  139 + v-if="isRuleAlarmRuleConditions === 5"
  140 + ref="getChildData5"
  141 + @getAllFieldsEnab="getAllClearFieldsEnabFunc"
  142 + @register="registerModal5"
  143 + />
  144 + <!-- 报警规则条件 -->
  145 + <AlarmRuleConditions
  146 + v-if="isRuleAlarmRuleConditions === 6"
  147 + ref="getChildData6"
  148 + @getAllFieldsRule="getAllClearFieldsRuleFunc"
  149 + @register="registerModal6"
  150 + />
  151 + </div>
  152 + <div class="aic mb-1" style="border: 1px solid #bfbfbf">
  153 + <div class="w-3/4" style="margin-left: 40px">
  154 + <div style="margin-left: 5px">
  155 + <div style="color: #f5594e" class="mt-4 ml-4"
  156 + >报警规则条件:
  157 + <Button
  158 + style="margin-left: 2px"
  159 + size="small"
  160 + type="primary"
  161 + @click="handleOpenClearAlaramRuleConditions"
137 162 >添加</Button
138 163 >
139   - <p>{{ detailClearTemplateData }}</p> -->
  164 + <!-- <p>{{ ruleClearTemplateData }}</p> -->
140 165 </div>
141   - <div style="margin-left: 0px; margin-top: 25px">
142   - <div style="margin-left: -14px">
143   - <BasicForm @register="dashboardForm" />
  166 + <div style="white-space: wrap; margin-top: 25px" class="mt-4 ml-4"
  167 + >报警启用规则:
  168 + <Button
  169 + style="margin-left: 2px"
  170 + size="small"
  171 + type="primary"
  172 + @click="handleOpenClearEnableRule"
  173 + >添加</Button
  174 + >
  175 + <!-- <p>{{ enableClearTemplateData }}</p> -->
  176 + <div
  177 + class="mt-4 ml-4"
  178 + style="margin-left: 0px; position: relative; margin-top: 25px"
  179 + >报警详情模板:
  180 + <div style="position: absolute; top: -5px; left: 106px; width: 581px">
  181 + <BasicForm @register="registerFormChangeClearDetail" />
  182 + </div>
  183 + </div>
  184 + <div style="margin-left: 0px; margin-top: 25px">
  185 + <div style="margin-left: -14px">
  186 + <BasicForm @register="dashboardForm" />
  187 + </div>
144 188 </div>
145 189 </div>
146 190 </div>
147 191 </div>
148 192 </div>
149   - </div>
150   - </template>
151   - </div>
152   - </CollapseContainer>
153   - </template>
154   - </div>
155   - <div class="flex justify-center" style="display: fixed; top: 100px">
156   - <a-button class="mr-5" @click="prevStep">上一步</a-button>
157   - <a-button @click="handleFormStep3toStep4Next">下一步</a-button>
158   - <a-button style="margin-left: 20px" type="primary" @click="addAlarmRule">添加报警规则</a-button>
159   - </div>
160   - <div>
161   - <!-- 详情模板 -->
162   - <DetailTemplate
163   - v-if="isRuleAlarmRuleConditions == 1"
164   - @getAllFields="getAllFieldsFunc"
165   - @register="registerModal1"
166   - />
167   - <!-- 启用规则 -->
168   - <EnableRule
169   - v-if="isRuleAlarmRuleConditions == 2"
170   - ref="getChildData2"
171   - @getAllFieldsEnab="getAllFieldsEnabFunc"
172   - @register="registerModal2"
173   - />
174   - <!-- 报警规则条件 -->
175   - <AlarmRuleConditions
176   - v-if="isRuleAlarmRuleConditions == 3"
177   - ref="getChildData3"
178   - @getAllFieldsRule="getAllFieldsRuleFunc"
179   - @register="registerModal3"
180   - />
181   - </div>
182   -
183   - <div>
184   - <!-- 清除条件 -->
185   - <!-- 详情模板 -->
186   - <DetailTemplate
187   - v-if="isRuleAlarmRuleConditions == 4"
188   - @getAllFields="getAllClearFieldsFunc"
189   - @register="registerModal4"
190   - />
191   - <!-- 启用规则 -->
192   - <EnableRule
193   - v-if="isRuleAlarmRuleConditions == 5"
194   - ref="getChildData2"
195   - @getAllFieldsEnab="getAllClearFieldsEnabFunc"
196   - @register="registerModal5"
197   - />
198   - <!-- 报警规则条件 -->
199   - <AlarmRuleConditions
200   - v-if="isRuleAlarmRuleConditions == 6"
201   - ref="getChildData3"
202   - @getAllFieldsRule="getAllClearFieldsRuleFunc"
203   - @register="registerModal6"
204   - />
  193 + </template>
  194 + </div>
  195 + <!-- 清除报警规则 -->
  196 + </CollapseContainer>
  197 + </template>
  198 + </div>
  199 + <div class="flex justify-center" style="display: fixed; bottom: 100px">
  200 + <a-button class="mr-5" @click="prevStep">上一步</a-button>
  201 + <a-button @click="handleFormStep3toStep4Next">下一步</a-button>
  202 + <a-button style="margin-left: 20px" type="primary" @click="addAlarmRule"
  203 + >添加报警规则</a-button
  204 + >
  205 + </div>
205 206 </div>
206 207 </template>
207 208
208 209 <script lang="ts">
209   - import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue';
  210 + import { defineComponent, ref, unref, getCurrentInstance, watch, reactive } from 'vue';
210 211 import type { IProfileData } from './index.t';
211 212 import { CollapseContainer } from '/@/components/Container/index';
212 213 import { BasicForm, useForm } from '/@/components/Form';
... ... @@ -221,7 +222,6 @@
221 222 import { PlusCircleOutlined } from '@ant-design/icons-vue';
222 223 import { Checkbox } from 'ant-design-vue';
223 224 import { useModal } from '/@/components/Modal';
224   - import DetailTemplate from './cpns/detailtemplate/index.vue';
225 225 import EnableRule from './cpns/enablerule/index.vue';
226 226 import AlarmRuleConditions from './cpns/alarmruleconditions/index.vue';
227 227 import { Button } from '/@/components/Button';
... ... @@ -233,24 +233,21 @@
233 233 CollapseContainer,
234 234 PlusCircleOutlined,
235 235 Checkbox,
236   - DetailTemplate,
237 236 EnableRule,
238 237 AlarmRuleConditions,
239 238 Button,
240 239 },
241 240 emits: ['prev', 'next', 'redo', 'handleFormStep3toStep4Next'],
242 241 setup(_, { emit }) {
243   - const changeGetDetailValue: any = ref(null);
244   - const changeGetClearDetailValue: any = ref(null);
245   - const ruleNumber = ref(0);
246 242 const { proxy } = getCurrentInstance();
  243 + const changeGetDetailValue = ref({});
  244 + const changeGetClearDetailValue = ref({});
247 245 const getChildData1 = ref(null);
248 246 const getChildData2 = ref(null);
249 247 const getChildData3 = ref(null);
  248 + const getChildData5 = ref(null);
  249 + const getChildData6 = ref(null);
250 250 const isRuleAlarmRuleConditions = ref(0);
251   - const getAllFormData: any = ref({});
252   - const alarmss: any = ref([]);
253   - const emptyObj: any = ref({});
254 251 const detailObj: any = ref({});
255 252 const detailClearObj: any = ref({});
256 253 const ruleObj: any = ref({});
... ... @@ -266,13 +263,94 @@
266 263 const ruleClearTemplateData: any = ref(null);
267 264 const enableClearTemplateData: any = ref(null);
268 265 const detailClearTemplateData: any = ref(null);
269   - const scheduleCustomValue: any = ref({});
270   - const scheduleCustomClearValue: any = ref({});
271   - const clearIndex = ref(-1);
272   - const getSchduleCustomValue: any = ref([]);
273   - const getSchduleClearCustomValue: any = ref([]);
274   - //告警列表
  266 + //重构
  267 + //告警列表接口
275 268 let profileData = ref<IProfileData[]>([]);
  269 + //初始化alarams数据
  270 + const initProfileData = reactive({
  271 + alarms: [
  272 + {
  273 + id: Date.now() + Math.random() + '',
  274 + alarmType: '',
  275 + createRules: {},
  276 + propagate: false,
  277 + propagateRelationTypes: [''],
  278 + },
  279 + ],
  280 + clearRule: [
  281 + {
  282 + id: Date.now() + Math.random() + '',
  283 + alarmDetails: '',
  284 + dashboardId: {
  285 + id: '',
  286 + entityType: '',
  287 + },
  288 + propagate: '',
  289 + propagateRelationTypes: [''],
  290 + schedule: {
  291 + type: 'string',
  292 + },
  293 + condition: {},
  294 + },
  295 + ],
  296 + });
  297 + //初始化创建条件
  298 + const initCreateRules = reactive({
  299 + id: Date.now() + Math.random() + '',
  300 + alarmType: '',
  301 + createRules: {},
  302 + propagate: false,
  303 + propagateRelationTypes: [''],
  304 + });
  305 + //接收临时启用规则数据
  306 + const receiveOpenRuleTempArr = ref<[]>([]);
  307 + //接收临时规则条件数据
  308 + const receiveRuleConditionTempArr = ref<[]>([]);
  309 + //创建条件总对象
  310 + const createRulesObj = ref({});
  311 + const addCreateRulesObj = reactive({
  312 + createRules: {},
  313 + });
  314 + const addChangeSeverity = ref({});
  315 + let addNewOpenRule = reactive({
  316 + schedule: {},
  317 + });
  318 + let addNewRuleTem = reactive({
  319 + condition: {},
  320 + });
  321 + const refAlarmDetailTemplate = ref(null);
  322 + const tempDetailTempArr = ref<[]>([]);
  323 + const tempOpenRuleTempArr = ref<[]>([]);
  324 + const tempRuleConditionTempArr = ref<[]>([]);
  325 + let addClearRule = reactive({});
  326 + //总的alarms数据
  327 + let allAlarms = ref<[]>([]);
  328 + const getClearObj = ref({});
  329 + const getAllObjTemp = ref({});
  330 + //报警类型数据
  331 + const alarmTypeGet = ref({});
  332 + const propagateAndpropagateRelationTypes = reactive({
  333 + propagate: '',
  334 + propagateRelationTypes: [],
  335 + });
  336 + let clearObj = reactive({
  337 + clearRule: {},
  338 + });
  339 + let kongClearOpenRuleObj = reactive({
  340 + schedule: {},
  341 + });
  342 + let kongClearRuleConditionObj = reactive({
  343 + condition: {},
  344 + });
  345 + //
  346 + const kongDetail = ref({});
  347 + let kongOpenRuleObj = reactive({
  348 + schedule: {},
  349 + });
  350 + let kongRuleConditionObj = reactive({
  351 + condition: {},
  352 + });
  353 +
276 354 const log = (e) => {
277 355 console.log(e);
278 356 };
... ... @@ -282,7 +360,6 @@
282 360 };
283 361 //删除告警配置
284 362 const deleteAlarmRule = (index: number) => {
285   - ruleNumber.value--;
286 363 unref(profileData).splice(index, 1);
287 364 };
288 365 // 上一步
... ... @@ -291,44 +368,7 @@
291 368 };
292 369 //添加报警规则
293 370 const addAlarmRule = () => {
294   - ruleNumber.value++;
295   - clearIndex.value++;
296   - unref(profileData).push({
297   - configuration: {
298   - type: '',
299   - },
300   - transportConfiguration: {
301   - type: '',
302   - },
303   - provisionConfiguration: {
304   - provisionDeviceSecret: '',
305   - },
306   - alarms: [
307   - {
308   - id: Date.now() + Math.random() + '',
309   - alarmType: '',
310   - createRules: {},
311   - propagate: false,
312   - propagateRelationTypes: [''],
313   - },
314   - ],
315   - clearRule: [
316   - {
317   - id: Date.now() + Math.random() + '',
318   - alarmDetails: '',
319   - dashboardId: {
320   - id: '',
321   - entityType: '',
322   - },
323   - propagate: '',
324   - propagateRelationTypes: [''],
325   - schedule: {
326   - type: 'string',
327   - },
328   - condition: {},
329   - },
330   - ],
331   - });
  371 + unref(profileData).push(initProfileData);
332 372 };
333 373 //TODO Mobile dashboard:
334 374 const [dashboardForm] = useForm({
... ... @@ -343,7 +383,7 @@
343 383 {
344 384 setFieldsValue: setRegisterForm,
345 385 resetFields: resetRegisterForm,
346   - validate: validateRegisterForm,
  386 + getFieldsValue: validateRegisterForm,
347 387 },
348 388 ] = useForm({
349 389 labelWidth: 120,
... ... @@ -357,7 +397,7 @@
357 397 {
358 398 setFieldsValue: setRegisterFormHighSetting,
359 399 resetFields: resetRegisterFormHighSetting,
360   - validate: validateRegisterFormHighSetting,
  400 + getFieldsValue: validateRegisterFormHighSetting,
361 401 },
362 402 ] = useForm({
363 403 labelWidth: 120,
... ... @@ -409,7 +449,6 @@
409 449 setFieldsValue: setRegisterFormCreateAlarm,
410 450 resetFields: resetRegisterFormCreateAlarm,
411 451 validate: validateRegisterFormCreateAlarm,
412   - updateSchema,
413 452 },
414 453 ] = useForm({
415 454 labelWidth: 120,
... ... @@ -494,77 +533,92 @@
494 533 setRegisterFormClearChangeDetail(v);
495 534 };
496 535
497   - const tempValue1: string = ref<string>('');
498   - // 添加‘创建条件’
499   - const addCreateRole = (index: number) => {
500   - updateSchema({
501   - field: 'default',
502   - componentProps: ({ formModel }) => {
503   - if (formModel.default == 'CRITICAL') {
504   - tempValue1.value = formModel.default;
505   - } else if (formModel.default == 'MAJOR') {
506   - tempValue1.value = formModel.default;
507   - } else if (formModel.default == 'MINOR') {
508   - tempValue1.value = formModel.default;
509   - } else if (formModel.default == 'WARNING') {
510   - tempValue1.value = formModel.default;
511   - } else if (formModel.default == 'INDETERMINATE') {
512   - tempValue1.value = formModel.default;
513   - }
514   - return {
515   - options: [
516   - {
517   - value: 'CRITICAL',
518   - label: '危险',
519   - disabled: tempValue1.value == 'CRITICAL',
520   - },
521   - {
522   - value: 'MAJOR',
523   - label: '重要',
524   - disabled: tempValue1.value == 'MAJOR',
525   - },
526   - {
527   - value: 'MINOR',
528   - label: '次要',
529   - disabled: tempValue1.value == 'MINOR',
530   - },
531   - {
532   - value: 'WARNING',
533   - label: '警告',
534   - disabled: tempValue1.value == 'WARNING',
535   - },
536   - {
537   - value: 'INDETERMINATE',
538   - label: '不确定',
539   - disabled: tempValue1.value == 'INDETERMINATE',
540   - },
541   - ],
542   - };
543   - },
  536 + const getRegisterFormChangeDetailFunc = () => {
  537 + changeGetDetailValue.value = getRegisterFormChangeDetail();
  538 + };
  539 + const getRegisterClearFormChangeDetailFunc = () => {
  540 + changeGetClearDetailValue.value = getRegisterFormClearChangeDetail();
  541 + };
  542 +
  543 + const emptyCreateRoleFunc = () => {
  544 + receiveOpenRuleTempArr.value = [];
  545 + receiveRuleConditionTempArr.value = [];
  546 + addNewOpenRule.schedule = {};
  547 + addNewRuleTem.condition = {};
  548 + };
  549 +
  550 + const getOpenRuleAndRuleCondition = () => {
  551 + addNewOpenRule.schedule = enableObj.value as never;
  552 + addNewRuleTem.condition = ruleObj.value as never;
  553 + tempOpenRuleTempArr.value.push(addNewOpenRule.schedule as never);
  554 + tempRuleConditionTempArr.value.push(addNewRuleTem.condition as never);
  555 + };
  556 + const getClearOpenRuleAndRuleCondition = () => {
  557 + kongClearOpenRuleObj.schedule = enableClearObj.value as never;
  558 + kongClearRuleConditionObj.condition = ruleLastObj.value as never;
  559 + };
  560 +
  561 + //传递报警数据
  562 + const validateRegisterFormHighSettingFunc = () => {
  563 + const val = validateRegisterFormHighSetting();
  564 + propagateAndpropagateRelationTypes.propagate = val.propagate;
  565 + propagateAndpropagateRelationTypes.propagateRelationTypes.push(
  566 + val.propagateRelationTypes as never
  567 + );
  568 + };
  569 + //报警类型数据
  570 + const validateRegisterFormFunc = () => {
  571 + const val1 = validateRegisterForm();
  572 + alarmTypeGet.value = val1;
  573 + };
  574 +
  575 + // 添加创建条件方法
  576 + const addCreateRuleFunc = async () => {
  577 + getRegisterFormChangeDetailFunc();
  578 + tempDetailTempArr.value.push(changeGetDetailValue.value as never);
  579 + console.log(tempDetailTempArr.value);
  580 + tempDetailTempArr.value.forEach((f1) => {
  581 + kongDetail.value = f1;
544 582 });
545   - unref(profileData)[index].alarms.push({
546   - id: Date.now() + Math.random() + '',
547   - alarmType: '',
548   - createRules: {},
549   - // clearRule: [
550   - // {
551   - // id: Date.now() + Math.random() + '',
552   - // alarmDetails: '',
553   - // dashboardId: {
554   - // id: '',
555   - // entityType: '',
556   - // },
557   - // propagate: '',
558   - // propagateRelationTypes: [''],
559   - // schedule: {
560   - // type: 'string',
561   - // },
562   - // condition: {},
563   - // },
564   - // ],
565   - propagate: false,
566   - propagateRelationTypes: [''],
  583 + addChangeSeverity.value = await validateRegisterFormCreateAlarm();
  584 + emptyCreateRoleFunc();
  585 + getOpenRuleAndRuleCondition();
  586 +
  587 + tempOpenRuleTempArr.value.forEach((f2) => {
  588 + kongOpenRuleObj.schedule = f2;
567 589 });
  590 +
  591 + tempRuleConditionTempArr.value.forEach((f3) => {
  592 + kongRuleConditionObj.condition = f3;
  593 + });
  594 +
  595 + createRulesObj.value[addChangeSeverity.value.default] = {
  596 + ...kongDetail.value,
  597 + ...addNewOpenRule,
  598 + ...addNewRuleTem,
  599 + ...kongOpenRuleObj,
  600 + ...kongRuleConditionObj,
  601 + };
  602 + addCreateRulesObj.createRules = createRulesObj.value;
  603 + };
  604 +
  605 + //清除报警规则
  606 + const addClearAlaramRule = () => {
  607 + getClearOpenRuleAndRuleCondition();
  608 + getRegisterClearFormChangeDetailFunc();
  609 + addClearRule = {
  610 + ...kongClearOpenRuleObj,
  611 + ...kongClearRuleConditionObj,
  612 + ...changeGetClearDetailValue.value,
  613 + };
  614 + clearObj.clearRule = { ...addClearRule };
  615 + getClearObj.value = clearObj;
  616 + };
  617 +
  618 + // 添加创建条件
  619 + const addCreateRole = async (index: number) => {
  620 + unref(profileData)[index]?.alarms.push(initCreateRules);
  621 + addCreateRuleFunc();
568 622 };
569 623 // 删除‘创建条件’
570 624 const deleteCondition = (index: number, createIndex: number) => {
... ... @@ -583,8 +637,8 @@
583 637 const getAllFieldsFunc = (v) => {
584 638 detailObj.value = v;
585 639 detailTemplateData.value = `
586   - 报警详细信息:${v.alarmDetails}
587   - `;
  640 + 报警详细信息:${v.alarmDetails}
  641 + `;
588 642 };
589 643 //启用规则
590 644 const getAllFieldsEnabFunc = (v) => {
... ... @@ -625,7 +679,7 @@
625 679 return f.label;
626 680 }
627 681 } catch (e) {
628   - console.log(e);
  682 + return e;
629 683 }
630 684 });
631 685 const findDayCustomByValue = findDay.map((f, i) => {
... ... @@ -634,7 +688,7 @@
634 688 return f.label;
635 689 }
636 690 } catch (e) {
637   - console.log(e);
  691 + return e;
638 692 }
639 693 });
640 694 enableTemplateData.value =
... ... @@ -642,13 +696,14 @@
642 696 ? `始终启用`
643 697 : v.schedule == 'SPECIFIC_TIME'
644 698 ? `
645   - 开始时间:${v.startsOn},结束时间:${v.endsOn},天数:${findDayByValue}
646   - `
  699 + 开始时间:${v.startsOn},结束时间:${v.endsOn},天数:${findDayByValue}
  700 + `
647 701 : `天数:${findDayCustomByValue},开始时间: ${v.startsOn1},结束时间:${v.endsOn1}`;
648 702 };
649 703 //规则条件
650   - const getAllFieldsRuleFunc = (v, v1) => {
  704 + const getAllFieldsRuleFunc = (v) => {
651 705 ruleObj.value = v;
  706 + console.log(v);
652 707 const findDay = [
653 708 { label: '等于', value: 'EQUAL' },
654 709 { label: '不等于', value: 'NOT_EQUAL' },
... ... @@ -669,10 +724,10 @@
669 724 }
670 725 });
671 726 ruleTemplateData.value = `
672   - 键名:${v.key1} 操作:${findRuleByValue?.label} 值:${v.value1}
673   - `;
  727 + 键名:${v.key1} 操作:${findRuleByValue?.label} 值:${v.value1}
  728 + `;
674 729
675   - ruleLastObj.value = v1;
  730 + // ruleLastObj.value = v1;
676 731 const predicate = {
677 732 operation: ruleObj.value.operation,
678 733 value: {
... ... @@ -715,8 +770,8 @@
715 770 const getAllClearFieldsFunc = (v) => {
716 771 detailClearObj.value = v;
717 772 detailClearTemplateData.value = `
718   - 报警详细信息:${v.alarmDetails}
719   - `;
  773 + 报警详细信息:${v.alarmDetails}
  774 + `;
720 775 };
721 776 //启用规则
722 777 const getAllClearFieldsEnabFunc = (v) => {
... ... @@ -757,7 +812,7 @@
757 812 return f.label;
758 813 }
759 814 } catch (e) {
760   - console.log(e);
  815 + return e;
761 816 }
762 817 });
763 818 const findDayCustomByValue = findDay.map((f, i) => {
... ... @@ -766,7 +821,7 @@
766 821 return f.label;
767 822 }
768 823 } catch (e) {
769   - console.log(e);
  824 + return e;
770 825 }
771 826 });
772 827 enableClearTemplateData.value =
... ... @@ -774,13 +829,15 @@
774 829 ? `始终启用`
775 830 : v.schedule == 'SPECIFIC_TIME'
776 831 ? `
777   - 开始时间:${v.startsOn},结束时间:${v.endsOn},天数:${findDayByValue}
778   - `
  832 + 开始时间:${v.startsOn},结束时间:${v.endsOn},天数:${findDayByValue}
  833 + `
779 834 : `天数:${findDayCustomByValue},开始时间: ${v.startsOn1},结束时间:${v.endsOn1}`;
780 835 };
781 836 //规则条件
782   - const getAllClearFieldsRuleFunc = (v, v1) => {
783   - ruleObj.value = v;
  837 + const getAllClearFieldsRuleFunc = (v) => {
  838 + ruleLastObj.value = v;
  839 + console.log(v);
  840 +
784 841 const findDay = [
785 842 { label: '等于', value: 'EQUAL' },
786 843 { label: '不等于', value: 'NOT_EQUAL' },
... ... @@ -801,10 +858,10 @@
801 858 }
802 859 });
803 860 ruleClearTemplateData.value = `
804   - 键名:${v.key1} 操作:${findRuleByValue?.label} 值:${v.value1}
805   - `;
  861 + 键名:${v.key1} 操作:${findRuleByValue?.label} 值:${v.value1}
  862 + `;
806 863
807   - ruleLastObj.value = v1;
  864 + // ruleLastObj.value = v1;
808 865 const predicate = {
809 866 operation: ruleObj.value.operation,
810 867 value: {
... ... @@ -842,6 +899,7 @@
842 899 };
843 900 Object.assign(addClearitionalObj.value, getValueConditon);
844 901 };
  902 +
845 903 //生成uuid
846 904 function generateUUID() {
847 905 let d = new Date().getTime();
... ... @@ -857,166 +915,29 @@
857 915 }
858 916 const handleFormStep3toStep4Next = async () => {
859 917 try {
860   - changeGetDetailValue.value = getRegisterFormChangeDetail();
861   - changeGetClearDetailValue.value = getRegisterFormClearChangeDetail();
862   - if (enableObj.value.schedule == 'CUSTOM') {
863   - // for (let i in enableObj.value) {
864   - // console.log(i);
865   - // // let o = {};
866   - // // if(enableObj.value[i]=='1')
867   - // // o[i] = enableObj.value[i];
868   - // // getSchduleCustomValue.value.push(o);
869   - // // getSchduleCustomValue.value.push(enableObj.value[i]);
870   - // }
871   - // switch (enableObj.value.daysOfWeek1[0]) {
872   - // case '1':
873   - // getSchduleCustomValue.value.push({
874   - // enabled: true,
875   - // dayOfWeek: enableObj.value.daysOfWeek1[0],
876   - // startsOn: enableObj.value.startsOn1,
877   - // endsOn: enableObj.value.endsOn1,
878   - // });
879   - // break;
880   - // case '2':
881   - // getSchduleCustomValue.value.push({
882   - // enabled: true,
883   - // dayOfWeek: enableObj.value.daysOfWeek2[0],
884   - // startsOn: enableObj.value.startsOn2,
885   - // endsOn: enableObj.value.endsOn2,
886   - // });
887   - // break;
888   - // case '3':
889   - // getSchduleCustomValue.value.push({
890   - // enabled: true,
891   - // dayOfWeek: enableObj.value.daysOfWeek3[0],
892   - // startsOn: enableObj.value.startsOn3,
893   - // endsOn: enableObj.value.endsOn3,
894   - // });
895   - // break;
896   - // }
897   - scheduleCustomValue.value = {
898   - type: enableObj.value.schedule,
899   - timezone: enableObj.value.timezone,
900   - items: getSchduleCustomValue.value,
901   - };
902   - }
903   - //清除报警规则---报警日程表
904   - if (enableClearObj.value.schedule == 'CUSTOM') {
905   - switch (enableClearObj.value.daysOfWeek1[0]) {
906   - case '1':
907   - getSchduleClearCustomValue.value.push({
908   - enabled: true,
909   - dayOfWeek: enableClearObj.value.daysOfWeek1[0],
910   - startsOn: enableClearObj.value.startsOn1,
911   - endsOn: enableClearObj.value.endsOn1,
912   - });
913   - break;
914   - case '2':
915   - getSchduleClearCustomValue.value.push({
916   - enabled: true,
917   - dayOfWeek: enableClearObj.value.daysOfWeek2[0],
918   - startsOn: enableClearObj.value.startsOn2,
919   - endsOn: enableClearObj.value.endsOn2,
920   - });
921   - break;
922   - case '3':
923   - getSchduleClearCustomValue.value.push({
924   - enabled: true,
925   - dayOfWeek: enableClearObj.value.daysOfWeek3[0],
926   - startsOn: enableClearObj.value.startsOn3,
927   - endsOn: enableClearObj.value.endsOn3,
928   - });
929   - break;
930   - }
931   - scheduleCustomClearValue.value = {
932   - type: enableClearObj.value.schedule,
933   - timezone: enableClearObj.value.timezone,
934   - items: getSchduleClearCustomValue.value,
935   - };
936   - }
937   - const scheduleClearValue = {
938   - type: enableClearObj.value.schedule,
939   - daysOfWeek: enableClearObj.value.daysOfWeek,
940   - endsOn: enableClearObj.value.endsOn,
941   - startsOn: enableClearObj.value.startOn,
942   - timezone: enableClearObj.value.timezone,
943   - };
944   - const getClearSchedule = {
945   - schedule:
946   - enableClearObj.value.schedule == 'CUSTOM'
947   - ? scheduleCustomClearValue.value
948   - : scheduleClearValue,
949   - };
950   - const getClearAdditionalProp = Object.assign(
951   - {},
952   - changeGetClearDetailValue.value,
953   - getClearSchedule
954   - );
955   - const scheduleValue = {
956   - type: enableObj.value.schedule,
957   - daysOfWeek: enableObj.value.daysOfWeek,
958   - endsOn: enableObj.value.endsOn,
959   - startsOn: enableObj.value.startOn,
960   - timezone: enableObj.value.timezone,
961   - };
962   - const getSchedule = {
963   - schedule:
964   - enableObj.value.schedule == 'CUSTOM' ? scheduleCustomValue.value : scheduleValue,
965   - };
966   -
967   - const getAdditionalProp = Object.assign({}, changeGetDetailValue.value, getSchedule);
968   - const getScheduleAndAlarmDetails = Object.assign(
969   - {},
970   - getAdditionalProp,
971   - additionalObj.value
972   - );
973   - const getScheduleAndClearAlarmDetails = Object.assign(
974   - {},
975   - getClearAdditionalProp,
976   - addClearitionalObj.value
977   - );
978   - const getIsWhereTypeValue: any = isWhereTypeValue.value;
979   - const getAdditionalPropObj = {
980   - [getIsWhereTypeValue]: getScheduleAndAlarmDetails,
981   - };
982   - const getCreateRulesAllObj = {
983   - createRules: getAdditionalPropObj,
984   - };
985   - const getClearRulesAllObj = {
986   - clearRule: getScheduleAndClearAlarmDetails,
987   - };
988   - const valueRegisterForm = await validateRegisterForm();
989   - const valueRegisterFormAndId = {
990   - alarmType: Object.values(valueRegisterForm)[0],
991   - };
  918 + validateRegisterFormFunc();
  919 + validateRegisterFormHighSettingFunc();
992 920 const objectId = {
993 921 id: generateUUID(),
994 922 };
995   - const valueRegisterFormHighSetting = await validateRegisterFormHighSetting();
996   - const valueRegisterFormCreateAlarm = await validateRegisterFormCreateAlarm();
997   - console.log(valueRegisterFormCreateAlarm);
998   - const getValueRegisterFormHighSetting = {
999   - propagate: valueRegisterFormHighSetting?.propagate,
1000   - propagateRelationTypes: [valueRegisterFormHighSetting?.propagateRelationTypes].flat(1),
1001   - };
1002   - Object.assign(
1003   - emptyObj.value,
1004   - valueRegisterFormAndId,
1005   - getValueRegisterFormHighSetting,
1006   - getCreateRulesAllObj,
1007   - getClearRulesAllObj,
1008   - objectId
1009   - );
1010   - if (alarmss.value.length == 0) {
1011   - alarmss.value.push(emptyObj.value);
1012   - }
1013   - const getAlarms = {
1014   - alarms: alarmss.value,
  923 + getRegisterFormChangeDetailFunc();
  924 + addCreateRuleFunc();
  925 + addClearAlaramRule();
  926 + console.log(addCreateRulesObj);
  927 + console.log(getClearObj.value);
  928 +
  929 + getAllObjTemp.value = {
  930 + ...addCreateRulesObj,
  931 + ...getClearObj.value,
  932 + ...objectId,
  933 + ...alarmTypeGet.value,
  934 + ...propagateAndpropagateRelationTypes,
1015 935 };
1016   - Object.assign(getAllFormData.value, getAlarms);
1017   - emit('next', getAllFormData.value);
  936 + allAlarms.value.push(getAllObjTemp.value as never);
  937 + emit('next', allAlarms.value);
1018 938 } catch (error) {}
1019 939 };
  940 +
1020 941 const [registerModal1, { openModal: openModal1 }] = useModal();
1021 942 const [registerModal2, { openModal: openModal2 }] = useModal();
1022 943 const [registerModal3, { openModal: openModal3 }] = useModal();
... ... @@ -1087,13 +1008,15 @@
1087 1008 };
1088 1009
1089 1010 return {
  1011 + getChildData5,
  1012 + getChildData6,
  1013 + refAlarmDetailTemplate,
1090 1014 resetRegisterFormChangeDetailFunc,
1091 1015 resetRegisterFormClearChangeDetailFunc,
1092 1016 setRegisterFormClearChangeDetailFunc,
1093 1017 setRegisterFormChangeDetailFunc,
1094 1018 registerFormChangeClearDetail,
1095 1019 registerFormChangeDetail,
1096   - ruleNumber,
1097 1020 resetEnableClearFormDataFunc,
1098 1021 resetTemplateClearFormDataFunc,
1099 1022 resetRulesClearFormDataFunc,
... ... @@ -1107,7 +1030,6 @@
1107 1030 retryTemplateFormDataFunc,
1108 1031 retryRulesFormDataFunc,
1109 1032 clearProfileDataFunc,
1110   - clearIndex,
1111 1033 retryRegisterFormFunc,
1112 1034 retryRegisterFormHighSettingmFunc,
1113 1035 retryRegisterFormCreateAlarmFunc,
... ...
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
... ...
  1 +{
  2 + "name": "1",
  3 + "defaultRuleChainId": "de8bf640-8892-11ec-ac19-e398562c8b61",
  4 + "defaultQueueName": "HighPriority",
  5 + "description": "1",
  6 + "icon": "",
  7 + "transportType": "DEFAULT",
  8 + "profileData": {
  9 + "alarms": [
  10 + {
  11 + "createRules": {
  12 + "MAJOR": {
  13 + "alarmDetails": "1",
  14 + "schedule": {
  15 + "type": "ANY_TIME",
  16 + "timezone": "Asia/Shanghai (UTC+08:00)"
  17 + },
  18 + "condition": {
  19 + "type": "TIME_SERIES",
  20 + "key1": "1",
  21 + "type1": "NUMERIC",
  22 + "operation": "GREATER_OR_EQUAL",
  23 + "value1": "1",
  24 + "id": 3
  25 + }
  26 + },
  27 + "MINOR": {
  28 + "alarmDetails": "2",
  29 + "schedule": {
  30 + "type": "ANY_TIME",
  31 + "timezone": "Asia/Shanghai (UTC+08:00)"
  32 + },
  33 + "condition": {
  34 + "type": "TIME_SERIES",
  35 + "key1": "2",
  36 + "type1": "NUMERIC",
  37 + "operation": "GREATER",
  38 + "value1": "2",
  39 + "id": 2
  40 + }
  41 + }
  42 + },
  43 + "clearRule": {
  44 + "schedule": {
  45 + "type": "ANY_TIME",
  46 + "timezone": "Asia/Shanghai (UTC+08:00)"
  47 + },
  48 + "condition": {
  49 + "type": "TIME_SERIES",
  50 + "key1": "3",
  51 + "type1": "NUMERIC",
  52 + "operation": "LESS_OR_EQUAL",
  53 + "value1": "3",
  54 + "id": 2
  55 + },
  56 + "alarmDetails": "3"
  57 + },
  58 + "id": "a5043fdc-2ad0-4d7c-8a29-fa7e8e18fe8d",
  59 + "alarmType": "0",
  60 + "propagate": true,
  61 + "propagateRelationTypes": ["0"]
  62 + }
  63 + ]
  64 + },
  65 + "alarmProfile": {
  66 + "alarmContactId": ["224a312c-4f52-41ef-9dce-2aac69ec2e85"],
  67 + "messageMode": ["PHONE_MESSAGE", "EMAIL_MESSAGE"]
  68 + }
  69 +}
... ...
... ... @@ -3,9 +3,8 @@ import { FormSchema } from '/@/components/Table';
3 3 export const formSchema: FormSchema[] = [
4 4 {
5 5 field: 'alarmDetails',
6   - label: '报警详细信息',
  6 + label: '',
7 7 colProps: { span: 17 },
8   - required: true,
9 8 component: 'Input',
10 9 componentProps: {
11 10 maxLength: 255,
... ...
1 1 <template>
2   - <BasicModal
3   - v-bind="$attrs"
4   - width="55rem"
5   - @register="register"
6   - :title="getTitle"
7   - @ok="handleSubmit"
8   - >
  2 + <div>
9 3 <BasicForm :showResetButton="false" :showSubmitButton="false" @register="registerForm" />
10   - </BasicModal>
  4 + </div>
11 5 </template>
12 6 <script lang="ts">
13   - import { defineComponent, ref, computed, unref } from 'vue';
14   - import { BasicModal, useModalInner } from '/@/components/Modal';
  7 + import { defineComponent, ref } from 'vue';
15 8 import { BasicForm, useForm } from '/@/components/Form';
16 9 import { formSchema } from './config';
17 10
18 11 export default defineComponent({
19 12 name: 'DetailTemplate',
20 13 components: {
21   - BasicModal,
22 14 BasicForm,
23 15 },
24 16 emits: ['success', 'register', 'getAllFields'],
25   - setup(_, { emit }) {
26   - // const getValueData: any = ref({});
27   - const isUpdate = ref(true);
28   - const [registerForm, { getFieldsValue, resetFields }] = useForm({
  17 + setup() {
  18 + const fieldValue: any = ref({});
  19 + const [registerForm, { getFieldsValue }] = useForm({
29 20 labelWidth: 120,
30 21 schemas: formSchema,
31 22 });
32   - const getTitle = computed(() => (!unref(isUpdate) ? '新增详情模板' : '编辑详情模板'));
33   - const [register, { closeModal }] = useModalInner((data) => {
34   - isUpdate.value = !!data?.isUpdate;
35   - });
36   - const resetDataFunc = () => {
37   - resetFields();
38   - };
39   - const handleSubmit = () => {
40   - const values = getFieldsValue();
41   - emit('getAllFields', values);
42   - // let getV = {};
43   - // getAllFields(getV);
44   - closeModal();
  23 +
  24 + const getFieldsValueFunc = () => {
  25 + fieldValue.value = getFieldsValue();
  26 + return fieldValue.value;
45 27 };
46   - // function getAllFields(getV) {
47   - // const values = getFieldsValue();
48   - // getValueData.value = values;
49   - // getV = getValueData.value;
50   - // return getV;
51   - // }
  28 +
52 29 return {
53   - resetDataFunc,
54   - // getAllFields,
  30 + getFieldsValueFunc,
55 31 registerForm,
56   - handleSubmit,
57   - register,
58   - getTitle,
59 32 };
60 33 },
61 34 });
... ...
... ... @@ -23,7 +23,7 @@ export const isTimeAll = (type: string) => {
23 23
24 24 export const formSchema: FormSchema[] = [
25 25 {
26   - field: 'schedule',
  26 + field: 'type',
27 27 label: '报警日程表',
28 28 colProps: { span: 12 },
29 29 required: true,
... ... @@ -55,7 +55,7 @@ export const formSchema: FormSchema[] = [
55 55 ],
56 56 },
57 57 ifShow: ({ values }) =>
58   - isWenDu(Reflect.get(values, 'schedule')) || isTimeAll(Reflect.get(values, 'schedule')),
  58 + isWenDu(Reflect.get(values, 'type')) || isTimeAll(Reflect.get(values, 'type')),
59 59 },
60 60
61 61 {
... ... @@ -73,7 +73,7 @@ export const formSchema: FormSchema[] = [
73 73 },
74 74 ],
75 75 },
76   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  76 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
77 77 },
78 78 {
79 79 field: 'startsOn1',
... ... @@ -85,7 +85,7 @@ export const formSchema: FormSchema[] = [
85 85 colProps: {
86 86 span: 8,
87 87 },
88   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  88 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
89 89 },
90 90 {
91 91 field: 'endsOn1',
... ... @@ -97,7 +97,7 @@ export const formSchema: FormSchema[] = [
97 97 colProps: {
98 98 span: 8,
99 99 },
100   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  100 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
101 101 },
102 102
103 103 {
... ... @@ -115,7 +115,7 @@ export const formSchema: FormSchema[] = [
115 115 },
116 116 ],
117 117 },
118   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  118 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
119 119 },
120 120 {
121 121 field: 'startsOn2',
... ... @@ -127,7 +127,7 @@ export const formSchema: FormSchema[] = [
127 127 colProps: {
128 128 span: 8,
129 129 },
130   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  130 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
131 131 },
132 132 {
133 133 field: 'endsOn2',
... ... @@ -139,7 +139,7 @@ export const formSchema: FormSchema[] = [
139 139 colProps: {
140 140 span: 8,
141 141 },
142   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  142 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
143 143 },
144 144 {
145 145 field: 'daysOfWeek3',
... ... @@ -156,7 +156,7 @@ export const formSchema: FormSchema[] = [
156 156 },
157 157 ],
158 158 },
159   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  159 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
160 160 },
161 161 {
162 162 field: 'startsOn3',
... ... @@ -168,7 +168,7 @@ export const formSchema: FormSchema[] = [
168 168 colProps: {
169 169 span: 8,
170 170 },
171   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  171 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
172 172 },
173 173 {
174 174 field: 'endsOn3',
... ... @@ -180,7 +180,7 @@ export const formSchema: FormSchema[] = [
180 180 colProps: {
181 181 span: 8,
182 182 },
183   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  183 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
184 184 },
185 185 {
186 186 field: 'daysOfWeek4',
... ... @@ -197,7 +197,7 @@ export const formSchema: FormSchema[] = [
197 197 },
198 198 ],
199 199 },
200   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  200 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
201 201 },
202 202 {
203 203 field: 'startsOn4',
... ... @@ -209,7 +209,7 @@ export const formSchema: FormSchema[] = [
209 209 colProps: {
210 210 span: 8,
211 211 },
212   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  212 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
213 213 },
214 214 {
215 215 field: 'endsOn4',
... ... @@ -221,7 +221,7 @@ export const formSchema: FormSchema[] = [
221 221 colProps: {
222 222 span: 8,
223 223 },
224   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  224 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
225 225 },
226 226 {
227 227 field: 'daysOfWeek5',
... ... @@ -238,7 +238,7 @@ export const formSchema: FormSchema[] = [
238 238 },
239 239 ],
240 240 },
241   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  241 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
242 242 },
243 243 {
244 244 field: 'startsOn5',
... ... @@ -250,7 +250,7 @@ export const formSchema: FormSchema[] = [
250 250 colProps: {
251 251 span: 8,
252 252 },
253   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  253 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
254 254 },
255 255 {
256 256 field: 'endsOn5',
... ... @@ -262,7 +262,7 @@ export const formSchema: FormSchema[] = [
262 262 colProps: {
263 263 span: 8,
264 264 },
265   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  265 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
266 266 },
267 267 {
268 268 field: 'daysOfWeek6',
... ... @@ -279,7 +279,7 @@ export const formSchema: FormSchema[] = [
279 279 },
280 280 ],
281 281 },
282   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  282 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
283 283 },
284 284 {
285 285 field: 'startsOn6',
... ... @@ -291,7 +291,7 @@ export const formSchema: FormSchema[] = [
291 291 colProps: {
292 292 span: 8,
293 293 },
294   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  294 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
295 295 },
296 296 {
297 297 field: 'endsOn6',
... ... @@ -303,7 +303,7 @@ export const formSchema: FormSchema[] = [
303 303 colProps: {
304 304 span: 8,
305 305 },
306   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  306 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
307 307 },
308 308 {
309 309 field: 'daysOfWeek7',
... ... @@ -320,7 +320,7 @@ export const formSchema: FormSchema[] = [
320 320 },
321 321 ],
322 322 },
323   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  323 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
324 324 },
325 325 {
326 326 field: 'startsOn7',
... ... @@ -332,7 +332,7 @@ export const formSchema: FormSchema[] = [
332 332 colProps: {
333 333 span: 8,
334 334 },
335   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  335 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
336 336 },
337 337 {
338 338 field: 'endsOn7',
... ... @@ -344,7 +344,7 @@ export const formSchema: FormSchema[] = [
344 344 colProps: {
345 345 span: 8,
346 346 },
347   - ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'schedule')),
  347 + ifShow: ({ values }) => isTimeAll(Reflect.get(values, 'type')),
348 348 },
349 349
350 350 {
... ... @@ -392,7 +392,7 @@ export const formSchema: FormSchema[] = [
392 392 },
393 393 ],
394 394 },
395   - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'schedule')),
  395 + ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')),
396 396 },
397 397 {
398 398 field: 'startsOn',
... ... @@ -404,7 +404,7 @@ export const formSchema: FormSchema[] = [
404 404 componentProps: {
405 405 valueFormat: 'HH:mm:ss',
406 406 },
407   - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'schedule')),
  407 + ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')),
408 408 },
409 409 {
410 410 field: 'endsOn',
... ... @@ -416,6 +416,6 @@ export const formSchema: FormSchema[] = [
416 416 componentProps: {
417 417 valueFormat: 'HH:mm:ss',
418 418 },
419   - ifShow: ({ values }) => isWenDu(Reflect.get(values, 'schedule')),
  419 + ifShow: ({ values }) => isWenDu(Reflect.get(values, 'type')),
420 420 },
421 421 ];
... ...
... ... @@ -158,6 +158,7 @@ export const step3CreateAlarm: FormSchema[] = [
158 158 {
159 159 field: 'default',
160 160 component: 'Select',
  161 + required: true,
161 162 label: '报警严重程度:',
162 163 colProps: {
163 164 span: 17,
... ...
... ... @@ -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,
... ...