Commit 4cfebeff33c9a084ee612d40a17c675b371f60dd

Authored by xp.Huang
2 parents 33c61e82 5d13b23b

Merge branch 'ft-dev' into 'main'

fix:修改设备配置告警通知和联系人为多选和场景联动没有触发器按钮问题

See merge request huang/yun-teng-iot-front!106
... ... @@ -8,7 +8,7 @@
8 8 @cancel="handleCancel"
9 9 >
10 10 <div class="step-form-form">
11   - <a-steps :current="current" @change="handleChange">
  11 + <a-steps :current="current">
12 12 <a-step title="设备配置" />
13 13 <a-step title="传输配置" />
14 14 <a-step title="告警配置" />
... ... @@ -79,7 +79,6 @@
79 79 const DeviceProfileStep3Ref = ref(null);
80 80 const DeviceProfileStep4Ref = ref(null);
81 81 const { createMessage } = useMessage();
82   - // const getStepData = ref(null);
83 82 const { proxy } = getCurrentInstance();
84 83 const postDeviceConfogData: any = ref({});
85 84 const getStepOneData: any = ref({});
... ... @@ -91,10 +90,8 @@
91 90 const postEditId = ref('');
92 91 const current = ref(0);
93 92 const isUpdate = ref(true);
  93 +
