|
@@ -242,68 +242,85 @@ const append = async (data: any) => {
|
|
|
T_code: code,
|
|
|
T_menu
|
|
|
}
|
|
|
- // 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) => {
|
|
|
- let fatherData = menuMap.get(data.T_permission)
|
|
|
- if (['/base'].includes(data.T_permission)) {
|
|
|
- fatherData = menuMap.get('/stock')
|
|
|
+ const res = await User_Power_Edit_Menu(params)
|
|
|
+ if (res.Code === 200) {
|
|
|
+ ElMessage.success('修改成功!')
|
|
|
+ // dialog.value?.DialogClose()
|
|
|
}
|
|
|
-
|
|
|
- if (check) {
|
|
|
- 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)
|
|
|
- // }
|
|
|
- // }
|
|
|
}
|
|
|
+let fatherDataCopy: any = {}
|
|
|
+const getMenuChildren = (menuchildren: any, T_permission: string) => {
|
|
|
+ let fatherData = getFatherData(T_permission)
|
|
|
+ const { children } = fatherData
|
|
|
+ console.log(menuchildren, fatherData)
|
|
|
|
|
|
-/**
|
|
|
- * 处理点击父级 tree 时的处理
|
|
|
- */
|
|
|
-const fatherCheckHandle = (children: any[], father: any, check: boolean) => {
|
|
|
- if (check) {
|
|
|
- children.forEach((item: any) => {
|
|
|
+ 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) {
|
|
|
- if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
|
|
|
- father.children.push(item)
|
|
|
- fatherCheckHandle(item.Children, father, check)
|
|
|
- }
|
|
|
+ getMenuChildren(item, T_permission)
|
|
|
} else {
|
|
|
- if (father.children.findIndex((child: any) => item.T_permission === child.T_permission) === -1) {
|
|
|
- console.log('push3')
|
|
|
- father.children.push(item)
|
|
|
- }
|
|
|
+ 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)) {
|
|
|
+ fatherData = menuMap.get('/stock')
|
|
|
+ }
|
|
|
+ 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) {
|
|
|
+ console.log('1', data)
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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 关闭回调
|
|
|
*/
|
|
@@ -311,7 +328,7 @@ const dialogCloseCallback = () => {
|
|
|
nextTick(() => {
|
|
|
menuMap.clear()
|
|
|
permissionArr.value = []
|
|
|
- fatherData = {}
|
|
|
+ fatherDataCopy = {}
|
|
|
})
|
|
|
}
|
|
|
</script>
|