feat role menu

This commit is contained in:
smallwei 2019-02-15 09:13:51 +08:00
parent 9a84c3b812
commit d0cf933810
5 changed files with 26 additions and 6 deletions

View File

@ -16,6 +16,21 @@ export const getTree = () => {
method: 'get', method: 'get',
}) })
} }
export const grant = (roleIds, menuIds) => {
return request({
url: 'api/blade-system/role/grant',
method: 'post',
data: {
roleIds,
menuIds
},
meta: {
isSerialize: true,
}
})
}
export const remove = (ids) => { export const remove = (ids) => {
return request({ return request({
url: 'api/blade-system/role/remove', url: 'api/blade-system/role/remove',

View File

@ -156,7 +156,6 @@ export default {
if (["edit", "view"].includes(type)) { if (["edit", "view"].includes(type)) {
getDept(this.form.id).then(res => { getDept(this.form.id).then(res => {
this.form = res.data.data; this.form = res.data.data;
this.form.parentId = this.form.parentId + "";
}); });
} }
done(); done();

View File

@ -158,7 +158,6 @@ export default {
if (["edit", "view"].includes(type)) { if (["edit", "view"].includes(type)) {
getDict(this.form.id).then(res => { getDict(this.form.id).then(res => {
this.form = res.data.data; this.form = res.data.data;
this.form.parentId = this.form.parentId + "";
}); });
} }
done(); done();

View File

@ -36,6 +36,7 @@
<el-tree :data="list" <el-tree :data="list"
show-checkbox show-checkbox
node-key="id" node-key="id"
ref="tree"
:default-expanded-keys="defaultObj" :default-expanded-keys="defaultObj"
:default-checked-keys="defaultObj" :default-checked-keys="defaultObj"
:props="props"> :props="props">
@ -44,7 +45,7 @@
class="dialog-footer"> class="dialog-footer">
<el-button @click="box = false"> </el-button> <el-button @click="box = false"> </el-button>
<el-button type="primary" <el-button type="primary"
@click="box = false"> </el-button> @click="submit"> </el-button>
</span> </span>
</el-dialog> </el-dialog>
</basic-container> </basic-container>
@ -56,6 +57,7 @@ import {
remove, remove,
update, update,
add, add,
grant,
getTree, getTree,
getRole getRole
} from "@/api/system/role"; } from "@/api/system/role";
@ -112,6 +114,13 @@ export default {
} }
}, },
methods: { methods: {
submit() {
const menuLIst = this.$refs.tree.getCheckedKeys().join(",");
grant(this.ids[0], menuLIst).then(() => {
this.box = false;
this.onLoad(this.page);
});
},
rowSave(row, loading) { rowSave(row, loading) {
add(row).then(() => { add(row).then(() => {
loading(); loading();
@ -160,11 +169,11 @@ export default {
getTree() getTree()
.then(res => { .then(res => {
this.list = res.data.data; this.list = res.data.data;
this.box = true;
return getRole(this.ids[0]); return getRole(this.ids[0]);
}) })
.then(res => { .then(res => {
this.defaultObj = res.data.data; this.defaultObj = res.data.data;
this.box = true;
}); });
}, },
handleDelete() { handleDelete() {

View File

@ -213,8 +213,6 @@ export default {
if (["edit", "view"].includes(type)) { if (["edit", "view"].includes(type)) {
getUser(this.form.id).then(res => { getUser(this.form.id).then(res => {
this.form = res.data.data; this.form = res.data.data;
this.form.deptId = this.form.deptId + "";
this.form.roleId = this.form.roleId + "";
}); });
} }
done(); done();