|
@@ -47,7 +47,6 @@ const DialogOpen = async (row: any) => {
|
|
|
dialog.value?.DialogOpen()
|
|
|
}
|
|
|
|
|
|
-// const checkList = ref<string[]>([])
|
|
|
const columns: ColumnProps[] = [
|
|
|
{ type: 'index', label: '#', width: 80 },
|
|
|
{ prop: 'T_name', label: '姓名' },
|
|
@@ -58,9 +57,6 @@ const columns: ColumnProps[] = [
|
|
|
const getSysList = async () => {
|
|
|
const { Data } = await User_Sys_List({ User_tokey: globalStore.GET_User_tokey })
|
|
|
SysList.value = Data as InSys[]
|
|
|
- // for await (let item of SysList.value) {
|
|
|
- // getMenuList(item.T_sys)
|
|
|
- // }
|
|
|
const promises = []
|
|
|
for (let item of SysList.value) {
|
|
|
promises.push(getMenuList(item.T_sys))
|
|
@@ -82,6 +78,7 @@ const getSysList = async () => {
|
|
|
})
|
|
|
menuList.value = menuListTemporary
|
|
|
setCheckedTreeKeys(permissionArr.value)
|
|
|
+ console.log(permissionArr.value)
|
|
|
})
|
|
|
}
|
|
|
const getMenuList = async (code: string) => {
|
|
@@ -205,47 +202,88 @@ const searchHandle = () => {
|
|
|
const treeRef = ref<InstanceType<typeof ElTree>>()
|
|
|
const menuList = ref<any[]>([])
|
|
|
|
|
|
+/**
|
|
|
+ * 返回拼接的 M + Id
|
|
|
+ * @param children 菜单数组
|
|
|
+ */
|
|
|
+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)
|
|
|
+ })
|
|
|
+ return `M${node.Id}|${ids.join('')}`
|
|
|
+ }
|
|
|
+
|
|
|
+ children.forEach((item: any) => {
|
|
|
+ result += getChildIds(item)
|
|
|
+ })
|
|
|
+ return result
|
|
|
+}
|
|
|
+/**
|
|
|
+ * 提交
|
|
|
+ */
|
|
|
const append = async (data: any) => {
|
|
|
const currentMenu = menuMap.get(data.T_permission)
|
|
|
+ console.log(menuMap)
|
|
|
+
|
|
|
const { code, children } = currentMenu
|
|
|
|
|
|
- let T_menu = ''
|
|
|
- children.forEach((item: any) => {
|
|
|
- let str = 'M' + item.Id + '|'
|
|
|
- T_menu += str
|
|
|
- })
|
|
|
+ let T_menu = getMontageRole(children)
|
|
|
+ console.log(children)
|
|
|
+
|
|
|
const params = {
|
|
|
User_tokey: globalStore.GET_User_tokey,
|
|
|
T_id: currentVal.T_id,
|
|
|
T_code: code,
|
|
|
T_menu
|
|
|
}
|
|
|
- const res = await User_Power_Edit_Menu(params)
|
|
|
- if (res.Code === 200) {
|
|
|
- ElMessage.success('修改成功!')
|
|
|
- dialog.value?.DialogClose()
|
|
|
- }
|
|
|
+ // const res = await User_Power_Edit_Menu(params)
|
|
|
+ // if (res.Code === 200) {
|
|
|
+ // ElMessage.success('修改成功!')
|
|
|
+ // // dialog.value?.DialogClose()
|
|
|
+ // }
|
|
|
}
|
|
|
let fatherData: any = {}
|
|
|
const checkChange = (data: any, check: boolean) => {
|
|
|
- const father = menuMap.get(data.T_permission)
|
|
|
- if (father) {
|
|
|
- fatherData = data
|
|
|
- fatherCheckHandle(data.Children, father, check)
|
|
|
- return
|
|
|
+ let fatherData = menuMap.get(data.T_permission)
|
|
|
+ if (['/base'].includes(data.T_permission)) {
|
|
|
+ fatherData = menuMap.get('/stock')
|
|
|
}
|
|
|
- const prevFather = menuMap.get(fatherData.T_permission)
|
|
|
- const { children } = prevFather
|
|
|
+
|
|
|
if (check) {
|
|
|
- prevFather.children.push(data)
|
|
|
- }
|
|
|
- if (!father && !check) {
|
|
|
- const index = children.findIndex((item: any) => item.T_permission === data.T_permission)
|
|
|
- if (index !== -1) {
|
|
|
- children.splice(index, 1)
|
|
|
- }
|
|
|
+ console.log(data, fatherData)
|
|
|
}
|
|
|
+
|
|
|
+ // console.log(data, check)
|
|
|
+ // if (father) {
|
|
|
+ // fatherData = data
|
|
|
+ // fatherCheckHandle(data.Children, father, check)
|
|
|
+ // // console.log(father)
|
|
|
+ // return
|
|
|
+ // }
|
|
|
+ // const prevFather = menuMap.get(fatherData.T_permission)
|
|
|
+ // console.log(fatherData, prevFather)
|
|
|
+
|
|
|
+ // const children = prevFather?.children
|
|
|
+ // // console.log(children)
|
|
|
+ // if (check) {
|
|
|
+ // console.log(children)
|
|
|
+ // prevFather.children.push(data)
|
|
|
+ // }
|
|
|
+ // if (!father && !check) {
|
|
|
+ // const index = children.findIndex((item: any) => item.T_permission === data.T_permission)
|
|
|
+ // if (index !== -1) {
|
|
|
+ // console.log('-1')
|
|
|
+ // children.splice(index, 1)
|
|
|
+ // }
|
|
|
+ // }
|
|
|
}
|
|
|
+
|
|
|
/**
|
|
|
* 处理点击父级 tree 时的处理
|
|
|
*/
|
|
@@ -253,14 +291,17 @@ const fatherCheckHandle = (children: any[], father: any, check: boolean) => {
|
|
|
if (check) {
|
|
|
children.forEach((item: any) => {
|
|
|
if (item.Children) {
|
|
|
- father.children.push(item)
|
|
|
- fatherCheckHandle(item.Children, father, check)
|
|
|
+ if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
|
|
|
+ father.children.push(item)
|
|
|
+ fatherCheckHandle(item.Children, father, check)
|
|
|
+ }
|
|
|
} else {
|
|
|
- father.children.push(item)
|
|
|
+ if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
|
|
|
+ console.log('push3')
|
|
|
+ father.children.push(item)
|
|
|
+ }
|
|
|
}
|
|
|
})
|
|
|
- } else {
|
|
|
- father.children = []
|
|
|
}
|
|
|
}
|
|
|
/**
|