@@ -32,6 +35,7 @@ import Notice from './components/Notice.vue';
import DefaultSetting from '../../../config/config';
import { useMenuStore } from '@/store/menu';
import { clearMenuItem } from 'jetlinks-ui-components/es/ProLayout/util';
+import { AccountMenu } from '@/router/menu'
type StateType = {
collapsed: boolean;
@@ -50,7 +54,8 @@ const layoutConf = reactive({
siderWidth: DefaultSetting.layout.siderWidth,
logo: DefaultSetting.layout.logo,
title: DefaultSetting.layout.title,
- menuData: clearMenuItem(menu.siderMenus),
+ menuData: [...clearMenuItem(menu.siderMenus), AccountMenu],
+ // menuData: menu.siderMenus,
splitMenus: true,
});
@@ -61,26 +66,49 @@ const state = reactive
({
selectedKeys: [],
});
+const findRouteMeta = (code: string) => {
+ let meta = []
+ let menuItem: any = menu.menus[code]
+ while (menuItem) {
+ meta.unshift(menuItem)
+ if (menuItem.parentName) {
+ menuItem = menu.menus[menuItem.parentName]
+ } else {
+ menuItem = false
+ }
+ }
+ return meta
+}
+
+const jumpPage = (path: string) => {
+ console.log(path)
+ router.push(path)
+}
+
const breadcrumb = computed(() =>
- router.currentRoute.value.matched.concat().map((item, index) => {
- return {
- index,
- path: item.path,
- breadcrumbName: item.meta.title || '',
- };
- }),
+ {
+ const paths = router.currentRoute.value.name as string
+ const metas = findRouteMeta(paths)
+ return metas.map((item, index) => {
+ return {
+ index,
+ isLast: index === (metas.length - 1),
+ path: item.path,
+ breadcrumbName: item.title || '',
+ };
+ })
+ }
);
watchEffect(() => {
if (router.currentRoute) {
- const matched = router.currentRoute.value.matched.concat();
- state.selectedKeys = matched.map((r) => r.path);
- state.openKeys = matched
- .filter((r) => r.path !== router.currentRoute.value.path)
- .map((r) => r.path);
- console.log(state.selectedKeys);
+ const paths = router.currentRoute.value.name as string
+ if (paths) {
+ const _metas = findRouteMeta(paths)
+ state.selectedKeys = _metas.map(item => item.path)
+ state.openKeys = _metas.filter((r) => r !== router.currentRoute.value.path).map(item => item.path)
+ }
}
- // TODO 获取当前路由中参数,用于控制pure
});
watchEffect(() => {
diff --git a/src/router/menu.ts b/src/router/menu.ts
index 1dfae58c..db8ca7d7 100644
--- a/src/router/menu.ts
+++ b/src/router/menu.ts
@@ -5,6 +5,7 @@ export const AccountMenu = {
component: () => import('@/components/Layout/BasicLayoutPage.vue'),
redirect: '/account/center',
name: 'account',
+ code: 'account',
meta: {
title: '个人中心',
icon: '',
@@ -14,6 +15,7 @@ export const AccountMenu = {
{
path: '/account/center',
name: 'account/center',
+ code: 'account/center',
meta: {
title: '基本设置',
icon: '',
@@ -24,6 +26,7 @@ export const AccountMenu = {
{
path: '/account/NotificationSubscription',
name: 'account/NotificationSubscription',
+ code: 'account/NotificationSubscription',
meta: {
title: '通知订阅',
icon: '',
@@ -34,6 +37,7 @@ export const AccountMenu = {
{
path: '/account/NotificationRecord',
name: 'account/NotificationRecord',
+ code: 'account/NotificationRecord',
meta: {
title: '通知记录',
icon: '',
diff --git a/src/store/menu.ts b/src/store/menu.ts
index ad8390b8..a562d28e 100644
--- a/src/store/menu.ts
+++ b/src/store/menu.ts
@@ -1,6 +1,6 @@
import { defineStore } from 'pinia'
import { queryOwnThree } from '@/api/system/menu'
-import { filterAsnycRouter, MenuItem } from '@/utils/menu'
+import { filterAsyncRouter, findCodeRoute, MenuItem } from '@/utils/menu'
import { isArray } from 'lodash-es'
import { usePermissionStore } from './permission'
import router from '@/router'
@@ -33,6 +33,8 @@ type MenuStateType = {
menus: {
[key: string]: {
buttons?: string[]
+ title: string
+ parentName: string
path: string
}
}
@@ -98,24 +100,15 @@ export const useMenuStore = defineStore({
if (resp.success) {
const permission = usePermissionStore()
permission.permissions = {}
- const { menusData, silderMenus } = filterAsnycRouter(resp.result)
- this.menus = {}
- const handleMenuItem = (menu: any) => {
- if (isArray(menu)) {
- menu.forEach(menuItem => {
- this.menus[menuItem.name] = {
- path: menuItem.path,
- buttons: menuItem.meta.buttons
- }
- permission.permissions[menuItem.name] = menuItem.meta.buttons
- if (menuItem.children && menuItem.children.length) {
- handleMenuItem(menuItem.children)
- }
- })
+ const { menusData, silderMenus } = filterAsyncRouter(resp.result)
+ this.menus = findCodeRoute([...resp.result, AccountMenu])
+ Object.keys(this.menus).forEach((item) => {
+ const _item = this.menus[item]
+ if (_item.buttons?.length) {
+ permission.permissions[item] = _item.buttons
}
- }
+ })
- handleMenuItem(menusData)
menusData.push({
path: '/',
redirect: menusData[0]?.path,
@@ -124,10 +117,7 @@ export const useMenuStore = defineStore({
}
})
menusData.push(AccountMenu)
- silderMenus.push(AccountMenu)
this.siderMenus = silderMenus
- console.log('menusData', menusData)
- console.log('silderMenus', silderMenus)
res(menusData)
}
})
diff --git a/src/store/permission.ts b/src/store/permission.ts
index 289d16a9..464a541d 100644
--- a/src/store/permission.ts
+++ b/src/store/permission.ts
@@ -3,11 +3,12 @@ import { defineStore } from "pinia";
export const usePermissionStore = defineStore({
id: 'permission',
state: () => ({
- permissions: {} as {[key: string]: string},
+ permissions: {} as {[key: string]: string[]},
}),
getters: {
check(state) {
return (permissionCode: string) => {
+
if (!permissionCode) {
return true
}
@@ -16,6 +17,7 @@ export const usePermissionStore = defineStore({
}
const code = permissionCode.split(":")[0]
const value = permissionCode.split(":")[1]
+
const _buttonArray = state.permissions[code]
if (!_buttonArray) {
return false
diff --git a/src/utils/menu.ts b/src/utils/menu.ts
index a723734c..023318b9 100644
--- a/src/utils/menu.ts
+++ b/src/utils/menu.ts
@@ -151,7 +151,6 @@ const extraRouteObj = {
const resolveComponent = (name: any) => {
const importPage = pagesComponent[`../views/${name}/index.vue`];
if (!importPage) {
- console.warn(`Unknown page ${name}. Is it located under Pages with a .vue extension?`)
return undefined
} else {
const res = () => importPage()
@@ -201,7 +200,52 @@ const findDetailRoutes = (routes: any[]): any[] => {
return newRoutes
}
-export function filterAsnycRouter(asyncRouterMap: any, parentCode = '', level = 1): { menusData: any, silderMenus: any } {
+export const findCodeRoute = (asyncRouterMap: any[]) => {
+ const routeMeta = {}
+
+ function findChildren (data: any[], code: string = '') {
+ data.forEach(route => {
+ routeMeta[route.code] = {
+ path: route.url || route.path,
+ title: route.meta?.title || route.name,
+ parentName: code,
+ buttons: route.buttons?.map((b: any) => b.id) || []
+ }
+ const detail = findDetailRouteItem(route.code, route.url)
+ if (detail) {
+ routeMeta[(detail as MenuItem).code] = {
+ path: detail.url,
+ title: detail.name,
+ parentName: route.code,
+ buttons: detail.buttons?.map((b: any) => b.id) || []
+ }
+ }
+
+ const otherRoutes = extraRouteObj[route.code]
+ if (otherRoutes) {
+ otherRoutes.children.map((item: any) => {
+ const _code = `${route.code}/${item.code}`
+ routeMeta[_code] = {
+ path: `${route.url}/${item.code}`,
+ title: item.name,
+ parentName: route.code,
+ buttons: item.buttons?.map((b: any) => b.id) || []
+ }
+ })
+ }
+
+ if (route.children) {
+ findChildren(route.children, route.code)
+ }
+ })
+ }
+
+ findChildren(asyncRouterMap)
+
+ return routeMeta
+}
+
+export function filterAsyncRouter(asyncRouterMap: any, parentCode = '', level = 1): { menusData: any, silderMenus: any} {
const _asyncRouterMap = cloneDeep(asyncRouterMap)
const menusData: any[] = []
const silderMenus: any[] = []
@@ -224,7 +268,7 @@ export function filterAsnycRouter(asyncRouterMap: any, parentCode = '', level =
route.children = findDetailRoutes(route.children)
if (route.children && route.children.length) {
// TODO 查看是否具有详情页
- const { menusData: _menusData, silderMenus: _silderMenus } = filterAsnycRouter(route.children, `${parentCode}/${route.code}`, level + 1)
+ const { menusData: _menusData, silderMenus: _silderMenus } = filterAsyncRouter(route.children, `${parentCode}/${route.code}`, level + 1)
_route.children = _menusData
silder.children = _silderMenus
const showChildren = _route.children.some((r: any) => !r.meta.hideInMenu)
@@ -251,6 +295,6 @@ export function filterAsnycRouter(asyncRouterMap: any, parentCode = '', level =
})
return {
menusData,
- silderMenus
+ silderMenus,
}
}
\ No newline at end of file
diff --git a/src/views/iot-card/Home/index.vue b/src/views/iot-card/Home/index.vue
index af9a0b33..739a84a1 100644
--- a/src/views/iot-card/Home/index.vue
+++ b/src/views/iot-card/Home/index.vue
@@ -95,6 +95,7 @@ import { queryFlow, list } from '@/api/iot-card/home';
import * as echarts from 'echarts';
import { useMenuStore } from '@/store/menu';
import { usePermissionStore } from '@/store/permission';
+import { message } from 'jetlinks-ui-components'
const { proxy } = getCurrentInstance();
@@ -178,11 +179,10 @@ const pieChartData = ref([
]);
const jumpPage = (data: GuideItemProps) => {
- // if (data.url && data.auth) {
- // router.push({ path: `${data.url}`, ...data.param });
- // } else {
- // message.warning('暂无权限,请联系管理员');
- // }
+ if (!data.auth){
+ message.warning('暂无权限,请联系管理员');
+ return
+ }
if (data.key === 'EQUIPMENT') {
menuStory.jumpPage(data.url, { id: 'add' });
} else {
From 318a5cecafb3a9f62d6de6954704ca60739a03ac Mon Sep 17 00:00:00 2001
From: xieyonghong <18010623010@163.com>
Date: Tue, 14 Mar 2023 09:25:36 +0800
Subject: [PATCH 2/5] =?UTF-8?q?update:=20=E4=BC=98=E5=8C=96=E7=BB=84?=
=?UTF-8?q?=E4=BB=B6=E5=BA=93?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
yarn.lock | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index c1d0ad47..3a663ae9 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3695,8 +3695,8 @@ jetlinks-store@^0.0.3:
jetlinks-ui-components@^1.0.5:
version "1.0.5"
- resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#30de07a15481f13ea86ebc817baaab3c99034403"
- integrity sha512-ULgSPU0xY6xUky3beeHVvpHyAHmT6xHsO5eS5m7a3h7AmCoxA3oTWyF20vC+K1zTJBQ7LFCouySqRRz6GimAPg==
+ resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#360e87e3cba4d025ec4665943098a88b0d9ff59a"
+ integrity sha512-lYe7kx65XCvZzf7esQRTm/ljlQi5kMtv00yotnSmvMILR6tohx57fA5Ga895i63DrySSmJlqBUsniMtjQVzqqQ==
dependencies:
"@vueuse/core" "^9.12.0"
ant-design-vue "^3.2.15"
From f58414195019dac134ae6cdc71dae3e2335d49c4 Mon Sep 17 00:00:00 2001
From: JiangQiming <291854119@qq.com>
Date: Tue, 14 Mar 2023 10:47:43 +0800
Subject: [PATCH 3/5] =?UTF-8?q?update:=20=E7=BB=84=E4=BB=B6=E6=9B=B4?=
=?UTF-8?q?=E6=8D=A2=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/media/Device/Save/SaveProduct.vue | 97 ++++++++++++---------
1 file changed, 56 insertions(+), 41 deletions(-)
diff --git a/src/views/media/Device/Save/SaveProduct.vue b/src/views/media/Device/Save/SaveProduct.vue
index 298c1b49..9b86961e 100644
--- a/src/views/media/Device/Save/SaveProduct.vue
+++ b/src/views/media/Device/Save/SaveProduct.vue
@@ -9,32 +9,50 @@
:confirmLoading="btnLoading"
width="660px"
>
-
-
+
+
-
+
-
-
-
+
+
-
+
暂无数据,请先
@@ -119,16 +137,12 @@
From 351e4f35ab51c6a6cfa3de0b663e7e341f91bd5e Mon Sep 17 00:00:00 2001
From: JiangQiming <291854119@qq.com>
Date: Tue, 14 Mar 2023 11:38:21 +0800
Subject: [PATCH 4/5] =?UTF-8?q?update:=20=E7=BB=84=E4=BB=B6=E6=9B=B4?=
=?UTF-8?q?=E6=8D=A2=E6=B5=8B=E8=AF=95?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/notice/Template/Debug/index.vue | 92 +++++++++++++++-------
src/views/notice/Template/Detail/index.vue | 14 ++--
2 files changed, 73 insertions(+), 33 deletions(-)
diff --git a/src/views/notice/Template/Debug/index.vue b/src/views/notice/Template/Debug/index.vue
index ae42fee7..767e1e67 100644
--- a/src/views/notice/Template/Debug/index.vue
+++ b/src/views/notice/Template/Debug/index.vue
@@ -50,34 +50,50 @@
-
-
-
-
+
+
+
+
+
+
+
+
+
@@ -100,6 +116,8 @@ import { message } from 'ant-design-vue';
import ToUser from '../Detail/components/ToUser.vue';
import ToOrg from '../Detail/components/ToOrg.vue';
import ToTag from '../Detail/components/ToTag.vue';
+import type { Rule } from 'ant-design-vue/es/form';
+import { phoneRegEx } from '@/utils/validate';
type Emits = {
(e: 'update:visible', data: boolean): void;
@@ -156,6 +174,26 @@ const getTemplateDetail = async () => {
...m,
type: m.expands ? m.expands.businessType : m.type,
value: undefined,
+ // 电话字段校验
+ otherRules:
+ m.id === 'calledNumber'
+ ? [
+ {
+ max: 64,
+ message: '最多可输入64个字符',
+ trigger: 'change',
+ },
+ {
+ trigger: 'change',
+ validator(_rule: Rule, value: string) {
+ if (!value) return Promise.resolve();
+ if (!phoneRegEx(value))
+ return Promise.reject('请输入有效号码');
+ return Promise.resolve();
+ },
+ },
+ ]
+ : '',
}),
);
};
diff --git a/src/views/notice/Template/Detail/index.vue b/src/views/notice/Template/Detail/index.vue
index 3d371d45..5afbf687 100644
--- a/src/views/notice/Template/Detail/index.vue
+++ b/src/views/notice/Template/Detail/index.vue
@@ -85,7 +85,7 @@
>
- AgentID
+ AgentId
@@ -271,7 +271,7 @@
@@ -664,7 +664,6 @@
自定义
Date: Tue, 14 Mar 2023 13:39:49 +0800
Subject: [PATCH 5/5] =?UTF-8?q?fix:=20=E5=91=8A=E8=AD=A6=E4=B8=AD=E5=BF=83?=
=?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=9B=BF=E6=8D=A2=E5=8F=8A=E8=87=AA=E6=B5=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Alarm/Configuration/Save/Base/index.vue | 50 ++++----
.../Configuration/Save/Scene/Save/index.vue | 8 +-
.../Alarm/Configuration/Save/Scene/index.vue | 4 +-
.../Alarm/Configuration/Save/index.vue | 38 +++---
.../rule-engine/Alarm/Configuration/index.vue | 22 ++--
.../rule-engine/Alarm/Log/Detail/index.vue | 8 +-
.../rule-engine/Alarm/Log/Detail/info.vue | 38 +++---
.../Alarm/Log/SolveComponent/index.vue | 17 +--
.../rule-engine/Alarm/Log/SolveLog/index.vue | 8 +-
.../Alarm/Log/TabComponent/indev.vue | 111 +++++++++---------
src/views/rule-engine/Instance/Save/index.vue | 20 ++--
src/views/rule-engine/Instance/index.vue | 18 +--
12 files changed, 172 insertions(+), 170 deletions(-)
diff --git a/src/views/rule-engine/Alarm/Configuration/Save/Base/index.vue b/src/views/rule-engine/Alarm/Configuration/Save/Base/index.vue
index dc755f54..27d4ca36 100644
--- a/src/views/rule-engine/Alarm/Configuration/Save/Base/index.vue
+++ b/src/views/rule-engine/Alarm/Configuration/Save/Base/index.vue
@@ -1,27 +1,27 @@
-
-
-
-
-
+
+
+
+
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+ {{ item.label }}
-
-
-
-
-
-
+
+
+
+
+
+
保存
-
+
@@ -178,7 +178,7 @@ const handleSave = async () => {
const res = await save(form);
loading.value = false;
if (res.status === 200) {
- message.success('操作成功');
+ message.success('操作成功,请配置关联的场景联动');
menuStory.jumpPage(
'rule-engine/Alarm/Configuration/Save',
{},
diff --git a/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue b/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue
index 1b1445fd..d604f853 100644
--- a/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue
+++ b/src/views/rule-engine/Alarm/Configuration/Save/Scene/Save/index.vue
@@ -1,5 +1,5 @@
-
-
+
-
+
diff --git a/src/views/rule-engine/Instance/Save/index.vue b/src/views/rule-engine/Instance/Save/index.vue
index 2d55cf41..dac57c93 100644
--- a/src/views/rule-engine/Instance/Save/index.vue
+++ b/src/views/rule-engine/Instance/Save/index.vue
@@ -1,5 +1,5 @@
-
-
-
-
+
-
-
-
+
+
-
-
+
+
-
+