角色管理修改

master
wanglei 7 months ago
parent af2bd0ed89
commit 0e786132f7

@ -1,160 +1,178 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<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
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="权限字符" prop="roleKey">
<el-input
v-model="queryParams.roleKey"
placeholder="请输入权限字符"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select
v-model="queryParams.status"
placeholder="角色状态"
clearable
style="width: 240px"
>
<el-option
v-for="dict in dict.type.sys_normal_disable"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8"> <div class="company" v-if="!$store.state.user.tenantId">
<el-col :span="1.5"> <el-input
<el-button style="width: 200px"
type="primary" placeholder="公司名称"
plain prefix-icon="el-icon-search"
icon="el-icon-plus" v-model="gsInfo.tenantName"
size="mini" @keyup.enter.native="getGsInfoList">
@click="handleAdd" </el-input>
v-hasPermi="['system:role:add']" <div class="cp-content" style="width: 200px">
>新增</el-button> <div :class="gsInfo.active_id===item.id?'cp-item active':'cp-item'" @click="changCompany(item.id)" v-for="item in gsInfo.list">{{ item.name }}</div>
</el-col> </div>
<el-col :span="1.5"> </div>
<el-button
type="success" <div :class="$store.state.user.tenantId?'content-all':'content'">
plain
icon="el-icon-edit" <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch">
size="mini" <el-form-item label="角色名称" prop="roleName">
:disabled="single" <el-input
@click="handleUpdate" v-model="queryParams.roleName"
v-hasPermi="['system:role:edit']" placeholder="请输入角色名称"
>修改</el-button> clearable
</el-col> style="width: 240px"
<el-col :span="1.5"> @keyup.enter.native="handleQuery"
<el-button />
type="danger" </el-form-item>
plain <el-form-item label="权限字符" prop="roleKey">
icon="el-icon-delete" <el-input
size="mini" v-model="queryParams.roleKey"
:disabled="multiple" placeholder="请输入权限字符"
@click="handleDelete" clearable
v-hasPermi="['system:role:remove']" style="width: 240px"
>删除</el-button> @keyup.enter.native="handleQuery"
</el-col> />
<el-col :span="1.5"> </el-form-item>
<el-button <el-form-item label="状态" prop="status">
type="warning" <el-select
plain v-model="queryParams.status"
icon="el-icon-download" placeholder="角色状态"
size="mini" clearable
@click="handleExport" style="width: 240px"
v-hasPermi="['system:role:export']" >
>导出</el-button> <el-option
</el-col> v-for="dict in dict.type.sys_normal_disable"
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> :key="dict.value"
</el-row> :label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item label="创建时间">
<el-date-picker
v-model="dateRange"
style="width: 240px"
value-format="yyyy-MM-dd HH:mm:ss"
type="daterange"
range-separator="-"
start-placeholder="开始日期"
end-placeholder="结束日期"
:default-time="['00:00:00', '23:59:59']"
></el-date-picker>
</el-form-item>
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery"></el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery"></el-button>
</el-form-item>
</el-form>
<el-table v-loading="loading" :data="roleList" @selection-change="handleSelectionChange"> <el-row :gutter="10" class="mb8">
<el-table-column type="selection" width="55" align="center" /> <el-col :span="1.5">
<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="状态" align="center" width="100">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button <el-button
type="primary"
plain
icon="el-icon-plus"
size="mini" size="mini"
type="text" @click="handleAdd"
v-hasPermi="['system:role:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit" icon="el-icon-edit"
@click="handleUpdate(scope.row)" size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['system:role:edit']" v-hasPermi="['system:role:edit']"
>修改</el-button> >修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button <el-button
size="mini" type="danger"
type="text" plain
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDelete(scope.row)" size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['system:role:remove']" v-hasPermi="['system:role:remove']"
>删除</el-button> >删除</el-button>
<el-dropdown size="mini" @command="(command) => handleCommand(command, scope.row)" v-hasPermi="['system:role:edit']"> </el-col>
<el-button size="mini" type="text" icon="el-icon-d-arrow-right">更多</el-button> <el-col :span="1.5">
<el-dropdown-menu slot="dropdown"> <el-button
<el-dropdown-item command="handleDataScope" icon="el-icon-circle-check" type="warning"
v-hasPermi="['system:role:edit']">数据权限</el-dropdown-item> plain
<el-dropdown-item command="handleAuthUser" icon="el-icon-user" icon="el-icon-download"
v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item> size="mini"
</el-dropdown-menu> @click="handleExport"
</el-dropdown> v-hasPermi="['system:role:export']"
</template> >导出</el-button>
</el-table-column> </el-col>
</el-table> <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 label="状态" align="center" width="100">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
active-value="0"
inactive-value="1"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope" v-if="scope.row.roleId !== 1">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['system:role:edit']"
>修改</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 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>
<el-dropdown-item command="handleAuthUser" icon="el-icon-user"
v-hasPermi="['system:role:edit']">分配用户</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<pagination </div>
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改角色配置对话框 --> <!-- 添加或修改角色配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
@ -249,18 +267,26 @@
<el-button @click="cancelDataScope"> </el-button> <el-button @click="cancelDataScope"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listRole, getRole, delRole, addRole, updateRole, dataScope, changeRoleStatus, deptTreeSelect } 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 menuTreeselect, roleMenuTreeselect } from "@/api/system/menu";
import { listTenant } from "@/api/pay/tenant";
export default { export default {
name: "Role", name: "Role",
dicts: ['sys_normal_disable'], dicts: ['sys_normal_disable'],
data() { data() {
return { return {
//
gsInfo:{
tenantName:'',
active_id:this.$store.state.user.tenantId,
list:[]
},
// //
loading: true, loading: true,
// //
@ -343,12 +369,37 @@ export default {
}; };
}, },
created() { created() {
this.getList(); if (!this.$store.state.user.tenantId) {
this.getGsInfoList()
}else {
this.gsInfo.active_id = this.$store.state.user.tenantId
this.getList();
}
}, },
methods: { methods: {
//
getGsInfoList(){
listTenant({ name: this.gsInfo.tenantName }).then(response => {
if(response.rows.length>0){
this.gsInfo.list = response.rows;
this.gsInfo.active_id = this.gsInfo.list[0].id
this.getList()
}else{
this.$alert(`没有查到相关公司,暂无数据!`, `提示`, {
type: 'warning'
});
}
});
},
//
changCompany(id){
this.gsInfo.active_id = id
this.getList()
},
/** 查询角色列表 */ /** 查询角色列表 */
getList() { getList() {
this.loading = true; this.loading = true;
this.queryParams.tenantId = this.gsInfo.active_id;
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => { listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.roleList = response.rows; this.roleList = response.rows;
this.total = response.total; this.total = response.total;
@ -556,6 +607,7 @@ export default {
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.tenantId = this.gsInfo.active_id;
if (this.form.roleId != undefined) { if (this.form.roleId != undefined) {
this.form.menuIds = this.getMenuAllCheckedKeys(); this.form.menuIds = this.getMenuAllCheckedKeys();
updateRole(this.form).then(response => { updateRole(this.form).then(response => {
@ -605,3 +657,42 @@ export default {
}; };
</script> </script>
<style scoped lang="scss">
.app-container {
display: flex;
.company {
border-radius: 5px;
width: 230px;
height: calc(100vh - 115px);
overflow-y: auto;
.cp-content {
margin-top: 20px;
.cp-item {
cursor: pointer;
padding: 6px 10px 6px 5px;
color: #424242;
font-size: 14px;
&:hover {
background: #f6f6f6;
}
}
.active{
background: #edf6ff;
}
}
}
.content{
padding-left: 15px;
width: calc(100% - 250px);
.el-button--medium {
padding: 2px 0px;
}
}
.content-all{
width: 100%;
.el-button--medium {
padding: 2px 0px;
}
}
}
</style>

Loading…
Cancel
Save