|
@ -44,11 +44,11 @@ |
|
|
<el-dialog :visible.sync="menuDialogFlag" title="关联菜单"> |
|
|
<el-dialog :visible.sync="menuDialogFlag" title="关联菜单"> |
|
|
<el-tree |
|
|
<el-tree |
|
|
:data="treeData" |
|
|
:data="treeData" |
|
|
|
|
|
:default-checked-keys="treeIds" |
|
|
:props="defaultProps" |
|
|
:props="defaultProps" |
|
|
default-expand-all |
|
|
default-expand-all |
|
|
highlight-current |
|
|
highlight-current |
|
|
node-key="ID" |
|
|
node-key="ID" |
|
|
:default-checked-keys="treeIds" |
|
|
|
|
|
ref="tree" |
|
|
ref="tree" |
|
|
show-checkbox |
|
|
show-checkbox |
|
|
></el-tree> |
|
|
></el-tree> |
|
@ -67,6 +67,7 @@ import { |
|
|
createAuthority |
|
|
createAuthority |
|
|
} from '@/api/authority' |
|
|
} from '@/api/authority' |
|
|
import { getBaseMenuTree, addMenuAuthority, getMenuAuthority } from '@/api/menu' |
|
|
import { getBaseMenuTree, addMenuAuthority, getMenuAuthority } from '@/api/menu' |
|
|
|
|
|
import { mapActions } from 'vuex' |
|
|
export default { |
|
|
export default { |
|
|
name: 'Authority', |
|
|
name: 'Authority', |
|
|
data() { |
|
|
data() { |
|
@ -91,6 +92,8 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
|
|
|
...mapActions('router', ['SetAsyncRouter']), |
|
|
|
|
|
|
|
|
// 条数 |
|
|
// 条数 |
|
|
handleSizeChange(val) { |
|
|
handleSizeChange(val) { |
|
|
this.pageSize = val |
|
|
this.pageSize = val |
|
@ -109,19 +112,12 @@ export default { |
|
|
type: 'warning' |
|
|
type: 'warning' |
|
|
}) |
|
|
}) |
|
|
.then(async () => { |
|
|
.then(async () => { |
|
|
try { |
|
|
|
|
|
const res = await deleteAuthority({ authorityId: row.authorityId }) |
|
|
const res = await deleteAuthority({ authorityId: row.authorityId }) |
|
|
this.$message({ |
|
|
this.$message({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '删除成功!' |
|
|
message: '删除成功!' |
|
|
}) |
|
|
}) |
|
|
this.getAuthList() |
|
|
this.getAuthList() |
|
|
} catch (err) { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
type: 'error', |
|
|
|
|
|
message: '删除失败!' + err |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
}) |
|
|
.catch(() => { |
|
|
.catch(() => { |
|
|
this.$message({ |
|
|
this.$message({ |
|
@ -152,12 +148,6 @@ export default { |
|
|
}) |
|
|
}) |
|
|
this.getAuthList() |
|
|
this.getAuthList() |
|
|
this.closeDialog() |
|
|
this.closeDialog() |
|
|
} else { |
|
|
|
|
|
this.$message({ |
|
|
|
|
|
type: 'error', |
|
|
|
|
|
message: '添加失败!' |
|
|
|
|
|
}) |
|
|
|
|
|
this.closeDialog() |
|
|
|
|
|
} |
|
|
} |
|
|
this.initForm() |
|
|
this.initForm() |
|
|
this.dialogFormVisible = false |
|
|
this.dialogFormVisible = false |
|
@ -168,26 +158,24 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// 获取用户列表 |
|
|
// 获取用户列表 |
|
|
async getAuthList(page = this.page, pageSize = this.pageSize) { |
|
|
async getAuthList(page = this.page, pageSize = this.pageSize) { |
|
|
try { |
|
|
|
|
|
const table = await getAuthorityList({ page, pageSize }) |
|
|
const table = await getAuthorityList({ page, pageSize }) |
|
|
this.tableData = table.data.authList |
|
|
this.tableData = table.data.authList |
|
|
} catch (err) { |
|
|
|
|
|
console.log(err) |
|
|
|
|
|
} |
|
|
|
|
|
}, |
|
|
}, |
|
|
|
|
|
// 关联用户列表关系 |
|
|
async addAuthMenu(row) { |
|
|
async addAuthMenu(row) { |
|
|
const res1 = await getMenuAuthority({ authorityId: row.authorityId }) |
|
|
const res1 = await getMenuAuthority({ authorityId: row.authorityId }) |
|
|
const menus = res1.data.menus |
|
|
const menus = res1.data.menus |
|
|
const arr = [] |
|
|
const arr = [] |
|
|
menus.map(item=>{arr.push(Number(item.menuId))}) |
|
|
|
|
|
|
|
|
menus.map(item => { |
|
|
|
|
|
arr.push(Number(item.menuId)) |
|
|
|
|
|
}) |
|
|
this.treeIds = arr |
|
|
this.treeIds = arr |
|
|
const res2 = await getBaseMenuTree() |
|
|
const res2 = await getBaseMenuTree() |
|
|
this.treeData = res2.data.menus |
|
|
this.treeData = res2.data.menus |
|
|
console.log(this.treeData) |
|
|
|
|
|
this.activeUserId = row.authorityId |
|
|
this.activeUserId = row.authorityId |
|
|
this.menuDialogFlag = true |
|
|
this.menuDialogFlag = true |
|
|
}, |
|
|
}, |
|
|
// 关联树 |
|
|
|
|
|
|
|
|
// 关联树 确认方法 |
|
|
async relation() { |
|
|
async relation() { |
|
|
const checkArr = this.$refs.tree |
|
|
const checkArr = this.$refs.tree |
|
|
.getCheckedNodes() |
|
|
.getCheckedNodes() |
|
@ -201,6 +189,7 @@ export default { |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '添加成功!' |
|
|
message: '添加成功!' |
|
|
}) |
|
|
}) |
|
|
|
|
|
this.SetAsyncRouter() |
|
|
} |
|
|
} |
|
|
this.closeDialog() |
|
|
this.closeDialog() |
|
|
} |
|
|
} |
|
@ -208,7 +197,6 @@ export default { |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
this.getAuthList() |
|
|
this.getAuthList() |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|