|
|
|
@ -60,7 +60,8 @@
|
|
|
|
|
size="mini"
|
|
|
|
|
@click="handleAdd"
|
|
|
|
|
v-hasPermi="['system:role:add']"
|
|
|
|
|
>新增</el-button>
|
|
|
|
|
>新增
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button
|
|
|
|
@ -71,7 +72,8 @@
|
|
|
|
|
:disabled="single"
|
|
|
|
|
@click="handleUpdate"
|
|
|
|
|
v-hasPermi="['system:role:edit']"
|
|
|
|
|
>修改</el-button>
|
|
|
|
|
>修改
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button
|
|
|
|
@ -82,27 +84,19 @@
|
|
|
|
|
:disabled="multiple"
|
|
|
|
|
@click="handleDelete"
|
|
|
|
|
v-hasPermi="['system:role:remove']"
|
|
|
|
|
>删除</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<el-col :span="1.5">
|
|
|
|
|
<el-button
|
|
|
|
|
type="warning"
|
|
|
|
|
plain
|
|
|
|
|
icon="el-icon-download"
|
|
|
|
|
size="mini"
|
|
|
|
|
@click="handleExport"
|
|
|
|
|
v-hasPermi="['system:role:export']"
|
|
|
|
|
>导出</el-button>
|
|
|
|
|
>删除
|
|
|
|
|
</el-button>
|
|
|
|
|
</el-col>
|
|
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
|
|
</el-row>
|
|
|
|
|
|
|
|
|
|
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange">
|
|
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
|
|
<el-table-column label="角色编号" prop="roleId" width="120" />
|
|
|
|
|
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150" />
|
|
|
|
|
<el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150" />
|
|
|
|
|
<el-table-column label="显示顺序" prop="roleSort" width="100" />
|
|
|
|
|
<el-table-column type="selection" width="55" align="center"/>
|
|
|
|
|
<el-table-column label="角色编号" prop="roleId" width="120"/>
|
|
|
|
|
<el-table-column label="角色名称" prop="roleName" :show-overflow-tooltip="true" width="150"/>
|
|
|
|
|
<el-table-column label="权限字符" prop="roleKey" :show-overflow-tooltip="true" width="150"/>
|
|
|
|
|
<el-table-column label="显示顺序" prop="roleSort" width="100"/>
|
|
|
|
|
<el-table-column label="所属租户" prop="tenantName" width="100"/>
|
|
|
|
|
<el-table-column label="状态" align="center" width="100">
|
|
|
|
|
<template slot-scope="scope">
|
|
|
|
|
<el-switch
|
|
|
|
@ -126,21 +120,26 @@
|
|
|
|
|
icon="el-icon-edit"
|
|
|
|
|
@click="handleUpdate(scope.row)"
|
|
|
|
|
v-hasPermi="['system:role:edit']"
|
|
|
|
|
>修改</el-button>
|
|
|
|
|
>修改
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
size="mini"
|
|
|
|
|
type="text"
|
|
|
|
|
icon="el-icon-delete"
|
|
|
|
|
@click="handleDelete(scope.row)"
|
|
|
|
|
v-hasPermi="['system:role:remove']"
|
|
|
|
|
>删除</el-button>
|
|
|
|
|
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']">
|
|
|
|
|
>删除
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)"
|
|
|
|
|
v-hasPermi="['system:role:edit']">
|
|
|
|
|
<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>
|
|
|
|
|
v-hasPermi="['system:role:edit']">数据权限
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
<el-dropdown-item command="handleAuthUser" icon="el-icon-user"
|
|
|
|
|
v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item>
|
|
|
|
|
v-hasPermi="['system:role:edit']">分配用户
|
|
|
|
|
</el-dropdown-item>
|
|
|
|
|
</el-dropdown-menu>
|
|
|
|
|
</el-dropdown>
|
|
|
|
|
</template>
|
|
|
|
@ -159,7 +158,7 @@
|
|
|
|
|
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
|
|
|
|
|
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
|
|
|
|
|
<el-form-item label="角色名称" prop="roleName">
|
|
|
|
|
<el-input v-model="form.roleName" placeholder="请输入角色名称" />
|
|
|
|
|
<el-input v-model="form.roleName" placeholder="请输入角色名称"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item prop="roleKey">
|
|
|
|
|
<span slot="label">
|
|
|
|
@ -168,10 +167,10 @@
|
|
|
|
|
</el-tooltip>
|
|
|
|
|
权限字符
|
|
|
|
|
</span>
|
|
|
|
|
<el-input v-model="form.roleKey" placeholder="请输入权限字符" />
|
|
|
|
|
<el-input v-model="form.roleKey" placeholder="请输入权限字符"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="角色顺序" prop="roleSort">
|
|
|
|
|
<el-input-number v-model="form.roleSort" controls-position="right" :min="0" />
|
|
|
|
|
<el-input-number v-model="form.roleSort" controls-position="right" :min="0"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="状态">
|
|
|
|
|
<el-radio-group v-model="form.status">
|
|
|
|
@ -179,13 +178,16 @@
|
|
|
|
|
v-for="dict in dict.type.sys_normal_disable"
|
|
|
|
|
:key="dict.value"
|
|
|
|
|
:label="dict.value"
|
|
|
|
|
>{{dict.label}}</el-radio>
|
|
|
|
|
>{{ dict.label }}
|
|
|
|
|
</el-radio>
|
|
|
|
|
</el-radio-group>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="菜单权限">
|
|
|
|
|
<el-checkbox v-model="menuExpand" @change="handleCheckedTreeExpand($event, 'menu')">展开/折叠</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="menuNodeAll" @change="handleCheckedTreeNodeAll($event, 'menu')">全选/全不选
|
|
|
|
|
</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="form.menuCheckStrictly" @change="handleCheckedTreeConnect($event, 'menu')">父子联动
|
|
|
|
|
</el-checkbox>
|
|
|
|
|
<el-tree
|
|
|
|
|
class="tree-border"
|
|
|
|
|
:data="menuOptions"
|
|
|
|
@ -202,7 +204,7 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
</el-form>
|
|
|
|
|
<div slot="footer" class="dialog-footer">
|
|
|
|
|
<el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
|
<el-button type="primary" @click="submitForm" v-if="editable">确 定</el-button>
|
|
|
|
|
<el-button @click="cancel">取 消</el-button>
|
|
|
|
|
</div>
|
|
|
|
|
</el-dialog>
|
|
|
|
@ -211,10 +213,10 @@
|
|
|
|
|
<el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body>
|
|
|
|
|
<el-form :model="form" label-width="80px">
|
|
|
|
|
<el-form-item label="角色名称">
|
|
|
|
|
<el-input v-model="form.roleName" :disabled="true" />
|
|
|
|
|
<el-input v-model="form.roleName" :disabled="true"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="权限字符">
|
|
|
|
|
<el-input v-model="form.roleKey" :disabled="true" />
|
|
|
|
|
<el-input v-model="form.roleKey" :disabled="true"/>
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="权限范围">
|
|
|
|
|
<el-select v-model="form.dataScope" @change="dataScopeSelectChange">
|
|
|
|
@ -228,8 +230,10 @@
|
|
|
|
|
</el-form-item>
|
|
|
|
|
<el-form-item label="数据权限" v-show="form.dataScope == 2">
|
|
|
|
|
<el-checkbox v-model="deptExpand" @change="handleCheckedTreeExpand($event, 'dept')">展开/折叠</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="deptNodeAll" @change="handleCheckedTreeNodeAll($event, 'dept')">全选/全不选
|
|
|
|
|
</el-checkbox>
|
|
|
|
|
<el-checkbox v-model="form.deptCheckStrictly" @change="handleCheckedTreeConnect($event, 'dept')">父子联动
|
|
|
|
|
</el-checkbox>
|
|
|
|
|
<el-tree
|
|
|
|
|
class="tree-border"
|
|
|
|
|
:data="deptOptions"
|
|
|
|
@ -252,8 +256,17 @@
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } from "@/api/system/role";
|
|
|
|
|
import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
|
|
|
|
|
import {
|
|
|
|
|
listRole,
|
|
|
|
|
getRole,
|
|
|
|
|
delRole,
|
|
|
|
|
addRole,
|
|
|
|
|
updateRole,
|
|
|
|
|
dataScope,
|
|
|
|
|
changeRoleStatus,
|
|
|
|
|
deptTreeSelect
|
|
|
|
|
} from "@/api/system/role";
|
|
|
|
|
import {treeselect as menuTreeselect, roleMenuTreeselect} from "@/api/system/menu";
|
|
|
|
|
|
|
|
|
|
export default {
|
|
|
|
|
name: "Role",
|
|
|
|
@ -330,15 +343,16 @@ export default {
|
|
|
|
|
// 表单校验
|
|
|
|
|
rules: {
|
|
|
|
|
roleName: [
|
|
|
|
|
{ required: true, message: "角色名称不能为空", trigger: "blur" }
|
|
|
|
|
{required: true, message: "角色名称不能为空", trigger: "blur"}
|
|
|
|
|
],
|
|
|
|
|
roleKey: [
|
|
|
|
|
{ required: true, message: "权限字符不能为空", trigger: "blur" }
|
|
|
|
|
{required: true, message: "权限字符不能为空", trigger: "blur"}
|
|
|
|
|
],
|
|
|
|
|
roleSort: [
|
|
|
|
|
{ required: true, message: "角色顺序不能为空", trigger: "blur" }
|
|
|
|
|
{required: true, message: "角色顺序不能为空", trigger: "blur"}
|
|
|
|
|
]
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
editable: false
|
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
@ -396,11 +410,11 @@ export default {
|
|
|
|
|
// 角色状态修改
|
|
|
|
|
handleStatusChange(row) {
|
|
|
|
|
let text = row.status === "0" ? "启用" : "停用";
|
|
|
|
|
this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function() {
|
|
|
|
|
this.$modal.confirm('确认要"' + text + '""' + row.roleName + '"角色吗?').then(function () {
|
|
|
|
|
return changeRoleStatus(row.roleId, row.status);
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.$modal.msgSuccess(text + "成功");
|
|
|
|
|
}).catch(function() {
|
|
|
|
|
}).catch(function () {
|
|
|
|
|
row.status = row.status === "0" ? "1" : "0";
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
@ -420,21 +434,21 @@ export default {
|
|
|
|
|
this.$refs.menu.setCheckedKeys([]);
|
|
|
|
|
}
|
|
|
|
|
this.menuExpand = false,
|
|
|
|
|
this.menuNodeAll = false,
|
|
|
|
|
this.deptExpand = true,
|
|
|
|
|
this.deptNodeAll = false,
|
|
|
|
|
this.form = {
|
|
|
|
|
roleId: undefined,
|
|
|
|
|
roleName: undefined,
|
|
|
|
|
roleKey: undefined,
|
|
|
|
|
roleSort: 0,
|
|
|
|
|
status: "0",
|
|
|
|
|
menuIds: [],
|
|
|
|
|
deptIds: [],
|
|
|
|
|
menuCheckStrictly: true,
|
|
|
|
|
deptCheckStrictly: true,
|
|
|
|
|
remark: undefined
|
|
|
|
|
};
|
|
|
|
|
this.menuNodeAll = false,
|
|
|
|
|
this.deptExpand = true,
|
|
|
|
|
this.deptNodeAll = false,
|
|
|
|
|
this.form = {
|
|
|
|
|
roleId: undefined,
|
|
|
|
|
roleName: undefined,
|
|
|
|
|
roleKey: undefined,
|
|
|
|
|
roleSort: 0,
|
|
|
|
|
status: "0",
|
|
|
|
|
menuIds: [],
|
|
|
|
|
deptIds: [],
|
|
|
|
|
menuCheckStrictly: true,
|
|
|
|
|
deptCheckStrictly: true,
|
|
|
|
|
remark: undefined
|
|
|
|
|
};
|
|
|
|
|
this.resetForm("form");
|
|
|
|
|
},
|
|
|
|
|
/** 搜索按钮操作 */
|
|
|
|
@ -451,7 +465,7 @@ export default {
|
|
|
|
|
// 多选框选中数据
|
|
|
|
|
handleSelectionChange(selection) {
|
|
|
|
|
this.ids = selection.map(item => item.roleId)
|
|
|
|
|
this.single = selection.length!=1
|
|
|
|
|
this.single = selection.length != 1
|
|
|
|
|
this.multiple = !selection.length
|
|
|
|
|
},
|
|
|
|
|
// 更多操作触发
|
|
|
|
@ -484,21 +498,22 @@ export default {
|
|
|
|
|
// 树权限(全选/全不选)
|
|
|
|
|
handleCheckedTreeNodeAll(value, type) {
|
|
|
|
|
if (type == 'menu') {
|
|
|
|
|
this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
|
|
|
|
|
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []);
|
|
|
|
|
} else if (type == 'dept') {
|
|
|
|
|
this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []);
|
|
|
|
|
this.$refs.dept.setCheckedNodes(value ? this.deptOptions : []);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
// 树权限(父子联动)
|
|
|
|
|
handleCheckedTreeConnect(value, type) {
|
|
|
|
|
if (type == 'menu') {
|
|
|
|
|
this.form.menuCheckStrictly = value ? true: false;
|
|
|
|
|
this.form.menuCheckStrictly = value ? true : false;
|
|
|
|
|
} else if (type == 'dept') {
|
|
|
|
|
this.form.deptCheckStrictly = value ? true: false;
|
|
|
|
|
this.form.deptCheckStrictly = value ? true : false;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
/** 新增按钮操作 */
|
|
|
|
|
handleAdd() {
|
|
|
|
|
this.editable = true;
|
|
|
|
|
this.reset();
|
|
|
|
|
this.getMenuTreeselect();
|
|
|
|
|
this.open = true;
|
|
|
|
@ -506,6 +521,12 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
/** 修改按钮操作 */
|
|
|
|
|
handleUpdate(row) {
|
|
|
|
|
this.editable = false;
|
|
|
|
|
|
|
|
|
|
if (row.roleId !== 3 && (row.notEditable === undefined || row.notEditable === null)) {
|
|
|
|
|
this.editable = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this.reset();
|
|
|
|
|
const roleId = row.roleId || this.ids
|
|
|
|
|
const roleMenu = this.getRoleMenuTreeselect(roleId);
|
|
|
|
@ -516,9 +537,9 @@ export default {
|
|
|
|
|
roleMenu.then(res => {
|
|
|
|
|
let checkedKeys = res.checkedKeys
|
|
|
|
|
checkedKeys.forEach((v) => {
|
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
this.$refs.menu.setChecked(v, true ,false);
|
|
|
|
|
})
|
|
|
|
|
this.$nextTick(() => {
|
|
|
|
|
this.$refs.menu.setChecked(v, true, false);
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
@ -527,7 +548,7 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
/** 选择角色权限范围触发 */
|
|
|
|
|
dataScopeSelectChange(value) {
|
|
|
|
|
if(value !== '2') {
|
|
|
|
|
if (value !== '2') {
|
|
|
|
|
this.$refs.dept.setCheckedKeys([]);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
@ -547,12 +568,12 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 分配用户操作 */
|
|
|
|
|
handleAuthUser: function(row) {
|
|
|
|
|
handleAuthUser: function (row) {
|
|
|
|
|
const roleId = row.roleId;
|
|
|
|
|
this.$router.push("/system/role-auth/user/" + roleId);
|
|
|
|
|
},
|
|
|
|
|
/** 提交按钮 */
|
|
|
|
|
submitForm: function() {
|
|
|
|
|
submitForm: function () {
|
|
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
|
|
if (valid) {
|
|
|
|
|
if (this.form.roleId != undefined) {
|
|
|
|
@ -574,7 +595,7 @@ export default {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 提交按钮(数据权限) */
|
|
|
|
|
submitDataScope: function() {
|
|
|
|
|
submitDataScope: function () {
|
|
|
|
|
if (this.form.roleId != undefined) {
|
|
|
|
|
this.form.deptIds = this.getDeptAllCheckedKeys();
|
|
|
|
|
dataScope(this.form).then(response => {
|
|
|
|
@ -587,12 +608,13 @@ export default {
|
|
|
|
|
/** 删除按钮操作 */
|
|
|
|
|
handleDelete(row) {
|
|
|
|
|
const roleIds = row.roleId || this.ids;
|
|
|
|
|
this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() {
|
|
|
|
|
this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function () {
|
|
|
|
|
return delRole(roleIds);
|
|
|
|
|
}).then(() => {
|
|
|
|
|
this.getList();
|
|
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
|
|
}).catch(() => {});
|
|
|
|
|
}).catch(() => {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
/** 导出按钮操作 */
|
|
|
|
|
handleExport() {
|
|
|
|
@ -602,4 +624,4 @@ export default {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
</script>
|
|
|
|
|