94 94 const getTitle = computed(() => (!unref(isUpdate) ? '新增设备配置' : '编辑设备配置'));
95   - const handleChange = (v) => {
96   - console.log(v);
97   - };
98 95 const [register, { closeModal }] = useModalInner(async (data) => {
99 96 isUpdate.value = !!data?.isUpdate;
100 97 if (!unref(isUpdate)) {
... ... @@ -277,6 +274,8 @@
277 274 isGetStepThreeData.value.profileData = getStepThreeData.value;
278 275 alarmProfileData.value.alarmProfile =
279 276 await proxy.$refs.DeviceProfileStep4Ref.getAllFields();
  277 + alarmProfileData.value.alarmProfile.alarmContactId.shift();
  278 + alarmProfileData.value.alarmProfile.messageMode.shift();
280 279 Object.assign(
281 280 postDeviceConfogData.value,
282 281 getStepOneData.value,
... ... @@ -288,8 +287,7 @@
288 287 createMessage.success('新增设备配置成功');
289 288 closeModal();
290 289 emit('success');
291   - }
292   - if (unref(isUpdate)) {
  290 + } else {
293 291 postDeviceConfogData.value.id = postEditId.value;
294 292 isGetStepThreeData.value.profileData = getStepThreeData.value;
295 293 alarmProfileData.value.alarmProfile =
... ... @@ -311,13 +309,11 @@
311 309 closeModal();
312 310 };
313 311 return {
314   - handleChange,
315 312 DeviceProfileStep2Ref,
316 313 DeviceProfileStep3Ref,
317 314 DeviceProfileStep4Ref,
318 315 DeviceProfileStep1Ref,
319 316 editEchoData,
320   - // getStepData,
321 317 handleStep3Next,
322 318 handleSubmit,
323 319 handleCancel,
... ...
... ... @@ -8,6 +8,8 @@ export const alertContactsSchemas: FormSchema[] = [
8 8 label: '告警通知联系人',
9 9 component: 'ApiSelect',
10 10 componentProps: {
  11 + mode: 'multiple',
  12 +
11 13 api: alarmContactGetPage,
12 14 labelField: 'username',
13 15 valueField: 'id',
... ... @@ -20,6 +22,7 @@ export const alertContactsSchemas: FormSchema[] = [
20 22 required: true,
21 23 component: 'ApiSelect',
22 24 componentProps: {
  25 + mode: 'multiple',
23 26 api: findDictItemByCode,
24 27 params: {
25 28 dictCode: 'message_type',
... ...
... ... @@ -223,7 +223,7 @@
223 223 function handleSuccess() {
224 224 reload();
225 225 }
226   - return {
  226 + return {
227 227 deviceDetailRef,
228 228 setRowClassName,
229 229 registerModalDetail,
... ...
... ... @@ -207,7 +207,7 @@
207 207
208 208 <script lang="ts">
209 209 import { defineComponent, ref, unref, getCurrentInstance, watch } from 'vue';
210   - import type { IProfileData } from '../types/index';
  210 + import type { IProfileData } from './index.t';
211 211 import { CollapseContainer } from '/@/components/Container/index';
212 212 import { BasicForm, useForm } from '/@/components/Form';
213 213 import {
... ...
1 1 <template>
2 2 <div class="step-4">
3   - <!-- <span>请选择告警通知联系人:</span> -->
4   - <!-- <Tag v-for="(item, index) in 15" closable :key="index"> 冯涛+{{ item }}</Tag> -->
5 3 <BasicForm :showSubmitButton="false" @register="register" />
6 4 </div>
7 5 </template>
8 6 <script lang="ts">
9 7 import { defineComponent, ref } from 'vue';
10   - // import { Tag } from 'ant-design-vue';
11 8 import { BasicForm, useForm } from '/@/components/Form/index';
12 9 import { alertContactsSchemas } from '../cpns/config';
13 10
... ...
src/views/device/profile/step/index.t.ts renamed from src/views/device/profile/types/index.ts
... ... @@ -23,7 +23,7 @@
23 23
24 24 export default defineComponent({
25 25 components: { CollapseContainer, BasicForm, [Input.name]: Input },
26   - props: ['deviceInfo', 'editTriggerFather'],
  26 + props: ['deviceInfo', 'editTriggerFather', 'newFilterMapFather'],
27 27 setup(props) {
28 28 const fieldValue: any = ref({});
29 29 const [registerTrigger, { setFieldsValue, getFieldsValue, updateSchema }] = useForm({
... ... @@ -50,6 +50,7 @@
50 50 });
51 51 }
52 52 );
  53 +
53 54 //回显数据
54 55 const setFieldsFormValueFun = () => {
55 56 setTimeout(() => {
... ... @@ -66,15 +67,37 @@
66 67 },
67 68 });
68 69 };
69   - const editSelectDevice = (v) => {
  70 + const editSelectDevice = () => {
  71 + setTimeout(() => {
  72 + updateSchema({
  73 + field: 'deviceId',
  74 + componentProps: {
  75 + options: props.newFilterMapFather,
  76 + },
  77 + });
  78 + }, 100);
  79 + };
  80 + editSelectDevice();
  81 + //新增清空场景触发器选择
  82 + const clearSelectScene = () => {
  83 + updateSchema({
  84 + field: 'sceneLinkageId',
  85 + componentProps: {
  86 + options: [],
  87 + },
  88 + });
  89 + };
  90 + const editSelectScene = (v) => {
70 91 updateSchema({
71   - field: 'deviceId',
  92 + field: 'sceneLinkageId',
72 93 componentProps: {
73 94 options: v,
74 95 },
75 96 });
76 97 };
77 98 return {
  99 + clearSelectScene,
  100 + editSelectScene,
78 101 clearSelectDevice,
79 102 editSelectDevice,
80 103 getFieldsValueFunc,
... ...
... ... @@ -17,16 +17,14 @@
17 17 >
18 18 <span style="display: none">{{ item + index }}</span>
19 19 <span style="position: relative; top: 3.2vh; left: 0.3vw">触发器{{ index + 1 }}</span>
20   - <div v-if="isUpdate == true">
  20 + <div>
21 21 <AddTriggerForm
22   - :editTriggerFather="item"
  22 + :editTriggerFather="isUpdate == false ? null : item"
  23 + :newFilterMapFather="isUpdate == false ? null : newFilterMap"
23 24 :deviceInfo="getDeviceInfo"
24 25 ref="refTriggerChild"
25 26 />
26 27 </div>
27   - <div v-if="isUpdate == false">
28   - <AddTriggerForm :deviceInfo="getDeviceInfo" ref="refTriggerChild" />
29   - </div>
30 28 <div style="height: 3vh"></div>
31 29 </template>
32 30 <div
... ... @@ -45,6 +43,7 @@
45 43 </div>
46 44 <div style="display: flex; width: 4vw; height: 4vh">
47 45 <Button
  46 + v-if="addTriggerPushData.length != 0 || editTriggerPushData.length != 0"
48 47 type="default"
49 48 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
50 49 class="mt-5"
... ... @@ -83,6 +82,7 @@
83 82 </div>
84 83 <div style="display: flex; width: 4vw; height: 4vh">
85 84 <Button
  85 + v-if="addConditionPushData.length != 0"
86 86 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
87 87 type="default"
88 88 class="mt-5"
... ... @@ -121,6 +121,7 @@
121 121 </div>
122 122 <div style="display: flex; width: 4vw; height: 4vh">
123 123 <Button
  124 + v-if="addActionPushData.length > 0"
124 125 style="border-radius: 10px; background-color: rgba(237, 111, 111, 1)"
125 126 type="default"
126 127 class="mt-5"
... ... @@ -140,7 +141,11 @@
140 141 import { BasicForm, useForm } from '/@/components/Form';
141 142 import { formSchema, getData } from './config';
142 143 import { BasicDrawer, useDrawerInner } from '/@/components/Drawer';
143   - import { screenLinkPageAddApi, screenLinkPageUpdateApi } from '/@/api/ruleengine/ruleengineApi';
  144 + import {
  145 + screenLinkPageAddApi,
  146 + screenLinkPageUpdateApi,
  147 + screenLinkPageByDeptIdGetDevice,
  148 + } from '/@/api/ruleengine/ruleengineApi';
144 149 import { useMessage } from '/@/hooks/web/useMessage';
145 150 import AddTriggerForm from './addForm/trigger.vue';
146 151 import AddConditiForm from './addForm/condition.vue';
... ... @@ -216,7 +221,7 @@
216 221 const getDeviceInfo = ref(null);
217 222 const getDeviceInfo1 = ref(null);
218 223 const getDeviceInfo2 = ref(null);
219   - const editReveiveData = ref<[]>([]);
  224 + const newFilterMap = ref<[]>([]);
220 225
221 226 const [registerForm, { resetFields, setFieldsValue, validateFields }] = useForm({
222 227 labelWidth: 120,
... ... @@ -228,26 +233,39 @@
228 233 await resetFields();
229 234 setDrawerProps({ confirmLoading: false });
230 235 isUpdate.value = !!data?.isUpdate;
231   -
232 236 if (!unref(isUpdate)) {
233 237 try {
234 238 proxy.$refs.refTriggerChild.clearSelectDevice();
  239 + proxy.$refs.refTriggerChild.clearSelectScene();
235 240 proxy.$refs.refConditionChild.clearSelectDevice();
236 241 proxy.$refs.refActionChild.clearSelectDevice();
237 242 } catch (e) {
238 243 return e;
239 244 }
240   - }
241   - if (unref(isUpdate)) {
242   - //编辑
  245 + } else {
  246 + newFilterMap.value = [];
243 247 clearAllArrayFunc();
  248 + editTriggerPushData.value = [];
  249 + lastEditRefTriggerChildDataArray.value = [];
244 250 getId.value = data.record.id;
245 251 getTenantId.value = data.record.tenantId;
246 252 await setFieldsValue({
247 253 ...data.record,
248 254 });
249   - editReveiveData.value = data.record.triggers;
250   - editTriggerPushData.value = editReveiveData.value;
  255 + editTriggerPushData.value = data.record.triggers;
  256 + const options = await screenLinkPageByDeptIdGetDevice({
  257 + organizationId: data.record.organizationId,
  258 + });
  259 + data.record.triggers.forEach((f1) => {
  260 + options.items.forEach((f2) => {
  261 + if (f2.id == f1.deviceId) {
  262 + newFilterMap.value.push({
  263 + value: f2.id,
  264 + label: f2.name,
  265 + });
  266 + }
  267 + });
  268 + });
251 269 }
252 270 });
253 271 const getTitle = computed(() => (!unref(isUpdate) ? '新增场景联动' : '编辑场景联动'));
... ... @@ -259,7 +277,7 @@
259 277 lastRefTriggerChildDataArray.value.length = 0;
260 278 lastRefConditionChildDataArray.value.length = 0;
261 279 lastRefActionChildDataArray.value.length = 0;
262   - // lastEditRefTriggerChildDataArray.value.length = 0;
  280 + lastEditRefTriggerChildDataArray.value.length = 0;
263 281 };
264 282 const resetActionsAllArrayFunc = () => {
265 283 try {
... ... @@ -444,6 +462,7 @@
444 462 };
445 463
446 464 return {
  465 + newFilterMap,
447 466 editTriggerPushData,
448 467 isUpdate,
449 468 clearActionsAllDevice,
... ...