mirror of
https://github.com/chillzhuang/Saber.git
synced 2024-12-23 01:29:27 +08:00
⚡ 优化按钮权限功能
This commit is contained in:
parent
bc3632cc58
commit
ba3a438cfa
@ -108,10 +108,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.notice_add,
|
||||
viewBtn: this.permission.notice_view,
|
||||
delBtn: this.permission.notice_delete,
|
||||
editBtn: this.permission.notice_edit
|
||||
addBtn: this.vaildData(this.permission.notice_add, false),
|
||||
viewBtn: this.vaildData(this.permission.notice_view, false),
|
||||
delBtn: this.vaildData(this.permission.notice_delete, false),
|
||||
editBtn: this.vaildData(this.permission.notice_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -104,7 +104,7 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
viewBtn: this.permission.log_api_view
|
||||
viewBtn: this.vaildData(this.permission.log_api_view, false)
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -111,7 +111,7 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
viewBtn: this.permission.log_error_view
|
||||
viewBtn: this.vaildData(this.permission.log_error_view, false)
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -103,7 +103,7 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
viewBtn: this.permission.log_usual_view
|
||||
viewBtn: this.vaildData(this.permission.log_usual_view, false)
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -129,10 +129,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.dept_add,
|
||||
viewBtn: this.permission.dept_view,
|
||||
delBtn: this.permission.dept_delete,
|
||||
editBtn: this.permission.dept_edit
|
||||
addBtn: this.vaildData(this.permission.dept_add, false),
|
||||
viewBtn: this.vaildData(this.permission.dept_view, false),
|
||||
delBtn: this.vaildData(this.permission.dept_delete, false),
|
||||
editBtn: this.vaildData(this.permission.dept_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -127,10 +127,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.dict_add,
|
||||
viewBtn: this.permission.dict_view,
|
||||
delBtn: this.permission.dict_delete,
|
||||
editBtn: this.permission.dict_edit
|
||||
addBtn: this.vaildData(this.permission.dict_add, false),
|
||||
viewBtn: this.vaildData(this.permission.dict_view, false),
|
||||
delBtn: this.vaildData(this.permission.dict_delete, false),
|
||||
editBtn: this.vaildData(this.permission.dict_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -238,10 +238,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.menu_add,
|
||||
viewBtn: this.permission.menu_view,
|
||||
delBtn: this.permission.menu_delete,
|
||||
editBtn: this.permission.menu_edit
|
||||
addBtn: this.vaildData(this.permission.menu_add, false),
|
||||
viewBtn: this.vaildData(this.permission.menu_view, false),
|
||||
delBtn: this.vaildData(this.permission.menu_delete, false),
|
||||
editBtn: this.vaildData(this.permission.menu_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -92,10 +92,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.param_add,
|
||||
viewBtn: this.permission.param_view,
|
||||
delBtn: this.permission.param_delete,
|
||||
editBtn: this.permission.param_edit
|
||||
addBtn: this.vaildData(this.permission.param_add, false),
|
||||
viewBtn: this.vaildData(this.permission.param_view, false),
|
||||
delBtn: this.vaildData(this.permission.param_delete, false),
|
||||
editBtn: this.vaildData(this.permission.param_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -55,229 +55,229 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {
|
||||
getList,
|
||||
remove,
|
||||
update,
|
||||
add,
|
||||
grant,
|
||||
grantTree,
|
||||
getRole,
|
||||
getRoleTree
|
||||
} from "@/api/system/role";
|
||||
import {mapGetters} from "vuex";
|
||||
import {
|
||||
getList,
|
||||
remove,
|
||||
update,
|
||||
add,
|
||||
grant,
|
||||
grantTree,
|
||||
getRole,
|
||||
getRoleTree
|
||||
} from "@/api/system/role";
|
||||
import { mapGetters } from "vuex";
|
||||
|
||||
export default {
|
||||
data() {
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
form: {},
|
||||
box: false,
|
||||
props: {
|
||||
label: "title",
|
||||
valie: "key"
|
||||
},
|
||||
list: [],
|
||||
defaultObj: [],
|
||||
selectionList: [],
|
||||
page: {
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
},
|
||||
option: {
|
||||
tip: false,
|
||||
tree: true,
|
||||
border: true,
|
||||
index: true,
|
||||
selection: true,
|
||||
viewBtn: true,
|
||||
column: [
|
||||
{
|
||||
label: "角色名称",
|
||||
prop: "roleName",
|
||||
search: true,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色名称",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "角色别名",
|
||||
prop: "roleAlias",
|
||||
search: true,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色别名",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "上级角色",
|
||||
prop: "parentId",
|
||||
dicData: [],
|
||||
type: "tree",
|
||||
hide: true,
|
||||
props: {
|
||||
label: "title"
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false,
|
||||
message: "请选择上级角色",
|
||||
trigger: "click"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "角色排序",
|
||||
prop: "sort",
|
||||
type: "number",
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色排序",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
data: []
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
form: {},
|
||||
box: false,
|
||||
props: {
|
||||
label: "title",
|
||||
valie: "key"
|
||||
},
|
||||
list: [],
|
||||
defaultObj: [],
|
||||
selectionList: [],
|
||||
page: {
|
||||
pageSize: 10,
|
||||
currentPage: 1,
|
||||
total: 0
|
||||
},
|
||||
option: {
|
||||
tip: false,
|
||||
tree: true,
|
||||
border: true,
|
||||
index: true,
|
||||
selection: true,
|
||||
viewBtn: true,
|
||||
column: [
|
||||
{
|
||||
label: "角色名称",
|
||||
prop: "roleName",
|
||||
search: true,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色名称",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "角色别名",
|
||||
prop: "roleAlias",
|
||||
search: true,
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色别名",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "上级角色",
|
||||
prop: "parentId",
|
||||
dicData: [],
|
||||
type: "tree",
|
||||
hide: true,
|
||||
props: {
|
||||
label: "title"
|
||||
},
|
||||
rules: [
|
||||
{
|
||||
required: false,
|
||||
message: "请选择上级角色",
|
||||
trigger: "click"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "角色排序",
|
||||
prop: "sort",
|
||||
type: "number",
|
||||
rules: [
|
||||
{
|
||||
required: true,
|
||||
message: "请输入角色排序",
|
||||
trigger: "blur"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
data: []
|
||||
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)
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.role_add,
|
||||
viewBtn: this.permission.role_view,
|
||||
delBtn: this.permission.role_delete,
|
||||
editBtn: this.permission.role_edit
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
let ids = [];
|
||||
this.selectionList.forEach(ele => {
|
||||
ids.push(ele.id);
|
||||
});
|
||||
return ids.join(",");
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
const menuLIst = this.$refs.tree.getCheckedKeys().join(",");
|
||||
grant(this.ids[0], menuLIst).then(() => {
|
||||
this.box = false;
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.onLoad(this.page);
|
||||
});
|
||||
},
|
||||
rowSave(row, loading) {
|
||||
add(row).then(() => {
|
||||
loading();
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowUpdate(row, index, loading) {
|
||||
update(row).then(() => {
|
||||
this.onLoad(this.page);
|
||||
loading();
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowDel(row) {
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
searchReset() {
|
||||
this.onLoad(this.page);
|
||||
},
|
||||
searchChange(params) {
|
||||
this.onLoad(this.page, params);
|
||||
},
|
||||
selectionChange(list) {
|
||||
this.selectionList = list;
|
||||
},
|
||||
handleRole() {
|
||||
if (this.selectionList.length !== 1) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.defaultObj = [];
|
||||
grantTree()
|
||||
.then(res => {
|
||||
this.list = res.data.data;
|
||||
return getRole(this.ids[0]);
|
||||
})
|
||||
.then(res => {
|
||||
this.defaultObj = res.data.data;
|
||||
this.box = true;
|
||||
});
|
||||
},
|
||||
handleDelete() {
|
||||
if (this.selectionList.length === 0) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(this.ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.$refs.crud.toggleSelection();
|
||||
});
|
||||
},
|
||||
onLoad(page, params = {}) {
|
||||
getList(page.currentPage, page.pageSize, params).then(res => {
|
||||
const data = res.data.data;
|
||||
this.data = data;
|
||||
getRoleTree().then(res => {
|
||||
const data = res.data.data;
|
||||
const index = this.$refs.crud.findColumnIndex("parentId");
|
||||
this.option.column[index].dicData = data;
|
||||
});
|
||||
});
|
||||
}
|
||||
ids() {
|
||||
let ids = [];
|
||||
this.selectionList.forEach(ele => {
|
||||
ids.push(ele.id);
|
||||
});
|
||||
return ids.join(",");
|
||||
}
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
submit() {
|
||||
const menuLIst = this.$refs.tree.getCheckedKeys().join(",");
|
||||
grant(this.ids[0], menuLIst).then(() => {
|
||||
this.box = false;
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.onLoad(this.page);
|
||||
});
|
||||
},
|
||||
rowSave(row, loading) {
|
||||
add(row).then(() => {
|
||||
loading();
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowUpdate(row, index, loading) {
|
||||
update(row).then(() => {
|
||||
this.onLoad(this.page);
|
||||
loading();
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
rowDel(row) {
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(row.id);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
searchReset() {
|
||||
this.onLoad(this.page);
|
||||
},
|
||||
searchChange(params) {
|
||||
this.onLoad(this.page, params);
|
||||
},
|
||||
selectionChange(list) {
|
||||
this.selectionList = list;
|
||||
},
|
||||
handleRole() {
|
||||
if (this.selectionList.length !== 1) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.defaultObj = [];
|
||||
grantTree()
|
||||
.then(res => {
|
||||
this.list = res.data.data;
|
||||
return getRole(this.ids[0]);
|
||||
})
|
||||
.then(res => {
|
||||
this.defaultObj = res.data.data;
|
||||
this.box = true;
|
||||
});
|
||||
},
|
||||
handleDelete() {
|
||||
if (this.selectionList.length === 0) {
|
||||
this.$message.warning("请选择至少一条数据");
|
||||
return;
|
||||
}
|
||||
this.$confirm("确定将选择数据删除?", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning"
|
||||
})
|
||||
.then(() => {
|
||||
return remove(this.ids);
|
||||
})
|
||||
.then(() => {
|
||||
this.onLoad(this.page);
|
||||
this.$message({
|
||||
type: "success",
|
||||
message: "操作成功!"
|
||||
});
|
||||
this.$refs.crud.toggleSelection();
|
||||
});
|
||||
},
|
||||
onLoad(page, params = {}) {
|
||||
getList(page.currentPage, page.pageSize, params).then(res => {
|
||||
const data = res.data.data;
|
||||
this.data = data;
|
||||
getRoleTree().then(res => {
|
||||
const data = res.data.data;
|
||||
const index = this.$refs.crud.findColumnIndex("parentId");
|
||||
this.option.column[index].dicData = data;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
@ -86,6 +86,7 @@
|
||||
index: true,
|
||||
selection: true,
|
||||
viewBtn: true,
|
||||
dialogHeight: 450,
|
||||
column: [
|
||||
{
|
||||
label: "登录账号",
|
||||
@ -216,10 +217,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.user_add,
|
||||
viewBtn: this.permission.user_view,
|
||||
delBtn: this.permission.user_delete,
|
||||
editBtn: this.permission.user_edit
|
||||
addBtn: this.vaildData(this.permission.user_add, false),
|
||||
viewBtn: this.vaildData(this.permission.user_view, false),
|
||||
delBtn: this.vaildData(this.permission.user_delete, false),
|
||||
editBtn: this.vaildData(this.permission.user_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
@ -150,10 +150,10 @@
|
||||
...mapGetters(["permission"]),
|
||||
permissionList() {
|
||||
return {
|
||||
addBtn: this.permission.code_add,
|
||||
viewBtn: this.permission.code_view,
|
||||
delBtn: this.permission.code_delete,
|
||||
editBtn: this.permission.code_edit
|
||||
addBtn: this.vaildData(this.permission.code_add, false),
|
||||
viewBtn: this.vaildData(this.permission.code_view, false),
|
||||
delBtn: this.vaildData(this.permission.code_delete, false),
|
||||
editBtn: this.vaildData(this.permission.code_edit, false)
|
||||
};
|
||||
},
|
||||
ids() {
|
||||
|
Loading…
Reference in New Issue
Block a user