From e9f255ca3ce3e1faa294c722baca784577b87216 Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 31 Mar 2023 18:02:09 +0800 Subject: [PATCH 1/7] =?UTF-8?q?fix:=20=E6=96=B0=E5=A2=9E=E4=B8=AA=E4=BA=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/consts.ts | 2 ++ src/views/init-home/data/RoleData.ts | 30 ++++++++++++++++ src/views/init-home/data/baseMenu.ts | 47 +++++++++++++++++++++++++ src/views/system/Menu/Setting/index.vue | 3 +- src/views/system/Menu/index.vue | 4 +-- 5 files changed, 83 insertions(+), 3 deletions(-) diff --git a/src/utils/consts.ts b/src/utils/consts.ts index d04577ed..621b311b 100644 --- a/src/utils/consts.ts +++ b/src/utils/consts.ts @@ -47,3 +47,5 @@ export const SystemConst = { VERSION_CODE: 'version_code', AMAP_KEY : 'amap_key', } + +export const USER_CENTER_MENU_CODE = 'account-center' diff --git a/src/views/init-home/data/RoleData.ts b/src/views/init-home/data/RoleData.ts index 9729255d..56ad7175 100644 --- a/src/views/init-home/data/RoleData.ts +++ b/src/views/init-home/data/RoleData.ts @@ -1,3 +1,4 @@ +import USER_CENTER_MENU_DATA from './baseMenu' /** * 内置角色数据 */ @@ -9,6 +10,33 @@ export enum ROLEKEYS { export type roleKeysType = keyof typeof ROLEKEYS; +export const ROLE_USER_CENTER = { + ...USER_CENTER_MENU_DATA, + buttons: [ + { + id: 'passwd-update', + name: '密码修改', + enabled: true, + granted: true + }, + { + id: 'info-update', + name: '基本信息修改', + enabled: true, + granted: true + }, + { + id: 'message', + name: '消息订阅', + enabled: true, + granted: true + } + ], + assetAccesses: [], + granted: true, + owner: 'iot' +} + export const RoleData = { [ROLEKEYS.device]: { name: '设备接入岗', @@ -217,6 +245,7 @@ export default { createTime: 1659344075524, granted: true, }, + ROLE_USER_CENTER ], [ROLEKEYS.link]: [ { @@ -958,5 +987,6 @@ export default { accessDescription: '此菜单不支持数据权限控制', granted: true, }, + ROLE_USER_CENTER ], }; diff --git a/src/views/init-home/data/baseMenu.ts b/src/views/init-home/data/baseMenu.ts index f02c1674..83541bcb 100644 --- a/src/views/init-home/data/baseMenu.ts +++ b/src/views/init-home/data/baseMenu.ts @@ -1,3 +1,44 @@ +import { USER_CENTER_MENU_CODE } from '@/utils/consts' + +export const USER_CENTER_MENU_DATA = { + id: '19a1f2c763e1231f1e1', + accessSupport: { value: 'unsupported', label: '不支持'}, + supportDataAccess: false, + code: USER_CENTER_MENU_CODE, + buttons: [ + { + id: 'passwd-update', + name: '密码修改', + permissions: [ + { + permission: 'user', + action: ['update-self-pwd'] + } + ] + }, + { + id: 'info-update', + name: '基本信息修改', + permissions: [ + { + permission: 'user', + action: ['update-self-info'] + } + ] + }, + { + id: 'message', + name: '消息订阅', + permissions: [ + { + permission: 'alarm-config', + action: ['query'] + } + ] + } + ] +} + export default [ // 物联网 { @@ -4015,6 +4056,10 @@ export default [ permission: 'network-card', actions: ['save'], }, + { + permission: 'device-instance', + actions: ['query'], + }, ], }, { @@ -4219,4 +4264,6 @@ export default [ }, ], }, + // 用户中心 + USER_CENTER_MENU_DATA ]; diff --git a/src/views/system/Menu/Setting/index.vue b/src/views/system/Menu/Setting/index.vue index 68535772..cdb0d11c 100644 --- a/src/views/system/Menu/Setting/index.vue +++ b/src/views/system/Menu/Setting/index.vue @@ -73,6 +73,7 @@ import BaseMenu from '@/views/init-home/data/baseMenu'; import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree'; import { cloneDeep } from 'lodash'; import { onlyMessage } from '@/utils/comm'; +import { USER_CENTER_MENU_CODE } from '@/utils/consts' const selectedKeys: any = ref([]); const treeData = ref([]); @@ -185,7 +186,7 @@ onMounted(() => { ); getMenuTree_api(params).then((resp: any) => { if (resp.status == 200) { - systemMenu.value = resp.result; + systemMenu.value = resp.result?.filter((item: { code: string }) => item.code !== USER_CENTER_MENU_CODE); //初始化菜单 const baseMenuData = developArrToMap(baseMenu.value); const systemMenuData = developArrToMap(systemMenu.value, true); diff --git a/src/views/system/Menu/index.vue b/src/views/system/Menu/index.vue index 3d7cf206..e7edd234 100644 --- a/src/views/system/Menu/index.vue +++ b/src/views/system/Menu/index.vue @@ -84,7 +84,7 @@ import { getMenuTree_api, delMenuInfo_api } from '@/api/system/menu'; import { message } from 'jetlinks-ui-components'; import dayjs from 'dayjs'; import { useUserInfo } from '@/store/userInfo'; - +import { USER_CENTER_MENU_CODE } from '@/utils/consts' const admin = useUserInfo().userInfos?.type.id === 'admin'; const permission = 'system/Menu'; @@ -206,7 +206,7 @@ const table = reactive({ return { code: resp.message, result: { - data: resp.result, + data: resp.result?.filter((item: { code: string }) => item.code !== USER_CENTER_MENU_CODE), pageIndex: resp.pageIndex, pageSize: resp.pageSize, total: resp.total, From f5a125df65ec53340dda055f660cad24aa9cdbf5 Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 31 Mar 2023 19:07:25 +0800 Subject: [PATCH 2/7] fix: bug#11328 --- .../Save/action/ListItem/FilterCondition.vue | 16 ++++++++++------ .../Scene/Save/components/Terms/ParamsItem.vue | 17 ++++++++++------- yarn.lock | 4 ++-- 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue b/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue index 705449db..53433a86 100644 --- a/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue +++ b/src/views/rule-engine/Scene/Save/action/ListItem/FilterCondition.vue @@ -159,6 +159,7 @@ const paramsValue = reactive({ const formItemContext = Form.useInjectFormItemContext() const showDelete = ref(false) const columnOptions: any = inject('filter-params') // +const columnType = ref() const termTypeOptions = ref>([]) // 条件值 const valueOptions = ref([]) // 默认手动输入下拉 const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains'] @@ -175,6 +176,7 @@ const handOptionByColumn = (option: any) => { if (option) { termTypeOptions.value = option.termTypes || [] tabsOptions.value[0].component = option.type + columnType.value = option.type const _options = isArray(option.options) ? option.options : [] if (option.type === 'boolean') { valueOptions.value = _options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || [ @@ -289,14 +291,16 @@ const termsTypeSelect = (e: { key: string, name: string }) => { let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue // 如果上次的值 在 timeTypeKeys中 则不变 - if (timeTypeKeys.includes(e.key)) { - if (tabsOptions.value[0].component !== 'int') { + if (columnType.value ==='date') { + if (timeTypeKeys.includes(e.key)) { + if (tabsOptions.value[0].component !== 'int') { + value = undefined + } + tabsOptions.value[0].component = 'int' + } else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') { value = undefined + tabsOptions.value[0].component = 'date' } - tabsOptions.value[0].component = 'int' - } else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') { - value = undefined - tabsOptions.value[0].component = 'date' } paramsValue.value = { diff --git a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue index 0584fa46..c84abc93 100644 --- a/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue +++ b/src/views/rule-engine/Scene/Save/components/Terms/ParamsItem.vue @@ -152,6 +152,7 @@ const paramsValue = reactive({ const showDelete = ref(false) const columnOptions: any = inject(ContextKey) // +const columnType = ref() const termTypeOptions = ref>([]) // 条件值 const valueOptions = ref([]) // 默认手动输入下拉 const metricOption = ref([]) // 根据termType获取对应指标值 @@ -165,7 +166,7 @@ const handOptionByColumn = (option: any) => { metricsCacheOption.value = option.metrics?.map((item: any) => ({...item, label: item.name})) || [] tabsOptions.value.length = 1 tabsOptions.value[0].component = option.dataType - + columnType.value = option.dataType if (option.metrics && option.metrics.length) { tabsOptions.value.push( @@ -281,14 +282,16 @@ const termsTypeSelect = (e: { key: string, name: string }) => { const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue // 如果上次的值 在 timeTypeKeys中 则不变 - if (timeTypeKeys.includes(e.key)) { - if (tabsOptions.value[0].component !== 'int') { + if (columnType.value === 'date') { + if (timeTypeKeys.includes(e.key)) { + if (tabsOptions.value[0].component !== 'int') { + value = undefined + } + tabsOptions.value[0].component = 'int' + } else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') { value = undefined + tabsOptions.value[0].component = 'date' } - tabsOptions.value[0].component = 'int' - } else if (!timeTypeKeys.includes(e.key) && tabsOptions.value[0].component == 'int') { - value = undefined - tabsOptions.value[0].component = 'date' } paramsValue.value = { diff --git a/yarn.lock b/yarn.lock index 5dcb1134..7ff4dfe5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3700,8 +3700,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#c71ecae61776bff738f43efe46aac7264f092736" - integrity sha512-+1a/4nA5RCiInRFyyaVCMEWSBzNU8lzxOYTTpY0GiNhuJuhGE5AbBsVp9CXXF0lFECK2iqaAElY+QN4Wjms1Dw== + resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#8cbd59900e692dd931d289f3d5a6f4541485fd9f" + integrity sha512-ytX39qMt3kkEisURoIKlv2rAhGSvI74/WLLqkP6dJdz4q1k3UpANDtcnrz9rGRwTAKszVQ6kCga6VL6kGJiteQ== dependencies: "@vueuse/core" "^9.12.0" ant-design-vue "^3.2.15" From df6bf4d9eeb994ab7670ec0af71db66c68f0079e Mon Sep 17 00:00:00 2001 From: xieyonghong <18010623010@163.com> Date: Fri, 31 Mar 2023 21:18:45 +0800 Subject: [PATCH 3/7] fix: bug#11262 --- src/router/menu.ts | 2 + src/store/menu.ts | 14 ++++-- src/utils/consts.ts | 5 ++ src/views/account/Center/index.vue | 7 ++- src/views/init-home/Menu/index.vue | 5 +- src/views/init-home/data/RoleData.ts | 30 ------------ src/views/init-home/data/baseMenu.ts | 49 +++++++++++-------- src/views/init-home/index.vue | 6 +-- src/views/system/Menu/Setting/index.vue | 4 +- src/views/system/Menu/index.vue | 4 +- .../system/Role/Detail/Permiss/index.vue | 3 +- .../Role/Detail/components/PermissTree.vue | 26 ++++++++-- 12 files changed, 86 insertions(+), 69 deletions(-) diff --git a/src/router/menu.ts b/src/router/menu.ts index 18aab90b..0224dc75 100644 --- a/src/router/menu.ts +++ b/src/router/menu.ts @@ -2,6 +2,8 @@ export const LoginPath = '/login' export const InitHomePath = '/init-home' export const AccountCenterBindPath = '/account/center/bind' export const InitLicense = '/init-license' +export const NotificationSubscriptionCode = 'account/NotificationSubscription' +export const NotificationRecordCode = 'account/NotificationRecord' export const AccountMenu = { path: '/account', diff --git a/src/store/menu.ts b/src/store/menu.ts index 645471f8..16f65155 100644 --- a/src/store/menu.ts +++ b/src/store/menu.ts @@ -1,11 +1,12 @@ import { defineStore } from 'pinia' import { queryOwnThree } from '@/api/system/menu' import { filterAsyncRouter, findCodeRoute, MenuItem } from '@/utils/menu' -import { isArray } from 'lodash-es' +import { cloneDeep, isArray } from 'lodash-es' import { usePermissionStore } from './permission' import router from '@/router' import { onlyMessage } from '@/utils/comm' -import { AccountMenu } from '@/router/menu' +import { AccountMenu, NotificationRecordCode, NotificationSubscriptionCode } from '@/router/menu' +import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts' const defaultOwnParams = [ { @@ -96,6 +97,13 @@ export const useMenuStore = defineStore({ const permission = usePermissionStore() permission.permissions = {} const { menusData, silderMenus } = filterAsyncRouter(resp.result) + + // 是否存在通知订阅 + const hasMessageSub = resp.result.some((item: { code: string }) => item.code === MESSAGE_SUBSCRIBE_MENU_CODE) + console.log('hasMessageSub', hasMessageSub) + if (!hasMessageSub) { + AccountMenu.children = AccountMenu.children.filter((item: { code: string }) => ![NotificationSubscriptionCode, NotificationRecordCode].includes(item.code) ) + } this.menus = findCodeRoute([...resp.result, AccountMenu]) Object.keys(this.menus).forEach((item) => { const _item = this.menus[item] @@ -112,7 +120,7 @@ export const useMenuStore = defineStore({ } }) menusData.push(AccountMenu) - this.siderMenus = silderMenus + this.siderMenus = silderMenus.filter((item: { name: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.name)) res(menusData) } }) diff --git a/src/utils/consts.ts b/src/utils/consts.ts index 621b311b..04458dd8 100644 --- a/src/utils/consts.ts +++ b/src/utils/consts.ts @@ -1,3 +1,5 @@ +import { MESSAGE_SUBSCRIBE_MENU_DATA } from '@/views/init-home/data/baseMenu' + /** * 状态颜色 */ @@ -49,3 +51,6 @@ export const SystemConst = { } export const USER_CENTER_MENU_CODE = 'account-center' +export const USER_CENTER_MENU_BUTTON_CODE = 'user-center-passwd-update' +export const MESSAGE_SUBSCRIBE_MENU_CODE = 'message-subscribe' +export const MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE = 'message-subscribe-view' diff --git a/src/views/account/Center/index.vue b/src/views/account/Center/index.vue index dd36cfd7..becf59e7 100644 --- a/src/views/account/Center/index.vue +++ b/src/views/account/Center/index.vue @@ -110,7 +110,7 @@ /> -
+

修改密码

@@ -245,7 +245,10 @@ import moment from 'moment'; import { getMe_api, getView_api, setView_api } from '@/api/home'; import { isNoCommunity } from '@/utils/utils'; import { userInfoType } from './typing'; +import { usePermissionStore } from 'store/permission' +const btnHasPermission = usePermissionStore().hasPermission; +const updatePassword = btnHasPermission('account-center:user-center-passwd-update') const permission = 'system/User'; const userInfo = ref({} as any); // 第三方账号 @@ -361,7 +364,7 @@ function getViews() { .then((resp: any) => { if (resp?.status === 200) { if (resp.result) currentView.value = resp.result?.content; - else if (resp.result.username === 'admin') { + else if (resp.result?.username === 'admin') { currentView.value = 'comprehensive'; } else currentView.value = 'init'; } diff --git a/src/views/init-home/Menu/index.vue b/src/views/init-home/Menu/index.vue index b39a312a..6fa18e54 100644 --- a/src/views/init-home/Menu/index.vue +++ b/src/views/init-home/Menu/index.vue @@ -12,7 +12,7 @@