<template>
|
<div class="view">
|
<OperateC
|
:top-level="topLevel"
|
:add="addRole"
|
:edit="editRole"
|
:remove="removeRole"
|
:add-show="this.$getButtonAuth('role:add')"
|
:remove-show="this.$getButtonAuth('role:del:batch')"
|
/>
|
<RoleTable
|
:top-level="topLevel"
|
:edit-show="this.$getButtonAuth('role:edit')"
|
:permission-show="this.$getButtonAuth('role:permission')"
|
:del-show="this.$getButtonAuth('role:del')"
|
/>
|
<RoleDialog></RoleDialog>
|
</div>
|
</template>
|
|
<script>
|
import RoleTable from "@/components/table/RoleTable";
|
import OperateC from "@/components/OperateC";
|
import RoleDialog from "@/components/dialog/RoleDialog";
|
import {deleteRoleByIds, getRoles} from "@/api/role";
|
export default {
|
name: "RoleView",
|
components:{RoleDialog, RoleTable, OperateC},
|
data() {
|
return {
|
topLevel: -1
|
}
|
},
|
methods: {
|
addRole() {
|
// 打开添加dialog
|
var params = {
|
dialogTitle: "添加角色",
|
dialogFormVisible: true
|
}
|
this.$store.commit("role/openDialogForm",params);
|
},
|
editRole() {
|
var selected = this.$store.state.role.multipleSelection;
|
if (selected.length < 1) {
|
this.$message.warning("你还没有选中数据哦!");
|
return;
|
}
|
if (selected.length > 1) {
|
this.$message.warning("一次只能修改一条数据哦!")
|
return;
|
}
|
this.$store.dispatch("role/editRole", selected[0]);
|
},
|
removeRole() {
|
var selected = this.$store.state.role.multipleSelection;
|
if (selected.length < 1) {
|
this.$message.warning("请先选择要删除的数据哦!");
|
return;
|
}
|
this.$confirm('确定删除吗?', '提示', {
|
confirmButtonText: '确定',
|
cancelButtonText: '取消',
|
type: 'warning'
|
}).then(() => {
|
deleteRoleByIds(selected).then((res) => {
|
this.$message.success(res.data.msg);
|
// 刷新
|
var params = {
|
"current": this.$store.state.role.currentPage,
|
"size": this.$store.state.role.pageSize
|
};
|
getRoles(params).then((res) => {
|
this.$store.state.role.tableData = res.data.data;
|
this.$store.state.role.total = res.data.total;
|
})
|
})
|
}).catch(() => {
|
this.$message({
|
type: 'info',
|
message: '已取消删除'
|
});
|
});
|
|
},
|
|
}
|
}
|
</script>
|
|
<style scoped>
|
|
</style>
|