Commit 82443355c72a0c7429d7957b1108a50085869ab1
1 parent
7c87f4b7
fix:修复租户角色回显问题,修复场景联动中新增时应该清处请选择设备问题
Showing
11 changed files
with
135 additions
and
47 deletions
| 1 | import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'; | 1 | import type { AppRouteRecordRaw, AppRouteModule } from '/@/router/types'; |
| 2 | - | ||
| 3 | import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'; | 2 | import { PAGE_NOT_FOUND_ROUTE, REDIRECT_ROUTE } from '/@/router/routes/basic'; |
| 4 | - | ||
| 5 | import { mainOutRoutes } from './mainOut'; | 3 | import { mainOutRoutes } from './mainOut'; |
| 6 | import { PageEnum } from '/@/enums/pageEnum'; | 4 | import { PageEnum } from '/@/enums/pageEnum'; |
| 7 | import { t } from '/@/hooks/web/useI18n'; | 5 | import { t } from '/@/hooks/web/useI18n'; |
| 8 | 6 | ||
| 9 | const modules = import.meta.globEager('./modules/**/*.ts'); | 7 | const modules = import.meta.globEager('./modules/**/*.ts'); |
| 10 | - | ||
| 11 | const routeModuleList: AppRouteModule[] = []; | 8 | const routeModuleList: AppRouteModule[] = []; |
| 12 | - | ||
| 13 | Object.keys(modules).forEach((key) => { | 9 | Object.keys(modules).forEach((key) => { |
| 14 | const mod = modules[key].default || {}; | 10 | const mod = modules[key].default || {}; |
| 15 | const modList = Array.isArray(mod) ? [...mod] : [mod]; | 11 | const modList = Array.isArray(mod) ? [...mod] : [mod]; |
| 16 | routeModuleList.push(...modList); | 12 | routeModuleList.push(...modList); |
| 17 | }); | 13 | }); |
| 18 | - | ||
| 19 | export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; | 14 | export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; |
| 20 | - | ||
| 21 | export const RootRoute: AppRouteRecordRaw = { | 15 | export const RootRoute: AppRouteRecordRaw = { |
| 22 | path: '/', | 16 | path: '/', |
| 23 | name: 'Root', | 17 | name: 'Root', |
| 24 | - // redirect: '/', | ||
| 25 | redirect: PageEnum.BASE_HOME, | 18 | redirect: PageEnum.BASE_HOME, |
| 26 | - // redirect: !PageEnum.BASE_HOME ? '/dashboard' : PageEnum.BASE_HOME, | ||
| 27 | - // redirect: '/dashboard', | ||
| 28 | meta: { | 19 | meta: { |
| 29 | title: 'Root', | 20 | title: 'Root', |
| 30 | }, | 21 | }, |
| @@ -43,7 +43,6 @@ export const formSchema: FormSchema[] = [ | @@ -43,7 +43,6 @@ export const formSchema: FormSchema[] = [ | ||
| 43 | componentProps: { | 43 | componentProps: { |
| 44 | maxLength: 255, | 44 | maxLength: 255, |
| 45 | placeholder: '请输入设备名称', | 45 | placeholder: '请输入设备名称', |
| 46 | - maxLength: 255, | ||
| 47 | }, | 46 | }, |
| 48 | }, | 47 | }, |
| 49 | { | 48 | { |
| @@ -58,7 +58,6 @@ export const searchFormSchema: FormSchema[] = [ | @@ -58,7 +58,6 @@ export const searchFormSchema: FormSchema[] = [ | ||
| 58 | componentProps: { | 58 | componentProps: { |
| 59 | maxLength: 36, | 59 | maxLength: 36, |
| 60 | placeholder: '请输入联系人姓名', | 60 | placeholder: '请输入联系人姓名', |
| 61 | - maxLength: 36, | ||
| 62 | }, | 61 | }, |
| 63 | }, | 62 | }, |
| 64 | ]; | 63 | ]; |
| @@ -99,6 +99,23 @@ | @@ -99,6 +99,23 @@ | ||
| 99 | function funcResetFields() { | 99 | function funcResetFields() { |
| 100 | resetFields(); | 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 | const n = ref(1); | 120 | const n = ref(1); |
| 104 | function add() { | 121 | function add() { |
| @@ -311,7 +328,16 @@ | @@ -311,7 +328,16 @@ | ||
| 311 | ]); | 328 | ]); |
| 312 | n.value--; | 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 | </script> | 343 | </script> |
| @@ -93,6 +93,23 @@ | @@ -93,6 +93,23 @@ | ||
| 93 | function funcResetFields() { | 93 | function funcResetFields() { |
| 94 | resetFields(); | 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 | const n = ref(1); | 113 | const n = ref(1); |
| 97 | function add() { | 114 | function add() { |
| 98 | appendSchemaByField( | 115 | appendSchemaByField( |
| @@ -236,7 +253,16 @@ | @@ -236,7 +253,16 @@ | ||
| 236 | n.value--; | 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 | </script> | 268 | </script> |
| @@ -101,6 +101,23 @@ | @@ -101,6 +101,23 @@ | ||
| 101 | const setFieldsFormValue = (v) => { | 101 | const setFieldsFormValue = (v) => { |
| 102 | setFieldsValue(v); | 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 | // function trimNumber(str) { | 122 | // function trimNumber(str) { |
| 106 | // return str.replace(/\d+/g, ''); | 123 | // return str.replace(/\d+/g, ''); |
| @@ -119,16 +136,15 @@ | @@ -119,16 +136,15 @@ | ||
| 119 | console.log(getPushValueData.value); | 136 | console.log(getPushValueData.value); |
| 120 | return getV; | 137 | return getV; |
| 121 | } | 138 | } |
| 122 | - function funcResetFields() { | ||
| 123 | - resetFields(); | 139 | + async function funcResetFields() { |
| 140 | + await resetFields(); | ||
| 124 | } | 141 | } |
| 125 | const addString: any = ref('tiggerEvent1') || ref('tiggerEvent2') || ref('tiggerEvent3'); | 142 | const addString: any = ref('tiggerEvent1') || ref('tiggerEvent2') || ref('tiggerEvent3'); |
| 126 | 143 | ||
| 127 | const n = ref(1); | 144 | const n = ref(1); |
| 128 | function add() { | 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 | // newMapGetPushValueData.value = getPushValueData.value.map((m) => { | 148 | // newMapGetPushValueData.value = getPushValueData.value.map((m) => { |
| 133 | // const getKeys = Object.keys(m); | 149 | // const getKeys = Object.keys(m); |
| 134 | // getKeys.map((f) => { | 150 | // getKeys.map((f) => { |
| @@ -372,6 +388,8 @@ | @@ -372,6 +388,8 @@ | ||
| 372 | n.value--; | 388 | n.value--; |
| 373 | } | 389 | } |
| 374 | return { | 390 | return { |
| 391 | + editSelectDevice, | ||
| 392 | + clearSelectDevice, | ||
| 375 | clearGetPushValueDataEmpty, | 393 | clearGetPushValueDataEmpty, |
| 376 | setFieldsFormValue, | 394 | setFieldsFormValue, |
| 377 | registerTrigger, | 395 | registerTrigger, |
| @@ -292,10 +292,8 @@ export const useTriggerDrawerSchema: FormSchema[] = [ | @@ -292,10 +292,8 @@ export const useTriggerDrawerSchema: FormSchema[] = [ | ||
| 292 | field: 'deviceId', | 292 | field: 'deviceId', |
| 293 | label: '', | 293 | label: '', |
| 294 | component: 'Select', | 294 | component: 'Select', |
| 295 | - componentProps() { | ||
| 296 | - return { | ||
| 297 | - placeholder: '请选择设备', | ||
| 298 | - }; | 295 | + componentProps: { |
| 296 | + placeholder: '请选择设备', | ||
| 299 | }, | 297 | }, |
| 300 | // componentProps: { | 298 | // componentProps: { |
| 301 | // placeholder: '请选择设备', | 299 | // placeholder: '请选择设备', |
| @@ -18,7 +18,11 @@ | @@ -18,7 +18,11 @@ | ||
| 18 | import { BasicForm, useForm } from '/@/components/Form'; | 18 | import { BasicForm, useForm } from '/@/components/Form'; |
| 19 | import { formSchema, getData } from './config.d'; | 19 | import { formSchema, getData } from './config.d'; |
| 20 | import { BasicDrawer, useDrawerInner } from '/@/components/Drawer'; | 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 | import { useMessage } from '/@/hooks/web/useMessage'; | 26 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 23 | import AddTriggerForm from './addForm/trigger.vue'; | 27 | import AddTriggerForm from './addForm/trigger.vue'; |
| 24 | import AddActionForm from './addForm/doaction.vue'; | 28 | import AddActionForm from './addForm/doaction.vue'; |
| @@ -45,12 +49,14 @@ | @@ -45,12 +49,14 @@ | ||
| 45 | let getDeviceInfo1 = ref(null); | 49 | let getDeviceInfo1 = ref(null); |
| 46 | let getDeviceInfo2 = ref(null); | 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 | watch(getData, (newV) => { | 61 | watch(getData, (newV) => { |
| 56 | getDeviceInfo.value = newV; | 62 | getDeviceInfo.value = newV; |
| @@ -59,18 +65,55 @@ | @@ -59,18 +65,55 @@ | ||
| 59 | }); | 65 | }); |
| 60 | 66 | ||
| 61 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { | 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 | await resetFields(); | 69 | await resetFields(); |
| 66 | setDrawerProps({ confirmLoading: false }); | 70 | setDrawerProps({ confirmLoading: false }); |
| 67 | isUpdate.value = !!data?.isUpdate; | 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 | if (unref(isUpdate)) { | 82 | if (unref(isUpdate)) { |
| 70 | getId.value = data.record.id; | 83 | getId.value = data.record.id; |
| 71 | await setFieldsValue({ | 84 | await setFieldsValue({ |
| 72 | ...data.record, | 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 | try { | 117 | try { |
| 75 | proxy.$refs.getTriggerChildData.setFieldsFormValue({ | 118 | proxy.$refs.getTriggerChildData.setFieldsFormValue({ |
| 76 | triggerEvent: data.record.triggers[0].triggerEvent, | 119 | triggerEvent: data.record.triggers[0].triggerEvent, |
| @@ -70,10 +70,10 @@ | @@ -70,10 +70,10 @@ | ||
| 70 | if (value == findUserName?.username) { | 70 | if (value == findUserName?.username) { |
| 71 | reject('账号已存在'); | 71 | reject('账号已存在'); |
| 72 | } else { | 72 | } else { |
| 73 | - return reject(''); | 73 | + reject('请输入'); |
| 74 | } | 74 | } |
| 75 | } catch (e) { | 75 | } catch (e) { |
| 76 | - return e; | 76 | + return reject(e); |
| 77 | } | 77 | } |
| 78 | resolve(); | 78 | resolve(); |
| 79 | } | 79 | } |
| @@ -105,7 +105,7 @@ | @@ -105,7 +105,7 @@ | ||
| 105 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); | 105 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); |
| 106 | treeData.value.map((m) => { | 106 | treeData.value.map((m) => { |
| 107 | roleMenus.value.map((m1) => { | 107 | roleMenus.value.map((m1) => { |
| 108 | - if (m.key === m1) { | 108 | + if (m.key === m1 && m.children.length !== 0) { |
| 109 | proxy.useChildrenIdsRemoveParentId(m1, roleMenus.value); | 109 | proxy.useChildrenIdsRemoveParentId(m1, roleMenus.value); |
| 110 | } | 110 | } |
| 111 | }); | 111 | }); |
| @@ -117,17 +117,6 @@ | @@ -117,17 +117,6 @@ | ||
| 117 | ...data.record, | 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 | // Tree check事件 | 122 | // Tree check事件 |