Commit 7599ac86f23244300d38f0aa16ade2552b128a6d
1 parent
77398391
'换图标,换logo,修复路由,修复角色菜单不能正常清除,设备列表跳转修复'
Showing
14 changed files
with
56 additions
and
47 deletions
No preview for this file type
| ... | ... | @@ -61,9 +61,7 @@ |
| 61 | 61 | // components |
| 62 | 62 | import { Dropdown, Menu } from 'ant-design-vue'; |
| 63 | 63 | |
| 64 | - import { defineComponent, computed, getCurrentInstance, ref, reactive } from 'vue'; | |
| 65 | - | |
| 66 | - import { DOC_URL } from '/@/settings/siteSetting'; | |
| 64 | + import { defineComponent, computed, ref, reactive } from 'vue'; | |
| 67 | 65 | |
| 68 | 66 | import { useUserStore } from '/@/store/modules/user'; |
| 69 | 67 | import { useHeaderSetting } from '/@/hooks/setting/useHeaderSetting'; |
| ... | ... | @@ -72,7 +70,6 @@ |
| 72 | 70 | import { useModal } from '/@/components/Modal'; |
| 73 | 71 | import headerImg from '/@/assets/images/header.jpg'; |
| 74 | 72 | import { propTypes } from '/@/utils/propTypes'; |
| 75 | - import { openWindow } from '/@/utils'; | |
| 76 | 73 | import { createAsyncComponent } from '/@/utils/factory/createAsyncComponent'; |
| 77 | 74 | import { USER_INFO_KEY } from '/@/enums/cacheEnum'; |
| 78 | 75 | import { getAuthCache } from '/@/utils/auth'; |
| ... | ... | @@ -101,7 +98,6 @@ |
| 101 | 98 | realName: '', |
| 102 | 99 | }); |
| 103 | 100 | const userInfo = getAuthCache(USER_INFO_KEY); |
| 104 | - const { proxy } = getCurrentInstance(); | |
| 105 | 101 | const personalRef = ref(null); |
| 106 | 102 | const { prefixCls } = useDesign('header-user-dropdown'); |
| 107 | 103 | const { t } = useI18n(); |
| ... | ... | @@ -124,26 +120,17 @@ |
| 124 | 120 | function handleLoginOut() { |
| 125 | 121 | userStore.confirmLoginOut(); |
| 126 | 122 | } |
| 127 | - | |
| 128 | - // open doc | |
| 129 | - function openDoc() { | |
| 130 | - openWindow(DOC_URL); | |
| 131 | - } | |
| 132 | - | |
| 133 | 123 | function handleMenuClick(e: { key: MenuEvent }) { |
| 134 | 124 | switch (e.key) { |
| 135 | 125 | case 'logout': |
| 136 | 126 | handleLoginOut(); |
| 137 | 127 | break; |
| 138 | - case 'doc': | |
| 139 | - openDoc(); | |
| 128 | + case 'personal': | |
| 129 | + openPersonalFunc(); | |
| 140 | 130 | break; |
| 141 | 131 | case 'lock': |
| 142 | 132 | handleLock(); |
| 143 | 133 | break; |
| 144 | - case 'personal': | |
| 145 | - openPersonalFunc(); | |
| 146 | - break; | |
| 147 | 134 | case 'changePassword': |
| 148 | 135 | changePassword(); |
| 149 | 136 | break; | ... | ... |
| ... | ... | @@ -29,14 +29,24 @@ export function createPermissionGuard(router: Router) { |
| 29 | 29 | return; |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | + const token = userStore.getJwtToken; | |
| 32 | 33 | // Whitelist can be directly entered |
| 34 | + // 路由守卫拦截, 如果是已经登陆情况, 就不要回到登陆页面了; | |
| 33 | 35 | if (whitePathList.includes(to.path as PageEnum)) { |
| 36 | + if (to.path === LOGIN_PATH && token) { | |
| 37 | + const isSessionTimeout = userStore.getSessionTimeout; | |
| 38 | + try { | |
| 39 | + // await userStore.afterLoginAction(); | |
| 40 | + if (!isSessionTimeout) { | |
| 41 | + next((to.query?.redirect as string) || '/'); | |
| 42 | + return; | |
| 43 | + } | |
| 44 | + } catch {} | |
| 45 | + } | |
| 34 | 46 | next(); |
| 35 | 47 | return; |
| 36 | 48 | } |
| 37 | 49 | |
| 38 | - const token = userStore.getJwtToken; | |
| 39 | - | |
| 40 | 50 | // token does not exist |
| 41 | 51 | if (!token) { |
| 42 | 52 | // You can access without permission. You need to set the routing meta.ignoreAuth to true | ... | ... |
| ... | ... | @@ -101,14 +101,14 @@ export const useUserStore = defineStore({ |
| 101 | 101 | setAuthCache(REFRESH_TOKEN_KEY, refreshToken); |
| 102 | 102 | }, |
| 103 | 103 | setToken(info: string | undefined) { |
| 104 | - this.token = info; | |
| 105 | - setAuthCache(TOKEN_KEY, info); | |
| 104 | + this.jwtToken = info; | |
| 105 | + setAuthCache(JWT_TOKEN_KEY, info); | |
| 106 | 106 | }, |
| 107 | 107 | setRoleList(roleList: RoleEnum[]) { |
| 108 | 108 | this.roleList = roleList; |
| 109 | 109 | setAuthCache(ROLES_KEY, roleList); |
| 110 | 110 | }, |
| 111 | - setUserInfo(info: UserInfo) { | |
| 111 | + setUserInfo(info: UserInfo | null) { | |
| 112 | 112 | this.userInfo = info; |
| 113 | 113 | this.lastUpdateTime = new Date().getTime(); |
| 114 | 114 | setAuthCache(USER_INFO_KEY, info); |
| ... | ... | @@ -190,18 +190,23 @@ export const useUserStore = defineStore({ |
| 190 | 190 | /** |
| 191 | 191 | * @description: logout |
| 192 | 192 | */ |
| 193 | - async logout() { | |
| 193 | + async logout(goLogin = false) { | |
| 194 | 194 | // try { |
| 195 | 195 | // await doLogout(); |
| 196 | 196 | // } catch { |
| 197 | 197 | // console.log('注销Token失败'); |
| 198 | 198 | // } |
| 199 | - this.resetState(); | |
| 200 | - setAuthCache(JWT_TOKEN_KEY, undefined); | |
| 201 | - setAuthCache(REFRESH_TOKEN_KEY, undefined); | |
| 199 | + // this.resetState(); | |
| 200 | + // setAuthCache(JWT_TOKEN_KEY, undefined); | |
| 201 | + // setAuthCache(REFRESH_TOKEN_KEY, undefined); | |
| 202 | 202 | // this.setSessionTimeout(false); |
| 203 | - // goLogin && router.push(PageEnum.BASE_LOGIN); | |
| 204 | - await router.push(PageEnum.BASE_LOGIN); | |
| 203 | + // // goLogin && router.push(PageEnum.BASE_LOGIN); | |
| 204 | + | |
| 205 | + this.setToken(undefined); | |
| 206 | + this.setSessionTimeout(false); | |
| 207 | + setAuthCache(REFRESH_TOKEN_KEY, undefined); | |
| 208 | + this.setUserInfo(null); | |
| 209 | + goLogin && router.push(PageEnum.BASE_LOGIN); | |
| 205 | 210 | window.localStorage.clear(); |
| 206 | 211 | window.localStorage.removeItem('updateUserInfo'); |
| 207 | 212 | }, |
| ... | ... | @@ -228,7 +233,7 @@ export const useUserStore = defineStore({ |
| 228 | 233 | title: t('sys.app.logoutTip'), |
| 229 | 234 | content: t('sys.app.logoutMessage'), |
| 230 | 235 | onOk: async () => { |
| 231 | - await this.logout(); | |
| 236 | + await this.logout(true); | |
| 232 | 237 | }, |
| 233 | 238 | }); |
| 234 | 239 | }, | ... | ... |
| ... | ... | @@ -64,14 +64,14 @@ export const step1Schemas: FormSchema[] = [ |
| 64 | 64 | |
| 65 | 65 | onChange() { |
| 66 | 66 | setFieldsValue({ |
| 67 | - gateWayId: null, | |
| 67 | + gatewayId: null, | |
| 68 | 68 | }); |
| 69 | 69 | }, |
| 70 | 70 | }; |
| 71 | 71 | }, |
| 72 | 72 | }, |
| 73 | 73 | { |
| 74 | - field: 'gateWayId', | |
| 74 | + field: 'gatewayId', | |
| 75 | 75 | label: '网关设备', |
| 76 | 76 | required: true, |
| 77 | 77 | component: 'ApiSelect', | ... | ... |
| ... | ... | @@ -15,7 +15,7 @@ |
| 15 | 15 | <Step title="添加设备凭证" /> |
| 16 | 16 | </Steps> |
| 17 | 17 | </div> |
| 18 | - <div class="mt-5"> | |
| 18 | + <div class="mt-4"> | |
| 19 | 19 | <DeviceStep1 |
| 20 | 20 | @next="handleStep1Next" |
| 21 | 21 | ref="DeviceStep1Ref" |
| ... | ... | @@ -70,13 +70,14 @@ |
| 70 | 70 | const [register, { closeModal }] = useModalInner((data) => { |
| 71 | 71 | isUpdate.value = data?.isUpdate; |
| 72 | 72 | if (unref(isUpdate)) { |
| 73 | - unref(DeviceStep1Ref)?.parentSetFieldsValue(data.record); | |
| 73 | + const { record } = data; | |
| 74 | 74 | unref(DeviceStep1Ref)?.parentSetFieldsValue({ |
| 75 | - profile: data.record.deviceProfile.name, | |
| 76 | - profileId: data.record.profileId, | |
| 77 | - deviceType: data.record.deviceType, | |
| 75 | + ...record, | |
| 76 | + profile: record.deviceProfile.name, | |
| 77 | + profileId: record.profileId, | |
| 78 | + deviceType: record.deviceType, | |
| 78 | 79 | }); |
| 79 | - deviceInfo.value = data.record.deviceInfo; | |
| 80 | + deviceInfo.value = record.deviceInfo; | |
| 80 | 81 | unref(DeviceStep1Ref)?.disabledDeviceType(true); |
| 81 | 82 | } else { |
| 82 | 83 | unref(DeviceStep1Ref)?.disabledDeviceType(false); |
| ... | ... | @@ -107,6 +108,7 @@ |
| 107 | 108 | unref(DeviceStep2Ref)?.resetFieldsValueAndStatus(); |
| 108 | 109 | } |
| 109 | 110 | // 提交 |
| 111 | + const msg = computed(() => (unref(isUpdate) ? '更新设备成功' : '新增设备成功')); | |
| 110 | 112 | async function handleOk() { |
| 111 | 113 | if (current.value === 0) { |
| 112 | 114 | // 验证 |
| ... | ... | @@ -114,10 +116,12 @@ |
| 114 | 116 | if (!valid) return; |
| 115 | 117 | stepState.value = unref(DeviceStep1Ref)?.parentGetFieldsValue(); |
| 116 | 118 | } else { |
| 119 | + // !!!此处需要删除地图的属性,否则会报堆栈溢出的错误 Uncaught RangeError: Maximum call stack size exceeded | |
| 120 | + Reflect.deleteProperty(stepState.value, 'map'); | |
| 121 | + Reflect.deleteProperty(stepState.value, 'marker'); | |
| 117 | 122 | if (unref(DeviceStep2Ref)?.getFieldsValue().addAgree) { |
| 118 | 123 | const valid = await unref(DeviceStep2Ref)?.validate(); |
| 119 | 124 | if (!valid) return; |
| 120 | - | |
| 121 | 125 | // 第二页验证通过情况 |
| 122 | 126 | stepState.value = { |
| 123 | 127 | ...unref(stepState), |
| ... | ... | @@ -126,11 +130,10 @@ |
| 126 | 130 | } |
| 127 | 131 | } |
| 128 | 132 | // 验证成功 --调-- 新增或者编辑接口 |
| 129 | - const msg = computed(() => (unref(stepState).id ? '更新设备成功' : '新增设备成功')); | |
| 130 | - // 此处需要删除地图的属性,否则会报堆栈溢出的错误 Uncaught RangeError: Maximum call stack size exceeded | |
| 133 | + // !!!此处需要删除地图的属性,否则会报堆栈溢出的错误 Uncaught RangeError: Maximum call stack size exceeded | |
| 131 | 134 | Reflect.deleteProperty(DeviceStep1Ref.value.positionState, 'map'); |
| 132 | 135 | Reflect.deleteProperty(DeviceStep1Ref.value.positionState, 'marker'); |
| 133 | - if (unref(stepState).id) { | |
| 136 | + if (unref(isUpdate)) { | |
| 134 | 137 | const editData = { |
| 135 | 138 | ...unref(stepState), |
| 136 | 139 | deviceInfo: { |
| ... | ... | @@ -138,7 +141,6 @@ |
| 138 | 141 | ...DeviceStep1Ref.value?.positionState, |
| 139 | 142 | }, |
| 140 | 143 | }; |
| 141 | - | |
| 142 | 144 | await createOrEditDevice(editData); |
| 143 | 145 | } else { |
| 144 | 146 | const createData = { | ... | ... |
| ... | ... | @@ -194,7 +194,6 @@ |
| 194 | 194 | } |
| 195 | 195 | // 取消分配客户 |
| 196 | 196 | async function handleCancelDispatchCustomer(record: Recordable) { |
| 197 | - console.log('record', record); | |
| 198 | 197 | await cancelDispatchCustomer(record); |
| 199 | 198 | handleSuccess(); |
| 200 | 199 | } |
| ... | ... | @@ -210,7 +209,8 @@ |
| 210 | 209 | async function handleEdit(record: Recordable) { |
| 211 | 210 | if (record.deviceType === 'SENSOR') { |
| 212 | 211 | const res = await getGATEWAY(record.tbDeviceId); |
| 213 | - Reflect.set(record, 'gateWayId', res.id); | |
| 212 | + console.log(res); | |
| 213 | + Reflect.set(record, 'gatewayId', res.id); | |
| 214 | 214 | } |
| 215 | 215 | openModal(true, { |
| 216 | 216 | isUpdate: true, |
| ... | ... | @@ -221,6 +221,7 @@ |
| 221 | 221 | function handleSuccess() { |
| 222 | 222 | reload(); |
| 223 | 223 | } |
| 224 | + // 140049ee-6b8c-4ce1-93d4-00faeddf9719 | |
| 224 | 225 | function handleSelect(organization) { |
| 225 | 226 | searchInfo.organizationId = organization; |
| 226 | 227 | handleSuccess(); | ... | ... |
| ... | ... | @@ -14,7 +14,7 @@ |
| 14 | 14 | <PageWrapper dense contentFullHeight contentBackground> |
| 15 | 15 | <div class="detail-notice-info"> |
| 16 | 16 | <span class="mr-6" |
| 17 | - ><UserOutlined class="mr-2" />发送者:{{ dataSource?.user?.realName }}</span | |
| 17 | + ><UserOutlined class="mr-2" />发送者:{{ dataSource?.sysNotice?.senderName }}</span | |
| 18 | 18 | > |
| 19 | 19 | <span class="mr-6" |
| 20 | 20 | ><SolutionOutlined class="mr-2" />通知类型:{{ |
| ... | ... | @@ -74,5 +74,6 @@ |
| 74 | 74 | border-bottom: 1px solid #ccc; |
| 75 | 75 | padding-top: 5px; |
| 76 | 76 | padding-bottom: 5px; |
| 77 | + margin-bottom: 16px; | |
| 77 | 78 | } |
| 78 | 79 | </style> | ... | ... |
| ... | ... | @@ -80,6 +80,8 @@ |
| 80 | 80 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 81 | 81 | resetFields(); |
| 82 | 82 | roleId.value = ''; |
| 83 | + // 在打开弹窗时清除所有选择的菜单 | |
| 84 | + treeRef.value && treeRef.value.checkAll(false); | |
| 83 | 85 | isUpdate.value = data.isUpdate; |
| 84 | 86 | // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 |
| 85 | 87 | if (!unref(treeData).length) { |
| ... | ... | @@ -101,7 +103,6 @@ |
| 101 | 103 | } |
| 102 | 104 | } |
| 103 | 105 | treeRef.value.setCheckedKeys(roleMenus.value); |
| 104 | - console.log(originMenus.value); | |
| 105 | 106 | roleId.value = data.record.id; |
| 106 | 107 | setFieldsValue(data.record); |
| 107 | 108 | } | ... | ... |
| ... | ... | @@ -82,6 +82,8 @@ |
| 82 | 82 | const [registerDrawer, { setDrawerProps, closeDrawer }] = useDrawerInner(async (data) => { |
| 83 | 83 | resetFields(); |
| 84 | 84 | roleId.value = ''; |
| 85 | + // 在打开弹窗时清除所有选择的菜单 | |
| 86 | + treeRef.value && treeRef.value.checkAll(false); | |
| 85 | 87 | isUpdate.value = data.isUpdate; |
| 86 | 88 | // 需要在setFieldsValue之前先填充treeData,否则Tree组件可能会报key not exist警告 |
| 87 | 89 | if (!unref(treeData).length) { | ... | ... |