Merge branch 'dev' of github.com:jetlinks/jetlinks-ui-vue into dev
This commit is contained in:
commit
bc7d170666
|
@ -2,6 +2,8 @@ export const LoginPath = '/login'
|
||||||
export const InitHomePath = '/init-home'
|
export const InitHomePath = '/init-home'
|
||||||
export const AccountCenterBindPath = '/account/center/bind'
|
export const AccountCenterBindPath = '/account/center/bind'
|
||||||
export const InitLicense = '/init-license'
|
export const InitLicense = '/init-license'
|
||||||
|
export const NotificationSubscriptionCode = 'account/NotificationSubscription'
|
||||||
|
export const NotificationRecordCode = 'account/NotificationRecord'
|
||||||
|
|
||||||
export const AccountMenu = {
|
export const AccountMenu = {
|
||||||
path: '/account',
|
path: '/account',
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
import { defineStore } from 'pinia'
|
import { defineStore } from 'pinia'
|
||||||
import { queryOwnThree } from '@/api/system/menu'
|
import { queryOwnThree } from '@/api/system/menu'
|
||||||
import { filterAsyncRouter, findCodeRoute, MenuItem } from '@/utils/menu'
|
import { filterAsyncRouter, findCodeRoute, MenuItem } from '@/utils/menu'
|
||||||
import { isArray } from 'lodash-es'
|
import { cloneDeep, isArray } from 'lodash-es'
|
||||||
import { usePermissionStore } from './permission'
|
import { usePermissionStore } from './permission'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { onlyMessage } from '@/utils/comm'
|
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 = [
|
const defaultOwnParams = [
|
||||||
{
|
{
|
||||||
|
@ -96,6 +97,13 @@ export const useMenuStore = defineStore({
|
||||||
const permission = usePermissionStore()
|
const permission = usePermissionStore()
|
||||||
permission.permissions = {}
|
permission.permissions = {}
|
||||||
const { menusData, silderMenus } = filterAsyncRouter(resp.result)
|
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])
|
this.menus = findCodeRoute([...resp.result, AccountMenu])
|
||||||
Object.keys(this.menus).forEach((item) => {
|
Object.keys(this.menus).forEach((item) => {
|
||||||
const _item = this.menus[item]
|
const _item = this.menus[item]
|
||||||
|
@ -112,7 +120,7 @@ export const useMenuStore = defineStore({
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
menusData.push(AccountMenu)
|
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)
|
res(menusData)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
import { MESSAGE_SUBSCRIBE_MENU_DATA } from '@/views/init-home/data/baseMenu'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 状态颜色
|
* 状态颜色
|
||||||
*/
|
*/
|
||||||
|
@ -47,3 +49,8 @@ export const SystemConst = {
|
||||||
VERSION_CODE: 'version_code',
|
VERSION_CODE: 'version_code',
|
||||||
AMAP_KEY : 'amap_key',
|
AMAP_KEY : 'amap_key',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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'
|
||||||
|
|
|
@ -110,7 +110,7 @@
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card">
|
<div class="card" v-if='updatePassword'>
|
||||||
<h3>修改密码</h3>
|
<h3>修改密码</h3>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="content" style="align-items: flex-end">
|
<div class="content" style="align-items: flex-end">
|
||||||
|
@ -245,7 +245,10 @@ import moment from 'moment';
|
||||||
import { getMe_api, getView_api, setView_api } from '@/api/home';
|
import { getMe_api, getView_api, setView_api } from '@/api/home';
|
||||||
import { isNoCommunity } from '@/utils/utils';
|
import { isNoCommunity } from '@/utils/utils';
|
||||||
import { userInfoType } from './typing';
|
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 permission = 'system/User';
|
||||||
const userInfo = ref<userInfoType>({} as any);
|
const userInfo = ref<userInfoType>({} as any);
|
||||||
// 第三方账号
|
// 第三方账号
|
||||||
|
@ -361,7 +364,7 @@ function getViews() {
|
||||||
.then((resp: any) => {
|
.then((resp: any) => {
|
||||||
if (resp?.status === 200) {
|
if (resp?.status === 200) {
|
||||||
if (resp.result) currentView.value = resp.result?.content;
|
if (resp.result) currentView.value = resp.result?.content;
|
||||||
else if (resp.result.username === 'admin') {
|
else if (resp.result?.username === 'admin') {
|
||||||
currentView.value = 'comprehensive';
|
currentView.value = 'comprehensive';
|
||||||
} else currentView.value = 'init';
|
} else currentView.value = 'init';
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { getImage } from '@/utils/comm';
|
import { getImage } from '@/utils/comm';
|
||||||
import BaseMenu from '../data/baseMenu';
|
import BaseMenu, { MESSAGE_SUBSCRIBE_MENU_DATA, USER_CENTER_MENU_DATA } from '../data/baseMenu'
|
||||||
import { getSystemPermission, updateMenus } from '@/api/initHome';
|
import { getSystemPermission, updateMenus } from '@/api/initHome';
|
||||||
/**
|
/**
|
||||||
* 获取菜单数据
|
* 获取菜单数据
|
||||||
|
@ -70,7 +70,8 @@ const menuCount = (menus: any[]) => {
|
||||||
*/
|
*/
|
||||||
const initMenu = async () => {
|
const initMenu = async () => {
|
||||||
return new Promise(async (resolve) => {
|
return new Promise(async (resolve) => {
|
||||||
const res = await updateMenus(menuDatas.current);
|
// 用户中心
|
||||||
|
const res = await updateMenus([...menuDatas.current!, USER_CENTER_MENU_DATA, MESSAGE_SUBSCRIBE_MENU_DATA]);
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,3 +1,55 @@
|
||||||
|
import {
|
||||||
|
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
|
||||||
|
MESSAGE_SUBSCRIBE_MENU_CODE,
|
||||||
|
USER_CENTER_MENU_BUTTON_CODE,
|
||||||
|
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,
|
||||||
|
name: '个人中心',
|
||||||
|
url: '/user-center',
|
||||||
|
sortIndex: 9999,
|
||||||
|
granted: true,
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
id: USER_CENTER_MENU_BUTTON_CODE,
|
||||||
|
name: '修改密码',
|
||||||
|
permissions: [
|
||||||
|
{
|
||||||
|
permission: 'user',
|
||||||
|
action: ['update-self-pwd']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
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',
|
||||||
|
action: ['query']
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
sortIndex: 9998
|
||||||
|
}
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
// 物联网
|
// 物联网
|
||||||
{
|
{
|
||||||
|
@ -4015,6 +4067,10 @@ export default [
|
||||||
permission: 'network-card',
|
permission: 'network-card',
|
||||||
actions: ['save'],
|
actions: ['save'],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
permission: 'device-instance',
|
||||||
|
actions: ['query'],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -4218,5 +4274,5 @@ export default [
|
||||||
supportDataAccess: false
|
supportDataAccess: false
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
}
|
||||||
];
|
];
|
||||||
|
|
|
@ -139,9 +139,9 @@ const judgeInitSet = async () => {
|
||||||
window.location.href = '/';
|
window.location.href = '/';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
onMounted(() => {
|
onBeforeMount(() => {
|
||||||
judgeInitSet();
|
// judgeInitSet();
|
||||||
});
|
})
|
||||||
</script>
|
</script>
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.page-container {
|
.page-container {
|
||||||
|
|
|
@ -70,6 +70,7 @@
|
||||||
import { queryPlatformNoPage, recharge } from '@/api/iot-card/cardManagement';
|
import { queryPlatformNoPage, recharge } from '@/api/iot-card/cardManagement';
|
||||||
import { message } from 'jetlinks-ui-components';
|
import { message } from 'jetlinks-ui-components';
|
||||||
import { PaymentMethod } from '@/views/iot-card/data';
|
import { PaymentMethod } from '@/views/iot-card/data';
|
||||||
|
import { onlyMessage } from '@/utils/comm'
|
||||||
|
|
||||||
const emit = defineEmits(['change', 'save']);
|
const emit = defineEmits(['change', 'save']);
|
||||||
|
|
||||||
|
@ -168,6 +169,8 @@ const handleOk = () => {
|
||||||
if (resp.status === 200) {
|
if (resp.status === 200) {
|
||||||
if (resp.result === '失败') {
|
if (resp.result === '失败') {
|
||||||
message.error('缴费失败')
|
message.error('缴费失败')
|
||||||
|
} else if(resp.result) {
|
||||||
|
onlyMessage('操作过于频繁,请稍后再试!', 'warning')
|
||||||
} else {
|
} else {
|
||||||
window.open(resp.result);
|
window.open(resp.result);
|
||||||
}
|
}
|
||||||
|
|
|
@ -161,7 +161,7 @@ const saveChange = (val: any) => {
|
||||||
if (val) {
|
if (val) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
rechargeRef.value?.reload();
|
rechargeRef.value?.reload();
|
||||||
}, 500)
|
}, 700)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -315,7 +315,7 @@ const getActions = (data: Partial<Record<string, any>>): ActionsType[] => {
|
||||||
text: '删除',
|
text: '删除',
|
||||||
disabled: state === 'enabled',
|
disabled: state === 'enabled',
|
||||||
tooltip: {
|
tooltip: {
|
||||||
title: state === 'enabled' ? '已启用的设备不能删除' : '删除',
|
title: state === 'enabled' ? '请先禁用,再删除' : '删除',
|
||||||
},
|
},
|
||||||
popConfirm: {
|
popConfirm: {
|
||||||
title: '确认删除?',
|
title: '确认删除?',
|
||||||
|
|
|
@ -159,6 +159,7 @@ const paramsValue = reactive<TermsType>({
|
||||||
const formItemContext = Form.useInjectFormItemContext()
|
const formItemContext = Form.useInjectFormItemContext()
|
||||||
const showDelete = ref(false)
|
const showDelete = ref(false)
|
||||||
const columnOptions: any = inject('filter-params') //
|
const columnOptions: any = inject('filter-params') //
|
||||||
|
const columnType = ref<string>()
|
||||||
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
||||||
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
||||||
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains']
|
const arrayParamsKey = ['nbtw', 'btw', 'in', 'nin', 'contains_all', 'contains_any', 'not_contains']
|
||||||
|
@ -175,6 +176,7 @@ const handOptionByColumn = (option: any) => {
|
||||||
if (option) {
|
if (option) {
|
||||||
termTypeOptions.value = option.termTypes || []
|
termTypeOptions.value = option.termTypes || []
|
||||||
tabsOptions.value[0].component = option.type
|
tabsOptions.value[0].component = option.type
|
||||||
|
columnType.value = option.type
|
||||||
const _options = isArray(option.options) ? option.options : []
|
const _options = isArray(option.options) ? option.options : []
|
||||||
if (option.type === 'boolean') {
|
if (option.type === 'boolean') {
|
||||||
valueOptions.value = _options?.map((item: any) => ({ ...item, label: item.name, value: item.id})) || [
|
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
|
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
|
||||||
|
|
||||||
// 如果上次的值 在 timeTypeKeys中 则不变
|
// 如果上次的值 在 timeTypeKeys中 则不变
|
||||||
if (timeTypeKeys.includes(e.key)) {
|
if (columnType.value ==='date') {
|
||||||
if (tabsOptions.value[0].component !== 'int') {
|
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
|
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 = {
|
paramsValue.value = {
|
||||||
|
|
|
@ -152,6 +152,7 @@ const paramsValue = reactive<TermsType>({
|
||||||
|
|
||||||
const showDelete = ref(false)
|
const showDelete = ref(false)
|
||||||
const columnOptions: any = inject(ContextKey) //
|
const columnOptions: any = inject(ContextKey) //
|
||||||
|
const columnType = ref<string>()
|
||||||
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
const termTypeOptions = ref<Array<{ id: string, name: string}>>([]) // 条件值
|
||||||
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
const valueOptions = ref<any[]>([]) // 默认手动输入下拉
|
||||||
const metricOption = ref<any[]>([]) // 根据termType获取对应指标值
|
const metricOption = ref<any[]>([]) // 根据termType获取对应指标值
|
||||||
|
@ -165,7 +166,7 @@ const handOptionByColumn = (option: any) => {
|
||||||
metricsCacheOption.value = option.metrics?.map((item: any) => ({...item, label: item.name})) || []
|
metricsCacheOption.value = option.metrics?.map((item: any) => ({...item, label: item.name})) || []
|
||||||
tabsOptions.value.length = 1
|
tabsOptions.value.length = 1
|
||||||
tabsOptions.value[0].component = option.dataType
|
tabsOptions.value[0].component = option.dataType
|
||||||
|
columnType.value = option.dataType
|
||||||
if (option.metrics && option.metrics.length) {
|
if (option.metrics && option.metrics.length) {
|
||||||
|
|
||||||
tabsOptions.value.push(
|
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
|
const oldValue = isArray(paramsValue.value!.value) ? paramsValue.value!.value[0] : paramsValue.value!.value
|
||||||
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
|
let value = arrayParamsKey.includes(e.key) ? [ oldValue, undefined ] : oldValue
|
||||||
// 如果上次的值 在 timeTypeKeys中 则不变
|
// 如果上次的值 在 timeTypeKeys中 则不变
|
||||||
if (timeTypeKeys.includes(e.key)) {
|
if (columnType.value === 'date') {
|
||||||
if (tabsOptions.value[0].component !== 'int') {
|
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
|
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 = {
|
paramsValue.value = {
|
||||||
|
|
|
@ -73,6 +73,7 @@ import BaseMenu from '@/views/init-home/data/baseMenu';
|
||||||
import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree';
|
import type { AntTreeNodeDropEvent } from 'ant-design-vue/es/tree';
|
||||||
import { cloneDeep } from 'lodash';
|
import { cloneDeep } from 'lodash';
|
||||||
import { onlyMessage } from '@/utils/comm';
|
import { onlyMessage } from '@/utils/comm';
|
||||||
|
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||||
|
|
||||||
const selectedKeys: any = ref([]);
|
const selectedKeys: any = ref([]);
|
||||||
const treeData = ref<any>([]);
|
const treeData = ref<any>([]);
|
||||||
|
@ -103,10 +104,55 @@ const params = {
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// 过滤子级空children
|
||||||
|
const filterAndClean = (data: any) => {
|
||||||
|
// 如果 data 是一个数组,则对每个元素递归调用此函数
|
||||||
|
if (Array.isArray(data)) {
|
||||||
|
return data
|
||||||
|
.filter((item) => item !== null) // 过滤掉 null 元素
|
||||||
|
.map((item: any) => filterAndClean(item)); // 递归调用此函数
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果 data 是一个对象,则递归调用此函数来清除其子元素
|
||||||
|
if (typeof data === 'object') {
|
||||||
|
let cleanedChildren = filterAndClean(data.children); // 递归清除子元素
|
||||||
|
if (Array.isArray(cleanedChildren)) {
|
||||||
|
cleanedChildren = cleanedChildren.filter((i) => i);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cleanedChildren !== undefined) {
|
||||||
|
data.children = cleanedChildren;
|
||||||
|
} else {
|
||||||
|
delete data.children; // 如果 children 是 undefined,则将其删除
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return data;
|
||||||
|
};
|
||||||
|
|
||||||
const handleOk = async () => {
|
const handleOk = async () => {
|
||||||
|
const { arrMap, rootSet } = developArrToMap(
|
||||||
|
cloneDeep(treeData.value),
|
||||||
|
false,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
const dataMap = new Map();
|
||||||
|
// 过滤选中菜单的map
|
||||||
|
selectedKeys.value.forEach((item: string) => {
|
||||||
|
if (arrMap.has(item)) {
|
||||||
|
dataMap.set(item, arrMap.get(item));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
const _saveDataMap = {
|
||||||
|
arrMap: dataMap,
|
||||||
|
rootSet,
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataArr = filterAndClean(mergeMapToArr(_saveDataMap, _saveDataMap));
|
||||||
|
|
||||||
loading.value = true;
|
loading.value = true;
|
||||||
const res = await updateMenus(treeData.value);
|
const res = await updateMenus(dataArr).catch(() => {});
|
||||||
if (res.status === 200) {
|
if (res?.status === 200) {
|
||||||
onlyMessage('操作成功', 'success');
|
onlyMessage('操作成功', 'success');
|
||||||
}
|
}
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
|
@ -140,7 +186,7 @@ onMounted(() => {
|
||||||
);
|
);
|
||||||
getMenuTree_api(params).then((resp: any) => {
|
getMenuTree_api(params).then((resp: any) => {
|
||||||
if (resp.status == 200) {
|
if (resp.status == 200) {
|
||||||
systemMenu.value = resp.result;
|
systemMenu.value = resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.code));
|
||||||
//初始化菜单
|
//初始化菜单
|
||||||
const baseMenuData = developArrToMap(baseMenu.value);
|
const baseMenuData = developArrToMap(baseMenu.value);
|
||||||
const systemMenuData = developArrToMap(systemMenu.value, true);
|
const systemMenuData = developArrToMap(systemMenu.value, true);
|
||||||
|
|
|
@ -31,12 +31,12 @@ export const filterMenu = (permissions: string[], menus: any[]) => {
|
||||||
export const mergeMapToArr = (baseMenuData: any, systemMenuData: any) => {
|
export const mergeMapToArr = (baseMenuData: any, systemMenuData: any) => {
|
||||||
const updataArr = (r: any) => {
|
const updataArr = (r: any) => {
|
||||||
for (let i = 0; i < r.length; i++) {
|
for (let i = 0; i < r.length; i++) {
|
||||||
const child = r[i].children;
|
let child = r[i].children;
|
||||||
if (child) {
|
if (child) {
|
||||||
updataArr(child);
|
updataArr(child);
|
||||||
}
|
}
|
||||||
r[i] = newMap.get(r[i].code);
|
r[i] = newMap.get(r[i].code);
|
||||||
delete r[i].parentCode;
|
r[i]?.parentCode && delete r[i].parentCode;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const root: any = [];
|
const root: any = [];
|
||||||
|
@ -45,7 +45,7 @@ export const mergeMapToArr = (baseMenuData: any, systemMenuData: any) => {
|
||||||
...new Set([...baseMenuData?.rootSet, ...systemMenuData.rootSet]),
|
...new Set([...baseMenuData?.rootSet, ...systemMenuData.rootSet]),
|
||||||
];
|
];
|
||||||
newRootArr.forEach((item: any) => {
|
newRootArr.forEach((item: any) => {
|
||||||
root.push(newMap.get(item));
|
newMap.has(item) && root.push(newMap.get(item));
|
||||||
});
|
});
|
||||||
updataArr(root);
|
updataArr(root);
|
||||||
return root;
|
return root;
|
||||||
|
@ -55,9 +55,10 @@ export const mergeMapToArr = (baseMenuData: any, systemMenuData: any) => {
|
||||||
* 平铺菜单
|
* 平铺菜单
|
||||||
* @param value 默认菜单以及查询系统菜单 baseMenu systemMenu
|
* @param value 默认菜单以及查询系统菜单 baseMenu systemMenu
|
||||||
* @param checked 查询系统菜单传true
|
* @param checked 查询系统菜单传true
|
||||||
|
* @param save 保存时传true
|
||||||
* @returns 平铺菜单Map、根菜单名、系统选中的keys
|
* @returns 平铺菜单Map、根菜单名、系统选中的keys
|
||||||
*/
|
*/
|
||||||
export const developArrToMap = (Menu: any, checked = false) => {
|
export const developArrToMap = (Menu: any, checked = false, save = false) => {
|
||||||
const rootSet = new Set();
|
const rootSet = new Set();
|
||||||
const arrMap = new Map();
|
const arrMap = new Map();
|
||||||
const checkedKeys: any = [];
|
const checkedKeys: any = [];
|
||||||
|
@ -65,10 +66,16 @@ export const developArrToMap = (Menu: any, checked = false) => {
|
||||||
arr.forEach((item: any) => {
|
arr.forEach((item: any) => {
|
||||||
item.title = item.code;
|
item.title = item.code;
|
||||||
item.key = item.code;
|
item.key = item.code;
|
||||||
if (checked || item?.checked) {
|
if (save) {
|
||||||
item.checked = item?.checked || checked;
|
delete item.checked; //保存时删除 checked 字段
|
||||||
checkedKeys.push(item.code);
|
checkedKeys.push(item.code);
|
||||||
|
} else {
|
||||||
|
if (checked || item?.checked) {
|
||||||
|
item.checked = item?.checked || checked;
|
||||||
|
checkedKeys.push(item.code);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
arrMap.set(item.code, item);
|
arrMap.set(item.code, item);
|
||||||
if (parentCode === 'root') {
|
if (parentCode === 'root') {
|
||||||
rootSet.add(item.code); //处理根菜单
|
rootSet.add(item.code); //处理根菜单
|
||||||
|
|
|
@ -84,7 +84,7 @@ import { getMenuTree_api, delMenuInfo_api } from '@/api/system/menu';
|
||||||
import { message } from 'jetlinks-ui-components';
|
import { message } from 'jetlinks-ui-components';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
import { useUserInfo } from '@/store/userInfo';
|
import { useUserInfo } from '@/store/userInfo';
|
||||||
|
import { MESSAGE_SUBSCRIBE_MENU_CODE, USER_CENTER_MENU_CODE } from '@/utils/consts'
|
||||||
const admin = useUserInfo().userInfos?.type.id === 'admin';
|
const admin = useUserInfo().userInfos?.type.id === 'admin';
|
||||||
|
|
||||||
const permission = 'system/Menu';
|
const permission = 'system/Menu';
|
||||||
|
@ -206,7 +206,7 @@ const table = reactive({
|
||||||
return {
|
return {
|
||||||
code: resp.message,
|
code: resp.message,
|
||||||
result: {
|
result: {
|
||||||
data: resp.result,
|
data: resp.result?.filter((item: { code: string }) => ![USER_CENTER_MENU_CODE, MESSAGE_SUBSCRIBE_MENU_CODE].includes(item.code)),
|
||||||
pageIndex: resp.pageIndex,
|
pageIndex: resp.pageIndex,
|
||||||
pageSize: resp.pageSize,
|
pageSize: resp.pageSize,
|
||||||
total: resp.total,
|
total: resp.total,
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
import { FormInstance, message } from 'ant-design-vue';
|
import { FormInstance, message } from 'ant-design-vue';
|
||||||
import PermissTree from '../components/PermissTree.vue';
|
import PermissTree from '../components/PermissTree.vue';
|
||||||
import { useMenuStore } from '@/store/menu';
|
import { useMenuStore } from '@/store/menu';
|
||||||
|
import { USER_CENTER_MENU_DATA } from '@/views/init-home/data/baseMenu'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
getRoleDetails_api,
|
getRoleDetails_api,
|
||||||
|
@ -71,7 +72,7 @@ const form = reactive({
|
||||||
name: '',
|
name: '',
|
||||||
description: '',
|
description: '',
|
||||||
},
|
},
|
||||||
menus: [],
|
menus: [USER_CENTER_MENU_DATA],
|
||||||
getForm: () => {
|
getForm: () => {
|
||||||
getRoleDetails_api(roleId).then((resp) => {
|
getRoleDetails_api(roleId).then((resp) => {
|
||||||
if (resp.status) {
|
if (resp.status) {
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
<j-checkbox
|
<j-checkbox
|
||||||
v-model:checked="record.granted"
|
v-model:checked="record.granted"
|
||||||
:indeterminate="record.indeterminate"
|
:indeterminate="record.indeterminate"
|
||||||
|
:disabled='record.code === USER_CENTER_MENU_CODE'
|
||||||
@change="menuChange(record, true)"
|
@change="menuChange(record, true)"
|
||||||
>{{ record.name }}</j-checkbox
|
>{{ record.name }}</j-checkbox
|
||||||
>
|
>
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
v-for="button in record.buttons"
|
v-for="button in record.buttons"
|
||||||
v-model:checked="button.granted"
|
v-model:checked="button.granted"
|
||||||
@change="actionChange(record)"
|
@change="actionChange(record)"
|
||||||
|
:disabled='[USER_CENTER_MENU_BUTTON_CODE].includes(button.id)'
|
||||||
>{{ button.name }}</j-checkbox
|
>{{ button.name }}</j-checkbox
|
||||||
>
|
>
|
||||||
</div>
|
</div>
|
||||||
|
@ -101,6 +103,13 @@
|
||||||
import { cloneDeep, uniqBy } from 'lodash-es';
|
import { cloneDeep, uniqBy } from 'lodash-es';
|
||||||
import { getPrimissTree_api } from '@/api/system/role';
|
import { getPrimissTree_api } from '@/api/system/role';
|
||||||
import { getCurrentInstance } from 'vue';
|
import { getCurrentInstance } from 'vue';
|
||||||
|
import {
|
||||||
|
USER_CENTER_MENU_BUTTON_CODE,
|
||||||
|
MESSAGE_SUBSCRIBE_MENU_BUTTON_CODE,
|
||||||
|
USER_CENTER_MENU_CODE,
|
||||||
|
MESSAGE_SUBSCRIBE_MENU_CODE
|
||||||
|
} from '@/utils/consts'
|
||||||
|
|
||||||
const emits = defineEmits(['update:selectItems']);
|
const emits = defineEmits(['update:selectItems']);
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
@ -222,9 +231,10 @@ const init = () => {
|
||||||
() => {
|
() => {
|
||||||
// 深克隆表格数据的扁平版 因为会做一些改动 该改动只用于反馈给父组件,本组件无需变化
|
// 深克隆表格数据的扁平版 因为会做一些改动 该改动只用于反馈给父组件,本组件无需变化
|
||||||
const selected = cloneDeep(flatTableData).filter(
|
const selected = cloneDeep(flatTableData).filter(
|
||||||
(item) =>
|
(item: any) =>
|
||||||
(item.granted && item.parentId) ||
|
(item.granted && item.parentId) ||
|
||||||
(item.indeterminate && item.buttons),
|
(item.indeterminate && item.buttons) ||
|
||||||
|
item.code === USER_CENTER_MENU_CODE || item.code === MESSAGE_SUBSCRIBE_MENU_CODE, // 放开个人中心以及消息订阅
|
||||||
);
|
);
|
||||||
|
|
||||||
selected.forEach((item) => {
|
selected.forEach((item) => {
|
||||||
|
@ -260,9 +270,17 @@ init();
|
||||||
function getAllPermiss() {
|
function getAllPermiss() {
|
||||||
const id = route.params.id as string;
|
const id = route.params.id as string;
|
||||||
getPrimissTree_api(id).then((resp) => {
|
getPrimissTree_api(id).then((resp) => {
|
||||||
tableData.value = resp.result;
|
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}))
|
||||||
|
}
|
||||||
|
return item
|
||||||
|
});
|
||||||
|
|
||||||
treeToSimple(resp.result); // 表格数据扁平化
|
treeToSimple(tableData.value); // 表格数据扁平化
|
||||||
|
|
||||||
const selectList = flatTableData.filter((item) => item.granted); // 第一列选中的项
|
const selectList = flatTableData.filter((item) => item.granted); // 第一列选中的项
|
||||||
emits('update:selectItems', selectList); // 选中的项传回父组件
|
emits('update:selectItems', selectList); // 选中的项传回父组件
|
||||||
|
|
|
@ -3700,8 +3700,8 @@ jetlinks-store@^0.0.3:
|
||||||
|
|
||||||
jetlinks-ui-components@^1.0.5:
|
jetlinks-ui-components@^1.0.5:
|
||||||
version "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"
|
resolved "http://47.108.170.157:9013/jetlinks-ui-components/-/jetlinks-ui-components-1.0.5.tgz#8cbd59900e692dd931d289f3d5a6f4541485fd9f"
|
||||||
integrity sha512-+1a/4nA5RCiInRFyyaVCMEWSBzNU8lzxOYTTpY0GiNhuJuhGE5AbBsVp9CXXF0lFECK2iqaAElY+QN4Wjms1Dw==
|
integrity sha512-ytX39qMt3kkEisURoIKlv2rAhGSvI74/WLLqkP6dJdz4q1k3UpANDtcnrz9rGRwTAKszVQ6kCga6VL6kGJiteQ==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@vueuse/core" "^9.12.0"
|
"@vueuse/core" "^9.12.0"
|
||||||
ant-design-vue "^3.2.15"
|
ant-design-vue "^3.2.15"
|
||||||
|
|
Loading…
Reference in New Issue