Commit aae82259b57c99baf05eda5ec0adb4c78b9610f5

Authored by xp.Huang
2 parents 655799a1 6a225297

Merge branch 'ft-dev' into 'main'

fix:修复场景联动新增问题

See merge request huang/yun-teng-iot-front!103
@@ -39,15 +39,9 @@ @@ -39,15 +39,9 @@
39 alt="avatar" 39 alt="avatar"
40 /> 40 />
41 <div v-else> 41 <div v-else>
42 - <div style="margin-top: 30px"> 42 + <div style="margin-top: 5.2vh; margin-left: 3.35vw">
43 <PlusOutlined style="font-size: 30px" /> 43 <PlusOutlined style="font-size: 30px" />
44 </div> 44 </div>
45 - <div  
46 - class="ant-upload-text flex"  
47 - style="width: 280px; height: 130px; align-items: center"  
48 - >  
49 - 支持.PNG、.JPG、.SVG格式,建议尺寸为300px × 300px(及以上),大小不超过2M。</div  
50 - >  
51 </div> 45 </div>
52 </Upload> 46 </Upload>
53 </div> 47 </div>
1 <template> 1 <template>
2 - <CollapseContainer title="执行条件" style="background-color: #eeeeee"> 2 + <CollapseContainer style="background-color: #eeeeee">
3 <div style="position: relative"> 3 <div style="position: relative">
4 <BasicForm 4 <BasicForm
5 :labelWidth="100" 5 :labelWidth="100"
1 <template> 1 <template>
2 - <CollapseContainer class="prefixRedDot" title="执行动作" style="background-color: #eeeeee"> 2 + <CollapseContainer class="prefixRedDot" style="background-color: #eeeeee">
3 <div style="position: relative"> 3 <div style="position: relative">
4 <BasicForm 4 <BasicForm
5 :labelWidth="100" 5 :labelWidth="100"
@@ -87,7 +87,7 @@ @@ -87,7 +87,7 @@
87 vertical-align: middle; 87 vertical-align: middle;
88 display: inline-block; 88 display: inline-block;
89 position: relative; 89 position: relative;
90 - top: 33px; 90 + top: 25px;
91 left: 5px; 91 left: 5px;
92 } 92 }
93 </style> 93 </style>
1 <template> 1 <template>
2 <div> 2 <div>
3 - <CollapseContainer title="触发器" style="background-color: #eeeeee"> 3 + <CollapseContainer style="background-color: #eeeeee">
4 <div> 4 <div>
5 <BasicForm 5 <BasicForm
6 :labelWidth="100" 6 :labelWidth="100"
@@ -23,10 +23,10 @@ @@ -23,10 +23,10 @@
23 23
24 export default defineComponent({ 24 export default defineComponent({
25 components: { CollapseContainer, BasicForm, [Input.name]: Input }, 25 components: { CollapseContainer, BasicForm, [Input.name]: Input },
26 - props: ['deviceInfo'], 26 + props: ['deviceInfo', 'editTriggerFather'],
27 setup(props) { 27 setup(props) {
28 const fieldValue: any = ref({}); 28 const fieldValue: any = ref({});
29 - const [registerTrigger, { getFieldsValue, updateSchema }] = useForm({ 29 + const [registerTrigger, { setFieldsValue, getFieldsValue, updateSchema }] = useForm({
30 labelWidth: 100, 30 labelWidth: 100,
31 schemas: useTriggerDrawerSchema, 31 schemas: useTriggerDrawerSchema,
32 actionColOptions: { span: 24 }, 32 actionColOptions: { span: 24 },
@@ -38,9 +38,7 @@ @@ -38,9 +38,7 @@
38 watch( 38 watch(
39 () => props.deviceInfo, 39 () => props.deviceInfo,
40 async (newV) => { 40 async (newV) => {
41 - console.log(newV);  
42 const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV }); 41 const options = await screenLinkPageByDeptIdGetDevice({ organizationId: newV });
43 - console.log(options);  
44 options.items.forEach((v) => { 42 options.items.forEach((v) => {
45 return (v.value = v.id), (v.label = v.name); 43 return (v.value = v.id), (v.label = v.name);
46 }); 44 });
@@ -52,6 +50,13 @@ @@ -52,6 +50,13 @@
52 }); 50 });
53 } 51 }
54 ); 52 );
  53 + //回显数据
  54 + const setFieldsFormValueFun = () => {
  55 + setTimeout(() => {
  56 + setFieldsValue(props.editTriggerFather);
  57 + }, 100);
  58 + };
  59 + setFieldsFormValueFun();
55 //新增清空设备选择 60 //新增清空设备选择
56 const clearSelectDevice = () => { 61 const clearSelectDevice = () => {
57 updateSchema({ 62 updateSchema({
@@ -597,6 +597,7 @@ export const useActionDrawerSchema: FormSchema[] = [ @@ -597,6 +597,7 @@ export const useActionDrawerSchema: FormSchema[] = [
597 field: 'outTarget', 597 field: 'outTarget',
598 label: '', 598 label: '',
599 component: 'Select', 599 component: 'Select',
  600 + required: true,
600 componentProps: { 601 componentProps: {
601 placeholder: '设备输出', 602 placeholder: '设备输出',
602 options: [ 603 options: [
@@ -611,6 +612,7 @@ export const useActionDrawerSchema: FormSchema[] = [ @@ -611,6 +612,7 @@ export const useActionDrawerSchema: FormSchema[] = [
611 field: 'deviceId', 612 field: 'deviceId',
612 label: '', 613 label: '',
613 component: 'Select', 614 component: 'Select',
  615 + required: true,
614 componentProps: { 616 componentProps: {
615 placeholder: '请选择设备', 617 placeholder: '请选择设备',
616 }, 618 },
@@ -624,6 +626,8 @@ export const useActionDrawerSchema: FormSchema[] = [ @@ -624,6 +626,8 @@ export const useActionDrawerSchema: FormSchema[] = [
624 field: 'command', 626 field: 'command',
625 component: 'Input', 627 component: 'Input',
626 label: '', 628 label: '',
  629 + required: true,
  630 +
627 componentProps: { 631 componentProps: {
628 maxLength: 255, 632 maxLength: 255,
629 placeholder: '请输入下发指定', 633 placeholder: '请输入下发指定',
@@ -119,10 +119,14 @@ @@ -119,10 +119,14 @@
119 echoEditData = record; 119 echoEditData = record;
120 } 120 }
121 async function handleDelete(record: Recordable) { 121 async function handleDelete(record: Recordable) {
122 - let ids = [record.id];  
123 - await screenLinkPageDeleteApi(ids);  
124 - createMessage.success('删除成功');  
125 - reload(); 122 + try {
  123 + let ids = [record.id];
  124 + await screenLinkPageDeleteApi(ids);
  125 + createMessage.success('删除成功');
  126 + reload();
  127 + } catch (e) {
  128 + return e;
  129 + }
126 } 130 }
127 function handleSuccess() { 131 function handleSuccess() {
128 reload(); 132 reload();
@@ -7,94 +7,130 @@ @@ -7,94 +7,130 @@
7 width="1000px" 7 width="1000px"
8 @ok="handleSubmit" 8 @ok="handleSubmit"
9 > 9 >
10 - <BasicForm @register="registerForm" />  
11 - <!-- 触发器 -->  
12 <div> 10 <div>
13 - <template v-for="(item, index) in addTriggerPushData" :key="index">  
14 - <div>  
15 - <AddTriggerForm :deviceInfo="getDeviceInfo" ref="refTriggerChild" />  
16 - </div>  
17 - <div style="height: 3vh"></div>  
18 - </template>  
19 - <div  
20 - style="  
21 - display: flex;  
22 - width: 13vw;  
23 - height: 4vh;  
24 - flex-direction: row;  
25 - justify-content: space-between;  
26 - "  
27 - >  
28 - <div style="display: flex; width: 4vw; height: 4vh">  
29 - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addTrigger"  
30 - ><PlusCircleOutlined />新增触发器</Button  
31 - >  
32 - </div>  
33 - <div style="display: flex; width: 4vw; height: 4vh">  
34 - <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeTrigger"  
35 - ><PlusCircleOutlined />删除</Button  
36 - > 11 + <BasicForm @register="registerForm" />
  12 + <!-- 触发器 -->
  13 + <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 v-if="isUpdate == true">
  21 + <AddTriggerForm
  22 + :editTriggerFather="item"
  23 + :deviceInfo="getDeviceInfo"
  24 + ref="refTriggerChild"
  25 + />
  26 + </div>
  27 + <div v-if="isUpdate == false">
  28 + <AddTriggerForm :deviceInfo="getDeviceInfo" ref="refTriggerChild" />
  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 + type="default"
  49 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  50 + class="mt-5"
  51 + @click="removeTrigger"
  52 + >
  53 + <span style="color: white">删除</span></Button
  54 + >
  55 + </div>
37 </div> 56 </div>
38 </div> 57 </div>
39 - </div>  
40 - <div style="height: 5vh"></div>  
41 - <!-- 执行条件 -->  
42 - <div>  
43 - <template v-for="(item, index) in addConditionPushData" :key="index">  
44 - <div>  
45 - <AddConditiForm :deviceInfo1="getDeviceInfo1" ref="refConditionChild" />  
46 - </div>  
47 - <div style="height: 3vh"></div>  
48 - </template>  
49 - <div  
50 - style="  
51 - display: flex;  
52 - width: 13vw;  
53 - height: 4vh;  
54 - flex-direction: row;  
55 - justify-content: space-between;  
56 - "  
57 - >  
58 - <div style="display: flex; width: 4vw; height: 4vh">  
59 - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition"  
60 - ><PlusCircleOutlined />新增执行条件</Button  
61 - >  
62 - </div>  
63 - <div style="display: flex; width: 4vw; height: 4vh">  
64 - <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeCondition"  
65 - ><PlusCircleOutlined />删除</Button  
66 - > 58 + <div style="height: 5vh"></div>
  59 + <!-- 执行条件 -->
  60 + <div>
  61 + <template v-for="(item, index) in addConditionPushData" :key="index">
  62 + <span style="display: none">{{ item + index }}</span>
  63 + <span style="position: relative; top: 3.2vh; left: 0.3vw">执行条件{{ index + 1 }}</span>
  64 +
  65 + <div>
  66 + <AddConditiForm :deviceInfo1="getDeviceInfo1" ref="refConditionChild" />
  67 + </div>
  68 + <div style="height: 3vh"></div>
  69 + </template>
  70 + <div
  71 + style="
  72 + display: flex;
  73 + width: 11vw;
  74 + height: 4vh;
  75 + flex-direction: row;
  76 + justify-content: space-between;
  77 + "
  78 + >
  79 + <div style="display: flex; width: 4vw; height: 4vh">
  80 + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addCondition"
  81 + >新增执行条件</Button
  82 + >
  83 + </div>
  84 + <div style="display: flex; width: 4vw; height: 4vh">
  85 + <Button
  86 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  87 + type="default"
  88 + class="mt-5"
  89 + @click="removeCondition"
  90 + >
  91 + <span style="color: white">删除</span></Button
  92 + >
  93 + </div>
67 </div> 94 </div>
68 </div> 95 </div>
69 - </div>  
70 - <!-- 执行动作 -->  
71 - <div style="height: 5vh"></div>  
72 - <div>  
73 - <template v-for="(item, index) in addActionPushData" :key="index">  
74 - <div>  
75 - <AddActionForm :deviceInfo2="getDeviceInfo2" ref="refActionChild" />  
76 - </div>  
77 - <div style="height: 3vh"></div>  
78 - </template>  
79 - <div  
80 - style="  
81 - display: flex;  
82 - width: 13vw;  
83 - height: 4vh;  
84 - flex-direction: row;  
85 - justify-content: space-between;  
86 - "  
87 - >  
88 - <div style="display: flex; width: 4vw; height: 4vh">  
89 - <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction"  
90 - ><PlusCircleOutlined />新增执行动作</Button  
91 - >  
92 - </div>  
93 - <div style="display: flex; width: 4vw; height: 4vh">  
94 - <Button type="error" style="border-radius: 10px" class="mt-5" @click="removeAction"  
95 - ><PlusCircleOutlined />删除</Button  
96 - > 96 + <!-- 执行动作 -->
  97 + <div style="height: 5vh"></div>
  98 + <div>
  99 + <template v-for="(item, index) in addActionPushData" :key="index">
  100 + <span style="display: none">{{ item + index }}</span>
  101 + <span style="position: relative; top: 4.2vh; left: 0.65vw">执行动作{{ index + 1 }}</span>
  102 +
  103 + <div>
  104 + <AddActionForm :deviceInfo2="getDeviceInfo2" ref="refActionChild" />
  105 + </div>
  106 + <div style="height: 3vh"></div>
  107 + </template>
  108 + <div
  109 + style="
  110 + display: flex;
  111 + width: 11vw;
  112 + height: 4vh;
  113 + flex-direction: row;
  114 + justify-content: space-between;
  115 + "
  116 + >
  117 + <div style="display: flex; width: 4vw; height: 4vh">
  118 + <Button type="primary" style="border-radius: 10px" class="mt-5" @click="addAction"
  119 + >新增执行动作</Button
  120 + >
  121 + </div>
  122 + <div style="display: flex; width: 4vw; height: 4vh">
  123 + <Button
  124 + style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
  125 + type="default"
  126 + class="mt-5"
  127 + @click="removeAction"
  128 + >
  129 + <span style="color: white">删除</span></Button
  130 + >
  131 + </div>
97 </div> 132 </div>
  133 + <div style="height: 5vh"></div>
98 </div> 134 </div>
99 </div> 135 </div>
100 </BasicDrawer> 136 </BasicDrawer>
@@ -104,11 +140,7 @@ @@ -104,11 +140,7 @@
104 import { BasicForm, useForm } from '/@/components/Form'; 140 import { BasicForm, useForm } from '/@/components/Form';
105 import { formSchema, getData } from './config'; 141 import { formSchema, getData } from './config';
106 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; 142 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
107 - import {  
108 - screenLinkPageAddApi,  
109 - // screenLinkPageUpdateApi,  
110 - // screenLinkPageByDeptIdGetDevice,  
111 - } from '/@/api/ruleengine/ruleengineApi'; 143 + import { screenLinkPageAddApi, screenLinkPageUpdateApi } from '/@/api/ruleengine/ruleengineApi';
112 import { useMessage } from '/@/hooks/web/useMessage'; 144 import { useMessage } from '/@/hooks/web/useMessage';
113 import AddTriggerForm from './addForm/trigger.vue'; 145 import AddTriggerForm from './addForm/trigger.vue';
114 import AddConditiForm from './addForm/condition.vue'; 146 import AddConditiForm from './addForm/condition.vue';
@@ -118,10 +150,19 @@ @@ -118,10 +150,19 @@
118 150
119 export default defineComponent({ 151 export default defineComponent({
120 name: 'ConfigDrawer', 152 name: 'ConfigDrawer',
121 - components: { BasicDrawer, BasicForm, AddTriggerForm, AddConditiForm, AddActionForm, Button }, 153 + components: {
  154 + BasicDrawer,
  155 + BasicForm,
  156 + AddTriggerForm,
  157 + AddConditiForm,
  158 + AddActionForm,
  159 + Button,
  160 + },
122 emits: ['success', 'register', 'registerForm'], 161 emits: ['success', 'register', 'registerForm'],
123 setup(_, { emit }) { 162 setup(_, { emit }) {
  163 + const { proxy } = getCurrentInstance();
124 const lastRefTriggerChildDataArray = ref<[]>([]); 164 const lastRefTriggerChildDataArray = ref<[]>([]);
  165 + const lastEditRefTriggerChildDataArray = ref<[]>([]);
125 const lastRefConditionChildDataArray = ref<[]>([]); 166 const lastRefConditionChildDataArray = ref<[]>([]);
126 const lastRefActionChildDataArray = ref<[]>([]); 167 const lastRefActionChildDataArray = ref<[]>([]);
127 const lastRefTriggerChildData: any = ref({}); 168 const lastRefTriggerChildData: any = ref({});
@@ -159,7 +200,8 @@ @@ -159,7 +200,8 @@
159 const addTriggerPushData = ref<[]>([]); 200 const addTriggerPushData = ref<[]>([]);
160 const addConditionPushData = ref<[]>([]); 201 const addConditionPushData = ref<[]>([]);
161 const addActionPushData = ref<[]>([]); 202 const addActionPushData = ref<[]>([]);
162 - const { proxy } = getCurrentInstance(); 203 + //edit data
  204 + const editTriggerPushData = ref<[]>([]);
163 const getChildData = ref(null); 205 const getChildData = ref(null);
164 const refTriggerChild = ref(null); 206 const refTriggerChild = ref(null);
165 const refConditionChild = ref(null); 207 const refConditionChild = ref(null);
@@ -167,13 +209,14 @@ @@ -167,13 +209,14 @@
167 const getConditionChildData = ref(null); 209 const getConditionChildData = ref(null);
168 const { createMessage } = useMessage(); 210 const { createMessage } = useMessage();
169 const isUpdate = ref(true); 211 const isUpdate = ref(true);
170 - let getAllFormData: any = reactive({}); 212 + const getAllFormData: any = reactive({});
171 let getValuesFormData: any = reactive({}); 213 let getValuesFormData: any = reactive({});
172 - let getId = ref('');  
173 - let getTenantId = ref('');  
174 - let getDeviceInfo = ref(null);  
175 - let getDeviceInfo1 = ref(null);  
176 - let getDeviceInfo2 = ref(null); 214 + const getId = ref('');
  215 + const getTenantId = ref('');
  216 + const getDeviceInfo = ref(null);
  217 + const getDeviceInfo1 = ref(null);
  218 + const getDeviceInfo2 = ref(null);
  219 + const editReveiveData = ref<[]>([]);
177 220
178 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({ 221 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
179 labelWidth: 120, 222 labelWidth: 120,
@@ -195,13 +238,16 @@ @@ -195,13 +238,16 @@
195 return e; 238 return e;
196 } 239 }
197 } 240 }
198 - //编辑  
199 if (unref(isUpdate)) { 241 if (unref(isUpdate)) {
  242 + //编辑
  243 + clearAllArrayFunc();
200 getId.value = data.record.id; 244 getId.value = data.record.id;
201 getTenantId.value = data.record.tenantId; 245 getTenantId.value = data.record.tenantId;
202 await setFieldsValue({ 246 await setFieldsValue({
203 ...data.record, 247 ...data.record,
204 }); 248 });
  249 + editReveiveData.value = data.record.triggers;
  250 + editTriggerPushData.value = editReveiveData.value;
205 } 251 }
206 }); 252 });
207 const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动')); 253 const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
@@ -213,6 +259,7 @@ @@ -213,6 +259,7 @@
213 lastRefTriggerChildDataArray.value.length = 0; 259 lastRefTriggerChildDataArray.value.length = 0;
214 lastRefConditionChildDataArray.value.length = 0; 260 lastRefConditionChildDataArray.value.length = 0;
215 lastRefActionChildDataArray.value.length = 0; 261 lastRefActionChildDataArray.value.length = 0;
  262 + // lastEditRefTriggerChildDataArray.value.length = 0;
216 }; 263 };
217 const resetActionsAllArrayFunc = () => { 264 const resetActionsAllArrayFunc = () => {
218 try { 265 try {
@@ -259,69 +306,120 @@ @@ -259,69 +306,120 @@
259 } 306 }
260 }; 307 };
261 308
262 - const getDefaultValue = async () => {  
263 - getValuesFormData = await validateFields();  
264 - refTriggerChildDataFunc();  
265 - refConditionChildDataFunc();  
266 - refActionChildDataFunc();  
267 - lastRefTriggerChildDataArray.value.push(refTriggerChildData.value);  
268 - lastRefConditionChildDataArray.value.push(refConditionChildData.value);  
269 - lastRefActionChildDataArray.value.push(refActionChildData.value);  
270 - const triggersObj = {  
271 - triggers: lastRefTriggerChildDataArray.value,  
272 - };  
273 - const conditionsObj = {  
274 - conditions: lastRefConditionChildDataArray.value,  
275 - };  
276 - const actionsObj = {  
277 - actions: lastRefActionChildDataArray.value,  
278 - };  
279 - Object.assign(getAllFormData, getValuesFormData, triggersObj, conditionsObj, actionsObj); 309 + const getDefaultValue = () => {
280 if (!unref(isUpdate)) { 310 if (!unref(isUpdate)) {
281 delete getAllFormData.id; 311 delete getAllFormData.id;
282 delete getAllFormData.getTenantId; 312 delete getAllFormData.getTenantId;
  313 + refTriggerChildDataFunc();
  314 + refConditionChildDataFunc();
  315 + refActionChildDataFunc();
  316 + lastRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
  317 + lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
  318 + lastRefActionChildDataArray.value.push(refActionChildData.value as never);
  319 + //删除第一个
  320 + lastRefTriggerChildDataArray.value.shift();
  321 + lastRefConditionChildDataArray.value.shift();
  322 + lastRefActionChildDataArray.value.shift();
  323 + const triggersObj = {
  324 + triggers: lastRefTriggerChildDataArray.value,
  325 + };
  326 + const conditionsObj = {
  327 + doConditions: lastRefConditionChildDataArray.value,
  328 + };
  329 + const actionsObj = {
  330 + doActions: lastRefActionChildDataArray.value,
  331 + };
  332 + Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
  333 + } else {
  334 + refTriggerChildDataFunc();
  335 + refConditionChildDataFunc();
  336 + refActionChildDataFunc();
  337 + lastEditRefTriggerChildDataArray.value.push(refTriggerChildData.value as never);
  338 + lastRefConditionChildDataArray.value.push(refConditionChildData.value as never);
  339 + lastRefActionChildDataArray.value.push(refActionChildData.value as never);
  340 + const triggersObj = {
  341 + triggers: lastEditRefTriggerChildDataArray.value,
  342 + };
  343 + const conditionsObj = {
  344 + doConditions: lastRefConditionChildDataArray.value,
  345 + };
  346 + const actionsObj = {
  347 + doActions: lastRefActionChildDataArray.value,
  348 + };
  349 + Object.assign(getAllFormData, triggersObj, conditionsObj, actionsObj);
283 } 350 }
284 }; 351 };
285 352
286 - async function handleSubmit() { 353 + const handleSubmit = async () => {
287 if (!unref(isUpdate)) { 354 if (!unref(isUpdate)) {
288 getDefaultValue(); 355 getDefaultValue();
289 - console.log(getAllFormData); 356 + getValuesFormData = await validateFields();
  357 + if (!getValuesFormData) return;
  358 + Object.assign(getAllFormData, getValuesFormData);
290 await screenLinkPageAddApi(getAllFormData); 359 await screenLinkPageAddApi(getAllFormData);
291 createMessage.success('场景联动新增成功'); 360 createMessage.success('场景联动新增成功');
292 closeDrawer(); 361 closeDrawer();
293 emit('success'); 362 emit('success');
294 } else { 363 } else {
295 getDefaultValue(); 364 getDefaultValue();
  365 + getValuesFormData = await validateFields();
  366 + if (!getValuesFormData) return;
  367 + Object.assign(getAllFormData, getValuesFormData);
  368 + getAllFormData.id = getId.value;
  369 + getAllFormData.tenantId = getTenantId.value;
  370 + await screenLinkPageUpdateApi(getAllFormData);
296 createMessage.success('场景联动编辑成功'); 371 createMessage.success('场景联动编辑成功');
297 closeDrawer(); 372 closeDrawer();
298 emit('success'); 373 emit('success');
299 } 374 }
300 - } 375 + };
  376 +
301 //新增触发器 377 //新增触发器
302 const addTrigger = () => { 378 const addTrigger = () => {
303 - unref(addTriggerPushData).push(addTriggerData);  
304 - refTriggerChildDataFunc();  
305 - lastRefTriggerChildData.value = refTriggerChildData.value;  
306 - lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value); 379 + if (!unref(isUpdate)) {
  380 + unref(addTriggerPushData).push(addTriggerData as never);
  381 + refTriggerChildDataFunc();
  382 + lastRefTriggerChildData.value = refTriggerChildData.value;
  383 + lastRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value as never);
  384 + } else {
  385 + unref(editTriggerPushData).push(addTriggerData as never);
  386 + refTriggerChildDataFunc();
  387 + lastRefTriggerChildData.value = refTriggerChildData.value;
  388 + lastEditRefTriggerChildDataArray.value.push(lastRefTriggerChildData.value as never);
  389 + }
307 }; 390 };
308 const removeTrigger = () => { 391 const removeTrigger = () => {
309 - unref(addTriggerPushData).splice(0, 1);  
310 - lastRefTriggerChildDataArray.value.splice(0, 1);  
311 - getAllFormData.triggers.splice(0, 1); 392 + if (!unref(isUpdate)) {
  393 + try {
  394 + unref(addTriggerPushData).splice(0, 1);
  395 + lastRefTriggerChildDataArray.value.splice(0, 1);
  396 + } catch (e) {
  397 + return e;
  398 + }
  399 + } else {
  400 + try {
  401 + unref(editTriggerPushData).splice(0, 1);
  402 + lastEditRefTriggerChildDataArray.value.splice(0, 1);
  403 + } catch (e) {
  404 + return e;
  405 + }
  406 + }
312 }; 407 };
313 408
314 //新增执行条件 409 //新增执行条件
315 const addCondition = () => { 410 const addCondition = () => {
316 - unref(addConditionPushData).push(addConditionData); 411 + unref(addConditionPushData).push(addConditionData as never);
317 refConditionChildDataFunc(); 412 refConditionChildDataFunc();
318 lastRefConditionChildData.value = refConditionChildData.value; 413 lastRefConditionChildData.value = refConditionChildData.value;
319 - lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value); 414 + lastRefConditionChildDataArray.value.push(lastRefConditionChildData.value as never);
320 }; 415 };
321 const removeCondition = () => { 416 const removeCondition = () => {
322 - unref(addConditionPushData).splice(0, 1);  
323 - lastRefConditionChildDataArray.value.splice(0, 1);  
324 - getAllFormData.conditions.splice(0, 1); 417 + try {
  418 + unref(addConditionPushData).splice(0, 1);
  419 + lastRefConditionChildDataArray.value.splice(0, 1);
  420 + } catch (e) {
  421 + return e;
  422 + }
325 }; 423 };
326 424
327 //新增执行动作 425 //新增执行动作
@@ -331,18 +429,23 @@ @@ -331,18 +429,23 @@
331 } 429 }
332 }; 430 };
333 const addAction = () => { 431 const addAction = () => {
334 - unref(addActionPushData).push(addActionData); 432 + unref(addActionPushData).push(addActionData as never);
335 refActionChildDataFunc(); 433 refActionChildDataFunc();
336 lastRefActionChildData.value = refActionChildData.value; 434 lastRefActionChildData.value = refActionChildData.value;
337 - lastRefActionChildDataArray.value.push(lastRefActionChildData.value); 435 + lastRefActionChildDataArray.value.push(lastRefActionChildData.value as never);
338 }; 436 };
339 const removeAction = () => { 437 const removeAction = () => {
340 - unref(addActionPushData).splice(0, 1);  
341 - lastRefActionChildDataArray.value.splice(0, 1);  
342 - getAllFormData.actions.splice(0, 1); 438 + try {
  439 + unref(addActionPushData).splice(0, 1);
  440 + lastRefActionChildDataArray.value.splice(0, 1);
  441 + } catch (e) {
  442 + return e;
  443 + }
343 }; 444 };
344 445
345 return { 446 return {
  447 + editTriggerPushData,
  448 + isUpdate,
346 clearActionsAllDevice, 449 clearActionsAllDevice,
347 getDeviceInfo, 450 getDeviceInfo,
348 getDeviceInfo1, 451 getDeviceInfo1,