|
@@ -3,7 +3,6 @@
|
|
<div class="app-container role">
|
|
<div class="app-container role">
|
|
<div class="role_n" v-if="pageType==1">
|
|
<div class="role_n" v-if="pageType==1">
|
|
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true" class="form-box" >
|
|
<el-form :model="queryParams" ref="queryForm" v-show="showSearch" :inline="true" class="form-box" >
|
|
-
|
|
|
|
<el-form-item label="角色名称" prop="roleName" style="margin-left:20px;">
|
|
<el-form-item label="角色名称" prop="roleName" style="margin-left:20px;">
|
|
<el-input
|
|
<el-input
|
|
v-model="queryParams.roleName"
|
|
v-model="queryParams.roleName"
|
|
@@ -40,36 +39,23 @@
|
|
<p class="reset-button-one" @click="resetQuery">重置</p>
|
|
<p class="reset-button-one" @click="resetQuery">重置</p>
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-form>
|
|
</el-form>
|
|
-
|
|
|
|
- <el-table v-loading="loading" border :data="roleList" @selection-change="handleSelectionChange" class="table-box" v-if="pageType==1">
|
|
|
|
- <el-table-column label="角色名称" prop="roleName" align="left" :show-overflow-tooltip="true"/>
|
|
|
|
- <el-table-column label="显示顺序" prop="roleSort" align="left"/>
|
|
|
|
- <el-table-column label="状态" align="left">
|
|
|
|
|
|
+ <el-table v-loading="loading" border :data="roleList" class="table-box" v-if="pageType==1">
|
|
|
|
+ <el-table-column label="序号" width="100" align="center" type="index"/>
|
|
|
|
+ <el-table-column label="名称" prop="roleName" align="center" :show-overflow-tooltip="true" width="200"/>
|
|
|
|
+ <el-table-column label="数据范围" prop="dataScope" align="center" :show-overflow-tooltip="true" width="296">
|
|
<template slot-scope="scope">
|
|
<template slot-scope="scope">
|
|
- <el-switch
|
|
|
|
- class="switch"
|
|
|
|
- @change="handleStatusChange(scope.row)"
|
|
|
|
- v-model="scope.row.status"
|
|
|
|
- active-value="0"
|
|
|
|
- inactive-value="1"
|
|
|
|
- active-text="开"
|
|
|
|
- inactive-text="关"
|
|
|
|
- >
|
|
|
|
- </el-switch>
|
|
|
|
|
|
+ <p v-for="(item,index) in optionsDataList" :key="index" v-if="scope.row.dataScope == item.type">{{item.value}}</p>
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
- <el-table-column label="操作" align="left" class-name="small-padding fixed-width" width="280" v-if="tableButtonType">
|
|
|
|
|
|
+ <el-table-column label="对应身份" prop="postNameStr" align="center" :show-overflow-tooltip="true"/>
|
|
|
|
+ <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180" v-if="tableButtonType">
|
|
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
|
|
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
|
|
<div class="table-button-box">
|
|
<div class="table-button-box">
|
|
<p class="table-button-null"></p>
|
|
<p class="table-button-null"></p>
|
|
<p class="table-button-p"
|
|
<p class="table-button-p"
|
|
- @click="handleAuthUser(scope.row)"
|
|
|
|
|
|
+ @click="copyButton(scope.row)"
|
|
v-hasPermi="['system:dict:edit']"
|
|
v-hasPermi="['system:dict:edit']"
|
|
- >分配用户</p>
|
|
|
|
- <p class="table-button-p"
|
|
|
|
- @click="handleDataScope(scope.row)"
|
|
|
|
- v-hasPermi="['system:dict:edit']"
|
|
|
|
- >数据结构</p>
|
|
|
|
|
|
+ >复制</p>
|
|
<p class="table-button-p"
|
|
<p class="table-button-p"
|
|
@click="handleUpdate(scope.row)"
|
|
@click="handleUpdate(scope.row)"
|
|
v-hasPermi="['system:role:edit']"
|
|
v-hasPermi="['system:role:edit']"
|
|
@@ -83,7 +69,6 @@
|
|
</template>
|
|
</template>
|
|
</el-table-column>
|
|
</el-table-column>
|
|
</el-table>
|
|
</el-table>
|
|
-
|
|
|
|
<pagination :page-sizes="[20, 30, 40, 50]"
|
|
<pagination :page-sizes="[20, 30, 40, 50]"
|
|
v-if="pageType==1"
|
|
v-if="pageType==1"
|
|
v-show="total>0"
|
|
v-show="total>0"
|
|
@@ -93,119 +78,18 @@
|
|
:limit.sync="queryParams.pageSize"
|
|
:limit.sync="queryParams.pageSize"
|
|
@pagination="getList"
|
|
@pagination="getList"
|
|
/>
|
|
/>
|
|
-
|
|
|
|
- <!-- 添加或修改角色配置对话框 -->
|
|
|
|
- <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body class="role-el-dialog" :close-on-click-modal="false">
|
|
|
|
- <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-form-item>
|
|
|
|
- <el-form-item prop="roleKey">
|
|
|
|
- <span slot="label">
|
|
|
|
- <el-tooltip content="控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)" placement="top">
|
|
|
|
- <i class="el-icon-question"></i>
|
|
|
|
- </el-tooltip>
|
|
|
|
- 权限字符
|
|
|
|
- </span>
|
|
|
|
- <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-form-item>
|
|
|
|
- <el-form-item label="状态">
|
|
|
|
- <el-radio-group v-model="form.status">
|
|
|
|
- <el-radio
|
|
|
|
- v-for="dict in statusOptions"
|
|
|
|
- :key="dict.dictValue"
|
|
|
|
- :label="dict.dictValue"
|
|
|
|
- >{{dict.dictLabel}}</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-tree
|
|
|
|
- class="tree-border"
|
|
|
|
- :data="menuOptions"
|
|
|
|
- show-checkbox
|
|
|
|
- ref="menu"
|
|
|
|
- node-key="id"
|
|
|
|
- :check-strictly="!form.menuCheckStrictly"
|
|
|
|
- empty-text="加载中,请稍后"
|
|
|
|
- :props="defaultProps"
|
|
|
|
- ></el-tree>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="备注">
|
|
|
|
- <el-input v-model="form.remark" type="text" placeholder="请输入内容"></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
|
- <el-button @click="cancel">取 消</el-button>
|
|
|
|
- <el-button type="primary" @click="submitForm">确 定</el-button>
|
|
|
|
- </div>
|
|
|
|
- </el-dialog>
|
|
|
|
-
|
|
|
|
- <!-- 分配角色数据权限对话框 -->
|
|
|
|
- <el-dialog :title="title" :visible.sync="openDataScope" width="500px" append-to-body :close-on-click-modal="false">
|
|
|
|
- <el-form :model="form" label-width="80px">
|
|
|
|
- <el-form-item label="角色名称">
|
|
|
|
- <el-input v-model="form.roleName" :disabled="true" />
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="权限字符">
|
|
|
|
- <el-input v-model="form.roleKey" :disabled="true" />
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item label="权限范围">
|
|
|
|
- <el-select v-model="form.dataScope" @change="dataScopeSelectChange">
|
|
|
|
- <el-option
|
|
|
|
- v-for="item in dataScopeOptions"
|
|
|
|
- :key="item.value"
|
|
|
|
- :label="item.label"
|
|
|
|
- :value="item.value"
|
|
|
|
- ></el-option>
|
|
|
|
- </el-select>
|
|
|
|
- </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-tree
|
|
|
|
- class="tree-border"
|
|
|
|
- :data="deptOptions"
|
|
|
|
- show-checkbox
|
|
|
|
- default-expand-all
|
|
|
|
- ref="dept"
|
|
|
|
- node-key="id"
|
|
|
|
- :check-strictly="!form.deptCheckStrictly"
|
|
|
|
- empty-text="加载中,请稍后"
|
|
|
|
- :props="defaultProps"
|
|
|
|
- ></el-tree>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- <div slot="footer" class="dialog-footer">
|
|
|
|
- <el-button @click="cancelDataScope">取 消</el-button>
|
|
|
|
- <el-button type="primary" @click="submitDataScope">确 定</el-button>
|
|
|
|
- </div>
|
|
|
|
- </el-dialog>
|
|
|
|
</div>
|
|
</div>
|
|
-
|
|
|
|
-
|
|
|
|
- <!--分配用户-->
|
|
|
|
-<!-- <auth-user :roleId="roleId" v-if="pageType == 2"></auth-user>-->
|
|
|
|
- <add-page v-if="pageType == 2" :editType="editType" :propsData="propsData" :titleName="titleName"></add-page>
|
|
|
|
|
|
+ <!--编辑-->
|
|
|
|
+ <add-page v-if="pageType == 2" :propsData="propsData"></add-page>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role";
|
|
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus } from "@/api/system/role";
|
|
-import { treeselect as menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
|
|
|
|
-import { treeselect as deptTreeselect, roleDeptTreeselect } from "@/api/system/dept";
|
|
|
|
-import authUser from "./authUser.vue";
|
|
|
|
import addPage from "./addPage.vue"
|
|
import addPage from "./addPage.vue"
|
|
|
|
|
|
export default {
|
|
export default {
|
|
components: {
|
|
components: {
|
|
- authUser,
|
|
|
|
addPage
|
|
addPage
|
|
},
|
|
},
|
|
name: "Role",
|
|
name: "Role",
|
|
@@ -214,94 +98,30 @@ export default {
|
|
tableButtonType:this.hasPermiDom(['system:dict:edit','system:role:edit','system:role:remove']),
|
|
tableButtonType:this.hasPermiDom(['system:dict:edit','system:role:edit','system:role:remove']),
|
|
// 遮罩层
|
|
// 遮罩层
|
|
loading: true,
|
|
loading: true,
|
|
- // 选中数组
|
|
|
|
- ids: [],
|
|
|
|
- // 非单个禁用
|
|
|
|
- single: true,
|
|
|
|
- // 非多个禁用
|
|
|
|
- multiple: true,
|
|
|
|
// 显示搜索条件
|
|
// 显示搜索条件
|
|
showSearch: true,
|
|
showSearch: true,
|
|
// 总条数
|
|
// 总条数
|
|
total: 0,
|
|
total: 0,
|
|
- // 角色表格数据
|
|
|
|
- roleList: [],
|
|
|
|
- // 弹出层标题
|
|
|
|
- title: "",
|
|
|
|
- // 是否显示弹出层
|
|
|
|
- open: false,
|
|
|
|
- // 是否显示弹出层(数据权限)
|
|
|
|
- openDataScope: false,
|
|
|
|
- menuExpand: false,
|
|
|
|
- menuNodeAll: false,
|
|
|
|
- deptExpand: true,
|
|
|
|
- deptNodeAll: false,
|
|
|
|
- // 日期范围
|
|
|
|
- dateRange: [],
|
|
|
|
// 状态数据字典
|
|
// 状态数据字典
|
|
statusOptions: [],
|
|
statusOptions: [],
|
|
- // 数据范围选项
|
|
|
|
- dataScopeOptions: [
|
|
|
|
- {
|
|
|
|
- value: "1",
|
|
|
|
- label: "全部数据权限"
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- value: "2",
|
|
|
|
- label: "自定数据权限"
|
|
|
|
- },
|
|
|
|
- // {
|
|
|
|
- // value: "3",
|
|
|
|
- // label: "本部门数据权限"
|
|
|
|
- // },
|
|
|
|
- {
|
|
|
|
- value: "4",
|
|
|
|
- label: "本部门及以下数据权限"
|
|
|
|
- },
|
|
|
|
- // {
|
|
|
|
- // value: "5",
|
|
|
|
- // label: "仅本人数据权限"
|
|
|
|
- // }
|
|
|
|
- ],
|
|
|
|
- // 菜单列表
|
|
|
|
- menuOptions: [],
|
|
|
|
- // 部门列表
|
|
|
|
- deptOptions: [],
|
|
|
|
// 查询参数
|
|
// 查询参数
|
|
queryParams: {
|
|
queryParams: {
|
|
pageNum: 1,
|
|
pageNum: 1,
|
|
pageSize:20,
|
|
pageSize:20,
|
|
- roleName: undefined,
|
|
|
|
- roleKey: undefined,
|
|
|
|
- status: undefined
|
|
|
|
- },
|
|
|
|
- // 表单参数
|
|
|
|
- form: {},
|
|
|
|
- defaultProps: {
|
|
|
|
- children: "children",
|
|
|
|
- label: "label"
|
|
|
|
- },
|
|
|
|
- // 表单校验
|
|
|
|
- rules: {
|
|
|
|
- roleName: [
|
|
|
|
- { required: true, message: "角色名称不能为空", trigger: "blur" },
|
|
|
|
- { required: true, message: "角色名称不能为空", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
|
- ],
|
|
|
|
- roleKey: [
|
|
|
|
- { required: true, message: "权限字符不能为空", trigger: "blur" },
|
|
|
|
- { required: true, message: "权限字符不能为空", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
|
- ],
|
|
|
|
- roleSort: [
|
|
|
|
- { required: true, message: "角色顺序不能为空", trigger: "blur" },
|
|
|
|
- { required: true, message: "角色顺序不能为空", validator: this.spaceJudgment, trigger: "blur" }
|
|
|
|
- ]
|
|
|
|
|
|
+ roleName: null,
|
|
|
|
+ status: null
|
|
},
|
|
},
|
|
|
|
+ roleList:[],
|
|
pageType:1,
|
|
pageType:1,
|
|
- roleId:"",
|
|
|
|
- editType:false,
|
|
|
|
//组件传参数据
|
|
//组件传参数据
|
|
propsData:{},
|
|
propsData:{},
|
|
- titleName:'新增身份',
|
|
|
|
|
|
+ //数据范围列表
|
|
|
|
+ optionsDataList:[
|
|
|
|
+ {type: '1', value: "所有数据",},
|
|
|
|
+ {type: '2', value: "本部门及指定部门数据",},
|
|
|
|
+ {type: '4', value: "本部门及下级部门数据",},
|
|
|
|
+ {type: '5', value: "当前账号数据",},
|
|
|
|
+ ],
|
|
};
|
|
};
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
@@ -311,14 +131,15 @@ export default {
|
|
});
|
|
});
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- outPage(){
|
|
|
|
- this.pageType = 1;
|
|
|
|
- this.getList();
|
|
|
|
- },
|
|
|
|
- //页面切换
|
|
|
|
- clickPage(){
|
|
|
|
- this.roleId="";
|
|
|
|
- this.pageType=1;
|
|
|
|
|
|
+ goPage(type){
|
|
|
|
+ if(this.pageType != type){
|
|
|
|
+ if(type == 1){
|
|
|
|
+ this.$set(this,'pageType',type);
|
|
|
|
+ }else if(type == 3){
|
|
|
|
+ this.$set(this,'pageType',1);
|
|
|
|
+ this.resetQuery();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
},
|
|
},
|
|
/** 查询角色列表 */
|
|
/** 查询角色列表 */
|
|
getList() {
|
|
getList() {
|
|
@@ -331,98 +152,6 @@ export default {
|
|
}
|
|
}
|
|
);
|
|
);
|
|
},
|
|
},
|
|
- /** 查询菜单树结构 */
|
|
|
|
- getMenuTreeselect() {
|
|
|
|
- menuTreeselect().then(response => {
|
|
|
|
- this.menuOptions = response.data;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- /** 查询部门树结构 */
|
|
|
|
- getDeptTreeselect() {
|
|
|
|
- deptTreeselect().then(response => {
|
|
|
|
- this.deptOptions = response.data;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- // 所有菜单节点数据
|
|
|
|
- getMenuAllCheckedKeys() {
|
|
|
|
- // 目前被选中的菜单节点
|
|
|
|
- let checkedKeys = this.$refs.menu.getCheckedKeys();
|
|
|
|
- // 半选中的菜单节点
|
|
|
|
- let halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys();
|
|
|
|
- checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
|
|
|
- return checkedKeys;
|
|
|
|
- },
|
|
|
|
- // 所有部门节点数据
|
|
|
|
- getDeptAllCheckedKeys() {
|
|
|
|
- // 目前被选中的部门节点
|
|
|
|
- let checkedKeys = this.$refs.dept.getCheckedKeys();
|
|
|
|
- // 半选中的部门节点
|
|
|
|
- let halfCheckedKeys = this.$refs.dept.getHalfCheckedKeys();
|
|
|
|
- checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
|
|
|
- return checkedKeys;
|
|
|
|
- },
|
|
|
|
- /** 根据角色ID查询菜单树结构 */
|
|
|
|
- getRoleMenuTreeselect(roleId) {
|
|
|
|
- return roleMenuTreeselect(roleId).then(response => {
|
|
|
|
- this.menuOptions = response.menus;
|
|
|
|
- return response;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- /** 根据角色ID查询部门树结构 */
|
|
|
|
- getRoleDeptTreeselect(roleId) {
|
|
|
|
- return roleDeptTreeselect(roleId).then(response => {
|
|
|
|
- this.deptOptions = response.depts;
|
|
|
|
- return response;
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- // 角色状态修改
|
|
|
|
- handleStatusChange(row) {
|
|
|
|
- let text = row.status === "0" ? "启用" : "停用";
|
|
|
|
- this.$confirm('确认要"' + text + '""' + row.roleName + '"角色吗?', "警告", {
|
|
|
|
- confirmButtonText: "确定",
|
|
|
|
- cancelButtonText: "取消",
|
|
|
|
- type: "warning"
|
|
|
|
- }).then(function() {
|
|
|
|
- return changeRoleStatus(row.roleId, row.status);
|
|
|
|
- }).then(() => {
|
|
|
|
- this.msgSuccess(text + "成功");
|
|
|
|
- }).catch(function() {
|
|
|
|
- row.status = row.status === "0" ? "1" : "0";
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- // 取消按钮
|
|
|
|
- cancel() {
|
|
|
|
- this.open = false;
|
|
|
|
- this.reset();
|
|
|
|
- },
|
|
|
|
- // 取消按钮(数据权限)
|
|
|
|
- cancelDataScope() {
|
|
|
|
- this.openDataScope = false;
|
|
|
|
- this.reset();
|
|
|
|
- },
|
|
|
|
- // 表单重置
|
|
|
|
- reset() {
|
|
|
|
- if (this.$refs.menu != undefined) {
|
|
|
|
- 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.resetForm("form");
|
|
|
|
- },
|
|
|
|
/** 搜索按钮操作 */
|
|
/** 搜索按钮操作 */
|
|
handleQuery() {
|
|
handleQuery() {
|
|
this.queryParams.pageNum = 1;
|
|
this.queryParams.pageNum = 1;
|
|
@@ -430,175 +159,69 @@ export default {
|
|
},
|
|
},
|
|
/** 重置按钮操作 */
|
|
/** 重置按钮操作 */
|
|
resetQuery() {
|
|
resetQuery() {
|
|
- this.dateRange = [];
|
|
|
|
- this.resetForm("queryForm");
|
|
|
|
- this.handleQuery();
|
|
|
|
- },
|
|
|
|
- // 多选框选中数据
|
|
|
|
- handleSelectionChange(selection) {
|
|
|
|
- this.ids = selection.map(item => item.roleId)
|
|
|
|
- this.single = selection.length!=1
|
|
|
|
- this.multiple = !selection.length
|
|
|
|
- },
|
|
|
|
- // 更多操作触发
|
|
|
|
- handleCommand(command, row) {
|
|
|
|
- switch (command) {
|
|
|
|
- case "handleDataScope":
|
|
|
|
- this.handleDataScope(row);
|
|
|
|
- break;
|
|
|
|
- case "handleAuthUser":
|
|
|
|
- this.handleAuthUser(row);
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 树权限(展开/折叠)
|
|
|
|
- handleCheckedTreeExpand(value, type) {
|
|
|
|
- if (type == 'menu') {
|
|
|
|
- let treeList = this.menuOptions;
|
|
|
|
- for (let i = 0; i < treeList.length; i++) {
|
|
|
|
- this.$refs.menu.store.nodesMap[treeList[i].id].expanded = value;
|
|
|
|
- }
|
|
|
|
- } else if (type == 'dept') {
|
|
|
|
- let treeList = this.deptOptions;
|
|
|
|
- for (let i = 0; i < treeList.length; i++) {
|
|
|
|
- this.$refs.dept.store.nodesMap[treeList[i].id].expanded = value;
|
|
|
|
|
|
+ this.$set(this,"form",
|
|
|
|
+ {
|
|
|
|
+ pageNum: 1,
|
|
|
|
+ pageSize:20,
|
|
|
|
+ roleName: null,
|
|
|
|
+ status: null
|
|
}
|
|
}
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 树权限(全选/全不选)
|
|
|
|
- handleCheckedTreeNodeAll(value, type) {
|
|
|
|
- if (type == 'menu') {
|
|
|
|
- this.$refs.menu.setCheckedNodes(value ? this.menuOptions: []);
|
|
|
|
- } else if (type == 'dept') {
|
|
|
|
- this.$refs.dept.setCheckedNodes(value ? this.deptOptions: []);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- // 树权限(父子联动)
|
|
|
|
- handleCheckedTreeConnect(value, type) {
|
|
|
|
- if (type == 'menu') {
|
|
|
|
- this.form.menuCheckStrictly = value ? true: false;
|
|
|
|
- } else if (type == 'dept') {
|
|
|
|
- this.form.deptCheckStrictly = value ? true: false;
|
|
|
|
- }
|
|
|
|
|
|
+ );
|
|
|
|
+ this.handleQuery();
|
|
},
|
|
},
|
|
/** 新增按钮操作 */
|
|
/** 新增按钮操作 */
|
|
handleAdd() {
|
|
handleAdd() {
|
|
- this.reset();
|
|
|
|
- this.getMenuTreeselect();
|
|
|
|
- this.pageType = 2;
|
|
|
|
- this.title = "编辑角色";
|
|
|
|
|
|
+ let obj = {
|
|
|
|
+ type:1,
|
|
|
|
+ title:"新增角色",
|
|
|
|
+ };
|
|
|
|
+ this.$set(this,'propsData',obj);
|
|
|
|
+ this.$set(this,'pageType',2);
|
|
},
|
|
},
|
|
/** 修改按钮操作 */
|
|
/** 修改按钮操作 */
|
|
handleUpdate(row) {
|
|
handleUpdate(row) {
|
|
-
|
|
|
|
- this.reset();
|
|
|
|
- const roleId = row.roleId || this.ids
|
|
|
|
- const roleMenu = this.getRoleMenuTreeselect(roleId);
|
|
|
|
- getRole(roleId).then(response => {
|
|
|
|
- //this.form = response.data;
|
|
|
|
- console.log(response.data)
|
|
|
|
- this.titleName = '角色编辑';
|
|
|
|
- this.propsData = response;
|
|
|
|
- this.editType = false;
|
|
|
|
- this.pageType = 2;
|
|
|
|
- //this.open = true;
|
|
|
|
- // this.$nextTick(() => {
|
|
|
|
- // roleMenu.then(res => {
|
|
|
|
- // let checkedKeys = res.checkedKeys
|
|
|
|
- // console.log(checkedKeys)
|
|
|
|
- // checkedKeys.forEach((v) => {
|
|
|
|
- // this.$nextTick(()=>{
|
|
|
|
- // this.$refs.menu.setChecked(v, true ,false);
|
|
|
|
- // })
|
|
|
|
- // })
|
|
|
|
- // });
|
|
|
|
- // });
|
|
|
|
- //this.title = "修改角色";
|
|
|
|
- });
|
|
|
|
- },
|
|
|
|
- /** 选择角色权限范围触发 */
|
|
|
|
- dataScopeSelectChange(value) {
|
|
|
|
- if(value !== '2') {
|
|
|
|
- this.$refs.dept.setCheckedKeys([]);
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
- /** 分配数据权限操作 */
|
|
|
|
- handleDataScope(row) {
|
|
|
|
- this.reset();
|
|
|
|
- const roleDeptTreeselect = this.getRoleDeptTreeselect(row.roleId);
|
|
|
|
getRole(row.roleId).then(response => {
|
|
getRole(row.roleId).then(response => {
|
|
- this.form = response.data;
|
|
|
|
- this.openDataScope = true;
|
|
|
|
- this.$nextTick(() => {
|
|
|
|
- roleDeptTreeselect.then(res => {
|
|
|
|
- this.$refs.dept.setCheckedKeys(res.checkedKeys);
|
|
|
|
- });
|
|
|
|
- });
|
|
|
|
- this.title = "分配数据权限";
|
|
|
|
|
|
+ let obj = {
|
|
|
|
+ type:2,
|
|
|
|
+ roleId:response.role.roleId,
|
|
|
|
+ name:response.role.roleName,
|
|
|
|
+ key:response.role.roleKey,
|
|
|
|
+ dataScope:response.role.dataScope,
|
|
|
|
+ viewDeptIds:response.role.viewDeptIds,
|
|
|
|
+ list:response.checkedKeys,
|
|
|
|
+ title:"编辑角色",
|
|
|
|
+ };
|
|
|
|
+ this.$set(this,'propsData',obj);
|
|
|
|
+ this.$set(this,'pageType',2);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- /** 分配用户操作 */
|
|
|
|
- handleAuthUser: function(row) {
|
|
|
|
- this.roleId=row.roleId;
|
|
|
|
- this.pageType=2;
|
|
|
|
- // const roleId = row.roleId;
|
|
|
|
- // this.$router.push("/system/role-auth/user/" + roleId);
|
|
|
|
- },
|
|
|
|
- /** 提交按钮 */
|
|
|
|
- submitForm: function() {
|
|
|
|
- this.$refs["form"].validate(valid => {
|
|
|
|
- if (valid) {
|
|
|
|
- if (this.form.roleId != undefined) {
|
|
|
|
- this.form.menuIds = this.getMenuAllCheckedKeys();
|
|
|
|
- updateRole(this.form).then(response => {
|
|
|
|
- this.msgSuccess("修改成功");
|
|
|
|
- this.open = false;
|
|
|
|
- this.getList();
|
|
|
|
- });
|
|
|
|
- } else {
|
|
|
|
- this.form.menuIds = this.getMenuAllCheckedKeys();
|
|
|
|
- addRole(this.form).then(response => {
|
|
|
|
- this.msgSuccess("新增成功");
|
|
|
|
- this.open = false;
|
|
|
|
- this.getList();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ /** 复制按钮 */
|
|
|
|
+ copyButton(row){
|
|
|
|
+ getRole(row.roleId).then(response => {
|
|
|
|
+ let obj = {
|
|
|
|
+ type:3,
|
|
|
|
+ dataScope:response.role.dataScope,
|
|
|
|
+ viewDeptIds:response.role.viewDeptIds,
|
|
|
|
+ list:response.checkedKeys,
|
|
|
|
+ title:"复制角色",
|
|
|
|
+ };
|
|
|
|
+ this.$set(this,'propsData',obj);
|
|
|
|
+ this.$set(this,'pageType',2);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- /** 提交按钮(数据权限) */
|
|
|
|
- submitDataScope: function() {
|
|
|
|
- if (this.form.roleId != undefined) {
|
|
|
|
- this.form.deptIds = this.getDeptAllCheckedKeys();
|
|
|
|
- dataScope(this.form).then(response => {
|
|
|
|
- this.msgSuccess("修改成功");
|
|
|
|
- this.openDataScope = false;
|
|
|
|
- this.getList();
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
- },
|
|
|
|
/** 删除按钮操作 */
|
|
/** 删除按钮操作 */
|
|
handleDelete(row) {
|
|
handleDelete(row) {
|
|
- const roleIds = row.roleId || this.ids;
|
|
|
|
this.$confirm('是否确认删除角色?', "警告", {
|
|
this.$confirm('是否确认删除角色?', "警告", {
|
|
confirmButtonText: "确定",
|
|
confirmButtonText: "确定",
|
|
cancelButtonText: "取消",
|
|
cancelButtonText: "取消",
|
|
type: "warning"
|
|
type: "warning"
|
|
}).then(function() {
|
|
}).then(function() {
|
|
- return delRole(roleIds);
|
|
|
|
|
|
+ return delRole(row.roleId);
|
|
}).then(() => {
|
|
}).then(() => {
|
|
this.getList();
|
|
this.getList();
|
|
this.msgSuccess("删除成功");
|
|
this.msgSuccess("删除成功");
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
},
|
|
},
|
|
- /** 导出按钮操作 */
|
|
|
|
- handleExport() {
|
|
|
|
- this.download('system/role/export', {
|
|
|
|
- ...this.queryParams
|
|
|
|
- }, `role_${new Date().getTime()}.xlsx`)
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|