| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | <el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true">
|
| | | <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
|
| | | <el-form-item label="角色名称" prop="roleName">
|
| | | <el-input
|
| | | v-model="queryParams.roleName"
|
| | | placeholder="请输入角色名称"
|
| | | clearable
|
| | | size="small"
|
| | | style="width: 240px"
|
| | | @keyup.enter.native="handleQuery"
|
| | | />
|
| | |
| | | v-model="queryParams.roleKey"
|
| | | placeholder="请输入权限字符"
|
| | | clearable
|
| | | size="small"
|
| | | style="width: 240px"
|
| | | @keyup.enter.native="handleQuery"
|
| | | />
|
| | |
| | | v-model="queryParams.status"
|
| | | placeholder="角色状态"
|
| | | clearable
|
| | | size="small"
|
| | | style="width: 240px"
|
| | | >
|
| | | <el-option
|
| | |
| | | <el-form-item label="创建时间">
|
| | | <el-date-picker
|
| | | v-model="dateRange"
|
| | | size="small"
|
| | | style="width: 240px"
|
| | | value-format="yyyy-MM-dd"
|
| | | type="daterange"
|
| | |
| | | plain
|
| | | icon="el-icon-download"
|
| | | size="mini"
|
| | | :loading="exportLoading"
|
| | | @click="handleExport"
|
| | | v-hasPermi="['system:role:export']"
|
| | | >导出</el-button>
|
| | |
| | | v-hasPermi="['system:role:remove']"
|
| | | >删除</el-button>
|
| | | <el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']">
|
| | | <span class="el-dropdown-link">
|
| | | <i class="el-icon-d-arrow-right el-icon--right"></i>更多
|
| | | </span>
|
| | | <el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button>
|
| | | <el-dropdown-menu slot="dropdown">
|
| | | <el-dropdown-item command="handleDataScope" icon="el-icon-circle-check"
|
| | | v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item>
|
| | |
| | | ref="menu"
|
| | | node-key="id"
|
| | | :check-strictly="!form.menuCheckStrictly"
|
| | | empty-text="加载中,请稍后"
|
| | | empty-text="加载中,请稍候"
|
| | | :props="defaultProps"
|
| | | ></el-tree>
|
| | | </el-form-item>
|
| | |
| | | ref="dept"
|
| | | node-key="id"
|
| | | :check-strictly="!form.deptCheckStrictly"
|
| | | empty-text="加载中,请稍后"
|
| | | empty-text="加载中,请稍候"
|
| | | :props="defaultProps"
|
| | | ></el-tree>
|
| | | </el-form-item>
|
| | |
| | | </template>
|
| | |
|
| | | <script>
|
| | | import { listRole, getRole, delRole, addRole, updateRole, exportRole, dataScope, changeRoleStatus } from "@/api/system/role";
|
| | | import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
|
| | | import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
|
| | | import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
|
| | |
|
| | | export default {
|
| | | name: "Role",
|
| | |
| | | return {
|
| | | // 遮罩层
|
| | | loading: true,
|
| | | // 导出遮罩层
|
| | | exportLoading: false,
|
| | | // 选中数组
|
| | | ids: [],
|
| | | // 非单个禁用
|
| | |
| | | /** 查询角色列表 */
|
| | | getList() {
|
| | | this.loading = true;
|
| | | listRole(this.addDateRange(this.queryParams, this.dateRange)).then(
|
| | | response => {
|
| | | listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
| | | this.roleList = response.rows;
|
| | | this.total = response.total;
|
| | | this.loading = false;
|
| | |
| | | getMenuTreeselect() {
|
| | | menuTreeselect().then(response => {
|
| | | this.menuOptions = response.data;
|
| | | });
|
| | | },
|
| | | /** 查询部门树结构 */
|
| | | getDeptTreeselect() {
|
| | | deptTreeselect().then(response => {
|
| | | this.deptOptions = response.data;
|
| | | });
|
| | | },
|
| | | // 所有菜单节点数据
|
| | |
| | | });
|
| | | },
|
| | | /** 根据角色ID查询部门树结构 */
|
| | | getRoleDeptTreeselect(roleId) {
|
| | | return roleDeptTreeselect(roleId).then(response => {
|
| | | getDeptTree(roleId) {
|
| | | return deptTreeSelect(roleId).then(response => {
|
| | | this.deptOptions = response.depts;
|
| | | return response;
|
| | | });
|
| | |
| | | /** 分配数据权限操作 */
|
| | | handleDataScope(row) {
|
| | | this.reset();
|
| | | const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
|
| | | const deptTreeSelect = this.getDeptTree(row.roleId);
|
| | | getRole(row.roleId).then(response => {
|
| | | this.form = response.data;
|
| | | this.openDataScope = true;
|
| | | this.$nextTick(() => {
|
| | | roleDeptTreeselect.then(res => {
|
| | | deptTreeSelect.then(res => {
|
| | | this.$refs.dept.setCheckedKeys(res.checkedKeys);
|
| | | });
|
| | | });
|
| | |
| | | },
|
| | | /** 导出按钮操作 */
|
| | | handleExport() {
|
| | | const queryParams = this.queryParams;
|
| | | this.$modal.confirm('是否确认导出所有用户数据项?').then(() => {
|
| | | this.exportLoading = true;
|
| | | return exportRole(queryParams);
|
| | | }).then(response => {
|
| | | this.download(response.msg);
|
| | | this.exportLoading = false;
|
| | | }).catch(() => {});
|
| | | this.download('system/role/export', {
|
| | | ...this.queryParams
|
| | | }, `role_${new Date().getTime()}.xlsx`)
|
| | | }
|
| | | }
|
| | | };
|