|
|
@@ -2,48 +2,22 @@
|
|
|
<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-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-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 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"
|
|
|
- type="daterange"
|
|
|
- range-separator="-"
|
|
|
- start-placeholder="开始日期"
|
|
|
- end-placeholder="结束日期"
|
|
|
- ></el-date-picker>
|
|
|
+ <el-date-picker v-model="dateRange" style="width: 240px" value-format="yyyy-MM-dd" type="daterange"
|
|
|
+ range-separator="-" start-placeholder="开始日期" end-placeholder="结束日期"></el-date-picker>
|
|
|
</el-form-item>
|
|
|
<el-form-item>
|
|
|
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
|
|
|
@@ -53,47 +27,27 @@
|
|
|
|
|
|
<el-row :gutter="10" class="mb8">
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button
|
|
|
- type="primary"
|
|
|
- plain
|
|
|
- icon="el-icon-plus"
|
|
|
- size="mini"
|
|
|
- @click="handleAdd"
|
|
|
- v-hasPermi="['system:role:add']"
|
|
|
- >新增</el-button>
|
|
|
+ <el-button type="primary" plain icon="el-icon-plus" size="mini" @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"
|
|
|
- size="mini"
|
|
|
- :disabled="single"
|
|
|
- @click="handleUpdate"
|
|
|
- v-hasPermi="['system:role:edit']"
|
|
|
- >修改</el-button>
|
|
|
+ <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
|
|
|
+ v-hasPermi="['system:role:edit']">修改</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="1.5">
|
|
|
- <el-button
|
|
|
- type="danger"
|
|
|
- plain
|
|
|
- icon="el-icon-delete"
|
|
|
- size="mini"
|
|
|
- :disabled="multiple"
|
|
|
- @click="handleDelete"
|
|
|
- v-hasPermi="['system:role:remove']"
|
|
|
- >删除</el-button>
|
|
|
+ <el-button type="danger" plain icon="el-icon-delete" size="mini" :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-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-col>-->
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
|
|
|
@@ -105,36 +59,24 @@
|
|
|
<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>
|
|
|
+ <el-switch v-model="scope.row.status" active-text inactive-text 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 label="创建时间" align="center" prop="createTime" width="150">
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
|
|
<template slot-scope="scope" v-if="scope.row.id !== 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-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"
|
|
|
@@ -147,13 +89,8 @@
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
|
|
|
- <pagination
|
|
|
- v-show="total>0"
|
|
|
- :total="total"
|
|
|
- :page.sync="queryParams.pageNum"
|
|
|
- :limit.sync="queryParams.pageSize"
|
|
|
- @pagination="getList"
|
|
|
- />
|
|
|
+ <pagination 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>
|
|
|
@@ -175,28 +112,19 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="状态">
|
|
|
<el-radio-group v-model="form.status">
|
|
|
- <el-radio
|
|
|
- v-for="dict in dict.type.sys_normal_disable"
|
|
|
- :key="dict.value"
|
|
|
- :label="dict.value">
|
|
|
- {{dict.label}}
|
|
|
+ <el-radio v-for="dict in dict.type.sys_normal_disable" :key="dict.value" :label="dict.value">
|
|
|
+ {{ 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="form.menuCheckStrictly"
|
|
|
+ @change="handleCheckedTreeConnect($event, 'menu')">自动选中下级</el-checkbox>
|
|
|
<div style="max-height: 300px;overflow: auto;">
|
|
|
- <el-tree
|
|
|
- class="tree-border"
|
|
|
- :data="menuOptions"
|
|
|
- show-checkbox
|
|
|
- ref="menu"
|
|
|
- node-key="id"
|
|
|
- :check-strictly="!form.menuCheckStrictly"
|
|
|
- empty-text="加载中,请稍候"
|
|
|
- ></el-tree>
|
|
|
+ <el-tree class="tree-border" :data="menuOptions" show-checkbox ref="menu" node-key="id"
|
|
|
+ :check-strictly="!form.menuCheckStrictly" empty-text="加载中,请稍候"></el-tree>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="备注">
|
|
|
@@ -220,30 +148,18 @@
|
|
|
</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-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-checkbox v-model="form.deptCheckStrictly"
|
|
|
+ @change="handleCheckedTreeConnect($event, 'dept')">父子联动</el-checkbox>
|
|
|
<div class="tree-container" style="max-height: 300px;">
|
|
|
- <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-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>
|
|
|
</div>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
@@ -268,6 +184,7 @@ export default {
|
|
|
loading: true,
|
|
|
// 选中数组
|
|
|
ids: [],
|
|
|
+ roleNames: [],
|
|
|
// 非单个禁用
|
|
|
single: true,
|
|
|
// 非多个禁用
|
|
|
@@ -353,10 +270,10 @@ export default {
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
listRole(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
|
|
- this.roleList = response.rows;
|
|
|
- this.total = response.total;
|
|
|
- this.loading = false;
|
|
|
- }
|
|
|
+ this.roleList = response.rows;
|
|
|
+ this.total = response.total;
|
|
|
+ this.loading = false;
|
|
|
+ }
|
|
|
);
|
|
|
},
|
|
|
/** 查询菜单树结构 */
|
|
|
@@ -402,15 +319,15 @@ 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 () {
|
|
|
const data = {
|
|
|
- id:row.id,
|
|
|
- status:row.status
|
|
|
+ id: row.id,
|
|
|
+ status: row.status
|
|
|
}
|
|
|
return changeRoleStatus(data);
|
|
|
}).then(() => {
|
|
|
this.$modal.msgSuccess(text + "成功");
|
|
|
- }).catch(function() {
|
|
|
+ }).catch(function () {
|
|
|
row.status = row.status === "0" ? "1" : "0";
|
|
|
});
|
|
|
},
|
|
|
@@ -430,21 +347,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");
|
|
|
},
|
|
|
/** 搜索按钮操作 */
|
|
|
@@ -460,8 +377,9 @@ export default {
|
|
|
},
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
|
- this.ids = selection.map(item => item.roleId)
|
|
|
- this.single = selection.length!=1
|
|
|
+ this.ids = selection.map(item => item.id)
|
|
|
+ this.names = selection.map(item => item.roleName)
|
|
|
+ this.single = selection.length != 1
|
|
|
this.multiple = !selection.length
|
|
|
},
|
|
|
// 更多操作触发
|
|
|
@@ -494,17 +412,17 @@ 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;
|
|
|
}
|
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
|
@@ -526,9 +444,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);
|
|
|
+ })
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
@@ -537,18 +455,18 @@ export default {
|
|
|
},
|
|
|
/** 选择角色权限范围触发 */
|
|
|
dataScopeSelectChange(value) {
|
|
|
- if(value !== '2') {
|
|
|
+ if (value !== '2') {
|
|
|
this.$refs.dept.setCheckedKeys([]);
|
|
|
}
|
|
|
},
|
|
|
/** 分配数据权限操作 */
|
|
|
handleDataScope(row) {
|
|
|
this.reset();
|
|
|
- console.log(row,'row')
|
|
|
+ console.log(row, 'row')
|
|
|
deptTreeSelect(row.id).then(response => {
|
|
|
this.deptOptions = response.depts;
|
|
|
const deptTreeSelect = response.depts;
|
|
|
- console.log(deptTreeSelect,'deptTreeSelect')
|
|
|
+ console.log(deptTreeSelect, 'deptTreeSelect')
|
|
|
getRole(row.id).then(response => {
|
|
|
this.form = response.data;
|
|
|
this.openDataScope = true;
|
|
|
@@ -562,13 +480,13 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
/** 分配用户操作 */
|
|
|
- handleAuthUser: function(row) {
|
|
|
- console.log(row,'row')
|
|
|
+ handleAuthUser: function (row) {
|
|
|
+ console.log(row, 'row')
|
|
|
const roleId = row.id;
|
|
|
this.$router.push("/system/role-auth/user/" + roleId);
|
|
|
},
|
|
|
/** 提交按钮 */
|
|
|
- submitForm: function() {
|
|
|
+ submitForm: function () {
|
|
|
this.$refs["form"].validate(valid => {
|
|
|
if (valid) {
|
|
|
if (this.form.id != undefined) {
|
|
|
@@ -590,7 +508,7 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
/** 提交按钮(数据权限) */
|
|
|
- submitDataScope: function() {
|
|
|
+ submitDataScope: function () {
|
|
|
if (this.form.roleId != undefined) {
|
|
|
this.form.deptIds = this.getDeptAllCheckedKeys();
|
|
|
dataScope(this.form).then(response => {
|
|
|
@@ -598,8 +516,8 @@ export default {
|
|
|
this.openDataScope = false;
|
|
|
this.getList();
|
|
|
});
|
|
|
- }else{
|
|
|
- this.form.deptIds = this.getDeptAllCheckedKeys();
|
|
|
+ } else {
|
|
|
+ this.form.deptIds = this.getDeptAllCheckedKeys();
|
|
|
dataScope(this.form).then(response => {
|
|
|
this.$modal.msgSuccess("修改成功");
|
|
|
this.openDataScope = false;
|
|
|
@@ -611,12 +529,13 @@ export default {
|
|
|
/** 删除按钮操作 */
|
|
|
handleDelete(row) {
|
|
|
const roleIds = row.id || this.ids;
|
|
|
- this.$modal.confirm('是否确认删除角色编号为"' + roleIds + '"的数据项?').then(function() {
|
|
|
+ const roleNames = row.roleName || this.names;
|
|
|
+ this.$modal.confirm('确认要停用"' + roleNames + '"角色吗?').then(function () {
|
|
|
return delRole(roleIds);
|
|
|
}).then(() => {
|
|
|
this.getList();
|
|
|
this.$modal.msgSuccess("删除成功");
|
|
|
- }).catch(() => {});
|
|
|
+ }).catch(() => { });
|
|
|
},
|
|
|
/** 导出按钮操作 */
|
|
|
handleExport() {
|