Commit fb67b8ce51aae1274ab1badcdef4f35571f94609

Authored by xp.Huang
2 parents f102e732 572e045c

Merge branch 'ft-dev' into 'main'

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

See merge request huang/yun-teng-iot-front!124
@@ -6,15 +6,16 @@ import { @@ -6,15 +6,16 @@ import {
6 } from './model/dataManagerModel'; 6 } from './model/dataManagerModel';
7 7
8 enum DataManagerApi { 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 DATA_MANAGER_CONVERT_GET = '/convert', 13 DATA_MANAGER_CONVERT_GET = '/convert',
14 } 14 }
15 15
16 // 转换配置分页查询 16 // 转换配置分页查询
17 export const getConvertApi = (params: TDataManagerModelQuery) => { 17 export const getConvertApi = (params: TDataManagerModelQuery) => {
  18 + params.nodeType = 1;
18 return defHttp.get<TDataManagerModelQuery>({ 19 return defHttp.get<TDataManagerModelQuery>({
19 url: DataManagerApi.DATA_MANAGER_CONVERT_GET, 20 url: DataManagerApi.DATA_MANAGER_CONVERT_GET,
20 params, 21 params,
@@ -49,6 +50,7 @@ export const isExistDataManagerNameApi = (check: {}) => { @@ -49,6 +50,7 @@ export const isExistDataManagerNameApi = (check: {}) => {
49 50
50 // 启用或者禁用配置 51 // 启用或者禁用配置
51 export const isEnableOrDisableApi = (params: IEnableOrDisableModel) => { 52 export const isEnableOrDisableApi = (params: IEnableOrDisableModel) => {
  53 + params.nodeType = 1;
52 return defHttp.post<IEnableOrDisableModel>({ 54 return defHttp.post<IEnableOrDisableModel>({
53 url: DataManagerApi.DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED, 55 url: DataManagerApi.DATA_MANAGER_CONVERT_POST_ENABLE_OR_DISABLED,
54 params, 56 params,
@@ -5,6 +5,7 @@ export type TDataManagerModelQuery = BasicPageParams & TDataManagerParam; @@ -5,6 +5,7 @@ export type TDataManagerModelQuery = BasicPageParams & TDataManagerParam;
5 export type TDataManagerParam = { 5 export type TDataManagerParam = {
6 name?: string; 6 name?: string;
7 status?: string; 7 status?: string;
  8 + nodeType?: number;
8 }; 9 };
9 10
10 export interface IDataManagerModel { 11 export interface IDataManagerModel {
@@ -31,4 +32,5 @@ export interface IDataManagerModel { @@ -31,4 +32,5 @@ export interface IDataManagerModel {
31 export interface IEnableOrDisableModel { 32 export interface IEnableOrDisableModel {
32 convertIds?: [string]; 33 convertIds?: [string];
33 status?: number; 34 status?: number;
  35 + nodeType?: number;
34 } 36 }
@@ -147,6 +147,9 @@ @@ -147,6 +147,9 @@
147 } 147 }
148 }; 148 };
149 const addOrEditFunc = async () => { 149 const addOrEditFunc = async () => {
  150 + if (!unref(isUpdate)) {
  151 + proxy.$refs.refTransferConfigParams.clearSonValueValidateFunc();
  152 + }
150 getModeSonFormValue.value = await proxy.$refs.refTransferConfigMode.getSonValueFunc(); 153 getModeSonFormValue.value = await proxy.$refs.refTransferConfigMode.getSonValueFunc();
151 getSonFormValue.value = await proxy.$refs.refTransferConfigParams.getSonValueDataFunc(); 154 getSonFormValue.value = await proxy.$refs.refTransferConfigParams.getSonValueDataFunc();
152 if (getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') { 155 if (getModeSonFormValue.value?.type == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
@@ -2,6 +2,8 @@ import { FormSchema } from '/@/components/Form'; @@ -2,6 +2,8 @@ import { FormSchema } from '/@/components/Form';
2 import { findDictItemByCode } from '/@/api/system/dict'; 2 import { findDictItemByCode } from '/@/api/system/dict';
3 import { isExistDataManagerNameApi } from '/@/api/datamanager/dataManagerApi'; 3 import { isExistDataManagerNameApi } from '/@/api/datamanager/dataManagerApi';
4 import { ref } from 'vue'; 4 import { ref } from 'vue';
  5 +import { useMessage } from '/@/hooks/web/useMessage';
  6 +const { createMessage } = useMessage();
5 7
6 const typeValue = ref(''); 8 const typeValue = ref('');
7 9
@@ -124,9 +126,16 @@ export const modeKafkaForm: FormSchema[] = [ @@ -124,9 +126,16 @@ export const modeKafkaForm: FormSchema[] = [
124 reject('请输入名称'); 126 reject('请输入名称');
125 } else { 127 } else {
126 if (values.name != undefined) { 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 if (data == true) { 136 if (data == true) {
129 - reject('名称已存在'); 137 + createMessage.error('名称已存在');
  138 + resolve();
130 } else { 139 } else {
131 resolve(); 140 resolve();
132 } 141 }
@@ -319,9 +328,16 @@ export const modeMqttForm: FormSchema[] = [ @@ -319,9 +328,16 @@ export const modeMqttForm: FormSchema[] = [
319 reject('请输入名称'); 328 reject('请输入名称');
320 } else { 329 } else {
321 if (values.name != undefined) { 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 if (data == true) { 338 if (data == true) {
324 - reject('名称已存在'); 339 + createMessage.error('名称已存在');
  340 + resolve();
325 } else { 341 } else {
326 resolve(); 342 resolve();
327 } 343 }
@@ -512,9 +528,16 @@ export const modeRabbitMqForm: FormSchema[] = [ @@ -512,9 +528,16 @@ export const modeRabbitMqForm: FormSchema[] = [
512 reject('请输入名称'); 528 reject('请输入名称');
513 } else { 529 } else {
514 if (values.name != undefined) { 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 if (data == true) { 538 if (data == true) {
517 - reject('名称已存在'); 539 + createMessage.error('名称已存在');
  540 + resolve();
518 } else { 541 } else {
519 resolve(); 542 resolve();
520 } 543 }
@@ -632,7 +655,7 @@ export const modeRabbitMqForm: FormSchema[] = [ @@ -632,7 +655,7 @@ export const modeRabbitMqForm: FormSchema[] = [
632 }, 655 },
633 { 656 {
634 field: 'connectionTimeout', 657 field: 'connectionTimeout',
635 - label: 'Connection', 658 + label: 'Connect',
636 colProps: { span: 12 }, 659 colProps: { span: 12 },
637 component: 'InputNumber', 660 component: 'InputNumber',
638 defaultValue: 60000, 661 defaultValue: 60000,
@@ -693,9 +716,16 @@ export const modeApiForm: FormSchema[] = [ @@ -693,9 +716,16 @@ export const modeApiForm: FormSchema[] = [
693 reject('请输入名称'); 716 reject('请输入名称');
694 } else { 717 } else {
695 if (values.name != undefined) { 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 if (data == true) { 726 if (data == true) {
698 - reject('名称已存在'); 727 + createMessage.error('名称已存在');
  728 + resolve();
699 } else { 729 } else {
700 resolve(); 730 resolve();
701 } 731 }
@@ -282,6 +282,9 @@ @@ -282,6 +282,9 @@
282 width: 45vw; 282 width: 45vw;
283 margin: 1vh 1vw; 283 margin: 1vh 1vw;
284 position: relative; 284 position: relative;
  285 + :deep .ant-input-number {
  286 + width: 18.35vw !important;
  287 + }
285 :deep .ant-btn { 288 :deep .ant-btn {
286 position: absolute; 289 position: absolute;
287 right: 1vw; 290 right: 1vw;
@@ -115,17 +115,18 @@ @@ -115,17 +115,18 @@
115 otherProperties: {}, 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 const [ 131 const [
131 registerKeyAndValue, 132 registerKeyAndValue,
@@ -138,6 +139,11 @@ @@ -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 const setStepTwoFieldsValueFunc = async (v, v1) => { 147 const setStepTwoFieldsValueFunc = async (v, v1) => {
142 setFieldsValue(v); 148 setFieldsValue(v);
143 vType.value = v1; 149 vType.value = v1;
@@ -199,6 +205,7 @@ @@ -199,6 +205,7 @@
199 } 205 }
200 }; 206 };
201 return { 207 return {
  208 + clearValidateFunc,
202 getSonValueFunc, 209 getSonValueFunc,
203 keyAndValueArr, 210 keyAndValueArr,
204 register, 211 register,
@@ -224,6 +231,9 @@ @@ -224,6 +231,9 @@
224 width: 45vw; 231 width: 45vw;
225 margin: 1vh 1vw; 232 margin: 1vh 1vw;
226 position: relative; 233 position: relative;
  234 + :deep .ant-input-number {
  235 + width: 18.35vw !important;
  236 + }
227 } 237 }
228 } 238 }
229 </style> 239 </style>
@@ -163,6 +163,9 @@ @@ -163,6 +163,9 @@
163 width: 45vw; 163 width: 45vw;
164 margin: 1vh 1vw; 164 margin: 1vh 1vw;
165 position: relative; 165 position: relative;
  166 + :deep .ant-input-number {
  167 + width: 18.35vw !important;
  168 + }
166 :deep .ant-btn { 169 :deep .ant-btn {
167 position: absolute; 170 position: absolute;
168 right: 1vw; 171 right: 1vw;
@@ -205,6 +205,9 @@ @@ -205,6 +205,9 @@
205 width: 44vw; 205 width: 44vw;
206 margin: 1vh 1vw; 206 margin: 1vh 1vw;
207 position: relative; 207 position: relative;
  208 + :deep .ant-input-number {
  209 + width: 17.85vw !important;
  210 + }
208 :deep .ant-btn { 211 :deep .ant-btn {
209 position: absolute; 212 position: absolute;
210 right: 1vw; 213 right: 1vw;
@@ -66,6 +66,16 @@ @@ -66,6 +66,16 @@
66 return e; 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 const getSonValueDataFunc = () => { 79 const getSonValueDataFunc = () => {
70 if (isWhereComp.value == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') { 80 if (isWhereComp.value == 'org.thingsboard.rule.engine.kafka.TbKafkaNode') {
71 getTransferConfigKafkaValue.value = proxy.$refs.refTransferConfigKafka.getSonValueFunc(); 81 getTransferConfigKafkaValue.value = proxy.$refs.refTransferConfigKafka.getSonValueFunc();
@@ -102,6 +112,7 @@ @@ -102,6 +112,7 @@
102 } 112 }
103 }; 113 };
104 return { 114 return {
  115 + clearSonValueValidateFunc,
105 clearSonValueDataFunc, 116 clearSonValueDataFunc,
106 editSonValueDataFunc, 117 editSonValueDataFunc,
107 refTransferConfigKafka, 118 refTransferConfigKafka,
@@ -67,7 +67,7 @@ @@ -67,7 +67,7 @@
67 if (props.editTriggerFather != 1) { 67 if (props.editTriggerFather != 1) {
68 setTimeout(() => { 68 setTimeout(() => {
69 setFieldsValue(props.editTriggerFather); 69 setFieldsValue(props.editTriggerFather);
70 - }, 100); 70 + }, 10);
71 } 71 }
72 }; 72 };
73 73
@@ -94,7 +94,7 @@ @@ -94,7 +94,7 @@
94 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger(); 94 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddTrigger();
95 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition(); 95 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddCondition();
96 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction(); 96 proxy.$refs.sceneLinkAgeDrawerRef.defaultAddAction();
97 - }, 100); 97 + }, 50);
98 } catch (e) { 98 } catch (e) {
99 return e; 99 return e;
100 } 100 }
1 <template> 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 <div> 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 </div> 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 </div> 54 </div>
109 </div> 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 </div> 148 </div>
158 - <div style="height: 5vh"></div>  
159 </div> 149 </div>
  150 + <div style="height: 5vh"></div>
160 </div> 151 </div>
161 - </BasicDrawer>  
162 - </div> 152 + </div>
  153 + </BasicDrawer>
163 </template> 154 </template>
164 <script lang="ts"> 155 <script lang="ts">
165 import { defineComponent, ref, computed, unref, reactive, getCurrentInstance, watch } from 'vue'; 156 import { defineComponent, ref, computed, unref, reactive, getCurrentInstance, watch } from 'vue';
166 import { BasicForm, useForm } from '/@/components/Form'; 157 import { BasicForm, useForm } from '/@/components/Form';
167 - import { formSchema, getData, mockData } from './config'; 158 + import { formSchema, getData } from './config';
168 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 159 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
169 import { 160 import {
170 screenLinkPageAddApi, 161 screenLinkPageAddApi,
@@ -263,31 +254,56 @@ @@ -263,31 +254,56 @@
263 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { 254 const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => {
264 await resetFields(); 255 await resetFields();
265 setDrawerProps({ confirmLoading: false }); 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 try { 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 options.items?.forEach((f2) => { 307 options.items?.forEach((f2) => {
292 if (f2.id == f1.deviceId) { 308 if (f2.id == f1.deviceId) {
293 newFilterMap.value.push({ 309 newFilterMap.value.push({
@@ -298,7 +314,7 @@ @@ -298,7 +314,7 @@
298 }); 314 });
299 }); 315 });
300 316
301 - mockData.doConditions.forEach((f1) => { 317 + data.record.doConditions.forEach((f1) => {
302 options.items?.forEach((f2) => { 318 options.items?.forEach((f2) => {
303 if (f2.id == f1.deviceId) { 319 if (f2.id == f1.deviceId) {
304 newConditionFilterMap.value.push({ 320 newConditionFilterMap.value.push({
@@ -308,7 +324,7 @@ @@ -308,7 +324,7 @@
308 } 324 }
309 }); 325 });
310 }); 326 });
311 - mockData.doActions.forEach((f1) => { 327 + data.record.doActions.forEach((f1) => {
312 options.items?.forEach((f2) => { 328 options.items?.forEach((f2) => {
313 if (f2.id == f1.deviceId) { 329 if (f2.id == f1.deviceId) {
314 newActionFilterMap.value.push({ 330 newActionFilterMap.value.push({
@@ -318,41 +334,34 @@ @@ -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 try { 352 try {
330 - proxy.$refs.refConditionChild.resetFieldsValueFunc();  
331 proxy.$refs.refActionChild.resetFieldsValueFunc(); 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 } catch (e) { 354 } catch (e) {
349 return e; 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 watch(getData, (newV) => { 365 watch(getData, (newV) => {
357 getDeviceInfo.value = newV; 366 getDeviceInfo.value = newV;
358 getDeviceInfo1.value = newV; 367 getDeviceInfo1.value = newV;
@@ -385,7 +394,7 @@ @@ -385,7 +394,7 @@
385 }; 394 };
386 395
387 const getDefaultValue = () => { 396 const getDefaultValue = () => {
388 - if (!isUpdate.value) { 397 + if (!unref(isUpdate)) {
389 delete getAllFormData.id; 398 delete getAllFormData.id;
390 delete getAllFormData.getTenantId; 399 delete getAllFormData.getTenantId;
391 refTriggerChildDataFunc(); 400 refTriggerChildDataFunc();
@@ -431,7 +440,7 @@ @@ -431,7 +440,7 @@
431 }; 440 };
432 441
433 const handleSubmit = async () => { 442 const handleSubmit = async () => {
434 - if (!isUpdate.value) { 443 + if (!unref(isUpdate)) {
435 getDefaultValue(); 444 getDefaultValue();
436 getValuesFormData = await validateFields(); 445 getValuesFormData = await validateFields();
437 if (!getValuesFormData) return; 446 if (!getValuesFormData) return;
@@ -439,7 +448,6 @@ @@ -439,7 +448,6 @@
439 await screenLinkPageAddApi(getAllFormData); 448 await screenLinkPageAddApi(getAllFormData);
440 createMessage.success('场景联动新增成功'); 449 createMessage.success('场景联动新增成功');
441 closeDrawer(); 450 closeDrawer();
442 - handleCancel();  
443 emit('success'); 451 emit('success');
444 } else { 452 } else {
445 getDefaultValue(); 453 getDefaultValue();
@@ -455,12 +463,15 @@ @@ -455,12 +463,15 @@
455 }; 463 };
456 const defaultAddTrigger = () => { 464 const defaultAddTrigger = () => {
457 if (unref(addTriggerPushData).length == 0) { 465 if (unref(addTriggerPushData).length == 0) {
458 - addTrigger(); 466 + setTimeout(() => {
  467 + addTrigger();
  468 + }, 10);
459 } 469 }
460 }; 470 };
  471 +
461 //新增触发器 472 //新增触发器
462 const addTrigger = () => { 473 const addTrigger = () => {
463 - if (isUpdate.value == false) { 474 + if (!unref(isUpdate)) {
464 unref(addTriggerPushData).push(addTriggerData as never); 475 unref(addTriggerPushData).push(addTriggerData as never);
465 refTriggerChildDataFunc(); 476 refTriggerChildDataFunc();
466 lastRefTriggerChildData.value = refTriggerChildData.value; 477 lastRefTriggerChildData.value = refTriggerChildData.value;
@@ -473,7 +484,7 @@ @@ -473,7 +484,7 @@
473 } 484 }
474 }; 485 };
475 const removeTrigger = () => { 486 const removeTrigger = () => {
476 - if (!isUpdate.value) { 487 + if (!unref(isUpdate)) {
477 try { 488 try {
478 unref(addTriggerPushData).splice(0, 1); 489 unref(addTriggerPushData).splice(0, 1);
479 lastRefTriggerChildDataArray.value.splice(0, 1); 490 lastRefTriggerChildDataArray.value.splice(0, 1);
@@ -489,29 +500,28 @@ @@ -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 const addCondition = () => { 505 const addCondition = () => {
501 - if (!isUpdate.value) { 506 + if (!unref(isUpdate)) {
502 unref(addConditionPushData).push(addConditionData as never); 507 unref(addConditionPushData).push(addConditionData as never);
503 refConditionChildDataFunc(); 508 refConditionChildDataFunc();
504 lastRefConditionChildData.value = refConditionChildData.value; 509 lastRefConditionChildData.value = refConditionChildData.value;
505 lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never); 510 lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
506 } else { 511 } else {
507 unref(editConditionPushData).push(addConditionData as never); 512 unref(editConditionPushData).push(addConditionData as never);
  513 + console.log(unref(editConditionPushData));
508 refConditionChildDataFunc(); 514 refConditionChildDataFunc();
509 lastRefConditionChildData.value = refConditionChildData.value; 515 lastRefConditionChildData.value = refConditionChildData.value;
510 lastEditRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never); 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 const removeCondition = () => { 523 const removeCondition = () => {
514 - if (!isUpdate.value) { 524 + if (!unref(isUpdate)) {
515 try { 525 try {
516 unref(addConditionPushData).splice(0, 1); 526 unref(addConditionPushData).splice(0, 1);
517 lastRefConditionChildDataArray.value.splice(0, 1); 527 lastRefConditionChildDataArray.value.splice(0, 1);
@@ -528,13 +538,20 @@ @@ -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 const defaultAddCondition = () => { 548 const defaultAddCondition = () => {
532 if (unref(addConditionPushData).length == 0) { 549 if (unref(addConditionPushData).length == 0) {
533 addCondition(); 550 addCondition();
534 } 551 }
535 }; 552 };
536 const addAction = () => { 553 const addAction = () => {
537 - if (!isUpdate.value) { 554 + if (!unref(isUpdate)) {
538 unref(addActionPushData).push(addActionData as never); 555 unref(addActionPushData).push(addActionData as never);
539 refActionChildDataFunc(); 556 refActionChildDataFunc();
540 lastRefActionChildData.value = refActionChildData.value; 557 lastRefActionChildData.value = refActionChildData.value;
@@ -545,9 +562,13 @@ @@ -545,9 +562,13 @@
545 lastRefActionChildData.value = refActionChildData.value; 562 lastRefActionChildData.value = refActionChildData.value;
546 lastEditRefActionChildDataArray.value.push(lastRefActionChildData.value as never); 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 const removeAction = () => { 570 const removeAction = () => {
550 - if (!isUpdate.value) { 571 + if (!unref(isUpdate)) {
551 try { 572 try {
552 unref(addActionPushData).splice(0, 1); 573 unref(addActionPushData).splice(0, 1);
553 lastRefActionChildDataArray.value.splice(0, 1); 574 lastRefActionChildDataArray.value.splice(0, 1);
@@ -565,7 +586,6 @@ @@ -565,7 +586,6 @@
565 }; 586 };
566 587
567 return { 588 return {
568 - handleCancel,  
569 defaultAddTrigger, 589 defaultAddTrigger,
570 defaultAddCondition, 590 defaultAddCondition,
571 newFilterMap, 591 newFilterMap,
@@ -575,9 +595,11 @@ @@ -575,9 +595,11 @@
575 editConditionPushData, 595 editConditionPushData,
576 editActionPushData, 596 editActionPushData,
577 isUpdate, 597 isUpdate,
  598 + clearActionsAllDevice,
578 getDeviceInfo, 599 getDeviceInfo,
579 getDeviceInfo1, 600 getDeviceInfo1,
580 getDeviceInfo2, 601 getDeviceInfo2,
  602 + resetActionsAllArrayFunc,
581 addActionPushData, 603 addActionPushData,
582 defaultAddAction, 604 defaultAddAction,
583 refActionChild, 605 refActionChild,
@@ -587,6 +609,7 @@ @@ -587,6 +609,7 @@
587 refConditionChild, 609 refConditionChild,
588 addCondition, 610 addCondition,
589 removeCondition, 611 removeCondition,
  612 + clearAllArrayFunc,
590 removeTrigger, 613 removeTrigger,
591 addTriggerPushData, 614 addTriggerPushData,
592 addTriggerData, 615 addTriggerData,
@@ -7,6 +7,7 @@ export const formSchema: FormSchema[] = [ @@ -7,6 +7,7 @@ export const formSchema: FormSchema[] = [
7 field: 'type', 7 field: 'type',
8 label: '类型', 8 label: '类型',
9 component: 'Select', 9 component: 'Select',
  10 + defaultValue: '默认',
10 colProps: { span: 24 }, 11 colProps: { span: 24 },
11 componentProps: { 12 componentProps: {
12 placeholder: '请选择类型', 13 placeholder: '请选择类型',
@@ -7,7 +7,9 @@ @@ -7,7 +7,9 @@
7 > 7 >
8 <template #toolbar> 8 <template #toolbar>
9 <a-button type="primary" @click="handleAdd"> 新增租户配置 </a-button> 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 </template> 13 </template>
12 <template #action="{ record }"> 14 <template #action="{ record }">
13 <TableAction 15 <TableAction
@@ -38,7 +40,7 @@ @@ -38,7 +40,7 @@
38 </div> 40 </div>
39 </template> 41 </template>
40 <script lang="ts"> 42 <script lang="ts">
41 - import { defineComponent, reactive } from 'vue'; 43 + import { defineComponent, reactive, ref } from 'vue';
42 import { BasicTable, useTable, TableAction } from '/@/components/Table'; 44 import { BasicTable, useTable, TableAction } from '/@/components/Table';
43 import { useDrawer } from '/@/components/Drawer'; 45 import { useDrawer } from '/@/components/Drawer';
44 import TenantSettingDrawer from './useDrawer.vue'; 46 import TenantSettingDrawer from './useDrawer.vue';
@@ -50,6 +52,7 @@ @@ -50,6 +52,7 @@
50 name: 'Index', 52 name: 'Index',
51 components: { BasicTable, TenantSettingDrawer, TableAction }, 53 components: { BasicTable, TenantSettingDrawer, TableAction },
52 setup() { 54 setup() {
  55 + const disabled = ref(true);
53 let echoEditData = reactive({}); 56 let echoEditData = reactive({});
54 let selectedRowKeys: Array<string> = []; 57 let selectedRowKeys: Array<string> = [];
55 const [registerDrawer, { openDrawer }] = useDrawer(); 58 const [registerDrawer, { openDrawer }] = useDrawer();
@@ -97,6 +100,11 @@ @@ -97,6 +100,11 @@
97 } 100 }
98 const useSelectionChange = () => { 101 const useSelectionChange = () => {
99 selectedRowKeys = getSelectRowKeys(); 102 selectedRowKeys = getSelectRowKeys();
  103 + if (selectedRowKeys.length !== 0) {
  104 + disabled.value = false;
  105 + } else {
  106 + disabled.value = true;
  107 + }
100 }; 108 };
101 const handleMutilteDelete = async () => { 109 const handleMutilteDelete = async () => {
102 await deleteTenantProfileApi(selectedRowKeys); 110 await deleteTenantProfileApi(selectedRowKeys);
@@ -107,6 +115,7 @@ @@ -107,6 +115,7 @@
107 reload(); 115 reload();
108 } 116 }
109 return { 117 return {
  118 + disabled,
110 echoEditData, 119 echoEditData,
111 registerTable, 120 registerTable,
112 registerDrawer, 121 registerDrawer,