Commit bbed08f6 by 张晓玮

Merge branch 'v1.7.0' into 'develop'

v1.7.0版本需求已经上线,代码合并到develop

See merge request !14
2 parents f201f3db 138ecae0
This diff could not be displayed because it is too large.
<template> <template>
<div class="system-container"> <div class="system-container">
<div class="container"> <div class="container">
<search-form <search-form class="searchTop border-shadow" :formModel="searchForm" :formList="roleFormList">
class="searchTop border-shadow"
:formModel="searchForm"
:formList="roleFormList"
>
<span class="inline-b" slot="form-slot"> <span class="inline-b" slot="form-slot">
<el-button <el-button type="primary" :size="btn_size" icon="el-icon-search" :id="tableParams.btnId">搜索</el-button>
type="primary" <el-button type="primary" :size="btn_size" icon="el-icon-refresh" @click="refresh">重置</el-button>
:size="btn_size"
icon="el-icon-search"
:id="tableParams.btnId"
>搜索</el-button
>
<el-button
type="primary"
:size="btn_size"
icon="el-icon-refresh"
@click="refresh"
>重置</el-button
>
</span> </span>
</search-form> </search-form>
<h3> <h3>
角色管理 角色管理
<div class="pull-right"> <div class="pull-right">
<el-button <el-button type="primary" :size="btn_size" icon="el-icon-plus" @click="btnClick('create')">新增</el-button>
type="primary"
:size="btn_size"
icon="el-icon-plus"
@click="btnClick('create')"
>新增</el-button
>
</div> </div>
</h3> </h3>
<basic-table <basic-table ref="roleTable" :tableParams="tableParams" :getListApi="getListApi" :searchForm="searchForm" :hasNum="false">
ref="roleTable"
:tableParams="tableParams"
:getListApi="getListApi"
:searchForm="searchForm"
:hasNum="false"
>
<span slot="status" slot-scope="scope"> <span slot="status" slot-scope="scope">
<span <span class="dot" :class="
class="dot"
:class="
scope.scope.enableStatus scope.scope.enableStatus
? USERSTATUS[scope.scope.enableStatus].split(',')[1] ? USERSTATUS[scope.scope.enableStatus].split(',')[1]
: '' : ''
" "></span>
></span>
<span class="statusText">{{ <span class="statusText">{{
scope.scope.enableStatus scope.scope.enableStatus
? USERSTATUS[scope.scope.enableStatus].split(",")[0] ? USERSTATUS[scope.scope.enableStatus].split(",")[0]
...@@ -58,97 +27,42 @@ ...@@ -58,97 +27,42 @@
}}</span> }}</span>
</span> </span>
<span slot="table-button" slot-scope="scope"> <span slot="table-button" slot-scope="scope">
<el-button <el-button v-for="(j, idx) in tableParams.tableOption.btnList" :key="idx" :type="j.type || 'text'" :size="btn_size" @click="btnClick(j.pType, scope.scope)">{{ j.name }}</el-button>
v-for="(j, idx) in tableParams.tableOption.btnList"
:key="idx"
:type="j.type || 'text'"
:size="btn_size"
@click="btnClick(j.pType, scope.scope)"
>{{ j.name }}</el-button
>
</span> </span>
</basic-table> </basic-table>
<basic-dialog <basic-dialog class="role" :title="roleDialogTitle" :isVisible="roleVisible" @confirmDialog="handleConfirm" @closeDialog="handleClose">
class="role"
:title="roleDialogTitle"
:isVisible="roleVisible"
@confirmDialog="handleConfirm"
@closeDialog="handleClose"
>
<slot> <slot>
<rule-form <rule-form :ruleForm="roleForm" :rules="roleRules" :ruleData="roleData" :labelWidth="'140px'" ref="roleForm">
:ruleForm="roleForm"
:rules="roleRules"
:ruleData="roleData"
:labelWidth="'120px'"
ref="roleForm"
>
<div slot="visible-type"> <div slot="visible-type">
<el-radio-group <el-radio-group @change="radioChange(roleForm.roleVisibility)" v-model="roleForm.roleVisibility">
@change="radioChange(roleForm.roleVisibility)" <el-radio v-for="(child, childIndex) in visibilityList" :key="childIndex" :label="child.code">{{ child.value }}</el-radio>
v-model="roleForm.roleVisibility"
>
<el-radio
v-for="(child, childIndex) in visibilityList"
:key="childIndex"
:label="child.code"
>{{ child.value }}</el-radio
>
</el-radio-group> </el-radio-group>
<el-select <el-select v-if="roleForm.roleVisibility == 2" v-model="roleForm.roleTenants" placeholder="请选择" multiple filterable>
v-if="roleForm.roleVisibility == 2" <el-option v-for="i in tenantList" :key="i.tenantId" :label="i.departmentName" :value="i.tenantId">
v-model="roleForm.roleTenants"
placeholder="请选择"
multiple
filterable
>
<el-option
v-for="i in tenantList"
:key="i.tenantId"
:label="i.departmentName"
:value="i.tenantId"
>
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<div slot="service-visibility" class="settle_box">
<el-select v-model="roleForm.bizPermissionType">
<el-option v-for="(item,index) in permissionTypeList" :key="index" :label="item.label" :value="item.value"></el-option>
<!-- <el-option label="结清数据2" value="2"></el-option> -->
</el-select>
<div class="el_switch_box">
<el-switch v-model="dataVisibilityList[roleForm.bizPermissionType]" :active-value="1" :inactive-value="2">
</el-switch>
<span class="tips">{{dataVisibilityList[roleForm.bizPermissionType] == 1?'可见':'不可见'}}</span>
</div>
</div>
<div slot="data-auth"> <div slot="data-auth">
<el-radio-group <el-radio-group @change="radioChange(roleForm.roleVisibility)" v-model="roleForm.rolePermissionType">
@change="radioChange(roleForm.roleVisibility)" <el-radio v-for="(child, childIndex) in $Constants.ROLEAUTH_LIST" :key="childIndex" :label="child.value">{{ child.label }}</el-radio>
v-model="roleForm.rolePermissionType"
>
<el-radio
v-for="(child, childIndex) in $Constants.ROLEAUTH_LIST"
:key="childIndex"
:label="child.value"
>{{ child.label }}</el-radio
>
</el-radio-group> </el-radio-group>
<el-select <el-select v-if="roleForm.rolePermissionType == 6" v-model="roleForm.permTenants" placeholder="请选择" multiple filterable>
v-if="roleForm.rolePermissionType == 6" <el-option v-for="i in permissionList" :key="i.tenantId" :label="i.tenantName" :value="i.tenantId">
v-model="roleForm.permTenants"
placeholder="请选择"
multiple
filterable
>
<el-option
v-for="i in permissionList"
:key="i.tenantId"
:label="i.tenantName"
:value="i.tenantId"
>
</el-option> </el-option>
</el-select> </el-select>
</div> </div>
<el-tree <el-tree slot="menu-list" :data="treedata" show-checkbox default-expand-all node-key="id" ref="tree" :check-strictly="true" highlight-current>
slot="menu-list"
:data="treedata"
show-checkbox
default-expand-all
node-key="id"
ref="tree"
:check-strictly="true"
highlight-current
>
</el-tree> </el-tree>
</rule-form> </rule-form>
</slot> </slot>
...@@ -167,7 +81,7 @@ import { ...@@ -167,7 +81,7 @@ import {
deleteRole, deleteRole,
getMenuTree, getMenuTree,
getVisibility, getVisibility,
getPermission getPermission,
} from "services/role"; } from "services/role";
export default { export default {
data() { data() {
...@@ -200,8 +114,8 @@ export default { ...@@ -200,8 +114,8 @@ export default {
type: "input", type: "input",
inputType: "text", inputType: "text",
prop: "roleName", prop: "roleName",
placeholder: "请输入角色名称" placeholder: "请输入角色名称",
} },
], ],
tableParams: { tableParams: {
// mutiSelectName: 'role', // mutiSelectName: 'role',
...@@ -211,35 +125,35 @@ export default { ...@@ -211,35 +125,35 @@ export default {
tableColumns: [ tableColumns: [
{ {
label: "角色名称", label: "角色名称",
prop: "roleName" prop: "roleName",
}, },
{ {
label: "备注", label: "备注",
prop: "remark" prop: "remark",
}, },
{ {
label: "状态", label: "状态",
prop: "enableStatus", prop: "enableStatus",
addHtml: "status" addHtml: "status",
}, },
{ {
label: "创建时间", label: "创建时间",
prop: "createdDate" prop: "createdDate",
} },
], ],
tableOption: { tableOption: {
width: 300, width: 300,
btnList: [ btnList: [
{ {
name: "编辑", name: "编辑",
pType: "edit" pType: "edit",
}, },
{ {
name: "删除", name: "删除",
pType: "delete" pType: "delete",
} },
] ],
} },
}, },
getListApi: getRoleList, getListApi: getRoleList,
// 弹窗数据 // 弹窗数据
...@@ -247,7 +161,8 @@ export default { ...@@ -247,7 +161,8 @@ export default {
roleVisible: false, roleVisible: false,
roleForm: { roleForm: {
enableStatus: true, enableStatus: true,
menuIdList: [] menuIdList: [],
bizPermissionType: 1,
}, },
roleData: [ roleData: [
{ label: "角色名称:", prop: "roleName", type: "input", maxlength: 50 }, { label: "角色名称:", prop: "roleName", type: "input", maxlength: 50 },
...@@ -257,50 +172,71 @@ export default { ...@@ -257,50 +172,71 @@ export default {
type: "input", type: "input",
inputText: "textarea", inputText: "textarea",
maxlength: 200, maxlength: 200,
showWordLimit: true showWordLimit: true,
}, },
{ label: "状态:", prop: "enableStatus", type: "switch" }, { label: "状态:", prop: "enableStatus", type: "switch" },
{ {
label: "租户可见度:", label: "租户可见度:",
prop: "roleVisibility", prop: "roleVisibility",
type: "customize", type: "customize",
slotName: "visible-type" slotName: "visible-type",
}, },
{ {
label: "数据权限:", label: "数据权限:",
prop: "rolePermissionType", prop: "rolePermissionType",
type: "customize", type: "customize",
slotName: "data-auth" slotName: "data-auth",
// children: this.$Constants.ROLE_AUTH
},
{
label: "业务数据可见度:",
prop: "bizPermissionType",
type: "customize",
slotName: "service-visibility",
// children: this.$Constants.ROLE_AUTH // children: this.$Constants.ROLE_AUTH
}, },
{ {
label: "菜单权限:", label: "菜单权限:",
prop: "menuIdList", prop: "menuIdList",
type: "customize", type: "customize",
slotName: "menu-list" slotName: "menu-list",
} },
], ],
roleRules: { roleRules: {
roleName: [ roleName: [
{ required: true, message: "请输入角色名称", trigger: "blur" }, { required: true, message: "请输入角色名称", trigger: "blur" },
{ validator: this.$Common.checkName, trigger: "blur" }, { validator: this.$Common.checkName, trigger: "blur" },
{ min: 3, max: 50, message: "长度在 3 到 50 个字符", trigger: "blur" } {
min: 3,
max: 50,
message: "长度在 3 到 50 个字符",
trigger: "blur",
},
], ],
enableStatus: [{ required: true }], enableStatus: [{ required: true }],
roleVisibility: [ roleVisibility: [
{ required: true, message: "请选择租户可见度" }, { required: true, message: "请选择租户可见度" },
{ validator: checkRoleVisibility, trigger: "change" } { validator: checkRoleVisibility, trigger: "change" },
], ],
rolePermissionType: [ rolePermissionType: [
{ required: true, message: "请选择数据权限" }, { required: true, message: "请选择数据权限" },
{ validator: checkRolePermissionType, trigger: "change" } { validator: checkRolePermissionType, trigger: "change" },
],
bizPermissionType: [
{
required: true,
message: "请选择业务数据可见度",
trigger: "change",
},
], ],
menuIdList: [{ required: true, validator: checkMenu, trigger: "blur" }] menuIdList: [{ required: true, validator: checkMenu, trigger: "blur" }],
}, },
treedata: [], treedata: [],
tenantList: [], tenantList: [],
visibilityList: [], visibilityList: [],
permissionList: [] permissionList: [],
dataVisibilityList: { 1: 2 },
permissionTypeList: [{ label: "结清数据", value: 1 }],
}; };
}, },
mounted() { mounted() {
...@@ -317,17 +253,32 @@ export default { ...@@ -317,17 +253,32 @@ export default {
// 确定 // 确定
handleConfirm() { handleConfirm() {
this.getCheckedKeys(); this.getCheckedKeys();
this.$refs.roleForm.$children[0].validate(valid => { this.$refs.roleForm.$children[0].validate((valid) => {
if (valid) { if (valid) {
let api = addRole; let api = addRole;
let params = { let params = {
remark: this.roleForm.remark, remark: this.roleForm.remark,
roleName: this.roleForm.roleName, roleName: this.roleForm.roleName,
menuIdList: this.roleForm.menuIdList menuIdList: this.roleForm.menuIdList,
}; };
params.enableStatus = this.roleForm.enableStatus ? 1 : 2; params.enableStatus = this.roleForm.enableStatus ? 1 : 2;
params.roleVisibility = Number(this.roleForm.roleVisibility); params.roleVisibility = Number(this.roleForm.roleVisibility);
params.rolePermissionType = Number(this.roleForm.rolePermissionType); params.rolePermissionType = Number(this.roleForm.rolePermissionType);
// params.bizPermissionType = this.roleForm.bizPermissionType;
// params.bizPermissionVisibility =
// this.roleForm.bizPermissionVisibility;
// 业务数据可见度
let row = this.dataVisibilityList;
let arr = [];
for (let k in row) {
let m = {};
m.type = k;
m.visibility = row[k];
arr.push(m);
}
params.bizDataPermissions = arr;
if (params.roleVisibility == 2) { if (params.roleVisibility == 2) {
params.roleTenants = this.roleForm.roleTenants.toString(); params.roleTenants = this.roleForm.roleTenants.toString();
} }
...@@ -338,18 +289,18 @@ export default { ...@@ -338,18 +289,18 @@ export default {
api = editRole; api = editRole;
params.roleId = this.roleForm.id; params.roleId = this.roleForm.id;
} }
api(params).then(res => { api(params).then((res) => {
if (res.code == "200") { if (res.code == "200") {
this.$message({ this.$message({
type: "success", type: "success",
message: "操作成功!" message: "操作成功!",
}); });
this.handleClose(); this.handleClose();
this.$refs.roleTable.refreshTable(); this.$refs.roleTable.refreshTable();
} else { } else {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message message: res.message,
}); });
} }
}); });
...@@ -372,7 +323,8 @@ export default { ...@@ -372,7 +323,8 @@ export default {
this.roleDialogTitle = "新增角色"; this.roleDialogTitle = "新增角色";
this.roleForm = { this.roleForm = {
enableStatus: true, enableStatus: true,
menuIdList: [] menuIdList: [],
bizPermissionType: 1,
}; };
this.getMenuTree(); this.getMenuTree();
this.getTenantList(); this.getTenantList();
...@@ -394,11 +346,28 @@ export default { ...@@ -394,11 +346,28 @@ export default {
// 编辑触发事件 // 编辑触发事件
editEvent(row) { editEvent(row) {
const that = this; const that = this;
roleInfo({ id: row.id }).then(res => { roleInfo({ id: row.id }).then((res) => {
let obj = res.data || {};
this.roleForm = JSON.parse(JSON.stringify(res.data)); this.roleForm = JSON.parse(JSON.stringify(res.data));
this.roleForm.enableStatus = res.data.enableStatus == 1 ? true : false; this.roleForm.enableStatus = res.data.enableStatus == 1 ? true : false;
this.roleForm.roleVisibility = res.data.roleVisibility; this.roleForm.roleVisibility = res.data.roleVisibility;
this.roleForm.rolePermissionType = res.data.rolePermissionType; this.roleForm.rolePermissionType = res.data.rolePermissionType;
let list = obj.bizDataPermissions || [];
let options = {};
if (list && list.length > 0) {
list.map((k) => {
options[k.type] = k.visibility;
});
this.$set(this.roleForm, "bizPermissionType", Number(list[0].type));
} else {
// 针对历史数据,写个默认数据
options[1] = 2;
this.$set(this.roleForm, "bizPermissionType", 1);
}
this.dataVisibilityList = options;
if (res.data.roleTenants) { if (res.data.roleTenants) {
this.roleForm.roleTenants = res.data.roleTenants this.roleForm.roleTenants = res.data.roleTenants
.split(",") .split(",")
...@@ -422,27 +391,27 @@ export default { ...@@ -422,27 +391,27 @@ export default {
tipTitle: "提示", tipTitle: "提示",
type: "error", type: "error",
callBack: () => { callBack: () => {
deleteRole({ id: id }).then(res => { deleteRole({ id: id }).then((res) => {
if (res.code == "200") { if (res.code == "200") {
this.$message({ this.$message({
type: "success", type: "success",
message: "删除成功!" message: "删除成功!",
}); });
this.$refs.roleTable.refreshTable(); this.$refs.roleTable.refreshTable();
} else { } else {
this.$message({ this.$message({
type: "error", type: "error",
message: res.message message: res.message,
}); });
} }
}); });
} },
}; };
this.$Common.confirmDialog(tipData); this.$Common.confirmDialog(tipData);
}, },
// 获取菜单权限列表 // 获取菜单权限列表
getMenuTree(params) { getMenuTree(params) {
getMenuTree(params).then(res => { getMenuTree(params).then((res) => {
this.treedata = res.data.menuTree; this.treedata = res.data.menuTree;
setTimeout(() => { setTimeout(() => {
this.$refs.tree.setCheckedKeys(res.data.checkedIds); this.$refs.tree.setCheckedKeys(res.data.checkedIds);
...@@ -455,27 +424,27 @@ export default { ...@@ -455,27 +424,27 @@ export default {
}, },
// 获取角色可见度可选项 // 获取角色可见度可选项
getVisibility() { getVisibility() {
getVisibility().then(res => { getVisibility().then((res) => {
console.log(res.data); console.log(res.data);
this.visibilityList = res.data; this.visibilityList = res.data;
}); });
}, },
// 获取数据权限租户列表 // 获取数据权限租户列表
getPermission(params) { getPermission(params) {
getPermission(params).then(res => { getPermission(params).then((res) => {
this.permissionList = res.data; this.permissionList = res.data;
}); });
}, },
// 获取租户列表 // 获取租户列表
getTenantList(params) { getTenantList(params) {
getTenantList(params).then(res => { getTenantList(params).then((res) => {
this.tenantList = res.data; this.tenantList = res.data;
}); });
}, },
radioChange(e) { radioChange(e) {
this.$set(this.roleForm, "roleVisibility", e); this.$set(this.roleForm, "roleVisibility", e);
} },
} },
}; };
</script> </script>
<style lang="scss"> <style lang="scss">
...@@ -483,3 +452,20 @@ export default { ...@@ -483,3 +452,20 @@ export default {
margin-top: 7px; margin-top: 7px;
} }
</style> </style>
<style lang="scss" scoped>
.el_switch_box {
flex-shrink: 0;
display: flex;
align-items: center;
margin-left: 10px;
.tips {
font-size: 12px;
color: #333;
margin-left: 10px;
}
}
.settle_box {
display: flex;
align-items: center;
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!