Commit 7d72075015275530a095dcbdc74b3f78297c2807

Authored by fengtao
1 parent 52675b25

fix:修改数据转换配置接口路径

... ... @@ -6,15 +6,16 @@ import {
6 6 } from './model/dataManagerModel';
7 7
8 8 enum DataManagerApi {
9   - DATA_MANAGER_CONVERT_ADD_OR_EDIT = '/convert',
10   - DATA_MANAGER_CONVERT_DELETE = '/convert',
11   - DATA_MANAGER_CONVERT_POST_CHECK_NAME = '/convert/check',
12   - DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED = '/convert/update',
  9 + DATA_MANAGER_CONVERT_ADD_OR_EDIT = '/convert/config',
  10 + DATA_MANAGER_CONVERT_DELETE = '/convert/config',
  11 + DATA_MANAGER_CONVERT_POST_CHECK_NAME = '/convert/check/config',
  12 + DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED = '/convert/update/config',
13 13 DATA_MANAGER_CONVERT_GET = '/convert',
14 14 }
15 15
16 16 // 转换配置分页查询
17 17 export const getConvertApi = (params: TDataManagerModelQuery) => {
  18 + params.nodeType = 1;
18 19 return defHttp.get<TDataManagerModelQuery>({
19 20 url: DataManagerApi.DATA_MANAGER_CONVERT_GET,
20 21 params,
... ... @@ -49,6 +50,7 @@ export const isExistDataManagerNameApi = (check: {}) => {
49 50
50 51 // 启用或者禁用配置
51 52 export const isEnableOrDisableApi = (params: IEnableOrDisableModel) => {
  53 + params.nodeType = 1;
52 54 return defHttp.post<IEnableOrDisableModel>({
53 55 url: DataManagerApi.DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED,
54 56 params,
... ...
... ... @@ -5,6 +5,7 @@ export type TDataManagerModelQuery = BasicPageParams & TDataManagerParam;
5 5 export type TDataManagerParam = {
6 6 name?: string;
7 7 status?: string;
  8 + nodeType?: number;
8 9 };
9 10
10 11 export interface IDataManagerModel {
... ... @@ -31,4 +32,5 @@ export interface IDataManagerModel {
31 32 export interface IEnableOrDisableModel {
32 33 convertIds?: [string];
33 34 status?: number;
  35 + nodeType?: number;
34 36 }
... ...
... ... @@ -147,6 +147,9 @@
147 147 }
148 148 };
149 149 const addOrEditFunc = async () => {
  150 + if (!unref(isUpdate)) {
  151 + proxy.$refs.refTransferConfigParams.clearSonValueValidateFunc();
  152 + }
150 153 getModeSonFormValue.value = await proxy.$refs.refTransferConfigMode.getSonValueFunc();
151 154 getSonFormValue.value = await proxy.$refs.refTransferConfigParams.getSonValueDataFunc();
152 155 if (getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
... ...
... ... @@ -2,6 +2,8 @@ import { FormSchema } from '/@/components/Form';
2 2 import { findDictItemByCode } from '/@/api/system/dict';
3 3 import { isExistDataManagerNameApi } from '/@/api/datamanager/dataManagerApi';
4 4 import { ref } from 'vue';
  5 +import { useMessage } from '/@/hooks/web/useMessage';
  6 +const { createMessage } = useMessage();
5 7
6 8 const typeValue = ref('');
7 9
... ... @@ -124,9 +126,16 @@ export const modeKafkaForm: FormSchema[] = [
124 126 reject('请输入名称');
125 127 } else {
126 128 if (values.name != undefined) {
127   - isExistDataManagerNameApi({ name: value, type: typeValue.value }).then((data) => {
  129 + isExistDataManagerNameApi({
  130 + name: value,
  131 + type:
  132 + typeValue.value == ''
  133 + ? 'org.thingsboard.rule.engine.kafka.TbKafkaNode'
  134 + : typeValue.value,
  135 + }).then((data) => {
128 136 if (data == true) {
129   - reject('名称已存在');
  137 + createMessage.error('名称已存在');
  138 + resolve();
130 139 } else {
131 140 resolve();
132 141 }
... ... @@ -319,9 +328,16 @@ export const modeMqttForm: FormSchema[] = [
319 328 reject('请输入名称');
320 329 } else {
321 330 if (values.name != undefined) {
322   - isExistDataManagerNameApi({ name: value, type: typeValue.value }).then((data) => {
  331 + isExistDataManagerNameApi({
  332 + name: value,
  333 + type:
  334 + typeValue.value == ''
  335 + ? 'org.thingsboard.rule.engine.mqtt.TbMqttNode'
  336 + : typeValue.value,
  337 + }).then((data) => {
323 338 if (data == true) {
324   - reject('名称已存在');
  339 + createMessage.error('名称已存在');
  340 + resolve();
325 341 } else {
326 342 resolve();
327 343 }
... ... @@ -512,9 +528,16 @@ export const modeRabbitMqForm: FormSchema[] = [
512 528 reject('请输入名称');
513 529 } else {
514 530 if (values.name != undefined) {
515   - isExistDataManagerNameApi({ name: value, type: typeValue.value }).then((data) => {
  531 + isExistDataManagerNameApi({
  532 + name: value,
  533 + type:
  534 + typeValue.value == ''
  535 + ? 'org.thingsboard.rule.engine.rabbitmq.TbRabbitMqNode'
  536 + : typeValue.value,
  537 + }).then((data) => {
516 538 if (data == true) {
517   - reject('名称已存在');
  539 + createMessage.error('名称已存在');
  540 + resolve();
518 541 } else {
519 542 resolve();
520 543 }
... ... @@ -632,7 +655,7 @@ export const modeRabbitMqForm: FormSchema[] = [
632 655 },
633 656 {
634 657 field: 'connectionTimeout',
635   - label: 'Connection',
  658 + label: 'Connect',
636 659 colProps: { span: 12 },
637 660 component: 'InputNumber',
638 661 defaultValue: 60000,
... ... @@ -693,9 +716,16 @@ export const modeApiForm: FormSchema[] = [
693 716 reject('请输入名称');
694 717 } else {
695 718 if (values.name != undefined) {
696   - isExistDataManagerNameApi({ name: value, type: typeValue.value }).then((data) => {
  719 + isExistDataManagerNameApi({
  720 + name: value,
  721 + type:
  722 + typeValue.value == ''
  723 + ? 'org.thingsboard.rule.engine.rest.TbRestApiCallNode'
  724 + : typeValue.value,
  725 + }).then((data) => {
697 726 if (data == true) {
698   - reject('名称已存在');
  727 + createMessage.error('名称已存在');
  728 + resolve();
699 729 } else {
700 730 resolve();
701 731 }
... ...
... ... @@ -282,6 +282,9 @@
282 282 width: 45vw;
283 283 margin: 1vh 1vw;
284 284 position: relative;
  285 + :deep .ant-input-number {
  286 + width: 18.35vw !important;
  287 + }
285 288 :deep .ant-btn {
286 289 position: absolute;
287 290 right: 1vw;
... ...
... ... @@ -115,17 +115,18 @@
115 115 otherProperties: {},
116 116 });
117 117
118   - const [register, { validate, setFieldsValue, resetFields: defineClearFunc }] = useForm({
119   - labelWidth: 80,
120   - schemas: modeKafkaForm,
121   - actionColOptions: {
122   - span: 14,
123   - },
124   - resetButtonOptions: {
125   - text: '上一步',
126   - },
127   - resetFunc: customResetFunc,
128   - });
  118 + const [register, { validate, setFieldsValue, resetFields: defineClearFunc, clearValidate }] =
  119 + useForm({
  120 + labelWidth: 80,
  121 + schemas: modeKafkaForm,
  122 + actionColOptions: {
  123 + span: 14,
  124 + },
  125 + resetButtonOptions: {
  126 + text: '上一步',
  127 + },
  128 + resetFunc: customResetFunc,
  129 + });
129 130
130 131 const [
131 132 registerKeyAndValue,
... ... @@ -138,6 +139,11 @@
138 139 },
139 140 });
140 141
  142 + const clearValidateFunc = async () => {
  143 + console.log(1);
  144 + await clearValidate(['name']);
  145 + };
  146 +
141 147 const setStepTwoFieldsValueFunc = async (v, v1) => {
142 148 setFieldsValue(v);
143 149 vType.value = v1;
... ... @@ -199,6 +205,7 @@
199 205 }
200 206 };
201 207 return {
  208 + clearValidateFunc,
202 209 getSonValueFunc,
203 210 keyAndValueArr,
204 211 register,
... ... @@ -224,6 +231,9 @@
224 231 width: 45vw;
225 232 margin: 1vh 1vw;
226 233 position: relative;
  234 + :deep .ant-input-number {
  235 + width: 18.35vw !important;
  236 + }
227 237 }
228 238 }
229 239 </style>
... ...
... ... @@ -163,6 +163,9 @@
163 163 width: 45vw;
164 164 margin: 1vh 1vw;
165 165 position: relative;
  166 + :deep .ant-input-number {
  167 + width: 18.35vw !important;
  168 + }
166 169 :deep .ant-btn {
167 170 position: absolute;
168 171 right: 1vw;
... ...
... ... @@ -205,6 +205,9 @@
205 205 width: 44vw;
206 206 margin: 1vh 1vw;
207 207 position: relative;
  208 + :deep .ant-input-number {
  209 + width: 17.85vw !important;
  210 + }
208 211 :deep .ant-btn {
209 212 position: absolute;
210 213 right: 1vw;
... ...
... ... @@ -66,6 +66,16 @@
66 66 return e;
67 67 }
68 68 };
  69 + const clearSonValueValidateFunc = () => {
  70 + try {
  71 + proxy.$refs.refTransferConfigKafka?.clearValidateFunc();
  72 + // proxy.$refs.refTransferConfigMqtt?.customClearStepTwoValueFunc();
  73 + // proxy.$refs.refTransferConfigRabbitMq?.customClearStepTwoValueFunc();
  74 + // proxy.$refs.refTransferConfigApi?.customClearStepTwoValueFunc();
  75 + } catch (e) {
  76 + return e;
  77 + }
  78 + };
69 79 const getSonValueDataFunc = () => {
70 80 if (isWhereComp.value == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
71 81 getTransferConfigKafkaValue.value = proxy.$refs.refTransferConfigKafka.getSonValueFunc();
... ... @@ -102,6 +112,7 @@
102 112 }
103 113 };
104 114 return {
  115 + clearSonValueValidateFunc,
105 116 clearSonValueDataFunc,
106 117 editSonValueDataFunc,
107 118 refTransferConfigKafka,
... ...
... ... @@ -67,7 +67,7 @@
67 67 if (props.editTriggerFather != 1) {
68 68 setTimeout(() => {
69 69 setFieldsValue(props.editTriggerFather);
70   - }, 100);
  70 + }, 10);
71 71 }
72 72 };
73 73
... ...
... ... @@ -94,7 +94,7 @@
94 94 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger();
95 95 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition();
96 96 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction();
97   - }, 100);
  97 + }, 50);
98 98 } catch (e) {
99 99 return e;
100 100 }
... ...
1 1 <template>
2   - <div>
3   - <BasicDrawer
4   - v-bind="$attrs"
5   - @register="registerDrawer"
6   - showFooter
7   - :title="getTitle"
8   - width="1000px"
9   - @ok="handleSubmit"
10   - @close="handleCancel"
11   - >
  2 + <BasicDrawer
  3 + v-bind="$attrs"
  4 + @register="registerDrawer"
  5 + showFooter
  6 + :title="getTitle"
  7 + width="1000px"
  8 + @ok="handleSubmit"
  9 + >
  10 + <div>
  11 + <BasicForm @register="registerForm" />
  12 + <!-- 触发器 -->
12 13 <div>
13   - <BasicForm @register="registerForm" />
14   - <!-- 触发器 -->
15   - <div>
16   - <template
17   - v-for="(item, index) in isUpdate == false ? addTriggerPushData : editTriggerPushData"
18   - :key="index"
19   - >
20   - <span style="display: none">{{ item + index }}</span>
21   - <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器 {{ index + 1 }}</span>
22   - <div style="display: block">
23   - <AddTriggerForm
24   - :editTriggerFather="isUpdate == false ? 1 : item"
25   - :newFilterMapFather="isUpdate == false ? 1 : newFilterMap"
26   - :deviceInfo="getDeviceInfo"
27   - ref="refTriggerChild"
28   - />
29   - </div>
30   - <div style="height: 3vh"></div>
31   - </template>
32   - <div
33   - style="
34   - display: flex;
35   - width: 11vw;
36   - height: 4vh;
37   - flex-direction: row;
38   - justify-content: space-between;
39   - "
40   - >
41   - <div style="display: flex; width: 4vw; height: 4vh">
42   - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addTrigger"
43   - >新增触发器</Button
44   - >
45   - </div>
46   - <div style="display: flex; width: 4vw; height: 4vh">
47   - <Button
48   - v-if="addTriggerPushData.length != 0 || editTriggerPushData.length != 0"
49   - type="default"
50   - style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
51   - class="mt-5"
52   - @click="removeTrigger"
53   - >
54   - <span style="color: white">删除</span></Button
55   - >
56   - </div>
  14 + <template
  15 + v-for="(item, index) in isUpdate == false ? addTriggerPushData : editTriggerPushData"
  16 + :key="index"
  17 + >
  18 + <span style="display: none">{{ item + index }}</span>
  19 + <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器 {{ index + 1 }}</span>
  20 + <div style="display: block">
  21 + <AddTriggerForm
  22 + :editTriggerFather="isUpdate == false ? 1 : item"
  23 + :newFilterMapFather="isUpdate == false ? 1 : newFilterMap"
  24 + :deviceInfo="getDeviceInfo"
  25 + ref="refTriggerChild"
  26 + />
57 27 </div>
58   - </div>
59   - <div style="height: 5vh"></div>
60   - <!-- 执行条件 -->
61   - <div>
62   - <template
63   - v-for="(item, index) in isUpdate == false
64   - ? addConditionPushData
65   - : editConditionPushData"
66   - :key="index"
67   - >
68   - <span style="display: none">{{ item + index }}</span>
69   - <span style="position: relative; top: 3.2vh; left: 0.3vw"
70   - >执行条件 {{ index + 1 }}</span
  28 + <div style="height: 3vh"></div>
  29 + </template>
  30 + <div
  31 + style="
  32 + display: flex;
  33 + width: 11vw;
  34 + height: 4vh;
  35 + flex-direction: row;
  36 + justify-content: space-between;
  37 + "
  38 + >
  39 + <div style="display: flex; width: 4vw; height: 4vh">
  40 + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addTrigger"
  41 + >新增触发器</Button
  42 + >
  43 + </div>
  44 + <div style="display: flex; width: 4vw; height: 4vh">
  45 + <Button
  46 + v-if="addTriggerPushData.length != 0 || editTriggerPushData.length != 0"
  47 + type="default"
  48 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  49 + class="mt-5"
  50 + @click="removeTrigger"
  51 + >
  52 + <span style="color: white">删除</span></Button
71 53 >
72   -
73   - <div>
74   - <AddConditiForm
75   - :editConditionFather="isUpdate == false ? 1 : item"
76   - :newConditionMapFather="isUpdate == false ? 1 : newConditionFilterMap"
77   - :deviceInfo1="getDeviceInfo1"
78   - ref="refConditionChild"
79   - />
80   - </div>
81   - <div style="height: 3vh"></div>
82   - </template>
83   - <div
84   - style="
85   - display: flex;
86   - width: 11vw;
87   - height: 4vh;
88   - flex-direction: row;
89   - justify-content: space-between;
90   - "
91   - >
92   - <div style="display: flex; width: 4vw; height: 4vh">
93   - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition"
94   - >新增执行条件</Button
95   - >
96   - </div>
97   - <div style="display: flex; width: 4vw; height: 4vh">
98   - <Button
99   - v-if="addConditionPushData.length != 0 || editConditionPushData.length != 0"
100   - style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
101   - type="default"
102   - class="mt-5"
103   - @click="removeCondition"
104   - >
105   - <span style="color: white">删除</span></Button
106   - >
107   - </div>
108 54 </div>
109 55 </div>
110   - <!-- 执行动作 -->
111   - <div style="height: 5vh"></div>
112   - <div>
113   - <template
114   - v-for="(item, index) in isUpdate == false ? addActionPushData : editActionPushData"
115   - :key="index"
116   - >
117   - <span style="display: none">{{ item + index }}</span>
118   - <span style="position: relative; top: 4.2vh; left: 0.65vw"
119   - >执行动作 {{ index + 1 }}</span
  56 + </div>
  57 + <div style="height: 5vh"></div>
  58 + <!-- 执行条件 -->
  59 + <div>
  60 + <template
  61 + v-for="(item, index) in isUpdate == false ? addConditionPushData : editConditionPushData"
  62 + :key="index"
  63 + >
  64 + <span style="display: none">{{ item + index }}</span>
  65 + <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件 {{ index + 1 }}</span>
  66 +
  67 + <div>
  68 + <AddConditiForm
  69 + :editConditionFather="isUpdate == false ? 1 : item"
  70 + :newConditionMapFather="isUpdate == false ? 1 : newConditionFilterMap"
  71 + :deviceInfo1="getDeviceInfo1"
  72 + ref="refConditionChild"
  73 + />
  74 + </div>
  75 + <div style="height: 3vh"></div>
  76 + </template>
  77 + <div
  78 + style="
  79 + display: flex;
  80 + width: 11vw;
  81 + height: 4vh;
  82 + flex-direction: row;
  83 + justify-content: space-between;
  84 + "
  85 + >
  86 + <div style="display: flex; width: 4vw; height: 4vh">
  87 + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition"
  88 + >新增执行条件</Button
  89 + >
  90 + </div>
  91 + <div style="display: flex; width: 4vw; height: 4vh">
  92 + <Button
  93 + v-if="addConditionPushData.length != 0 || addConditionPushData.length != 0"
  94 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  95 + type="default"
  96 + class="mt-5"
  97 + @click="removeCondition"
120 98 >
  99 + <span style="color: white">删除</span></Button
  100 + >
  101 + </div>
  102 + </div>
  103 + </div>
  104 + <!-- 执行动作 -->
  105 + <div style="height: 5vh"></div>
  106 + <div>
  107 + <template
  108 + v-for="(item, index) in isUpdate == false ? addActionPushData : editActionPushData"
  109 + :key="index"
  110 + >
  111 + <span style="display: none">{{ item + index }}</span>
  112 + <span style="position: relative; top: 4.2vh; left: 0.65vw">执行动作 {{ index + 1 }}</span>
121 113
122   - <div>
123   - <AddActionForm
124   - :editActionFather="isUpdate == false ? 1 : item"
125   - :newActionMapFather="isUpdate == false ? 1 : newActionFilterMap"
126   - :deviceInfo2="getDeviceInfo2"
127   - ref="refActionChild"
128   - />
129   - </div>
130   - <div style="height: 3vh"></div>
131   - </template>
132   - <div
133   - style="
134   - display: flex;
135   - width: 11vw;
136   - height: 4vh;
137   - flex-direction: row;
138   - justify-content: space-between;
139   - "
140   - >
141   - <div style="display: flex; width: 4vw; height: 4vh">
142   - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction"
143   - >新增执行动作</Button
144   - >
145   - </div>
146   - <div style="display: flex; width: 4vw; height: 4vh">
147   - <Button
148   - v-if="addActionPushData.length != 0 || editActionPushData.length != 0"
149   - style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
150   - type="default"
151   - class="mt-5"
152   - @click="removeAction"
153   - >
154   - <span style="color: white">删除</span></Button
155   - >
156   - </div>
  114 + <div>
  115 + <AddActionForm
  116 + :editActionFather="isUpdate == false ? 1 : item"
  117 + :newActionMapFather="isUpdate == false ? 1 : newActionFilterMap"
  118 + :deviceInfo2="getDeviceInfo2"
  119 + ref="refActionChild"
  120 + />
  121 + </div>
  122 + <div style="height: 3vh"></div>
  123 + </template>
  124 + <div
  125 + style="
  126 + display: flex;
  127 + width: 11vw;
  128 + height: 4vh;
  129 + flex-direction: row;
  130 + justify-content: space-between;
  131 + "
  132 + >
  133 + <div style="display: flex; width: 4vw; height: 4vh">
  134 + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction"
  135 + >新增执行动作</Button
  136 + >
  137 + </div>
  138 + <div style="display: flex; width: 4vw; height: 4vh">
  139 + <Button
  140 + v-if="addActionPushData.length > 0 || addActionPushData.length > 0"
  141 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  142 + type="default"
  143 + class="mt-5"
  144 + @click="removeAction"
  145 + >
  146 + <span style="color: white">删除</span></Button
  147 + >
157 148 </div>
158   - <div style="height: 5vh"></div>
159 149 </div>
  150 + <div style="height: 5vh"></div>
160 151 </div>
161   - </BasicDrawer>
162   - </div>
  152 + </div>
  153 + </BasicDrawer>
163 154 </template>
164 155 <script lang="ts">
165 156 import { defineComponent, ref, computed, unref, reactive, getCurrentInstance, watch } from 'vue';
166 157 import { BasicForm, useForm } from '/@/components/Form';
167   - import { formSchema, getData, mockData } from './config';
  158 + import { formSchema, getData } from './config';
168 159 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
169 160 import {
170 161 screenLinkPageAddApi,
... ... @@ -263,31 +254,56 @@
263 254 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
264 255 await resetFields();
265 256 setDrawerProps({ confirmLoading: false });
266   - isUpdate.value = data?.isUpdate;
267   - if (isUpdate.value) {
  257 + isUpdate.value = !!data?.isUpdate;
  258 + if (!unref(isUpdate)) {
  259 + editTriggerPushData.value = [];
  260 + editTriggerPushData.value.length = 0;
  261 + addTriggerPushData.value = [];
  262 + addTriggerPushData.value.length = 0;
  263 + addConditionPushData.value = [];
  264 + addConditionPushData.value.length = 0;
  265 + addActionPushData.value = [];
  266 + addActionPushData.value.length = 0;
268 267 try {
269   - getId.value = mockData.id;
270   - getTenantId.value = mockData.tenantId;
271   - await setFieldsValue({
272   - ...data.record,
273   - });
274   - editTriggerPushData.value = mockData.triggers;
275   - editConditionPushData.value = mockData.doConditions;
276   - editActionPushData.value = mockData.doActions;
277   - // editTriggerPushData.value.forEach((f) => {
278   - // if (f?.id.length == 18) {
279   - // editTriggerPushData.value.pop();
280   - // if (editTriggerPushData.value.length) {
281   - // editTriggerPushData.value.length = editTriggerPushData.value.length;
282   - // }
283   - // }
284   - // });
285   -
286   - const options = await screenLinkPageByDeptIdGetDevice({
287   - organizationId: mockData.organizationId,
288   - });
289   -
290   - mockData.triggers.forEach((f1) => {
  268 + setTimeout(() => {
  269 + proxy.$refs.refTriggerChild.resetFieldsValueFunc();
  270 + proxy.$refs.refConditionChild.resetFieldsValueFunc();
  271 + proxy.$refs.refActionChild.resetFieldsValueFunc();
  272 + }, 50);
  273 + } catch (e) {
  274 + return e;
  275 + }
  276 + } else {
  277 + newFilterMap.value = [];
  278 + newConditionFilterMap.value = [];
  279 + newActionFilterMap.value = [];
  280 + clearAllArrayFunc();
  281 + editTriggerPushData.value = [];
  282 + editTriggerPushData.value.length = 0;
  283 + editConditionPushData.value = [];
  284 + editActionPushData.value = [];
  285 + lastEditRefTriggerChildDataArray.value = [];
  286 + getId.value = data.record.id;
  287 + getTenantId.value = data.record.tenantId;
  288 + await setFieldsValue({
  289 + ...data.record,
  290 + });
  291 + editTriggerPushData.value = data.record.triggers;
  292 + editTriggerPushData.value.forEach((f) => {
  293 + if (f?.id.length == 18) {
  294 + editTriggerPushData.value.pop();
  295 + if (editTriggerPushData.value.length) {
  296 + editTriggerPushData.value.length = editTriggerPushData.value.length;
  297 + }
  298 + }
  299 + });
  300 + editConditionPushData.value = data.record.doConditions;
  301 + editActionPushData.value = data.record.doActions;
  302 + const options = await screenLinkPageByDeptIdGetDevice({
  303 + organizationId: data.record.organizationId,
  304 + });
  305 + try {
  306 + data.record.triggers.forEach((f1) => {
291 307 options.items?.forEach((f2) => {
292 308 if (f2.id == f1.deviceId) {
293 309 newFilterMap.value.push({
... ... @@ -298,7 +314,7 @@
298 314 });
299 315 });
300 316
301   - mockData.doConditions.forEach((f1) => {
  317 + data.record.doConditions.forEach((f1) => {
302 318 options.items?.forEach((f2) => {
303 319 if (f2.id == f1.deviceId) {
304 320 newConditionFilterMap.value.push({
... ... @@ -308,7 +324,7 @@
308 324 }
309 325 });
310 326 });
311   - mockData.doActions.forEach((f1) => {
  327 + data.record.doActions.forEach((f1) => {
312 328 options.items?.forEach((f2) => {
313 329 if (f2.id == f1.deviceId) {
314 330 newActionFilterMap.value.push({
... ... @@ -318,41 +334,34 @@
318 334 }
319 335 });
320 336 });
321   - } catch (e) {
322   - return e;
323   - }
  337 + } catch (e) {}
324 338 }
325 339 });
326   - const getTitle = computed(() => (isUpdate.value == false ? '新增场景联动' : '编辑场景联动'));
  340 + const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
327 341
328   - const clearPushArrayFunc = () => {
  342 + const clearAllArrayFunc = () => {
  343 + unref(addTriggerPushData).length = 0;
  344 + unref(addConditionPushData).length = 0;
  345 + unref(addActionPushData).length = 0;
  346 + lastRefTriggerChildDataArray.value.length = 0;
  347 + lastRefConditionChildDataArray.value.length = 0;
  348 + lastRefActionChildDataArray.value.length = 0;
  349 + lastEditRefTriggerChildDataArray.value.length = 0;
  350 + };
  351 + const resetActionsAllArrayFunc = () => {
329 352 try {
330   - proxy.$refs.refConditionChild.resetFieldsValueFunc();
331 353 proxy.$refs.refActionChild.resetFieldsValueFunc();
332   - proxy.$refs.refActionChild.resetFieldsValueFunc();
333   - proxy.$refs.refActionChild.clearSelectDevice();
334   - newFilterMap.value.length = 0;
335   - newConditionFilterMap.value.length = 0;
336   - newActionFilterMap.value.length = 0;
337   - editTriggerPushData.value.length = 0;
338   - editConditionPushData.value.length = 0;
339   - editActionPushData.value.length = 0;
340   - lastEditRefTriggerChildDataArray.value.length = 0;
341   - addTriggerPushData.value.length = 0;
342   - addConditionPushData.value.length = 0;
343   - addActionPushData.value.length = 0;
344   - lastRefTriggerChildDataArray.value.length = 0;
345   - lastRefConditionChildDataArray.value.length = 0;
346   - lastRefActionChildDataArray.value.length = 0;
347   - lastEditRefTriggerChildDataArray.value.length = 0;
348 354 } catch (e) {
349 355 return e;
350 356 }
351 357 };
352   - const handleCancel = () => {
353   - clearPushArrayFunc();
  358 + const clearActionsAllDevice = () => {
  359 + try {
  360 + proxy.$refs.refActionChild.clearSelectDevice();
  361 + } catch (e) {
  362 + return e;
  363 + }
354 364 };
355   -
356 365 watch(getData, (newV) => {
357 366 getDeviceInfo.value = newV;
358 367 getDeviceInfo1.value = newV;
... ... @@ -385,7 +394,7 @@
385 394 };
386 395
387 396 const getDefaultValue = () => {
388   - if (!isUpdate.value) {
  397 + if (!unref(isUpdate)) {
389 398 delete getAllFormData.id;
390 399 delete getAllFormData.getTenantId;
391 400 refTriggerChildDataFunc();
... ... @@ -431,7 +440,7 @@
431 440 };
432 441
433 442 const handleSubmit = async () => {
434   - if (!isUpdate.value) {
  443 + if (!unref(isUpdate)) {
435 444 getDefaultValue();
436 445 getValuesFormData = await validateFields();
437 446 if (!getValuesFormData) return;
... ... @@ -439,7 +448,6 @@
439 448 await screenLinkPageAddApi(getAllFormData);
440 449 createMessage.success('场景联动新增成功');
441 450 closeDrawer();
442   - handleCancel();
443 451 emit('success');
444 452 } else {
445 453 getDefaultValue();
... ... @@ -455,12 +463,15 @@
455 463 };
456 464 const defaultAddTrigger = () => {
457 465 if (unref(addTriggerPushData).length == 0) {
458   - addTrigger();
  466 + setTimeout(() => {
  467 + addTrigger();
  468 + }, 10);
459 469 }
460 470 };
  471 +
461 472 //新增触发器
462 473 const addTrigger = () => {
463   - if (isUpdate.value == false) {
  474 + if (!unref(isUpdate)) {
464 475 unref(addTriggerPushData).push(addTriggerData as never);
465 476 refTriggerChildDataFunc();
466 477 lastRefTriggerChildData.value = refTriggerChildData.value;
... ... @@ -473,7 +484,7 @@
473 484 }
474 485 };
475 486 const removeTrigger = () => {
476   - if (!isUpdate.value) {
  487 + if (!unref(isUpdate)) {
477 488 try {
478 489 unref(addTriggerPushData).splice(0, 1);
479 490 lastRefTriggerChildDataArray.value.splice(0, 1);
... ... @@ -489,29 +500,28 @@
489 500 }
490 501 }
491 502 };
492   - //默认新增执行动作
493   - const defaultAddAction = () => {
494   - if (unref(addActionPushData).length == 0) {
495   - addAction();
496   - }
497   - };
498 503
499 504 //新增执行条件
500 505 const addCondition = () => {
501   - if (!isUpdate.value) {
  506 + if (!unref(isUpdate)) {
502 507 unref(addConditionPushData).push(addConditionData as never);
503 508 refConditionChildDataFunc();
504 509 lastRefConditionChildData.value = refConditionChildData.value;
505 510 lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
506 511 } else {
507 512 unref(editConditionPushData).push(addConditionData as never);
  513 + console.log(unref(editConditionPushData));
508 514 refConditionChildDataFunc();
509 515 lastRefConditionChildData.value = refConditionChildData.value;
510 516 lastEditRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
511 517 }
  518 + // unref(addConditionPushData).push(addConditionData as never);
  519 + // refConditionChildDataFunc();
  520 + // lastRefConditionChildData.value = refConditionChildData.value;
  521 + // lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
512 522 };
513 523 const removeCondition = () => {
514   - if (!isUpdate.value) {
  524 + if (!unref(isUpdate)) {
515 525 try {
516 526 unref(addConditionPushData).splice(0, 1);
517 527 lastRefConditionChildDataArray.value.splice(0, 1);
... ... @@ -528,13 +538,20 @@
528 538 }
529 539 };
530 540
  541 + //新增执行动作
  542 + const defaultAddAction = () => {
  543 + if (unref(addActionPushData).length == 0) {
  544 + addAction();
  545 + }
  546 + };
  547 +
531 548 const defaultAddCondition = () => {
532 549 if (unref(addConditionPushData).length == 0) {
533 550 addCondition();
534 551 }
535 552 };
536 553 const addAction = () => {
537   - if (!isUpdate.value) {
  554 + if (!unref(isUpdate)) {
538 555 unref(addActionPushData).push(addActionData as never);
539 556 refActionChildDataFunc();
540 557 lastRefActionChildData.value = refActionChildData.value;
... ... @@ -545,9 +562,13 @@
545 562 lastRefActionChildData.value = refActionChildData.value;
546 563 lastEditRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
547 564 }
  565 + // unref(addActionPushData).push(addActionData as never);
  566 + // refActionChildDataFunc();
  567 + // lastRefActionChildData.value = refActionChildData.value;
  568 + // lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
548 569 };
549 570 const removeAction = () => {
550   - if (!isUpdate.value) {
  571 + if (!unref(isUpdate)) {
551 572 try {
552 573 unref(addActionPushData).splice(0, 1);
553 574 lastRefActionChildDataArray.value.splice(0, 1);
... ... @@ -565,7 +586,6 @@
565 586 };
566 587
567 588 return {
568   - handleCancel,
569 589 defaultAddTrigger,
570 590 defaultAddCondition,
571 591 newFilterMap,
... ... @@ -575,9 +595,11 @@
575 595 editConditionPushData,
576 596 editActionPushData,
577 597 isUpdate,
  598 + clearActionsAllDevice,
578 599 getDeviceInfo,
579 600 getDeviceInfo1,
580 601 getDeviceInfo2,
  602 + resetActionsAllArrayFunc,
581 603 addActionPushData,
582 604 defaultAddAction,
583 605 refActionChild,
... ... @@ -587,6 +609,7 @@
587 609 refConditionChild,
588 610 addCondition,
589 611 removeCondition,
  612 + clearAllArrayFunc,
590 613 removeTrigger,
591 614 addTriggerPushData,
592 615 addTriggerData,
... ...
... ... @@ -7,6 +7,7 @@ export const formSchema: FormSchema[] = [
7 7 field: 'type',
8 8 label: '类型',
9 9 component: 'Select',
  10 + defaultValue: '默认',
10 11 colProps: { span: 24 },
11 12 componentProps: {
12 13 placeholder: '请选择类型',
... ...
... ... @@ -7,7 +7,9 @@
7 7 >
8 8 <template #toolbar>
9 9 <a-button type="primary" @click="handleAdd"> 新增租户配置 </a-button>
10   - <a-button color="error" @click="handleMutilteDelete"> 批量删除 </a-button>
  10 + <a-button color="error" :disabled="disabled" @click="handleMutilteDelete">
  11 + 批量删除
  12 + </a-button>
11 13 </template>
12 14 <template #action="{ record }">
13 15 <TableAction
... ... @@ -38,7 +40,7 @@
38 40 </div>
39 41 </template>
40 42 <script lang="ts">
41   - import { defineComponent, reactive } from 'vue';
  43 + import { defineComponent, reactive, ref } from 'vue';
42 44 import { BasicTable, useTable, TableAction } from '/@/components/Table';
43 45 import { useDrawer } from '/@/components/Drawer';
44 46 import TenantSettingDrawer from './useDrawer.vue';
... ... @@ -50,6 +52,7 @@
50 52 name: 'Index',
51 53 components: { BasicTable, TenantSettingDrawer, TableAction },
52 54 setup() {
  55 + const disabled = ref(true);
53 56 let echoEditData = reactive({});
54 57 let selectedRowKeys: Array<string> = [];
55 58 const [registerDrawer, { openDrawer }] = useDrawer();
... ... @@ -97,6 +100,11 @@
97 100 }
98 101 const useSelectionChange = () => {
99 102 selectedRowKeys = getSelectRowKeys();
  103 + if (selectedRowKeys.length !== 0) {
  104 + disabled.value = false;
  105 + } else {
  106 + disabled.value = true;
  107 + }
100 108 };
101 109 const handleMutilteDelete = async () => {
102 110 await deleteTenantProfileApi(selectedRowKeys);
... ... @@ -107,6 +115,7 @@
107 115 reload();
108 116 }
109 117 return {
  118 + disabled,
110 119 echoEditData,
111 120 registerTable,
112 121 registerDrawer,
... ...