Commit e57839398e415c9b445d13de6d187d842e3a1346
Merge branch 'f-dev' into 'main'
fix:修改teambition上的问题 See merge request huang/yun-teng-iot-front!233
Showing
13 changed files
with
84 additions
and
22 deletions
| ... | ... | @@ -17,7 +17,7 @@ enum ScreenManagerApi { |
| 17 | 17 | SCREEN_UPDATE_URL = '/sceneLinkage/update', |
| 18 | 18 | SCREEN_ORGANIZATION_URL = '/organization/me/list', |
| 19 | 19 | SCREEN_CHANGE_STATUS = '/convert/update/scene', |
| 20 | - SCREEN_GET_BY_DEPTID = '/sceneLinkage/device', | |
| 20 | + SCREEN_GET_BY_DEPTID = '/sceneLinkage/device/', | |
| 21 | 21 | GET_ATTRBUTELIST = '/device/keys', |
| 22 | 22 | ALARM_PROFILE = '/alarm/profile/', |
| 23 | 23 | MASTER_GET_DEVICE = '/device/list/master', | ... | ... |
| 1 | 1 | import { FormSchema } from '/@/components/Table'; |
| 2 | -import { phoneRule, emailRule } from '/@/utils/rules'; | |
| 2 | +import { phoneRule, emailRule, chineseAndEnlishRule } from '/@/utils/rules'; | |
| 3 | 3 | |
| 4 | 4 | export const formSchema: FormSchema[] = [ |
| 5 | 5 | { |
| ... | ... | @@ -12,6 +12,7 @@ export const formSchema: FormSchema[] = [ |
| 12 | 12 | maxLength: 10, |
| 13 | 13 | placeholder: '请输入用户昵称', |
| 14 | 14 | }, |
| 15 | + rules: chineseAndEnlishRule, | |
| 15 | 16 | }, |
| 16 | 17 | { |
| 17 | 18 | field: 'phoneNumber', | ... | ... |
| ... | ... | @@ -20,6 +20,23 @@ export const numberRule: Rule[] = [ |
| 20 | 20 | ]; |
| 21 | 21 | export const phoneRegexp = /^[1][3,4,5,6,7,8,9][0-9]{9}$/; |
| 22 | 22 | |
| 23 | +//中英文正则 | |
| 24 | +export const chineseAndEnlishRule: Rule[] = [ | |
| 25 | + { | |
| 26 | + required: true, | |
| 27 | + validator: (_, value: string) => { | |
| 28 | + const reg = /^[a-zA-Z\u4e00-\u9fa5]+$/; | |
| 29 | + if (value === '') { | |
| 30 | + return Promise.reject('请输入'); | |
| 31 | + } else if (!reg.test(value)) { | |
| 32 | + return Promise.reject('格式不正确'); | |
| 33 | + } | |
| 34 | + return Promise.resolve(); | |
| 35 | + }, | |
| 36 | + validateTrigger: 'blur', | |
| 37 | + }, | |
| 38 | +]; | |
| 39 | + | |
| 23 | 40 | // 手机号验证 |
| 24 | 41 | export const phoneRule: Rule[] = [ |
| 25 | 42 | { |
| ... | ... | @@ -41,7 +58,7 @@ export const phoneRule: Rule[] = [ |
| 41 | 58 | export const emailRule: Rule[] = [ |
| 42 | 59 | { |
| 43 | 60 | validator: (_, value: string) => { |
| 44 | - const reg = /^[a-zA-Z0-9_.-]+@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.[a-zA-Z0-9]{2,6}$/; | |
| 61 | + const reg = /^[a-zA-Z0-9]+([-_.][A-Za-zd]+)*@([a-zA-Z0-9]+[-.])+[A-Za-zd]{2,5}$/; | |
| 45 | 62 | if (!value) { |
| 46 | 63 | return Promise.resolve(); |
| 47 | 64 | } else if (!reg.test(value)) { | ... | ... |
| ... | ... | @@ -96,7 +96,7 @@ |
| 96 | 96 | import { useMessage } from '/@/hooks/web/useMessage'; |
| 97 | 97 | import { |
| 98 | 98 | screenLinkPageAddApi, |
| 99 | - // screenLinkPageByDeptIdGetDevice, | |
| 99 | + screenLinkPageByDeptIdGetDevice, | |
| 100 | 100 | getOrganizationAlarmConfig, |
| 101 | 101 | byOganizationIdGetMasterDevice, |
| 102 | 102 | getAttribute, |
| ... | ... | @@ -125,6 +125,7 @@ |
| 125 | 125 | let getConditionFormValue = ref([]); |
| 126 | 126 | let getActionFormValue = ref([]); |
| 127 | 127 | const editEntryIdData = ref([]); |
| 128 | + const editEntryIdExcludeDoActionData = ref([]); | |
| 128 | 129 | let editAttrIdData = []; |
| 129 | 130 | const editAlarmConfigData = ref([]); |
| 130 | 131 | const isUpdate = ref(false); |
| ... | ... | @@ -160,6 +161,7 @@ |
| 160 | 161 | provideOrgid.value = organizationId; |
| 161 | 162 | // 获取当前组织下的设备列表 |
| 162 | 163 | const options = await byOganizationIdGetMasterDevice(organizationId); |
| 164 | + const optionsExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId }); | |
| 163 | 165 | // 获取当前组织下的告警配置 |
| 164 | 166 | const alarmConfig = await getOrganizationAlarmConfig({ organizationId }); |
| 165 | 167 | // 获取当前组织下的属性列表 |
| ... | ... | @@ -179,6 +181,12 @@ |
| 179 | 181 | label: item.name, |
| 180 | 182 | }; |
| 181 | 183 | }); |
| 184 | + editEntryIdExcludeDoActionData.value = optionsExcludeDoAction.items.map((item) => { | |
| 185 | + return { | |
| 186 | + value: item.tbDeviceId, | |
| 187 | + label: item.name, | |
| 188 | + }; | |
| 189 | + }); | |
| 182 | 190 | editAlarmConfigData.value = alarmConfig.map((item) => { |
| 183 | 191 | return { |
| 184 | 192 | value: item.id, |
| ... | ... | @@ -189,8 +197,8 @@ |
| 189 | 197 | //回显属性列表 |
| 190 | 198 | editAttrIdData = attrList; |
| 191 | 199 | nextTick(() => { |
| 192 | - setEditFields(skipUnwrap.triggerItemRefs, editEntryIdData); | |
| 193 | - setEditFields(skipUnwrap.conditionItemRefs, editEntryIdData); | |
| 200 | + setEditFields(skipUnwrap.triggerItemRefs, editEntryIdExcludeDoActionData); | |
| 201 | + setEditFields(skipUnwrap.conditionItemRefs, editEntryIdExcludeDoActionData); | |
| 194 | 202 | setEditFields(skipUnwrap.actionItemRefs, editEntryIdData); |
| 195 | 203 | setEditAlarmConfig(skipUnwrap.actionItemRefs, editAlarmConfigData); |
| 196 | 204 | setEditAttr(skipUnwrap.triggerItemRefs, editAttrIdData); |
| ... | ... | @@ -482,7 +490,11 @@ |
| 482 | 490 | // 设置设备的options |
| 483 | 491 | const setEditFields = (linkAge, deviceList) => { |
| 484 | 492 | unref(linkAge).map((item) => { |
| 485 | - item.updateFieldDeviceId(deviceList); | |
| 493 | + if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') { | |
| 494 | + item.updateExcludeActionFieldDeviceId(deviceList); | |
| 495 | + } else { | |
| 496 | + item.updateFieldDeviceId(deviceList); | |
| 497 | + } | |
| 486 | 498 | }); |
| 487 | 499 | }; |
| 488 | 500 | // 设置告警配置options |
| ... | ... | @@ -502,10 +514,16 @@ |
| 502 | 514 | const deviceList = ref([]); |
| 503 | 515 | const alarmConfigList = ref([]); |
| 504 | 516 | let watchAttrList = []; |
| 517 | + const deviceExcludeDoAction = ref([]); | |
| 505 | 518 | watch(organizationId, async (newValue: string) => { |
| 506 | 519 | if (!newValue) return; |
| 507 | 520 | provideOrgid.value = newValue; |
| 508 | 521 | const items = await byOganizationIdGetMasterDevice(newValue); |
| 522 | + const itemExcludeDoAction = await screenLinkPageByDeptIdGetDevice({ organizationId: newValue }); | |
| 523 | + deviceExcludeDoAction.value = itemExcludeDoAction.items.map((item) => ({ | |
| 524 | + label: item.name, | |
| 525 | + value: item.tbDeviceId, | |
| 526 | + })); | |
| 509 | 527 | deviceList.value = items.map((item) => ({ label: item.name, value: item.id })); |
| 510 | 528 | watchAttrList = await getAttribute(newValue, null); |
| 511 | 529 | setFields(skipUnwrap.triggerItemRefs, true); |
| ... | ... | @@ -520,7 +538,12 @@ |
| 520 | 538 | function setFields(linkAge, isOrganizationChange = false) { |
| 521 | 539 | unref(linkAge).map((item) => { |
| 522 | 540 | isOrganizationChange && item.resetFieldsValueFunc(); |
| 523 | - item.updateFieldDeviceId(deviceList); | |
| 541 | + console.log(item); | |
| 542 | + if (item.isTriggerAndConditionFlag == 'isTriggerAndConditionFlag') { | |
| 543 | + item.updateExcludeActionFieldDeviceId(deviceExcludeDoAction); | |
| 544 | + } else { | |
| 545 | + item.updateFieldDeviceId(deviceList); | |
| 546 | + } | |
| 524 | 547 | // item.updateFieldAttr(watchAttrList); |
| 525 | 548 | }); |
| 526 | 549 | } | ... | ... |
| ... | ... | @@ -98,7 +98,7 @@ |
| 98 | 98 | ); |
| 99 | 99 | return { ...getFieldsValue(), predicate, schedule: alarmScheduleRef.value.scheduleData }; |
| 100 | 100 | }; |
| 101 | - const updateFieldDeviceId = (deviceList: any[]) => { | |
| 101 | + const updateExcludeActionFieldDeviceId = (deviceList: any[]) => { | |
| 102 | 102 | updateSchema({ |
| 103 | 103 | field: 'entityId', |
| 104 | 104 | componentProps: { |
| ... | ... | @@ -195,9 +195,11 @@ |
| 195 | 195 | currentIndex.value = index; |
| 196 | 196 | }; |
| 197 | 197 | const scheduleData = ref(null); |
| 198 | + const isTriggerAndConditionFlag = 'isTriggerAndConditionFlag'; | |
| 198 | 199 | defineExpose({ |
| 200 | + isTriggerAndConditionFlag, | |
| 199 | 201 | getFieldsValueFunc, |
| 200 | - updateFieldDeviceId, | |
| 202 | + updateExcludeActionFieldDeviceId, | |
| 201 | 203 | updateFieldAttr, |
| 202 | 204 | resetFieldsValueFunc, |
| 203 | 205 | setFieldsFormValueFun, | ... | ... |
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | formConfig: { |
| 46 | 46 | labelWidth: 120, |
| 47 | 47 | schemas: searchFormSchema, |
| 48 | - fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 48 | + fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'x']], | |
| 49 | 49 | }, |
| 50 | 50 | useSearchForm: true, |
| 51 | 51 | showTableSetting: true, | ... | ... |
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | formConfig: { |
| 46 | 46 | labelWidth: 120, |
| 47 | 47 | schemas: searchFormSchema, |
| 48 | - fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 48 | + fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'x']], | |
| 49 | 49 | }, |
| 50 | 50 | useSearchForm: true, |
| 51 | 51 | showTableSetting: true, | ... | ... |
| ... | ... | @@ -45,7 +45,7 @@ |
| 45 | 45 | formConfig: { |
| 46 | 46 | labelWidth: 120, |
| 47 | 47 | schemas: searchFormSchema, |
| 48 | - fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'YYYY-MM-DD HH:mm:ss']], | |
| 48 | + fieldMapToTime: [['queryTime', ['startTime', 'endTime'], 'x']], | |
| 49 | 49 | }, |
| 50 | 50 | useSearchForm: true, |
| 51 | 51 | showTableSetting: true, | ... | ... |
| ... | ... | @@ -13,7 +13,7 @@ |
| 13 | 13 | v-if="treeData.length" |
| 14 | 14 | checkable |
| 15 | 15 | toolbar |
| 16 | - autoExpandParent | |
| 16 | + :expandedKeys="treeExpandData" | |
| 17 | 17 | ref="treeRef" |
| 18 | 18 | :treeData="treeData" |
| 19 | 19 | :replaceFields="{ title: 'menuName' }" |
| ... | ... | @@ -43,6 +43,7 @@ |
| 43 | 43 | components: { BasicDrawer, BasicForm, BasicTree }, |
| 44 | 44 | emits: ['success', 'register'], |
| 45 | 45 | setup(_, { emit }) { |
| 46 | + const treeExpandData = ref([]); | |
| 46 | 47 | const isUpdate = ref<boolean>(true); |
| 47 | 48 | const treeData = ref<TreeItem[]>([]); |
| 48 | 49 | const roleMenus = ref<string[]>([]); |
| ... | ... | @@ -69,13 +70,12 @@ |
| 69 | 70 | } |
| 70 | 71 | }); |
| 71 | 72 | } |
| 72 | - // function lookForAllId(data = [], arr = []) { | |
| 73 | - // for (const item of data) { | |
| 74 | - // arr.push(item.parentId); | |
| 75 | - // if (item.children && item.children.length > 0) lookForAllId(item.children, arr); | |
| 76 | - // } | |
| 77 | - // return arr; | |
| 78 | - // } | |
| 73 | + function lookForAllId(data = [], arr = []) { | |
| 74 | + for (const item of data) { | |
| 75 | + arr.push(item.id); | |
| 76 | + } | |
| 77 | + return arr; | |
| 78 | + } | |
| 79 | 79 | const originMenus = ref(); |
| 80 | 80 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 81 | 81 | allCheckedKeys.value = []; |
| ... | ... | @@ -98,6 +98,9 @@ |
| 98 | 98 | //通过角色id去获取角色对应的菜单的ids |
| 99 | 99 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); |
| 100 | 100 | originMenus.value = [...roleMenus.value]; |
| 101 | + | |
| 102 | + const getAllIds = lookForAllId(treeData.value, []); | |
| 103 | + treeExpandData.value = getAllIds; | |
| 101 | 104 | for (let item of treeData.value) { |
| 102 | 105 | if (item?.children != 0) { |
| 103 | 106 | pidArr.value.push(item.key); |
| ... | ... | @@ -138,7 +141,6 @@ |
| 138 | 141 | status: values.status, |
| 139 | 142 | menu: allCheckedKeys.value.length ? allCheckedKeys.value : originMenus.value, |
| 140 | 143 | }; |
| 141 | - console.log(allCheckedKeys.value); | |
| 142 | 144 | if (allCheckedKeys.value.length == 0) return createMessage.error('请勾选权限菜单'); |
| 143 | 145 | if (req.menu == undefined) return createMessage.error('请勾选权限菜单'); |
| 144 | 146 | saveOrUpdateRoleInfoWithMenu(req).then(() => { |
| ... | ... | @@ -165,6 +167,7 @@ |
| 165 | 167 | treeRef, |
| 166 | 168 | handleCheckClick, |
| 167 | 169 | allCheckedKeys, |
| 170 | + treeExpandData, | |
| 168 | 171 | }; |
| 169 | 172 | }, |
| 170 | 173 | }); | ... | ... |
| ... | ... | @@ -18,6 +18,7 @@ |
| 18 | 18 | import { UserDTO } from '/@/api/tenant/tenantInfo'; |
| 19 | 19 | import { ChineseRegexp, EmailRegexp, emailRule, phoneRule } from '/@/utils/rules'; |
| 20 | 20 | // import { isAccountExist } from '/@/api/system/system'; |
| 21 | + import { chineseAndEnlishRule } from '/@/utils/rules'; | |
| 21 | 22 | |
| 22 | 23 | export default defineComponent({ |
| 23 | 24 | name: 'TenantAdminFormDrawer', |
| ... | ... | @@ -88,6 +89,7 @@ |
| 88 | 89 | componentProps: { |
| 89 | 90 | maxLength: 255, |
| 90 | 91 | }, |
| 92 | + rules: chineseAndEnlishRule, | |
| 91 | 93 | }, |
| 92 | 94 | { |
| 93 | 95 | field: 'phoneNumber', | ... | ... |
| ... | ... | @@ -12,6 +12,7 @@ |
| 12 | 12 | <BasicTree |
| 13 | 13 | v-if="treeData.length > 0" |
| 14 | 14 | :treeData="treeData" |
| 15 | + :expandedKeys="treeExpandData" | |
| 15 | 16 | autoExpandParent |
| 16 | 17 | :replaceFields="{ title: 'menuName' }" |
| 17 | 18 | :checkedKeys="roleMenus" |
| ... | ... | @@ -46,6 +47,8 @@ |
| 46 | 47 | components: { BasicDrawer, BasicForm, BasicTree }, |
| 47 | 48 | emits: ['success', 'register'], |
| 48 | 49 | setup(_, { emit }) { |
| 50 | + const treeExpandData = ref([]); | |
| 51 | + | |
| 49 | 52 | const isUpdate = ref(true); |
| 50 | 53 | const treeData = ref<TreeItem[]>([]); |
| 51 | 54 | const roleMenus = ref<string[]>([]); |
| ... | ... | @@ -71,6 +74,12 @@ |
| 71 | 74 | } |
| 72 | 75 | }); |
| 73 | 76 | } |
| 77 | + function lookForAllId(data = [], arr = []) { | |
| 78 | + for (const item of data) { | |
| 79 | + arr.push(item.id); | |
| 80 | + } | |
| 81 | + return arr; | |
| 82 | + } | |
| 74 | 83 | |
| 75 | 84 | const originMenus = ref(); |
| 76 | 85 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| ... | ... | @@ -95,6 +104,8 @@ |
| 95 | 104 | //通过角色id去获取角色对应的菜单的ids |
| 96 | 105 | roleMenus.value = await getMenusIdsByRoleId(data.record.id); |
| 97 | 106 | originMenus.value = [...roleMenus.value]; |
| 107 | + const getAllIds = lookForAllId(treeData.value, []); | |
| 108 | + treeExpandData.value = getAllIds; | |
| 98 | 109 | for (let item of treeData.value) { |
| 99 | 110 | if (item?.children != 0) { |
| 100 | 111 | pidArr.value.push(item.key); |
| ... | ... | @@ -160,6 +171,7 @@ |
| 160 | 171 | roleMenus, |
| 161 | 172 | treeRef, |
| 162 | 173 | handleCheckClick, |
| 174 | + treeExpandData, | |
| 163 | 175 | }; |
| 164 | 176 | }, |
| 165 | 177 | }); | ... | ... |