@@ -5,7 +5,7 @@ | |||
<link rel="icon" type="image/svg+xml" href="/logo_1.jpg" /> | |||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | |||
<title>后台管理系统</title> | |||
<script type="module" crossorigin src="/assets/index-uU_dXTTD.js"></script> | |||
<script type="module" crossorigin src="/assets/index-w08MfQVW.js"></script> | |||
<link rel="stylesheet" crossorigin href="/assets/index-ioYE9aJh.css"> | |||
</head> | |||
<body> |
@@ -36,14 +36,13 @@ const actions = { | |||
commit | |||
}) { | |||
try { | |||
// state.arrresult = []; | |||
// let res = await GetUserMenulist(); | |||
// res.data.menulist.map(item => { | |||
// pushItem(item) | |||
// }) | |||
// let arr = state.arrresult; | |||
// let arr = getArr | |||
let arr = ['permission', 'role', 'account', 'company', 'vip', 'member', 'homemake', 'homemakeType', 'homemakePosition', 'homemakeDemand', 'homemakeAppointment', 'job', 'department', 'jobSeeker', 'jobResume', 'jobFair', 'jobFairList', 'jobFairCompany', 'information', 'section', 'article', 'list', 'putIn', 'advertisementList', 'advertisement', 'activity', 'activityList', 'activityAddress', 'statistics', 'statisticsResume', 'statisticsResumeMajor']; | |||
state.arrresult = []; | |||
let res = await GetUserMenulist(); | |||
res.data.menulist.map(item => { | |||
pushItem(item) | |||
}) | |||
let arr = state.arrresult; | |||
// let arr = ['permission', 'role', 'account', 'company', 'vip', 'member', 'homemake', 'homemakeType', 'homemakePosition', 'homemakeDemand', 'homemakeAppointment', 'job', 'department', 'jobSeeker', 'jobResume', 'jobFair', 'jobFairList', 'jobFairCompany', 'information', 'section', 'article', 'list', 'putIn', 'advertisementList', 'advertisement', 'activity', 'activityList', 'activityAddress', 'statistics', 'statisticsResume', 'statisticsResumeMajor']; | |||
let routes = routerDynamic(arr, routesModuleList); | |||
LayoutRoute.children.push(...routes); | |||
commit('SET_MENU', LayoutRoute.children); |
@@ -1,52 +1,70 @@ | |||
export const findidx : Function = (arr: any, val: any) => { | |||
export const filterChildPermissionsByType : Function = (permissions : Object[]) => { | |||
return permissions.map(parent => ({ | |||
...parent, | |||
childs: parent.childs ? filterOutPermissionsOfCertainType(parent.childs, 1) : undefined, | |||
})); | |||
} | |||
export const filterOutPermissionsOfCertainType : Function = (permissions : Object[], excludeType : number) => { | |||
return permissions.filter(permission => permission.p_type !== excludeType) | |||
.map(child => ({ | |||
...child, | |||
childs: child.childs ? filterOutPermissionsOfCertainType(child.childs, excludeType) : undefined, | |||
})); | |||
} | |||
export const findidx : Function = (arr : any, val : any) => { | |||
return arr.findIndex(item => { | |||
return item.id === val | |||
return item.id === val | |||
}) | |||
} | |||
export const intersectionAlike : Function = (objA: any, objB: any) => { | |||
export const intersectionAlike : Function = (objA : any, objB : any) => { | |||
const result = {}; | |||
for (const keyA in objA) { | |||
if (objB.hasOwnProperty(keyA)) { | |||
result[keyA] = objB[keyA]; | |||
} | |||
if (objB.hasOwnProperty(keyA)) { | |||
result[keyA] = objB[keyA]; | |||
} | |||
} | |||
return result; | |||
} | |||
export const hasValue : Function = (obj: any) => { | |||
export const hasValue : Function = (obj : any) => { | |||
let result = ''; | |||
result = Object.keys(obj).filter(key => obj[key] !== 0).map(key => `${obj[key]}`).join('') | |||
return result; | |||
} | |||
export const divObj : Function = (obj: any) => { | |||
export const divObj : Function = (obj : any) => { | |||
const result = [] | |||
obj.reduce((acc, curr, index) => { | |||
curr.idx = index; | |||
result.push(curr) | |||
// const key = `node${index}Info`; | |||
// acc[key] = curr; | |||
// return acc; | |||
curr.idx = index; | |||
result.push(curr) | |||
// const key = `node${index}Info`; | |||
// acc[key] = curr; | |||
// return acc; | |||
}, {}); | |||
return result; | |||
} | |||
export const alreadyValue: Function = (obj: any) => { | |||
const result = [] | |||
obj.reduce((acc, curr, index) => { | |||
curr.idx = index; | |||
result.push(curr) | |||
// const key = `node${index}Info`; | |||
// acc[key] = curr; | |||
// return acc; | |||
}, {}); | |||
export const alreadyValue : Function = (obj : any) => { | |||
const result = [] | |||
obj.reduce((acc, curr, index) => { | |||
curr.idx = index; | |||
result.push(curr) | |||
// const key = `node${index}Info`; | |||
// acc[key] = curr; | |||
// return acc; | |||
}, {}); | |||
return result; | |||
return result; | |||
} |
@@ -62,9 +62,10 @@ | |||
import { addPermission, updatePermission, getPermissionListWithchilds } from '@/apis/models'; | |||
import { dataForm, otherDataForm, reset } from '@/views/permission/list/add/data.ts'; | |||
import { useCommon } from '@/hooks/useCommon'; | |||
import { filterChildPermissionsByType } from '@/utils/dataHelper.ts'; | |||
let { store, openAddModel, hideModal, message, } = useCommon(); | |||
const emit = defineEmits(); | |||
let props = defineProps(['edit_record']); | |||
let props = defineProps(['edit_record','level_record']); | |||
let title = ref<String>('新增权限/菜单'); | |||
let listOptions = ref([]); | |||
let cascaderParentId = ref([]); | |||
@@ -75,15 +76,19 @@ | |||
onMounted(() => { | |||
getPermissionListWithchilds({page:1, pagesize: 999}).then(res => { | |||
listOptions.value = res.data.permissions; | |||
listOptions.value = filterChildPermissionsByType(res.data.permissions) | |||
}) | |||
}) | |||
const pTypeChange = (val) => { | |||
addOtherForm.value.isAddLevel = true; | |||
addOtherForm.value.isTopLevel = true; | |||
addOtherForm.value.parent_id = 0; | |||
createForm.value.parent_id = 0; | |||
if(val.target.value == 1) { | |||
addOtherForm.value.isAddLevel = false; | |||
} else { | |||
addOtherForm.value.isAddLevel = true; | |||
} | |||
addOtherForm.value.isAddLevel == false | |||
addOtherForm.value.parent_id = addOtherForm.value.parent_id != 0 ? addOtherForm.value.parent_id : 0; | |||
createForm.value.parent_id = createForm.value.parent_id != 0 ? createForm.value.parent_id : 0; | |||
cascaderParentId.value = [] | |||
} | |||
@@ -104,18 +109,26 @@ | |||
if (createForm.value.name && createForm.value.p_type) { | |||
if (!createForm.value.id) { | |||
addPermission(createForm.value).then(res => { | |||
getPermissionListWithchilds({page:1, pagesize: 999}).then(res => { | |||
listOptions.value = filterChildPermissionsByType(res.data.permissions) | |||
}) | |||
message.success('新增菜单/权限成功'); | |||
hideModal(); | |||
resetForm(); | |||
emit('successAdd'); | |||
}).catch(err => { | |||
}) | |||
} else { | |||
updatePermission(createForm.value).then(res => { | |||
getPermissionListWithchilds({page:1, pagesize: 999}).then(res => { | |||
listOptions.value = filterChildPermissionsByType(res.data.permissions) | |||
}) | |||
message.success('修改菜单/权限成功'); | |||
hideModal(); | |||
resetForm(); | |||
emit('successAdd'); | |||
}).catch(err => { | |||
}) | |||
} | |||
@@ -141,21 +154,23 @@ | |||
return store.state.openAddModel; | |||
}) | |||
watch(() => props.edit_record, (newVal) => { | |||
if (newVal) { | |||
watch(() => [props.edit_record, props.level_record], (newVal) => { | |||
console.log(newVal) | |||
if (newVal[0]) { | |||
title.value = "编辑权限/菜单"; | |||
console.log(newVal) | |||
createForm.value = { | |||
id: newVal.id, | |||
name: newVal.name, | |||
path: newVal.path, | |||
action: newVal.action, | |||
module: newVal.module, | |||
p_type: newVal.p_type, | |||
parent_id: newVal.parent_id, | |||
description: newVal.description, | |||
id: newVal[0].id, | |||
name: newVal[0].name, | |||
path: newVal[0].path, | |||
action: newVal[0].action, | |||
module: newVal[0].module, | |||
p_type: newVal[0].p_type, | |||
parent_id: newVal[0].parent_id, | |||
description: newVal[0].description, | |||
} | |||
if(newVal.parent_id == -1) { | |||
if(newVal[0].parent_id == -1) { | |||
addOtherForm.value.isAddLevel = true; | |||
addOtherForm.value.isTopLevel = true; | |||
addOtherForm.value.parent_id = -1; | |||
@@ -164,8 +179,19 @@ | |||
addOtherForm.value.isTopLevel = false | |||
addOtherForm.value.parent_id = 0; | |||
} | |||
} else if(newVal[1]){ | |||
title.value = "添加下级权限/菜单"; | |||
console.log(newVal[1]) | |||
cascaderParentId.value = []; | |||
if(newVal[1].parent_id == -1) { | |||
cascaderParentId.value.push(newVal[1].id); | |||
} else { | |||
cascaderParentId.value.push(newVal[1].parent_id); | |||
cascaderParentId.value.push(newVal[1].id); | |||
} | |||
createForm.value.parent_id = newVal[1].id | |||
} else { | |||
title.value = "新增权限/菜单" | |||
title.value = "编辑权限/菜单"; | |||
} | |||
}) | |||
</script> |