# Conflicts:
#	admin/src/store/modules/user.ts
This commit is contained in:
Jason
2022-04-20 12:11:43 +08:00
47 changed files with 106 additions and 45 deletions

View File

@@ -3,10 +3,11 @@
<!-- <input class="search-input" placeholder="请输入搜索内容…" type="text" /> -->
<div class="admin-info flex flex-center m-l-40">
<el-avatar :size="40" :src="userInfo.avatar"></el-avatar>
<div class="m-l-10">
<el-dropdown trigger="hover" @command="handleCommand">
<div class="flex flex-center">
{{ userInfo.name }}
{{ userInfo.username }}
<el-icon class="el-icon--right"><arrow-down /></el-icon>
</div>
<template #dropdown>
@@ -33,6 +34,8 @@ export default defineComponent({
setup() {
const { store, router } = useAdmin()
const userInfo = computed(() => store.getters.userInfo)
console.log(userInfo, 'userInfo')
const handleCommand = (command: string) => {
switch (command) {
case 'logout':

View File

@@ -43,7 +43,7 @@
<el-tree
ref="treeRef"
:data="menu.permissionsTree"
node-key="auth_key"
node-key="id"
default-expand-all
icon="ArrowRight"
:props="{
@@ -93,14 +93,15 @@ export default defineComponent({
formData: {
name: '', // 角色名称
remark: '', // 备注
auth_keys: [], // 权限
menus: [], // 权限就选中的菜单id
isDisable: 0,
sort: ''
sort: '',
menuIds: '', // 菜单ID数组,逗号隔开
},
menu: {
permissionsTree: [], // 菜单
allAuthKeys: [] // 菜单全部的auth_keys
allAuthKeys: [] // 菜单全部的id
}
})
)
@@ -132,13 +133,13 @@ export default defineComponent({
.then((res: any) => {
// 获取菜单
menu.value.permissionsTree = res
// console.log('res', res)
console.log('res', res)
// 数组扁平化
const menuFlatten = flatten(res, [], 'sons')
const menuFlatten = flatten(res, [], 'children')
// console.log(menuFlatten)
// 获取菜单全部 auth_key
menu.value.allAuthKeys = menuFlatten.map((item: any) => item.auth_key) as never
// 获取菜单全部 id
menu.value.allAuthKeys = menuFlatten.map((item: any) => item.id) as never
})
.catch((err: any) => {
console.log('err', err)
@@ -160,6 +161,11 @@ export default defineComponent({
}
// 编辑角色
const roleEdit = () => {
// 选择中的权限id字符串
formData.value.menus.length == 0
? formData.value.menuIds = ''
: formData.value.menuIds = formData.value.menus.join(',')
apiRoleEdit({
...formData.value,
id: id.value
@@ -184,9 +190,8 @@ export default defineComponent({
console.log('res', res)
formData.value = res
// formData.value.auth_keys = []
treeRef.value?.setCheckedKeys(res.auth_keys)
treeRef.value?.setCheckedKeys(res.menus)
})
.catch((err: any) => {
console.log('err', err)
@@ -196,17 +201,17 @@ export default defineComponent({
// 权限树触发函数
const handlePermissionsCheckChange = (data: any, checked: boolean) => {
console.log(data)
if (!data.auth_key) {
if (!data.id) {
return
}
const index = formData.value.auth_keys.findIndex(item => item == data.auth_key)
const index = formData.value.menus.findIndex(item => item == data.id)
if (checked) {
index == -1 && (formData.value.auth_keys as any).push(data.auth_key)
index == -1 && (formData.value.menus as any).push(data.id)
return
}
if (index != -1) {
formData.value.auth_keys.splice(index, 1)
formData.value.menus.splice(index, 1)
}
}

View File

@@ -199,9 +199,16 @@ const getSystemCache = async () => {
formData.value.dbSize = res.dbSize || ''
statisticalData.commandChartOption.series[0].data = res.commandStats
statisticalData.memoryChartOption.series[0].data = res.info.used_memory_human
statisticalData.memoryChartOption.series[0].data[0].value = (
res.info.used_memory /
1024 /
1024
).toFixed(2)
statisticalData.memoryChartOption.series[0].detail.formatter = '{value}' + 'M'
console.log(res.info.used_memory_human, '-------------------------+')
console.log(
statisticalData.memoryChartOption.series[0].data,
(res.info.used_memory / 1024 / 1024).toFixed(2),
'-------------------------+'
)
})