Commit ea4a0db10cadb07bc9a374f43ee776568c3f5d5f

Authored by fengtao
1 parent e5b54e7a

fix:修复租户管理员新增账号问题,fix:修复未分配首页,地址栏输入/#/重定向404问题,feat:新增设备页面的设备名字跳转到设备配置页面,并且高亮当前行

... ... @@ -4,6 +4,8 @@ import { mainOutRoutes } from './mainOut';
4 4 import { PageEnum } from '/@/enums/pageEnum';
5 5 import { t } from '/@/hooks/web/useI18n';
6 6 import { LAYOUT } from '../constant';
  7 +import { getMenuList } from '/@/api/sys/menu';
  8 +import { router } from '/@/router';
7 9
8 10 const modules = import.meta.globEager('./modules/**/*.ts');
9 11 const routeModuleList: AppRouteModule[] = [];
... ... @@ -12,6 +14,41 @@ Object.keys(modules).forEach((key) => {
12 14 const modList = Array.isArray(mod) ? [...mod] : [mod];
13 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 52 export const asyncRoutes = [PAGE_NOT_FOUND_ROUTE, ...routeModuleList];
16 53 export const RootRoute: AppRouteRecordRaw = {
17 54 path: '/',
... ...
... ... @@ -11,7 +11,7 @@
11 11 <a-button type="primary" @click="handleCreate" v-if="authBtn(role)"> 新增设备 </a-button>
12 12 </template>
13 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 15 {{ record.deviceProfile.name }}
16 16 </a-button>
17 17 </template>
... ... @@ -213,8 +213,8 @@
213 213 searchInfo.organizationId = organization;
214 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 220 return {
... ...
1 1 <template>
2 2 <div>
3 3 <BasicTable
  4 + class="devide-profile"
4 5 @selection-change="useSelectionChange"
5 6 @register="registerTable"
6 7 :rowSelection="{ type: 'checkbox' }"
  8 + :rowClassName="setRowClassName"
7 9 >
8 10 <template #toolbar>
9 11 <a-button type="primary" @click="handleCreate"> 新增设备配置 </a-button>
... ... @@ -66,6 +68,8 @@
66 68 setup() {
67 69 let selectedRowKeys: string[] = reactive([]);
68 70 let isJudgeStatus = ref(true);
  71 + const getPathUrl = ref('');
  72 + const getPathUrlName = ref('');
69 73 const { createMessage } = useMessage();
70 74 const [registerModal, { openModal }] = useModal();
71 75 const [registerModalDetail, { openModal: openModalDetail }] = useModal();
... ... @@ -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 125 const tableListRef = ref<
96 126 {
97 127 title: string;
... ... @@ -181,6 +211,7 @@
181 211 reload();
182 212 }
183 213 return {
  214 + setRowClassName,
184 215 registerModalDetail,
185 216 // register1,
186 217 // defaultHeader,
... ... @@ -202,3 +233,12 @@
202 233 },
203 234 });
204 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 43 },
44 44 {
45 45 field: 'username',
46   - required: true,
47 46 label: '账号',
48 47 component: 'Input',
49 48 componentProps: {
50 49 maxLength: 255,
51 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 58 return [
55 59 {
56   - required: true,
57 60 validator(_, value) {
58 61 return new Promise((resolve, reject) => {
59 62 if (value == '') {
... ... @@ -62,19 +65,10 @@
62 65 reject('账号不能含有中文');
63 66 } else if (EmailRegexp.test(value)) {
64 67 reject('账号不能为电子邮箱格式');
  68 + } else if (value == findUserName?.username) {
  69 + reject('账号已存在');
  70 + return;
65 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 72 resolve();
79 73 }
80 74 });
... ...