Commit 15e508c78dbf0d10c108a6e3742c122cd865c020
Merge branch 'ft-dev' into 'main'
fix:修复租户角色回显问题,修复场景联动中新增时应该清处请选择设备问题 See merge request huang/yun-teng-iot-front!82
Showing
11 changed files
with
135 additions
and
47 deletions
1 | 1 | import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'; |
2 | - | |
3 | 2 | import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'; |
4 | - | |
5 | 3 | import { mainOutRoutes } from './mainOut'; |
6 | 4 | import { PageEnum } from '/@/enums/pageEnum'; |
7 | 5 | import { t } from '/@/hooks/web/useI18n'; |
8 | 6 | |
9 | 7 | const modules = import.meta.globEager('./modules/**/*.ts'); |
10 | - | |
11 | 8 | const routeModuleList: AppRouteModule[] = []; |
12 | - | |
13 | 9 | Object.keys(modules).forEach((key) => { |
14 | 10 | const mod = modules[key].default || {}; |
15 | 11 | const modList = Array.isArray(mod) ? [...mod] : [mod]; |
16 | 12 | routeModuleList.push(...modList); |
17 | 13 | }); |
18 | - | |
19 | 14 | export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; |
20 | - | |
21 | 15 | export const RootRoute: AppRouteRecordRaw = { |
22 | 16 | path: '/', |
23 | 17 | name: 'Root', |
24 | - // redirect: '/', | |
25 | 18 | redirect: PageEnum.BASE_HOME, |
26 | - // redirect: !PageEnum.BASE_HOME ? '/dashboard' : PageEnum.BASE_HOME, | |
27 | - // redirect: '/dashboard', | |
28 | 19 | meta: { |
29 | 20 | title: 'Root', |
30 | 21 | }, | ... | ... |
... | ... | @@ -99,6 +99,23 @@ |
99 | 99 | function funcResetFields() { |
100 | 100 | resetFields(); |
101 | 101 | } |
102 | + //新增清空设备选择 | |
103 | + const clearSelectDevice = () => { | |
104 | + updateSchema({ | |
105 | + field: 'deviceId', | |
106 | + componentProps: { | |
107 | + options: [], | |
108 | + }, | |
109 | + }); | |
110 | + }; | |
111 | + const editSelectDevice = (v) => { | |
112 | + updateSchema({ | |
113 | + field: 'deviceId', | |
114 | + componentProps: { | |
115 | + options: v, | |
116 | + }, | |
117 | + }); | |
118 | + }; | |
102 | 119 | |
103 | 120 | const n = ref(1); |
104 | 121 | function add() { |
... | ... | @@ -311,7 +328,16 @@ |
311 | 328 | ]); |
312 | 329 | n.value--; |
313 | 330 | } |
314 | - return { setFieldsFormValue, registerCondition, add, del, getAllFields, funcResetFields }; | |
331 | + return { | |
332 | + editSelectDevice, | |
333 | + clearSelectDevice, | |
334 | + setFieldsFormValue, | |
335 | + registerCondition, | |
336 | + add, | |
337 | + del, | |
338 | + getAllFields, | |
339 | + funcResetFields, | |
340 | + }; | |
315 | 341 | }, |
316 | 342 | }); |
317 | 343 | </script> | ... | ... |
... | ... | @@ -93,6 +93,23 @@ |
93 | 93 | function funcResetFields() { |
94 | 94 | resetFields(); |
95 | 95 | } |
96 | + //新增清空设备选择 | |
97 | + const clearSelectDevice = () => { | |
98 | + updateSchema({ | |
99 | + field: 'deviceId', | |
100 | + componentProps: { | |
101 | + options: [], | |
102 | + }, | |
103 | + }); | |
104 | + }; | |
105 | + const editSelectDevice = (v) => { | |
106 | + updateSchema({ | |
107 | + field: 'deviceId', | |
108 | + componentProps: { | |
109 | + options: v, | |
110 | + }, | |
111 | + }); | |
112 | + }; | |
96 | 113 | const n = ref(1); |
97 | 114 | function add() { |
98 | 115 | appendSchemaByField( |
... | ... | @@ -236,7 +253,16 @@ |
236 | 253 | n.value--; |
237 | 254 | } |
238 | 255 | |
239 | - return { setFieldsFormValue, registerAction, add, del, getAllFields, funcResetFields }; | |
256 | + return { | |
257 | + editSelectDevice, | |
258 | + clearSelectDevice, | |
259 | + setFieldsFormValue, | |
260 | + registerAction, | |
261 | + add, | |
262 | + del, | |
263 | + getAllFields, | |
264 | + funcResetFields, | |
265 | + }; | |
240 | 266 | }, |
241 | 267 | }); |
242 | 268 | </script> | ... | ... |
... | ... | @@ -101,6 +101,23 @@ |
101 | 101 | const setFieldsFormValue = (v) => { |
102 | 102 | setFieldsValue(v); |
103 | 103 | }; |
104 | + //新增清空设备选择 | |
105 | + const clearSelectDevice = () => { | |
106 | + updateSchema({ | |
107 | + field: 'deviceId', | |
108 | + componentProps: { | |
109 | + options: [], | |
110 | + }, | |
111 | + }); | |
112 | + }; | |
113 | + const editSelectDevice = (v) => { | |
114 | + updateSchema({ | |
115 | + field: 'deviceId', | |
116 | + componentProps: { | |
117 | + options: v, | |
118 | + }, | |
119 | + }); | |
120 | + }; | |
104 | 121 | // //去除字符串的数字 |
105 | 122 | // function trimNumber(str) { |
106 | 123 | // return str.replace(/\d+/g, ''); |
... | ... | @@ -119,16 +136,15 @@ |
119 | 136 | console.log(getPushValueData.value); |
120 | 137 | return getV; |
121 | 138 | } |
122 | - function funcResetFields() { | |
123 | - resetFields(); | |
139 | + async function funcResetFields() { | |
140 | + await resetFields(); | |
124 | 141 | } |
125 | 142 | const addString: any = ref('tiggerEvent1') || ref('tiggerEvent2') || ref('tiggerEvent3'); |
126 | 143 | |
127 | 144 | const n = ref(1); |
128 | 145 | function add() { |
129 | - const values = getFieldsValue(); | |
130 | - getPushValueData.value.push(values); | |
131 | - console.log(getPushValueData.value); | |
146 | + // const values = getFieldsValue(); | |
147 | + // getPushValueData.value.push(values); | |
132 | 148 | // newMapGetPushValueData.value = getPushValueData.value.map((m) => { |
133 | 149 | // const getKeys = Object.keys(m); |
134 | 150 | // getKeys.map((f) => { |
... | ... | @@ -372,6 +388,8 @@ |
372 | 388 | n.value--; |
373 | 389 | } |
374 | 390 | return { |
391 | + editSelectDevice, | |
392 | + clearSelectDevice, | |
375 | 393 | clearGetPushValueDataEmpty, |
376 | 394 | setFieldsFormValue, |
377 | 395 | registerTrigger, | ... | ... |
... | ... | @@ -292,10 +292,8 @@ export const useTriggerDrawerSchema: FormSchema[] = [ |
292 | 292 | field: 'deviceId', |
293 | 293 | label: '', |
294 | 294 | component: 'Select', |
295 | - componentProps() { | |
296 | - return { | |
297 | - placeholder: '请选择设备', | |
298 | - }; | |
295 | + componentProps: { | |
296 | + placeholder: '请选择设备', | |
299 | 297 | }, |
300 | 298 | // componentProps: { |
301 | 299 | // placeholder: '请选择设备', | ... | ... |
... | ... | @@ -18,7 +18,11 @@ |
18 | 18 | import { BasicForm, useForm } from '/@/components/Form'; |
19 | 19 | import { formSchema, getData } from './config.d'; |
20 | 20 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; |
21 | - import { screenLinkPageAddApi, screenLinkPageUpdateApi } from '/@/api/ruleengine/ruleengineApi'; | |
21 | + import { | |
22 | + screenLinkPageAddApi, | |
23 | + screenLinkPageUpdateApi, | |
24 | + screenLinkPageByDeptIdGetDevice, | |
25 | + } from '/@/api/ruleengine/ruleengineApi'; | |
22 | 26 | import { useMessage } from '/@/hooks/web/useMessage'; |
23 | 27 | import AddTriggerForm from './addForm/trigger.vue'; |
24 | 28 | import AddActionForm from './addForm/doaction.vue'; |
... | ... | @@ -45,12 +49,14 @@ |
45 | 49 | let getDeviceInfo1 = ref(null); |
46 | 50 | let getDeviceInfo2 = ref(null); |
47 | 51 | |
48 | - const [registerForm, { resetFields, setFieldsValue, validateFields, getFieldsValue }] = | |
49 | - useForm({ | |
50 | - labelWidth: 120, | |
51 | - schemas: formSchema, | |
52 | - showActionButtonGroup: false, | |
53 | - }); | |
52 | + const [ | |
53 | + registerForm, | |
54 | + { resetFields, setFieldsValue, validateFields, getFieldsValue, updateSchema }, | |
55 | + ] = useForm({ | |
56 | + labelWidth: 120, | |
57 | + schemas: formSchema, | |
58 | + showActionButtonGroup: false, | |
59 | + }); | |
54 | 60 | |
55 | 61 | watch(getData, (newV) => { |
56 | 62 | getDeviceInfo.value = newV; |
... | ... | @@ -59,18 +65,55 @@ |
59 | 65 | }); |
60 | 66 | |
61 | 67 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
62 | - proxy.$refs.getChildData.funcResetFields(); | |
63 | - proxy.$refs.getTriggerChildData.funcResetFields(); | |
64 | - proxy.$refs.getConditionChildData.funcResetFields(); | |
68 | + console.log(data); | |
65 | 69 | await resetFields(); |
66 | 70 | setDrawerProps({ confirmLoading: false }); |
67 | 71 | isUpdate.value = !!data?.isUpdate; |
72 | + | |
73 | + if (!unref(isUpdate)) { | |
74 | + proxy.$refs.getTriggerChildData.clearSelectDevice(); | |
75 | + proxy.$refs.getChildData.clearSelectDevice(); | |
76 | + proxy.$refs.getConditionChildData.clearSelectDevice(); | |
77 | + proxy.$refs.getChildData.funcResetFields(); | |
78 | + proxy.$refs.getTriggerChildData.funcResetFields(); | |
79 | + proxy.$refs.getConditionChildData.funcResetFields(); | |
80 | + } | |
68 | 81 | //编辑 |
69 | 82 | if (unref(isUpdate)) { |
70 | 83 | getId.value = data.record.id; |
71 | 84 | await setFieldsValue({ |
72 | 85 | ...data.record, |
73 | 86 | }); |
87 | + let newMap = null; | |
88 | + let newFilterMap = null; | |
89 | + let newTwoFilterMap = null; | |
90 | + let newFilterTwoFilterMap = null; | |
91 | + const options = await screenLinkPageByDeptIdGetDevice({ | |
92 | + organizationId: data.record.organizationId, | |
93 | + }); | |
94 | + newMap = options.items.map((m) => { | |
95 | + newTwoFilterMap = data.record?.triggers.map((m1) => { | |
96 | + if (m.id == m1.deviceId) { | |
97 | + return { | |
98 | + value: m.id, | |
99 | + label: m.name, | |
100 | + }; | |
101 | + } | |
102 | + }); | |
103 | + | |
104 | + if (m.id == data.record?.triggers[0].deviceId) { | |
105 | + return { | |
106 | + value: m.id, | |
107 | + label: m.name, | |
108 | + }; | |
109 | + } | |
110 | + }); | |
111 | + newFilterMap = newMap.filter((f) => f !== undefined); | |
112 | + newFilterTwoFilterMap = newTwoFilterMap.filter((f) => f !== undefined); | |
113 | + proxy.$refs.getTriggerChildData.editSelectDevice(newFilterMap); | |
114 | + proxy.$refs.getChildData.editSelectDevice(newFilterMap); | |
115 | + proxy.$refs.getConditionChildData.editSelectDevice(newFilterMap); | |
116 | + | |
74 | 117 | try { |
75 | 118 | proxy.$refs.getTriggerChildData.setFieldsFormValue({ |
76 | 119 | triggerEvent: data.record.triggers[0].triggerEvent, | ... | ... |
... | ... | @@ -105,7 +105,7 @@ |
105 | 105 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); |
106 | 106 | treeData.value.map((m) => { |
107 | 107 | roleMenus.value.map((m1) => { |
108 | - if (m.key === m1) { | |
108 | + if (m.key === m1 && m.children.length !== 0) { | |
109 | 109 | proxy.useChildrenIdsRemoveParentId(m1, roleMenus.value); |
110 | 110 | } |
111 | 111 | }); |
... | ... | @@ -117,17 +117,6 @@ |
117 | 117 | ...data.record, |
118 | 118 | }); |
119 | 119 | } |
120 | - | |
121 | - // if (data.record) { | |
122 | - // roleMenus.value = await getMenusIdsByRoleId(data.record.id); | |
123 | - // roleId.value = data.record.id; | |
124 | - // } | |
125 | - // isUpdate.value = !!data?.isUpdate; | |
126 | - // if (unref(isUpdate)) { | |
127 | - // setFieldsValue({ | |
128 | - // ...data.record, | |
129 | - // }); | |
130 | - // } | |
131 | 120 | }); |
132 | 121 | |
133 | 122 | // Tree check事件 | ... | ... |