menu和authority修改父级变为选择模式
This commit is contained in:
@@ -47,7 +47,21 @@
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="父节点Id">
|
||||
<el-input autocomplete="off" disabled v-model="form.parentId"></el-input>
|
||||
<el-select
|
||||
placeholder="请选择"
|
||||
v-model="form.parentId"
|
||||
:disabled="!this.isEdit"
|
||||
filterable
|
||||
>
|
||||
<el-option
|
||||
:disabled="canSelect(item)"
|
||||
:key="item.ID"
|
||||
:label="item.title"
|
||||
:value="item.ID"
|
||||
v-for="item in menuOption"
|
||||
>
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="文件路径" prop="component">
|
||||
<el-input autocomplete="off" v-model="form.component"></el-input>
|
||||
@@ -90,6 +104,12 @@ export default {
|
||||
listApi: getMenuList,
|
||||
dialogFormVisible: false,
|
||||
dialogTitle:"新增菜单",
|
||||
menuOption:[
|
||||
{
|
||||
ID:"0",
|
||||
title:"根菜单"
|
||||
}
|
||||
],
|
||||
form: {
|
||||
ID: 0,
|
||||
path: '',
|
||||
@@ -211,10 +231,45 @@ export default {
|
||||
this.form = res.data.menu
|
||||
this.dialogFormVisible = true
|
||||
this.isEdit = true
|
||||
}
|
||||
},
|
||||
getMenuList(MenuData){
|
||||
MenuData.map(item=>{
|
||||
this.menuOption.push({
|
||||
ID:String(item.ID),
|
||||
title:item.meta.title
|
||||
})
|
||||
if(item.children){
|
||||
this.getMenuList(item.children)
|
||||
}
|
||||
})
|
||||
},
|
||||
findAuthoritySelf(mune,muneData,outData){
|
||||
muneData&&muneData.some(item=>{
|
||||
if(item.ID == mune.ID){
|
||||
outData.push(item)
|
||||
return true
|
||||
}
|
||||
this.findAuthoritySelf(mune,item.children,outData)
|
||||
})
|
||||
},
|
||||
findAllChild(menu,array){
|
||||
menu&&menu.map(item=>{
|
||||
array.push(String(item.ID))
|
||||
this.findAllChild(item.children,array)
|
||||
})
|
||||
},
|
||||
canSelect(authority){
|
||||
const array = []
|
||||
const arrayIds = []
|
||||
this.findAuthoritySelf({ID:this.form.ID},this.tableData,array)
|
||||
this.findAllChild(array,arrayIds)
|
||||
return arrayIds.indexOf(authority.ID)>-1
|
||||
},
|
||||
},
|
||||
created() {
|
||||
async created() {
|
||||
this.pageSize = 999
|
||||
await this.getTableData()
|
||||
await this.getMenuList(this.tableData)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user