Commit ea4a0db10cadb07bc9a374f43ee776568c3f5d5f
1 parent
e5b54e7a
fix:修复租户管理员新增账号问题,fix:修复未分配首页,地址栏输入/#/重定向404问题,feat:新增设备页面的设备名字跳转到设备配置页面,并且高亮当前行
Showing
4 changed files
with
89 additions
and
18 deletions
@@ -4,6 +4,8 @@ import { mainOutRoutes } from './mainOut'; | @@ -4,6 +4,8 @@ import { mainOutRoutes } from './mainOut'; | ||
4 | import { PageEnum } from '/@/enums/pageEnum'; | 4 | import { PageEnum } from '/@/enums/pageEnum'; |
5 | import { t } from '/@/hooks/web/useI18n'; | 5 | import { t } from '/@/hooks/web/useI18n'; |
6 | import { LAYOUT } from '../constant'; | 6 | import { LAYOUT } from '../constant'; |
7 | +import { getMenuList } from '/@/api/sys/menu'; | ||
8 | +import { router } from '/@/router'; | ||
7 | 9 | ||
8 | const modules = import.meta.globEager('./modules/**/*.ts'); | 10 | const modules = import.meta.globEager('./modules/**/*.ts'); |
9 | const routeModuleList: AppRouteModule[] = []; | 11 | const routeModuleList: AppRouteModule[] = []; |
@@ -12,6 +14,41 @@ Object.keys(modules).forEach((key) => { | @@ -12,6 +14,41 @@ Object.keys(modules).forEach((key) => { | ||
12 | const modList = Array.isArray(mod) ? [...mod] : [mod]; | 14 | const modList = Array.isArray(mod) ? [...mod] : [mod]; |
13 | routeModuleList.push(...modList); | 15 | routeModuleList.push(...modList); |
14 | }); | 16 | }); |
17 | +let pushPath = ''; | ||
18 | +let pushSubPath = ''; | ||
19 | + | ||
20 | +async function hashChangeFunc() { | ||
21 | + const getMenuListData1 = window.localStorage.getItem('menuListStorage') || (await getMenuList()); | ||
22 | + const getMenuListData = JSON.parse(getMenuListData1); | ||
23 | + const getHomePage = getMenuListData.find((f) => { | ||
24 | + return f.path == '/dashboard/workbench'; | ||
25 | + }); | ||
26 | + if (getHomePage?.path == '/dashboard/workbench') { | ||
27 | + setTimeout(() => { | ||
28 | + router.push('/dashboard/workbench'); | ||
29 | + }, 200); | ||
30 | + } else { | ||
31 | + const routeF = getMenuListData[0]?.children[0]?.path || getMenuListData[0].path; | ||
32 | + pushPath = routeF; | ||
33 | + pushSubPath = pushPath.substring(1); | ||
34 | + } | ||
35 | +} | ||
36 | +hashChangeFunc(); | ||
37 | + | ||
38 | +window.onhashchange = (e) => { | ||
39 | + console.log(e); | ||
40 | + setTimeout(() => { | ||
41 | + if ( | ||
42 | + e.newURL == 'http://localhost:8083/#/' || | ||
43 | + e.newURL == 'http://localhost:8083/#' || | ||
44 | + e.newURL == 'http://localhost:8083/' || | ||
45 | + e.newURL == 'http://localhost:8083' | ||
46 | + ) { | ||
47 | + window.location.href = e.newURL + pushSubPath; | ||
48 | + } | ||
49 | + }, 1000); | ||
50 | +}; | ||
51 | + | ||
15 | export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; | 52 | export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList]; |
16 | export const RootRoute: AppRouteRecordRaw = { | 53 | export const RootRoute: AppRouteRecordRaw = { |
17 | path: '/', | 54 | path: '/', |
@@ -11,7 +11,7 @@ | @@ -11,7 +11,7 @@ | ||
11 | <a-button type="primary" @click="handleCreate" v-if="authBtn(role)"> 新增设备 </a-button> | 11 | <a-button type="primary" @click="handleCreate" v-if="authBtn(role)"> 新增设备 </a-button> |
12 | </template> | 12 | </template> |
13 | <template #deviceProfile="{ record }"> | 13 | <template #deviceProfile="{ record }"> |
14 | - <a-button type="link" class="ml-2" @click="goDeviceProfile"> | 14 | + <a-button type="link" class="ml-2" @click="goDeviceProfile(record.deviceProfile.name)"> |
15 | {{ record.deviceProfile.name }} | 15 | {{ record.deviceProfile.name }} |
16 | </a-button> | 16 | </a-button> |
17 | </template> | 17 | </template> |
@@ -213,8 +213,8 @@ | @@ -213,8 +213,8 @@ | ||
213 | searchInfo.organizationId = organization; | 213 | searchInfo.organizationId = organization; |
214 | handleSuccess(); | 214 | handleSuccess(); |
215 | } | 215 | } |
216 | - function goDeviceProfile() { | ||
217 | - go(PageEnum.DEVICE_PROFILE); | 216 | + function goDeviceProfile(e) { |
217 | + go(PageEnum.DEVICE_PROFILE + '?name=' + String(e)); | ||
218 | } | 218 | } |
219 | 219 | ||
220 | return { | 220 | return { |
1 | <template> | 1 | <template> |
2 | <div> | 2 | <div> |
3 | <BasicTable | 3 | <BasicTable |
4 | + class="devide-profile" | ||
4 | @selection-change="useSelectionChange" | 5 | @selection-change="useSelectionChange" |
5 | @register="registerTable" | 6 | @register="registerTable" |
6 | :rowSelection="{ type: 'checkbox' }" | 7 | :rowSelection="{ type: 'checkbox' }" |
8 | + :rowClassName="setRowClassName" | ||
7 | > | 9 | > |
8 | <template #toolbar> | 10 | <template #toolbar> |
9 | <a-button type="primary" @click="handleCreate"> 新增设备配置 </a-button> | 11 | <a-button type="primary" @click="handleCreate"> 新增设备配置 </a-button> |
@@ -66,6 +68,8 @@ | @@ -66,6 +68,8 @@ | ||
66 | setup() { | 68 | setup() { |
67 | let selectedRowKeys: string[] = reactive([]); | 69 | let selectedRowKeys: string[] = reactive([]); |
68 | let isJudgeStatus = ref(true); | 70 | let isJudgeStatus = ref(true); |
71 | + const getPathUrl = ref(''); | ||
72 | + const getPathUrlName = ref(''); | ||
69 | const { createMessage } = useMessage(); | 73 | const { createMessage } = useMessage(); |
70 | const [registerModal, { openModal }] = useModal(); | 74 | const [registerModal, { openModal }] = useModal(); |
71 | const [registerModalDetail, { openModal: openModalDetail }] = useModal(); | 75 | const [registerModalDetail, { openModal: openModalDetail }] = useModal(); |
@@ -92,6 +96,32 @@ | @@ -92,6 +96,32 @@ | ||
92 | }, | 96 | }, |
93 | }); | 97 | }); |
94 | 98 | ||
99 | + /** | ||
100 | + *@param url,name | ||
101 | + **/ | ||
102 | + function getParam(url, name) { | ||
103 | + try { | ||
104 | + let reg = new RegExp('(^|&)' + name + '=([^&]*)(&|$)'); | ||
105 | + let r = url.split('?')[1].match(reg); | ||
106 | + if (r != null) { | ||
107 | + return r[2]; | ||
108 | + } | ||
109 | + return ''; //如果此处只写return;则返回的是undefined | ||
110 | + } catch (e) { | ||
111 | + return ''; //如果此处只写return;则返回的是undefined | ||
112 | + } | ||
113 | + } | ||
114 | + getPathUrl.value = window.location.href; | ||
115 | + const name = 'name'; | ||
116 | + const getName = getParam(getPathUrl.value, name); | ||
117 | + getPathUrlName.value = decodeURIComponent(getName); | ||
118 | + | ||
119 | + const setRowClassName = (record) => { | ||
120 | + if (record.name === getPathUrlName.value) { | ||
121 | + return 'rowcolor2'; | ||
122 | + } | ||
123 | + }; | ||
124 | + | ||
95 | const tableListRef = ref< | 125 | const tableListRef = ref< |
96 | { | 126 | { |
97 | title: string; | 127 | title: string; |
@@ -181,6 +211,7 @@ | @@ -181,6 +211,7 @@ | ||
181 | reload(); | 211 | reload(); |
182 | } | 212 | } |
183 | return { | 213 | return { |
214 | + setRowClassName, | ||
184 | registerModalDetail, | 215 | registerModalDetail, |
185 | // register1, | 216 | // register1, |
186 | // defaultHeader, | 217 | // defaultHeader, |
@@ -202,3 +233,12 @@ | @@ -202,3 +233,12 @@ | ||
202 | }, | 233 | }, |
203 | }); | 234 | }); |
204 | </script> | 235 | </script> |
236 | + | ||
237 | +<style lang="css"> | ||
238 | + .devide-profile .rowcolor { | ||
239 | + color: red; | ||
240 | + } | ||
241 | + .devide-profile .rowcolor2 { | ||
242 | + background: #a2c3e6; | ||
243 | + } | ||
244 | +</style> |
@@ -43,17 +43,20 @@ | @@ -43,17 +43,20 @@ | ||
43 | }, | 43 | }, |
44 | { | 44 | { |
45 | field: 'username', | 45 | field: 'username', |
46 | - required: true, | ||
47 | label: '账号', | 46 | label: '账号', |
48 | component: 'Input', | 47 | component: 'Input', |
49 | componentProps: { | 48 | componentProps: { |
50 | maxLength: 255, | 49 | maxLength: 255, |
51 | placeholder: '请输入账号', | 50 | placeholder: '请输入账号', |
52 | }, | 51 | }, |
53 | - dynamicRules: () => { | 52 | + dynamicRules: ({ values }) => { |
53 | + const findUserName = isJudgeUserNameExist.value.find((f) => { | ||
54 | + if (f) { | ||
55 | + return f.username == values.username; | ||
56 | + } | ||
57 | + }); | ||
54 | return [ | 58 | return [ |
55 | { | 59 | { |
56 | - required: true, | ||
57 | validator(_, value) { | 60 | validator(_, value) { |
58 | return new Promise((resolve, reject) => { | 61 | return new Promise((resolve, reject) => { |
59 | if (value == '') { | 62 | if (value == '') { |
@@ -62,19 +65,10 @@ | @@ -62,19 +65,10 @@ | ||
62 | reject('账号不能含有中文'); | 65 | reject('账号不能含有中文'); |
63 | } else if (EmailRegexp.test(value)) { | 66 | } else if (EmailRegexp.test(value)) { |
64 | reject('账号不能为电子邮箱格式'); | 67 | reject('账号不能为电子邮箱格式'); |
68 | + } else if (value == findUserName?.username) { | ||
69 | + reject('账号已存在'); | ||
70 | + return; | ||
65 | } else { | 71 | } else { |
66 | - try { | ||
67 | - const findUserName = isJudgeUserNameExist.value.find((f) => { | ||
68 | - return f.username == value; | ||
69 | - }); | ||
70 | - if (value == findUserName?.username) { | ||
71 | - reject('账号已存在'); | ||
72 | - } else { | ||
73 | - reject('请输入'); | ||
74 | - } | ||
75 | - } catch (e) { | ||
76 | - return reject(e); | ||
77 | - } | ||
78 | resolve(); | 72 | resolve(); |
79 | } | 73 | } |
80 | }); | 74 | }); |