|
@@ -17,7 +17,7 @@ import TableBase from '@/components/TableBase/index.vue'
|
|
|
import type { FormInstance, FormRules } from 'element-plus'
|
|
|
import type { ColumnProps } from '@/components/TableBase/interface/index'
|
|
|
import { Edit, Delete, Operation } from '@element-plus/icons-vue'
|
|
|
-import { ElNotification, ElMessageBox, ElMessage } from 'element-plus'
|
|
|
+import { ElNotification, ElMessageBox, ElMessage,TabsPaneContext } from 'element-plus'
|
|
|
|
|
|
interface InSys {
|
|
|
T_sys: string
|
|
@@ -39,6 +39,8 @@ const drawerRef = ref<InstanceType<typeof Drawer> | null>(null)
|
|
|
const TableRef = ref<InstanceType<typeof TableBase> | null>(null)
|
|
|
const initParam = { User_tokey, T_name: '' }
|
|
|
|
|
|
+
|
|
|
+
|
|
|
const DialogOpen = async (row: any) => {
|
|
|
currentVal = row
|
|
|
await getSysList()
|
|
@@ -52,32 +54,31 @@ const columns: ColumnProps[] = [
|
|
|
{ prop: 'operation', label: '操作', width: 200, fixed: 'right' }
|
|
|
]
|
|
|
|
|
|
+const menuDir:any = reactive({
|
|
|
+ activeName:null,//选中的tabs
|
|
|
+ MenuData:[],//tabs导航栏
|
|
|
+ tabsMenu:[],//tab展开导航
|
|
|
+ defaultKeys:[]//默认选中
|
|
|
+})
|
|
|
const getSysList = async () => {
|
|
|
const { Data } = await User_Sys_List({ User_tokey })
|
|
|
- SysList.value = Data as InSys[]
|
|
|
- const promises = []
|
|
|
- for (let item of SysList.value) {
|
|
|
- promises.push(getMenuList(item.T_sys))
|
|
|
- }
|
|
|
-
|
|
|
- Promise.all(promises).then(res => {
|
|
|
- const menuListTemporary: any[] = []
|
|
|
- res.forEach((item: any) => {
|
|
|
- const { Children, T_permission } = item.Data.Menu[0]
|
|
|
- item.Data.Menu[0].children = Children
|
|
|
- if (['/account', 'mangage', '/salary', '/stock', '/projectMange'].includes(T_permission)) {
|
|
|
- item.Data.Menu[0].father = true
|
|
|
- menuMap.set(T_permission, { code: item.code, children: [] })
|
|
|
- }
|
|
|
- if (item.Data.Menu_checked) {
|
|
|
- getPermissionArr(item.Data)
|
|
|
- }
|
|
|
- menuListTemporary.push(item.Data.Menu[0])
|
|
|
- })
|
|
|
- menuList.value = menuListTemporary
|
|
|
- setCheckedTreeKeys(permissionArr.value)
|
|
|
- })
|
|
|
+ console.log('导航',Data)
|
|
|
+ menuDir.MenuData = Data
|
|
|
+ menuDir.activeName = menuDir.MenuData[0].T_sys
|
|
|
+ const {Data:resIt} = await getMenuList(menuDir.activeName)
|
|
|
+ menuDir.tabsMenu = resIt.Menu[0].Children
|
|
|
+ menuDir.defaultKeys = resIt.Menu_checked?resIt.Menu_checked:[]
|
|
|
}
|
|
|
+//点击切换tabs调用导航
|
|
|
+const handleClick = async(tab: TabsPaneContext, event: Event) => {
|
|
|
+ menuDir.defaultKeys = []
|
|
|
+ menuDir.activeName = tab.props.name
|
|
|
+ const {Data:resIt} = await getMenuList(menuDir.activeName)
|
|
|
+ menuDir.tabsMenu = resIt.Menu[0].Children
|
|
|
+ menuDir.defaultKeys = resIt.Menu_checked?resIt.Menu_checked:[]
|
|
|
+}
|
|
|
+
|
|
|
+//调用当前权限的子选项
|
|
|
const getMenuList = async (code: string) => {
|
|
|
const res: any = await User_Power_Get({ User_tokey, T_code: code, T_id: currentVal.T_id })
|
|
|
return {
|
|
@@ -87,26 +88,26 @@ const getMenuList = async (code: string) => {
|
|
|
}
|
|
|
|
|
|
const permissionArr = ref<string[]>([])
|
|
|
-const getPermissionArr = (menu: any) => {
|
|
|
- const { Menu, Menu_checked } = menu
|
|
|
- const { Children, T_permission } = Menu[0]
|
|
|
- getCurrentFlatMenu(Children, Menu_checked, T_permission)
|
|
|
-}
|
|
|
+// const getPermissionArr = (menu: any) => {
|
|
|
+// const { Menu, Menu_checked } = menu
|
|
|
+// const { Children, T_permission } = Menu[0]
|
|
|
+// getCurrentFlatMenu(Children, Menu_checked, T_permission)
|
|
|
+// }
|
|
|
|
|
|
-const getCurrentFlatMenu = (children: any[], arr: number[], permission: string) => {
|
|
|
- const fatherMenu = menuMap.get(permission)
|
|
|
+// const getCurrentFlatMenu = (children: any[], arr: number[], permission: string) => {
|
|
|
+// const fatherMenu = menuMap.get(permission)
|
|
|
|
|
|
- children.forEach((item: any) => {
|
|
|
- const index = arr.findIndex((num: any) => num === item.Id)
|
|
|
- if (item.Children) {
|
|
|
- getCurrentFlatMenu(item.Children, arr, permission)
|
|
|
- }
|
|
|
- if (index !== -1 && !item.Children) {
|
|
|
- permissionArr.value.push(item.T_permission)
|
|
|
- fatherMenu.children.push(item)
|
|
|
- }
|
|
|
- })
|
|
|
-}
|
|
|
+// children.forEach((item: any) => {
|
|
|
+// const index = arr.findIndex((num: any) => num === item.Id)
|
|
|
+// if (item.Children) {
|
|
|
+// getCurrentFlatMenu(item.Children, arr, permission)
|
|
|
+// }
|
|
|
+// if (index !== -1 && !item.Children) {
|
|
|
+// permissionArr.value.push(item.T_permission)
|
|
|
+// fatherMenu.children.push(item)
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|
|
|
const setCheckedTreeKeys = (arr: string[]) => treeRef.value?.setCheckedKeys(arr, true)
|
|
|
|
|
|
// 添加角色
|
|
@@ -204,36 +205,26 @@ const menuList = ref<any[]>([])
|
|
|
*/
|
|
|
const getMontageRole = (children: any[]) => {
|
|
|
let result = ''
|
|
|
-
|
|
|
- const getChildIds = (node: any) => {
|
|
|
- if (!node.Children) {
|
|
|
- return `M${node.Id}|`
|
|
|
- }
|
|
|
- let ids = node.Children.map((child: any) => {
|
|
|
- return getChildIds(child)
|
|
|
+ let arrMap:any = []
|
|
|
+ if(children.length!=0){
|
|
|
+ children.forEach((item:any)=>{
|
|
|
+ arrMap.push('M'+item)
|
|
|
})
|
|
|
- return `M${node.Id}|${ids.join('')}`
|
|
|
+ result = arrMap.join('|') + '|'
|
|
|
+ return result
|
|
|
+ }else{
|
|
|
+ return ''
|
|
|
}
|
|
|
-
|
|
|
- children.forEach((item: any) => {
|
|
|
- result += getChildIds(item)
|
|
|
- })
|
|
|
- return result
|
|
|
}
|
|
|
/**
|
|
|
* 提交
|
|
|
*/
|
|
|
-const append = async (data: any) => {
|
|
|
-
|
|
|
- const currentMenu = menuMap.get(data.T_permission)
|
|
|
- const { code, children } = currentMenu
|
|
|
- let T_menu = getMontageRole(children)
|
|
|
- console.log('提交',T_menu,children)
|
|
|
- // return
|
|
|
+const submit = async (data: any) => {
|
|
|
+ let T_menu = getMontageRole(menuDir.defaultKeys)
|
|
|
const params = {
|
|
|
User_tokey,
|
|
|
T_id: currentVal.T_id,
|
|
|
- T_code: code,
|
|
|
+ T_code: menuDir.activeName,
|
|
|
T_menu
|
|
|
}
|
|
|
const res = await User_Power_Edit_Menu(params)
|
|
@@ -243,24 +234,24 @@ const append = async (data: any) => {
|
|
|
}
|
|
|
}
|
|
|
let fatherDataCopy: any = {}
|
|
|
-const getMenuChildren = (menuchildren: any, T_permission: string) => {
|
|
|
- let fatherData = getFatherData(T_permission)
|
|
|
- const { children } = fatherData
|
|
|
+// const getMenuChildren = (menuchildren: any, T_permission: string) => {
|
|
|
+// let fatherData = getFatherData(T_permission)
|
|
|
+// const { children } = fatherData
|
|
|
|
|
|
- if (!menuchildren?.length) {
|
|
|
- const index = children.findIndex((child: any) => child.T_permission === menuchildren.T_permission)
|
|
|
- if (index === -1) children.push({ ...menuchildren })
|
|
|
- } else {
|
|
|
- menuchildren.forEach((item: any) => {
|
|
|
- if (item.Children) {
|
|
|
- getMenuChildren(item, T_permission)
|
|
|
- } else {
|
|
|
- const index = children.findIndex((child: any) => item.T_permission === child.T_permission)
|
|
|
- if (index === -1) children.push({ ...item })
|
|
|
- }
|
|
|
- })
|
|
|
- }
|
|
|
-}
|
|
|
+// if (!menuchildren?.length) {
|
|
|
+// const index = children.findIndex((child: any) => child.T_permission === menuchildren.T_permission)
|
|
|
+// if (index === -1) children.push({ ...menuchildren })
|
|
|
+// } else {
|
|
|
+// menuchildren.forEach((item: any) => {
|
|
|
+// if (item.Children) {
|
|
|
+// getMenuChildren(item, T_permission)
|
|
|
+// } else {
|
|
|
+// const index = children.findIndex((child: any) => item.T_permission === child.T_permission)
|
|
|
+// if (index === -1) children.push({ ...item })
|
|
|
+// }
|
|
|
+// })
|
|
|
+// }
|
|
|
+// }
|
|
|
const getFatherData = (T_permission: string) => {
|
|
|
let fatherData = menuMap.get(T_permission)
|
|
|
if (['/base', '/property', '/inventory', '/salesManage'].includes(T_permission)) {
|
|
@@ -268,51 +259,63 @@ const getFatherData = (T_permission: string) => {
|
|
|
}
|
|
|
return fatherData
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
const checkChange = (data: any, check: boolean) => {
|
|
|
- let fatherData = getFatherData(data.T_permission)
|
|
|
- if (fatherData) {
|
|
|
- fatherDataCopy = fatherData
|
|
|
- }
|
|
|
- if (check && fatherDataCopy) {
|
|
|
- const { children } = fatherDataCopy
|
|
|
- if (!data.Children) {
|
|
|
- const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
|
|
|
- if (index === -1) children.push({ ...data })
|
|
|
- } else {
|
|
|
- getMenuChildren(data.Children, data.T_permission)
|
|
|
- }
|
|
|
+ // console.log('选中',menuDir.defaultKeys,data,check)
|
|
|
+ if(check){//当前选中操作
|
|
|
+ const j = menuDir.defaultKeys.includes(data.Id)
|
|
|
+ if(!j)menuDir.defaultKeys.push(data.Id)//不在加入
|
|
|
+ }else{//当前取消操作
|
|
|
+ menuDir.defaultKeys.map((item: any, index: any) => {
|
|
|
+ if (item == data.Id) menuDir.defaultKeys.splice(index, 1)
|
|
|
+ })
|
|
|
}
|
|
|
+ return
|
|
|
+ // let fatherData = getFatherData(data.T_permission)
|
|
|
+ // if (fatherData) {
|
|
|
+ // fatherDataCopy = fatherData
|
|
|
+ // }
|
|
|
+ // if (check && fatherDataCopy) {
|
|
|
+ // const { children } = fatherDataCopy
|
|
|
+ // if (!data.Children) {
|
|
|
+ // const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
|
|
|
+ // if (index === -1) children.push({ ...data })
|
|
|
+ // } else {
|
|
|
+ // }
|
|
|
+ // }
|
|
|
|
|
|
- if (!check && fatherDataCopy) {
|
|
|
- let { children } = fatherDataCopy
|
|
|
- if (['/base', '/property', '/inventory', '/salesManage'].includes(data.T_permission)) {
|
|
|
- fatherData = menuMap.get('/stock')
|
|
|
- if (data.T_permission === '/base') {
|
|
|
- children = children.filter((item: any) => {
|
|
|
- return !['/list', '/classify', '/productionList', '/base'].includes(item.T_permission)
|
|
|
- })
|
|
|
- } else if (data.T_permission === '/property') {
|
|
|
- children = children.filter((item: any) => {
|
|
|
- return !['/ioTNetworkCard', '/property'].includes(item.T_permission)
|
|
|
- })
|
|
|
- } else if (data.T_permission === '/inventory') {
|
|
|
- children = children.filter((item: any) => {
|
|
|
- return !['/device', '/inStorage', '/outStock', '/inventoryStatistics', '/inventory'].includes(
|
|
|
- item.T_permission
|
|
|
- )
|
|
|
- })
|
|
|
- } else {
|
|
|
- children = children.filter((item: any) => {
|
|
|
- return !['/contract', '/contractSale', '/salesManage'].includes(item.T_permission)
|
|
|
- })
|
|
|
- }
|
|
|
- fatherData.children = children
|
|
|
- return
|
|
|
- }
|
|
|
- const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
|
|
|
- if (index === -1) children.splice(index, 1)
|
|
|
- }
|
|
|
+ // if (!check && fatherDataCopy) {
|
|
|
+ // let { children } = fatherDataCopy
|
|
|
+ // if (['/base', '/property', '/inventory', '/salesManage'].includes(data.T_permission)) {
|
|
|
+ // fatherData = menuMap.get('/stock')
|
|
|
+ // if (data.T_permission === '/base') {
|
|
|
+ // children = children.filter((item: any) => {
|
|
|
+ // return !['/list', '/classify', '/productionList', '/base'].includes(item.T_permission)
|
|
|
+ // })
|
|
|
+ // } else if (data.T_permission === '/property') {
|
|
|
+ // children = children.filter((item: any) => {
|
|
|
+ // return !['/ioTNetworkCard', '/property'].includes(item.T_permission)
|
|
|
+ // })
|
|
|
+ // } else if (data.T_permission === '/inventory') {
|
|
|
+ // children = children.filter((item: any) => {
|
|
|
+ // return !['/device', '/inStorage', '/outStock', '/inventoryStatistics', '/inventory'].includes(
|
|
|
+ // item.T_permission
|
|
|
+ // )
|
|
|
+ // })
|
|
|
+ // } else {
|
|
|
+ // children = children.filter((item: any) => {
|
|
|
+ // return !['/contract', '/contractSale', '/salesManage'].includes(item.T_permission)
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ // fatherData.children = children
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // const index = children.findIndex((child: any) => data.T_permission === child.T_permission)
|
|
|
+ // if (index === -1) children.splice(index, 1)
|
|
|
+ // }
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* dialog 关闭回调
|
|
|
*/
|
|
@@ -323,6 +326,8 @@ const dialogCloseCallback = () => {
|
|
|
fatherDataCopy = {}
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -346,36 +351,30 @@ const dialogCloseCallback = () => {
|
|
|
<el-button link type="danger" size="small" :icon="Delete" @click="UserDelete(row)">删除</el-button>
|
|
|
</template>
|
|
|
</TableBase>
|
|
|
- <Dialog ref="dialog" width="50%" :handleClose="dialogCloseCallback">
|
|
|
+ <Dialog ref="dialog" width="50%" :handleClose="dialogCloseCallback" draggable>
|
|
|
<template #header>
|
|
|
<h3>编辑权限</h3>
|
|
|
</template>
|
|
|
- <transition appear name="fade" mode="out-in">
|
|
|
- <el-tree
|
|
|
- ref="treeRef"
|
|
|
- :data="menuList"
|
|
|
- show-checkbox
|
|
|
- node-key="T_permission"
|
|
|
- :expand-on-click-node="false"
|
|
|
- :props="{ label: 'T_name', children: 'Children' }"
|
|
|
- @check-change="checkChange"
|
|
|
- >
|
|
|
- <template #default="{ data }">
|
|
|
- <div
|
|
|
- class="custom-tree-node"
|
|
|
- :style="{ 'border-bottom': data.Children && data.father ? ' 1px solid #ddd' : '' }"
|
|
|
- >
|
|
|
- <span>{{ data.T_name }}</span>
|
|
|
- <span v-if="data.Children && data.father">
|
|
|
- <el-button type="primary" size="small" @click="append(data)">提交</el-button>
|
|
|
- </span>
|
|
|
- </div>
|
|
|
- </template>
|
|
|
- <template #empty>
|
|
|
- <el-empty></el-empty>
|
|
|
- </template>
|
|
|
- </el-tree>
|
|
|
- </transition>
|
|
|
+ <el-tabs v-model="menuDir.activeName" class="demo-tabs" tabPosition="left" @tab-click="handleClick">
|
|
|
+ <el-tab-pane :label="item.T_name" :name="item.T_sys" v-for="item,index in menuDir.MenuData" :key="index">
|
|
|
+ <el-tree
|
|
|
+ :props="{ label: 'T_name', children: 'Children' }"
|
|
|
+ node-key="Id"
|
|
|
+ accordion
|
|
|
+ :default-expanded-keys="menuDir.defaultKeys"
|
|
|
+ :default-checked-keys="menuDir.defaultKeys"
|
|
|
+ :data="menuDir.tabsMenu"
|
|
|
+ show-checkbox
|
|
|
+ @check-change="checkChange"
|
|
|
+ />
|
|
|
+ </el-tab-pane>
|
|
|
+ </el-tabs>
|
|
|
+ <template #footer>
|
|
|
+ <div style="border-top: 1px solid #dcdfe6;padding-top: 10px;">
|
|
|
+ <el-button @click="dialog?.DialogClose()">取消</el-button>
|
|
|
+ <el-button type="primary" @click="submit">立即提交</el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
</Dialog>
|
|
|
<Drawer ref="drawerRef" :handleClose="callbackDrawer">
|
|
|
<template #header="{ params }">
|