| | |
| | | <template>
|
| | | <div class="app-container">
|
| | | <el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true">
|
| | | <el-form :model="queryParams" ref="queryRef" v-show="showSearch" :inline="true" label-width="68px">
|
| | | <el-form-item label="角色名称" prop="roleName">
|
| | | <el-input
|
| | | v-model="queryParams.roleName"
|
| | |
| | | </el-table-column>
|
| | | <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
| | | <template #default="scope">
|
| | | <el-tooltip content="修改" placement="top">
|
| | | <el-button
|
| | | v-if="scope.row.roleId !== 1"
|
| | | type="text"
|
| | | icon="Edit"
|
| | | @click="handleUpdate(scope.row)"
|
| | | v-hasPermi="['system:role:edit']"
|
| | | ></el-button>
|
| | | <el-tooltip content="修改" placement="top" v-if="scope.row.roleId !== 1">
|
| | | <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:role:edit']"></el-button>
|
| | | </el-tooltip>
|
| | | <el-tooltip content="删除" placement="top">
|
| | | <el-button
|
| | | v-if="scope.row.roleId !== 1"
|
| | | type="text"
|
| | | icon="Delete"
|
| | | @click="handleDelete(scope.row)"
|
| | | v-hasPermi="['system:role:remove']"
|
| | | ></el-button>
|
| | | <el-tooltip content="删除" placement="top" v-if="scope.row.roleId !== 1">
|
| | | <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:role:remove']"></el-button>
|
| | | </el-tooltip>
|
| | | <el-tooltip content="数据权限" placement="top">
|
| | | <el-button
|
| | | v-if="scope.row.roleId !== 1"
|
| | | type="text"
|
| | | icon="CircleCheck"
|
| | | @click="handleDataScope(scope.row)"
|
| | | v-hasPermi="['system:role:edit']"
|
| | | ></el-button>
|
| | | <el-tooltip content="数据权限" placement="top" v-if="scope.row.roleId !== 1">
|
| | | <el-button link type="primary" icon="CircleCheck" @click="handleDataScope(scope.row)" v-hasPermi="['system:role:edit']"></el-button>
|
| | | </el-tooltip>
|
| | | <el-tooltip content="分配用户" placement="top">
|
| | | <el-button
|
| | | v-if="scope.row.roleId !== 1"
|
| | | type="text"
|
| | | icon="User"
|
| | | @click="handleAuthUser(scope.row)"
|
| | | v-hasPermi="['system:role:edit']"
|
| | | ></el-button>
|
| | | <el-tooltip content="分配用户" placement="top" v-if="scope.row.roleId !== 1">
|
| | | <el-button link type="primary" icon="User" @click="handleAuthUser(scope.row)" v-hasPermi="['system:role:edit']"></el-button>
|
| | | </el-tooltip>
|
| | | </template>
|
| | | </el-table-column>
|
| | |
| | | <template #label>
|
| | | <span>
|
| | | <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top">
|
| | | <i class="el-icon-question"></i>
|
| | | <el-icon><question-filled /></el-icon>
|
| | | </el-tooltip>
|
| | | 权限字符
|
| | | </span>
|
| | |
| | | </template>
|
| | |
|
| | | <script setup name="Role">
|
| | | import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole } from "@/api/system/role";
|
| | | import { addRole, changeRoleStatus, dataScope, delRole, getRole, listRole, updateRole, deptTreeSelect } from "@/api/system/role";
|
| | | import { roleMenuTreeselect, treeselect as menuTreeselect } from "@/api/system/menu";
|
| | | import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
|
| | |
|
| | | const router = useRouter();
|
| | | const { proxy } = getCurrentInstance();
|
| | |
| | | loading.value = false;
|
| | | });
|
| | | }
|
| | |
|
| | | /** 搜索按钮操作 */
|
| | | function handleQuery() {
|
| | | queryParams.value.pageNum = 1;
|
| | | getList();
|
| | | }
|
| | |
|
| | | /** 重置按钮操作 */
|
| | | function resetQuery() {
|
| | | dateRange.value = [];
|
| | | proxy.resetForm("queryRef");
|
| | | handleQuery();
|
| | | }
|
| | |
|
| | | /** 删除按钮操作 */
|
| | | function handleDelete(row) {
|
| | | const roleIds = row.roleId || ids.value;
|
| | |
| | | proxy.$modal.msgSuccess("删除成功");
|
| | | }).catch(() => {});
|
| | | }
|
| | |
|
| | | /** 导出按钮操作 */
|
| | | function handleExport() {
|
| | | proxy.download("system/role/export", {
|
| | | ...queryParams.value,
|
| | | }, `role_${new Date().getTime()}.xlsx`);
|
| | | }
|
| | |
|
| | | /** 多选框选中数据 */
|
| | | function handleSelectionChange(selection) {
|
| | | ids.value = selection.map(item => item.roleId);
|
| | | single.value = selection.length != 1;
|
| | | multiple.value = !selection.length;
|
| | | }
|
| | |
|
| | | /** 角色状态修改 */
|
| | | function handleStatusChange(row) {
|
| | | let text = row.status === "0" ? "启用" : "停用";
|
| | |
| | | row.status = row.status === "0" ? "1" : "0";
|
| | | });
|
| | | }
|
| | |
|
| | | /** 更多操作 */
|
| | | function handleCommand(command, row) {
|
| | | switch (command) {
|
| | |
| | | break;
|
| | | }
|
| | | }
|
| | |
|
| | | /** 分配用户 */
|
| | | function handleAuthUser(row) {
|
| | | router.push("/system/role-auth/user/" + row.roleId);
|
| | | }
|
| | |
|
| | | /** 查询菜单树结构 */
|
| | | function getMenuTreeselect() {
|
| | | menuTreeselect().then(response => {
|
| | | menuOptions.value = response.data;
|
| | | });
|
| | | }
|
| | |
|
| | | /** 所有部门节点数据 */
|
| | | function getDeptAllCheckedKeys() {
|
| | | // 目前被选中的部门节点
|
| | |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
| | | return checkedKeys;
|
| | | }
|
| | |
|
| | | /** 重置新增的表单以及其他数据 */
|
| | | function reset() {
|
| | | if (menuRef.value != undefined) {
|
| | |
| | | };
|
| | | proxy.resetForm("roleRef");
|
| | | }
|
| | |
|
| | | /** 添加角色 */
|
| | | function handleAdd() {
|
| | | reset();
|
| | |
| | | open.value = true;
|
| | | title.value = "添加角色";
|
| | | }
|
| | |
|
| | | /** 修改角色 */
|
| | | function handleUpdate(row) {
|
| | | reset();
|
| | |
| | | title.value = "修改角色";
|
| | | });
|
| | | }
|
| | |
|
| | | /** 根据角色ID查询菜单树结构 */
|
| | | function getRoleMenuTreeselect(roleId) {
|
| | | return roleMenuTreeselect(roleId).then(response => {
|
| | |
| | | return response;
|
| | | });
|
| | | }
|
| | |
|
| | | /** 根据角色ID查询部门树结构 */
|
| | | function getRoleDeptTreeselect(roleId) {
|
| | | return roleDeptTreeselect(roleId).then(response => {
|
| | | function getDeptTree(roleId) {
|
| | | return deptTreeSelect(roleId).then(response => {
|
| | | deptOptions.value = response.depts;
|
| | | return response;
|
| | | });
|
| | | }
|
| | |
|
| | | /** 树权限(展开/折叠)*/
|
| | | function handleCheckedTreeExpand(value, type) {
|
| | | if (type == "menu") {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /** 树权限(全选/全不选) */
|
| | | function handleCheckedTreeNodeAll(value, type) {
|
| | | if (type == "menu") {
|
| | |
| | | deptRef.value.setCheckedNodes(value ? deptOptions.value : []);
|
| | | }
|
| | | }
|
| | |
|
| | | /** 树权限(父子联动) */
|
| | | function handleCheckedTreeConnect(value, type) {
|
| | | if (type == "menu") {
|
| | |
| | | form.value.deptCheckStrictly = value ? true : false;
|
| | | }
|
| | | }
|
| | |
|
| | | /** 所有菜单节点数据 */
|
| | | function getMenuAllCheckedKeys() {
|
| | | // 目前被选中的菜单节点
|
| | |
| | | checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
| | | return checkedKeys;
|
| | | }
|
| | |
|
| | | /** 提交按钮 */
|
| | | function submitForm() {
|
| | | proxy.$refs["roleRef"].validate(valid => {
|
| | |
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | /** 取消按钮 */
|
| | | function cancel() {
|
| | | open.value = false;
|
| | | reset();
|
| | | }
|
| | |
|
| | | /** 选择角色权限范围触发 */
|
| | | function dataScopeSelectChange(value) {
|
| | | if (value !== "2") {
|
| | | deptRef.value.setCheckedKeys([]);
|
| | | }
|
| | | }
|
| | |
|
| | | /** 分配数据权限操作 */
|
| | | function handleDataScope(row) {
|
| | | reset();
|
| | | const roleDeptTreeselect = getRoleDeptTreeselect(row.roleId);
|
| | | const deptTreeSelect = getDeptTree(row.roleId);
|
| | | getRole(row.roleId).then(response => {
|
| | | form.value = response.data;
|
| | | openDataScope.value = true;
|
| | | nextTick(() => {
|
| | | roleDeptTreeselect.then(res => {
|
| | | deptTreeSelect.then(res => {
|
| | | nextTick(() => {
|
| | | if (deptRef.value) {
|
| | | deptRef.value.setCheckedKeys(res.checkedKeys);
|
| | |
| | | title.value = "分配数据权限";
|
| | | });
|
| | | }
|
| | |
|
| | | /** 提交按钮(数据权限) */
|
| | | function submitDataScope() {
|
| | | if (form.value.roleId != undefined) {
|
| | |
| | | });
|
| | | }
|
| | | }
|
| | |
|
| | | /** 取消按钮(数据权限)*/
|
| | | function cancelDataScope() {
|
| | | openDataScope.value = false;
|