|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
<template> |
|
|
|
|
<basic-container> |
|
|
|
|
<avue-crud :option="option" |
|
|
|
|
<avue-crud |
|
|
|
|
:option="option" |
|
|
|
|
:table-loading="loading" |
|
|
|
|
:data="data" |
|
|
|
|
ref="crud" |
|
|
|
@ -16,71 +17,87 @@
|
|
|
|
|
@current-change="currentChange" |
|
|
|
|
@size-change="sizeChange" |
|
|
|
|
@refresh-change="refreshChange" |
|
|
|
|
@on-load="onLoad"> |
|
|
|
|
@on-load="onLoad" |
|
|
|
|
> |
|
|
|
|
<template slot="menuLeft"> |
|
|
|
|
<el-button type="danger" |
|
|
|
|
<el-button |
|
|
|
|
type="danger" |
|
|
|
|
size="small" |
|
|
|
|
icon="el-icon-delete" |
|
|
|
|
v-if="permission.role_delete" |
|
|
|
|
plain |
|
|
|
|
@click="handleDelete">删 除 |
|
|
|
|
@click="handleDelete" |
|
|
|
|
>删 除 |
|
|
|
|
</el-button> |
|
|
|
|
<el-button size="small" |
|
|
|
|
icon="el-icon-setting" |
|
|
|
|
@click="handleRole" |
|
|
|
|
v-if="userInfo.role_name.includes('admin')" |
|
|
|
|
plain>权限设置 |
|
|
|
|
<!-- v-if="userInfo.role_name.includes('admin')" --> |
|
|
|
|
<el-button size="small" icon="el-icon-setting" @click="handleRole" plain |
|
|
|
|
>权限设置 |
|
|
|
|
</el-button> |
|
|
|
|
</template> |
|
|
|
|
</avue-crud> |
|
|
|
|
<el-dialog title="角色权限配置" |
|
|
|
|
<el-dialog |
|
|
|
|
title="角色权限配置" |
|
|
|
|
append-to-body |
|
|
|
|
:visible.sync="box" |
|
|
|
|
width="345px"> |
|
|
|
|
width="345px" |
|
|
|
|
> |
|
|
|
|
<el-tabs type="border-card"> |
|
|
|
|
<el-tab-pane label="菜单权限"> |
|
|
|
|
<el-tree :data="menuGrantList" |
|
|
|
|
<el-tree |
|
|
|
|
:data="menuGrantList" |
|
|
|
|
show-checkbox |
|
|
|
|
node-key="id" |
|
|
|
|
ref="treeMenu" |
|
|
|
|
:default-checked-keys="menuTreeObj" |
|
|
|
|
:props="props"> |
|
|
|
|
:props="props" |
|
|
|
|
> |
|
|
|
|
</el-tree> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
<el-tab-pane label="数据权限"> |
|
|
|
|
<el-tree :data="dataScopeGrantList" |
|
|
|
|
<el-tree |
|
|
|
|
:data="dataScopeGrantList" |
|
|
|
|
show-checkbox |
|
|
|
|
node-key="id" |
|
|
|
|
ref="treeDataScope" |
|
|
|
|
:default-checked-keys="dataScopeTreeObj" |
|
|
|
|
:props="props"> |
|
|
|
|
:props="props" |
|
|
|
|
> |
|
|
|
|
</el-tree> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
<el-tab-pane label="接口权限"> |
|
|
|
|
<el-tree :data="apiScopeGrantList" |
|
|
|
|
<el-tree |
|
|
|
|
:data="apiScopeGrantList" |
|
|
|
|
show-checkbox |
|
|
|
|
node-key="id" |
|
|
|
|
ref="treeApiScope" |
|
|
|
|
:default-checked-keys="apiScopeTreeObj" |
|
|
|
|
:props="props"> |
|
|
|
|
:props="props" |
|
|
|
|
> |
|
|
|
|
</el-tree> |
|
|
|
|
</el-tab-pane> |
|
|
|
|
</el-tabs> |
|
|
|
|
|
|
|
|
|
<span slot="footer" |
|
|
|
|
class="dialog-footer"> |
|
|
|
|
<span slot="footer" class="dialog-footer"> |
|
|
|
|
<el-button @click="box = false">取 消</el-button> |
|
|
|
|
<el-button type="primary" |
|
|
|
|
@click="submit">确 定</el-button> |
|
|
|
|
<el-button type="primary" @click="submit">确 定</el-button> |
|
|
|
|
</span> |
|
|
|
|
</el-dialog> |
|
|
|
|
</basic-container> |
|
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
import {add, getList, getRole, getRoleTreeById, grant, grantTree, remove, update} from "@/api/system/role"; |
|
|
|
|
import { |
|
|
|
|
add, |
|
|
|
|
getList, |
|
|
|
|
getRole, |
|
|
|
|
getRoleTreeById, |
|
|
|
|
grant, |
|
|
|
|
grantTree, |
|
|
|
|
remove, |
|
|
|
|
update, |
|
|
|
|
} from "@/api/system/role"; |
|
|
|
|
import { mapGetters } from "vuex"; |
|
|
|
|
import website from '@/config/website'; |
|
|
|
|
import website from "@/config/website"; |
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
data() { |
|
|
|
@ -89,7 +106,7 @@
|
|
|
|
|
box: false, |
|
|
|
|
props: { |
|
|
|
|
label: "title", |
|
|
|
|
value: "key" |
|
|
|
|
value: "key", |
|
|
|
|
}, |
|
|
|
|
menuGrantList: [], |
|
|
|
|
dataScopeGrantList: [], |
|
|
|
@ -104,7 +121,7 @@
|
|
|
|
|
page: { |
|
|
|
|
pageSize: 10, |
|
|
|
|
currentPage: 1, |
|
|
|
|
total: 0 |
|
|
|
|
total: 0, |
|
|
|
|
}, |
|
|
|
|
option: { |
|
|
|
|
tip: false, |
|
|
|
@ -128,9 +145,9 @@
|
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: "请输入角色名称", |
|
|
|
|
trigger: "blur" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
trigger: "blur", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "所属租户", |
|
|
|
@ -143,15 +160,17 @@
|
|
|
|
|
span: 24, |
|
|
|
|
props: { |
|
|
|
|
label: "tenantName", |
|
|
|
|
value: "tenantId" |
|
|
|
|
value: "tenantId", |
|
|
|
|
}, |
|
|
|
|
hide: !website.tenantMode, |
|
|
|
|
search: website.tenantMode, |
|
|
|
|
rules: [{ |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: "请输入所属租户", |
|
|
|
|
trigger: "click" |
|
|
|
|
}] |
|
|
|
|
trigger: "click", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "角色别名", |
|
|
|
@ -162,9 +181,9 @@
|
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: "请输入角色别名", |
|
|
|
|
trigger: "blur" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
trigger: "blur", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "上级角色", |
|
|
|
@ -174,15 +193,15 @@
|
|
|
|
|
hide: true, |
|
|
|
|
span: 24, |
|
|
|
|
props: { |
|
|
|
|
label: "title" |
|
|
|
|
label: "title", |
|
|
|
|
}, |
|
|
|
|
rules: [ |
|
|
|
|
{ |
|
|
|
|
required: false, |
|
|
|
|
message: "请选择上级角色", |
|
|
|
|
trigger: "click" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
trigger: "click", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: "角色排序", |
|
|
|
@ -193,13 +212,13 @@
|
|
|
|
|
{ |
|
|
|
|
required: true, |
|
|
|
|
message: "请输入角色排序", |
|
|
|
|
trigger: "blur" |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
} |
|
|
|
|
] |
|
|
|
|
trigger: "blur", |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
], |
|
|
|
|
}, |
|
|
|
|
data: [] |
|
|
|
|
data: [], |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
computed: { |
|
|
|
@ -209,28 +228,27 @@
|
|
|
|
|
addBtn: this.vaildData(this.permission.role_add, false), |
|
|
|
|
viewBtn: this.vaildData(this.permission.role_view, false), |
|
|
|
|
delBtn: this.vaildData(this.permission.role_delete, false), |
|
|
|
|
editBtn: this.vaildData(this.permission.role_edit, false) |
|
|
|
|
editBtn: this.vaildData(this.permission.role_edit, false), |
|
|
|
|
}; |
|
|
|
|
}, |
|
|
|
|
ids() { |
|
|
|
|
let ids = []; |
|
|
|
|
this.selectionList.forEach(ele => { |
|
|
|
|
this.selectionList.forEach((ele) => { |
|
|
|
|
ids.push(ele.id); |
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
return ids.join(","); |
|
|
|
|
}, |
|
|
|
|
idsArray() { |
|
|
|
|
let ids = []; |
|
|
|
|
this.selectionList.forEach(ele => { |
|
|
|
|
this.selectionList.forEach((ele) => { |
|
|
|
|
ids.push(ele.id); |
|
|
|
|
}); |
|
|
|
|
return ids; |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
initData(roleId) { |
|
|
|
|
getRoleTreeById(roleId).then(res => { |
|
|
|
|
getRoleTreeById(roleId).then((res) => { |
|
|
|
|
const column = this.findObject(this.option.column, "parentId"); |
|
|
|
|
column.dicData = res.data.data; |
|
|
|
|
}); |
|
|
|
@ -243,42 +261,48 @@
|
|
|
|
|
this.box = false; |
|
|
|
|
this.$message({ |
|
|
|
|
type: "success", |
|
|
|
|
message: "操作成功!" |
|
|
|
|
message: "操作成功!", |
|
|
|
|
}); |
|
|
|
|
this.onLoad(this.page); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
rowSave(row, done, loading) { |
|
|
|
|
add(row).then(() => { |
|
|
|
|
add(row).then( |
|
|
|
|
() => { |
|
|
|
|
this.onLoad(this.page); |
|
|
|
|
this.$message({ |
|
|
|
|
type: "success", |
|
|
|
|
message: "操作成功!" |
|
|
|
|
message: "操作成功!", |
|
|
|
|
}); |
|
|
|
|
done(); |
|
|
|
|
}, error => { |
|
|
|
|
}, |
|
|
|
|
(error) => { |
|
|
|
|
window.console.log(error); |
|
|
|
|
loading(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
rowUpdate(row, index, done, loading) { |
|
|
|
|
update(row).then(() => { |
|
|
|
|
update(row).then( |
|
|
|
|
() => { |
|
|
|
|
this.onLoad(this.page); |
|
|
|
|
this.$message({ |
|
|
|
|
type: "success", |
|
|
|
|
message: "操作成功!" |
|
|
|
|
message: "操作成功!", |
|
|
|
|
}); |
|
|
|
|
done(); |
|
|
|
|
}, error => { |
|
|
|
|
}, |
|
|
|
|
(error) => { |
|
|
|
|
window.console.log(error); |
|
|
|
|
loading(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
|
}, |
|
|
|
|
rowDel(row) { |
|
|
|
|
this.$confirm("确定将选择数据删除?", { |
|
|
|
|
confirmButtonText: "确定", |
|
|
|
|
cancelButtonText: "取消", |
|
|
|
|
type: "warning" |
|
|
|
|
type: "warning", |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
return remove(row.id); |
|
|
|
@ -287,7 +311,7 @@
|
|
|
|
|
this.onLoad(this.page); |
|
|
|
|
this.$message({ |
|
|
|
|
type: "success", |
|
|
|
|
message: "操作成功!" |
|
|
|
|
message: "操作成功!", |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
@ -323,12 +347,11 @@
|
|
|
|
|
this.menuTreeObj = []; |
|
|
|
|
this.dataScopeTreeObj = []; |
|
|
|
|
this.apiScopeTreeObj = []; |
|
|
|
|
grantTree() |
|
|
|
|
.then(res => { |
|
|
|
|
grantTree().then((res) => { |
|
|
|
|
this.menuGrantList = res.data.data.menu; |
|
|
|
|
this.dataScopeGrantList = res.data.data.dataScope; |
|
|
|
|
this.apiScopeGrantList = res.data.data.apiScope; |
|
|
|
|
getRole(this.ids).then(res => { |
|
|
|
|
getRole(this.ids).then((res) => { |
|
|
|
|
this.menuTreeObj = res.data.data.menu; |
|
|
|
|
this.dataScopeTreeObj = res.data.data.dataScope; |
|
|
|
|
this.apiScopeTreeObj = res.data.data.apiScope; |
|
|
|
@ -344,7 +367,7 @@
|
|
|
|
|
this.$confirm("确定将选择数据删除?", { |
|
|
|
|
confirmButtonText: "确定", |
|
|
|
|
cancelButtonText: "取消", |
|
|
|
|
type: "warning" |
|
|
|
|
type: "warning", |
|
|
|
|
}) |
|
|
|
|
.then(() => { |
|
|
|
|
return remove(this.ids); |
|
|
|
@ -353,7 +376,7 @@
|
|
|
|
|
this.onLoad(this.page); |
|
|
|
|
this.$message({ |
|
|
|
|
type: "success", |
|
|
|
|
message: "操作成功!" |
|
|
|
|
message: "操作成功!", |
|
|
|
|
}); |
|
|
|
|
this.$refs.crud.toggleSelection(); |
|
|
|
|
}); |
|
|
|
@ -369,12 +392,16 @@
|
|
|
|
|
}, |
|
|
|
|
onLoad(page, params = {}) { |
|
|
|
|
this.loading = true; |
|
|
|
|
getList(page.currentPage, page.pageSize, Object.assign(params, this.query)).then(res => { |
|
|
|
|
getList( |
|
|
|
|
page.currentPage, |
|
|
|
|
page.pageSize, |
|
|
|
|
Object.assign(params, this.query) |
|
|
|
|
).then((res) => { |
|
|
|
|
this.data = res.data.data; |
|
|
|
|
this.loading = false; |
|
|
|
|
this.selectionClear(); |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|