fix: 修改密码权限
This commit is contained in:
parent
7b6684a9f4
commit
71ffdc13fe
|
@ -6,7 +6,7 @@ import { usePermissionStore } from './permission'
|
|||
import router from '@/router'
|
||||
import { onlyMessage } from '@/utils/comm'
|
||||
// import { AccountMenu, NotificationRecordCode, NotificationSubscriptionCode } from '@/router/menu'
|
||||
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||
import { USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||
import {isNoCommunity} from "@/utils/utils";
|
||||
|
||||
const defaultOwnParams = [
|
||||
|
@ -109,11 +109,6 @@ export const useMenuStore = defineStore({
|
|||
permission.permissions = {}
|
||||
const { menusData, silderMenus } = filterAsyncRouter(resultData)
|
||||
|
||||
// 是否存在通知订阅
|
||||
// const hasMessageSub = resultData.some((item: { code: string }) => item.code === MESSAGE_SUBSCRIBE_MENU_CODE)
|
||||
// if (!hasMessageSub) {
|
||||
// AccountMenu.children = AccountMenu.children.filter((item: { code: string }) => ![NotificationSubscriptionCode, NotificationRecordCode].includes(item.code) )
|
||||
// }
|
||||
this.menus = findCodeRoute([...resultData]) // AccountMenu
|
||||
Object.keys(this.menus).forEach((item) => {
|
||||
const _item = this.menus[item]
|
||||
|
@ -130,7 +125,7 @@ export const useMenuStore = defineStore({
|
|||
}
|
||||
})
|
||||
// menusData.push(AccountMenu)
|
||||
this.siderMenus = silderMenus.filter((item: { name: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.name))
|
||||
this.siderMenus = silderMenus.filter((item: { name: string }) => ![USER_CENTER_MENU_CODE].includes(item.name))
|
||||
res(menusData)
|
||||
}
|
||||
})
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
import { MESSAGE_SUBSCRIBE_MENU_DATA } from '@/views/init-home/data/baseMenu'
|
||||
|
||||
/**
|
||||
* 状态颜色
|
||||
*/
|
||||
|
@ -52,5 +50,3 @@ 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'
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
:defaultParams="defaultParams"
|
||||
>
|
||||
<template #headerTitle>
|
||||
<j-button type="primary">全部已读</j-button>
|
||||
<j-button @click="onAllRead" type="primary">全部已读</j-button>
|
||||
</template>
|
||||
<template #topicProvider="slotProps">
|
||||
{{ slotProps.topicName }}
|
||||
|
@ -242,6 +242,10 @@ watchEffect(() => {
|
|||
}
|
||||
})
|
||||
|
||||
const onAllRead = () => {
|
||||
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (routerParams.params?.value.row) {
|
||||
view(routerParams.params?.value.row);
|
||||
|
|
|
@ -58,14 +58,19 @@
|
|||
style="font-size: 24px"
|
||||
type="FormOutlined" /></j-button
|
||||
></j-tooltip>
|
||||
<j-tooltip title="修改密码"
|
||||
><j-button
|
||||
shape="circle"
|
||||
@click="editPasswordVisible = true"
|
||||
><AIcon
|
||||
style="font-size: 24px"
|
||||
type="LockOutlined" /></j-button
|
||||
></j-tooltip>
|
||||
<PermissionButton
|
||||
shape="circle"
|
||||
:hasPermission="`${USER_CENTER_MENU_CODE}:${USER_CENTER_MENU_BUTTON_CODE}`"
|
||||
:tooltip="{
|
||||
title: '修改密码'
|
||||
}"
|
||||
@click="editPasswordVisible = true"
|
||||
>
|
||||
<AIcon
|
||||
style="font-size: 24px"
|
||||
type="LockOutlined"
|
||||
/>
|
||||
</PermissionButton>
|
||||
</j-space>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -108,6 +113,10 @@ import UploadAvatar from './components/UploadAvatar/index.vue';
|
|||
import { updateMeInfo_api } from '@/api/account/center';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
import { useRouterParams } from '@/utils/hooks/useParams';
|
||||
import {
|
||||
USER_CENTER_MENU_BUTTON_CODE,
|
||||
USER_CENTER_MENU_CODE
|
||||
} from '@/utils/consts'
|
||||
|
||||
const imageTypes = reactive([
|
||||
'image/jpeg',
|
||||
|
@ -147,7 +156,7 @@ const tabs = {
|
|||
StationMessage,
|
||||
};
|
||||
|
||||
const router = useRouterParams()
|
||||
const router = useRouterParams();
|
||||
|
||||
// const activeKey = ref<KeyType>('HomeView');
|
||||
const visible = ref<boolean>(false);
|
||||
|
@ -196,10 +205,10 @@ const onAvatarChange = (url: string) => {
|
|||
};
|
||||
|
||||
watchEffect(() => {
|
||||
if(router.params.value?.tabKey) {
|
||||
user.tabKey = router.params.value?.tabKey
|
||||
if (router.params.value?.tabKey) {
|
||||
user.tabKey = router.params.value?.tabKey;
|
||||
}
|
||||
})
|
||||
});
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
@ -266,7 +275,7 @@ watchEffect(() => {
|
|||
}
|
||||
|
||||
.person-header-item-action-right {
|
||||
button {
|
||||
:deep(button) {
|
||||
height: 50px;
|
||||
width: 50px;
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<script lang="ts" setup>
|
||||
import { getImage } from '@/utils/comm';
|
||||
import BaseMenu, { MESSAGE_SUBSCRIBE_MENU_DATA, USER_CENTER_MENU_DATA } from '../data/baseMenu'
|
||||
import BaseMenu, { USER_CENTER_MENU_DATA } from '../data/baseMenu'
|
||||
import { getSystemPermission, updateMenus } from '@/api/initHome';
|
||||
/**
|
||||
* 获取菜单数据
|
||||
|
@ -71,7 +71,7 @@ const menuCount = (menus: any[]) => {
|
|||
const initMenu = async () => {
|
||||
return new Promise(async (resolve) => {
|
||||
// 用户中心
|
||||
const res = await updateMenus([...menuDatas.current!, USER_CENTER_MENU_DATA, MESSAGE_SUBSCRIBE_MENU_DATA]);
|
||||
const res = await updateMenus([...menuDatas.current!, USER_CENTER_MENU_DATA]);
|
||||
if (res.status === 200) {
|
||||
resolve(true);
|
||||
} else {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
import {
|
||||
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
|
||||
MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||
USER_CENTER_MENU_BUTTON_CODE,
|
||||
USER_CENTER_MENU_CODE
|
||||
} from '@/utils/consts'
|
||||
|
@ -11,7 +9,7 @@ export const USER_CENTER_MENU_DATA = {
|
|||
supportDataAccess: false,
|
||||
code: USER_CENTER_MENU_CODE,
|
||||
name: '个人中心',
|
||||
url: '/user-center',
|
||||
url: '/account/center',
|
||||
sortIndex: 9999,
|
||||
granted: true,
|
||||
buttons: [
|
||||
|
@ -32,28 +30,6 @@ export const USER_CENTER_MENU_DATA = {
|
|||
]
|
||||
}
|
||||
|
||||
export const MESSAGE_SUBSCRIBE_MENU_DATA = {
|
||||
id: '23a1f2c7123e56731f890',
|
||||
accessSupport: { value: 'unsupported', label: '不支持'},
|
||||
supportDataAccess: false,
|
||||
code: MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||
name: '通知订阅',
|
||||
url: '/message-subscribe',
|
||||
buttons: [
|
||||
{
|
||||
id: MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
|
||||
name: '查看',
|
||||
permissions: [
|
||||
{
|
||||
permission: 'alarm-config',
|
||||
actions: ['query']
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
sortIndex: 9998
|
||||
}
|
||||
|
||||
export default [
|
||||
// 物联网
|
||||
{
|
||||
|
|
|
@ -79,7 +79,6 @@ import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree';
|
|||
import { cloneDeep } from 'lodash';
|
||||
import { onlyMessage } from '@/utils/comm';
|
||||
import {
|
||||
MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||
USER_CENTER_MENU_CODE,
|
||||
} from '@/utils/consts';
|
||||
|
||||
|
@ -189,7 +188,6 @@ onMounted(() => {
|
|||
getSystemPermission_api().then((resp: any) => {
|
||||
const filterBaseMenu = BaseMenu.filter(item => ![
|
||||
USER_CENTER_MENU_CODE,
|
||||
MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||
].includes(item.code))
|
||||
baseMenu.value = filterMenu(
|
||||
resp.result.map((item: any) => JSON.parse(item).id),
|
||||
|
@ -200,8 +198,7 @@ onMounted(() => {
|
|||
systemMenu.value = resp.result?.filter(
|
||||
(item: { code: string }) =>
|
||||
![
|
||||
USER_CENTER_MENU_CODE,
|
||||
MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||
USER_CENTER_MENU_CODE
|
||||
].includes(item.code),
|
||||
);
|
||||
//初始化菜单
|
||||
|
|
|
@ -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 { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||
import { USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
const permission = 'system/Menu';
|
||||
|
@ -212,7 +212,7 @@ const table = reactive({
|
|||
return {
|
||||
code: resp.message,
|
||||
result: {
|
||||
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.code)),
|
||||
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE].includes(item.code)),
|
||||
pageIndex: resp.pageIndex,
|
||||
pageSize: resp.pageSize,
|
||||
total: resp.total,
|
||||
|
|
|
@ -97,10 +97,10 @@
|
|||
</template>
|
||||
</MCarousel>
|
||||
|
||||
<div class="child-item-right-auth" :class="{ active: auth.length }">
|
||||
<div class="child-item-right-auth">
|
||||
<j-tooltip :title="!update ? '暂无权限,请联系管理员' : ''">
|
||||
<j-button :disabled="!update" type="text" @click="onAuth">
|
||||
<div class="child-item-right-auth-btn">
|
||||
<div class="child-item-right-auth-btn" :class="{ active: auth.length }">
|
||||
<AIcon type="UserOutlined" />
|
||||
<span>权限控制</span>
|
||||
</div>
|
||||
|
|
|
@ -51,7 +51,7 @@
|
|||
import { FormInstance, message } from 'ant-design-vue';
|
||||
import PermissTree from '../components/PermissTree.vue';
|
||||
import { useMenuStore } from '@/store/menu';
|
||||
import { USER_CENTER_MENU_DATA } from '@/views/init-home/data/baseMenu'
|
||||
// import { USER_CENTER_MENU_DATA } from '@/views/init-home/data/baseMenu'
|
||||
|
||||
import {
|
||||
getRoleDetails_api,
|
||||
|
@ -72,7 +72,7 @@ const form = reactive({
|
|||
name: '',
|
||||
description: '',
|
||||
},
|
||||
menus: [USER_CENTER_MENU_DATA],
|
||||
menus: [], // USER_CENTER_MENU_DATA
|
||||
getForm: () => {
|
||||
getRoleDetails_api(roleId).then((resp) => {
|
||||
if (resp.status) {
|
||||
|
@ -86,7 +86,6 @@ const form = reactive({
|
|||
const updateTree = updatePrimissTree_api(roleId, {
|
||||
menus: form.menus,
|
||||
});
|
||||
// console.log(form.menus);
|
||||
Promise.all([updateRole, updateTree]).then((resp) => {
|
||||
message.success('操作成功');
|
||||
// jumpPage(`system/Role`);
|
||||
|
|
|
@ -52,10 +52,10 @@
|
|||
<j-checkbox
|
||||
v-model:checked="record.granted"
|
||||
:indeterminate="record.indeterminate"
|
||||
:disabled='record.code === USER_CENTER_MENU_CODE'
|
||||
@change="menuChange(record, true)"
|
||||
>{{ record.name }}</j-checkbox
|
||||
>
|
||||
<!-- :disabled='record.code === USER_CENTER_MENU_CODE' -->
|
||||
</div>
|
||||
|
||||
<div v-else-if="column.key === 'action'">
|
||||
|
@ -64,9 +64,10 @@
|
|||
v-for="button in record.buttons"
|
||||
v-model:checked="button.granted"
|
||||
@change="actionChange(record)"
|
||||
:disabled='[USER_CENTER_MENU_BUTTON_CODE].includes(button.id)'
|
||||
:key="button.id"
|
||||
>{{ button.name }}</j-checkbox
|
||||
>
|
||||
<!-- :disabled='[USER_CENTER_MENU_BUTTON_CODE].includes(button.id)' -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -82,6 +83,7 @@
|
|||
<j-radio
|
||||
:value="asset.supportId"
|
||||
v-for="asset in record.assetAccesses"
|
||||
:key="asset.name"
|
||||
>{{ asset.name }}</j-radio
|
||||
>
|
||||
</j-radio-group>
|
||||
|
@ -104,10 +106,8 @@ import { cloneDeep, uniqBy } from 'lodash-es';
|
|||
import { getPrimissTree_api } from '@/api/system/role';
|
||||
import { getCurrentInstance } from 'vue';
|
||||
import {
|
||||
USER_CENTER_MENU_BUTTON_CODE,
|
||||
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
|
||||
USER_CENTER_MENU_CODE,
|
||||
MESSAGE_SUBSCRIBE_MENU_CODE
|
||||
// USER_CENTER_MENU_BUTTON_CODE,
|
||||
USER_CENTER_MENU_CODE
|
||||
} from '@/utils/consts'
|
||||
import { isNoCommunity } from '@/utils/utils'
|
||||
|
||||
|
@ -172,7 +172,6 @@ const selectAllChange = () => {
|
|||
});
|
||||
}
|
||||
});
|
||||
// console.log('selectAllChange: ', flatTableData);
|
||||
indeterminate.value = false;
|
||||
emits(
|
||||
'update:selectItems',
|
||||
|
@ -215,7 +214,6 @@ const bulkChange = () => {
|
|||
});
|
||||
}
|
||||
});
|
||||
// console.log('bulkChange: ', flatTableData);
|
||||
emits(
|
||||
'update:selectItems',
|
||||
flatTableData.filter((item) => item.granted),
|
||||
|
@ -237,9 +235,9 @@ const init = () => {
|
|||
// 深克隆表格数据的扁平版 因为会做一些改动 该改动只用于反馈给父组件,本组件无需变化
|
||||
const selected = cloneDeep(flatTableData).filter(
|
||||
(item: any) =>
|
||||
(item.granted && item.parentId) ||
|
||||
(item.indeterminate && item.buttons) ||
|
||||
item.code === USER_CENTER_MENU_CODE || item.code === MESSAGE_SUBSCRIBE_MENU_CODE, // 放开个人中心以及消息订阅
|
||||
// (item.granted && item.parentId) ||
|
||||
(item.indeterminate && item.buttons)
|
||||
|| (item.granted), // 放开个人中心
|
||||
);
|
||||
|
||||
selected.forEach((item) => {
|
||||
|
@ -278,10 +276,10 @@ function getAllPermiss() {
|
|||
const _result = resp.result
|
||||
// 默认选中个人中心相关设置
|
||||
tableData.value = _result.map((item: { code: string , buttons: any[], granted: boolean}) => {
|
||||
if (item.code === USER_CENTER_MENU_CODE) {
|
||||
item.granted = true
|
||||
item.buttons = item.buttons.map( b => ({...b, granted: true, enabled: true}))
|
||||
}
|
||||
// if (item.code === USER_CENTER_MENU_CODE) {
|
||||
// item.granted = true
|
||||
// item.buttons = item.buttons.map( b => ({...b, granted: true, enabled: true}))
|
||||
// }
|
||||
return item
|
||||
});
|
||||
|
||||
|
@ -320,7 +318,7 @@ function menuChange(
|
|||
if (row.buttons && row.buttons.length > 0) setStatus(row, 'buttons');
|
||||
else setStatus(row, 'children');
|
||||
// 更新数据权限
|
||||
updataAuthority(row);
|
||||
updateAuthority(row);
|
||||
// if (row.accessSupport && row.accessSupport.value === 'support') {
|
||||
// // 如果当前数据权限已有值,且菜单权限没有被选中或被半选 则清空对应的数据权限
|
||||
// if (row.selectAccesses && !row.granted && !row.indeterminate)
|
||||
|
@ -358,6 +356,7 @@ function menuChange(
|
|||
selectedAll.value = false;
|
||||
indeterminate.value = false;
|
||||
}
|
||||
|
||||
emits('update:selectItems', selectList); // 选中的项传回父组件
|
||||
treeRef.value.$forceUpdate();
|
||||
}
|
||||
|
@ -365,7 +364,7 @@ function menuChange(
|
|||
/**
|
||||
* 更新权限
|
||||
*/
|
||||
const updataAuthority = (row: any) => {
|
||||
const updateAuthority = (row: any) => {
|
||||
if (row.accessSupport && row.accessSupport.value === 'support') {
|
||||
// 如果当前数据权限已有值,且菜单权限没有被选中或被半选 则清空对应的数据权限
|
||||
if (row.selectAccesses && !row.granted && !row.indeterminate)
|
||||
|
@ -375,7 +374,7 @@ const updataAuthority = (row: any) => {
|
|||
row.selectAccesses = 'creator';
|
||||
}
|
||||
if (row.children?.length > 0) {
|
||||
row.children?.forEach((item) => {
|
||||
row.children?.forEach((item: any) => {
|
||||
if (item.accessSupport && item.accessSupport.value === 'support') {
|
||||
// 如果当前数据权限已有值,且菜单权限没有被选中或被半选 则清空对应的数据权限
|
||||
if (item.selectAccesses && !item.granted && !item.indeterminate)
|
||||
|
@ -388,7 +387,7 @@ const updataAuthority = (row: any) => {
|
|||
item.selectAccesses = 'creator';
|
||||
}
|
||||
if (item.children) {
|
||||
updataAuthority(item.children);
|
||||
updateAuthority(item.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -439,12 +438,12 @@ function treeToSimple(_treeData: tableItemType[]) {
|
|||
}
|
||||
/**
|
||||
* 设置子节点的状态
|
||||
* @param childrens
|
||||
* @param _children
|
||||
* @param value
|
||||
*/
|
||||
function setChildrenChecked(childrens: tableItemType[], value: boolean) {
|
||||
if (childrens.length < 1) return;
|
||||
childrens.forEach((item) => {
|
||||
function setChildrenChecked(_children: tableItemType[], value: boolean) {
|
||||
if (_children.length < 1) return;
|
||||
_children.forEach((item) => {
|
||||
item.granted = value;
|
||||
item.indeterminate = false;
|
||||
if (item.buttons && item.buttons.length > 0)
|
||||
|
@ -457,7 +456,6 @@ function setChildrenChecked(childrens: tableItemType[], value: boolean) {
|
|||
i.granted = true;
|
||||
}
|
||||
});
|
||||
// console.log( item.assetAccesses);
|
||||
}
|
||||
item.children && setChildrenChecked(item.children, value);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue