系统管理

This commit is contained in:
2024-05-29 13:13:46 +08:00
parent 3228987c40
commit 71a428f034
10 changed files with 766 additions and 446 deletions

View File

@@ -1,12 +1,13 @@
<template>
<div class="app-container">
<doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
<!-- <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
<doc-alert title="三方登陆" url="https://doc.iocoder.cn/social-user/" />
<doc-alert
title="Excel 导入导出"
url="https://doc.iocoder.cn/excel-import-and-export/"
/>
/> -->
<!-- 搜索工作栏 -->
<el-row :gutter="20">
<!--部门数据-->
<el-col :span="4" :xs="24">
@@ -35,7 +36,12 @@
</el-col>
<!--用户数据-->
<el-col :span="20" :xs="24">
<el-form
<search-bar
:formConfigs="formConfig"
ref="searchBarForm"
@headBtnClick="buttonClick"
/>
<!-- <el-form
:model="queryParams"
ref="queryForm"
size="small"
@@ -96,9 +102,9 @@
>重置</el-button
>
</el-form-item>
</el-form>
</el-form> -->
<el-row :gutter="10" class="mb8">
<!-- <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
@@ -136,9 +142,27 @@
@queryTable="getList"
:columns="columns"
></right-toolbar>
</el-row>
</el-row> -->
<el-table v-loading="loading" :data="userList">
<!-- 列表 -->
<base-table
:page="queryParams.pageNo"
:limit="queryParams.pageSize"
:table-props="tableProps"
:table-data="userList"
:max-height="tableH"
@emitFun="handleStatusChange"
>
<method-btn
v-if="tableBtn.length"
slot="handleBtn"
:width="220"
label="操作"
:method-list="tableBtn"
@clickBtn="handleClick"
/>
</base-table>
<!-- <el-table v-loading="loading" :data="userList">
<el-table-column
label="用户编号"
align="center"
@@ -262,20 +286,19 @@
</el-dropdown>
</template>
</el-table-column>
</el-table>
</el-table> -->
<pagination
v-show="total > 0"
:total="total"
:page.sync="queryParams.pageNo"
:limit.sync="queryParams.pageSize"
:total="total"
@pagination="getList"
/>
</el-col>
</el-row>
<!-- 添加或修改参数配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
<base-dialog :dialogTitle="title" :dialogVisible="open" width="50%">
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row>
<el-col :span="12">
@@ -344,7 +367,11 @@
<el-row>
<el-col :span="12">
<el-form-item label="用户性别">
<el-select v-model="form.sex" placeholder="请选择">
<el-select
v-model="form.sex"
placeholder="请选择"
style="width: 100%"
>
<el-option
v-for="dict in sexDictDatas"
:key="parseInt(dict.value)"
@@ -356,7 +383,12 @@
</el-col>
<el-col :span="12">
<el-form-item label="岗位">
<el-select v-model="form.postIds" multiple placeholder="请选择">
<el-select
v-model="form.postIds"
multiple
placeholder="请选择"
style="width: 100%"
>
<el-option
v-for="item in postOptions"
:key="item.id"
@@ -383,14 +415,13 @@
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</base-dialog>
<!-- 用户导入对话框 -->
<el-dialog
:title="upload.title"
:visible.sync="upload.open"
<base-dialog
:dialogTitle="upload.title"
:dialogVisible="upload.open"
width="400px"
append-to-body
>
<el-upload
ref="upload"
@@ -425,15 +456,10 @@
<el-button type="primary" @click="submitFileForm">确 定</el-button>
<el-button @click="upload.open = false">取 消</el-button>
</div>
</el-dialog>
</base-dialog>
<!-- 分配角色 -->
<el-dialog
title="分配角色"
:visible.sync="openRole"
width="500px"
append-to-body
>
<base-dialog dialogTitle="分配角色" :dialogVisible="openRole" width="500px">
<el-form :model="form" label-width="80px">
<el-form-item label="用户名称">
<el-input v-model="form.username" :disabled="true" />
@@ -456,7 +482,7 @@
<el-button type="primary" @click="submitRole">确 定</el-button>
<el-button @click="cancelRole">取 消</el-button>
</div>
</el-dialog>
</base-dialog>
</div>
</template>
@@ -483,12 +509,161 @@ import { DICT_TYPE, getDictDatas } from "@/utils/dict";
import { assignUserRole, listUserRoles } from "@/api/system/permission";
import { listSimpleRoles } from "@/api/system/role";
import { getBaseHeader } from "@/utils/request";
import tableHeightMixin from "@/mixins/tableHeightMixin";
import { parseTime } from "@/utils/ruoyi";
import statusBtn5 from "./../components/statusBtn5.vue";
const tableProps = [
{
prop: "id",
label: "用户编号",
},
{
prop: "username",
label: "用户名称",
minWidth: 120,
showOverflowtooltip: true,
},
{
prop: "nickname",
label: "用户昵称",
minWidth: 120,
showOverflowtooltip: true,
},
{
prop: "deptName",
label: "部门",
minWidth: 120,
showOverflowtooltip: true,
},
{
prop: "mobile",
label: "手机号码",
minWidth: 150,
showOverflowtooltip: true,
},
{
prop: "status",
label: "状态",
minWidth: 80,
// filter: publicFormatter(DICT_TYPE.SYSTEM_OPERATE_TYPE),
subcomponent: statusBtn5,
},
{
prop: "createTime",
label: "创建时间",
filter: parseTime,
minWidth: 150,
showOverflowtooltip: true,
},
];
export default {
name: "SystemUser",
mixins: [tableHeightMixin],
components: { Treeselect },
data() {
return {
formConfig: [
{
type: "input",
label: "用户名称",
placeholder: "用户名称",
param: "username",
width: 150,
},
{
type: "input",
label: "手机号码",
placeholder: "手机号码",
param: "mobile",
width: 150,
},
{
type: "select",
label: "状态",
selectOptions: this.getDictDatas(this.DICT_TYPE.COMMON_STATUS),
labelField: "label",
valueField: "value",
param: "status",
width: 100,
},
{
type: "datePicker",
label: "创建时间",
dateType: "daterange",
format: "yyyy-MM-dd",
valueFormat: "yyyy-MM-dd HH:mm:ss",
rangeSeparator: "-",
startPlaceholder: "开始日期",
endPlaceholder: "结束日期",
param: "createTime",
defaultSelect: [],
defaultTime: ["00:00:00", "23:59:59"],
width: 250,
},
{
type: "button",
btnName: "查询",
name: "search",
color: "primary",
},
{
type: this.$auth.hasPermiOr([
"system:user:create",
"system:user:import",
"system:user:export",
])
? "separate"
: "",
},
{
type: this.$auth.hasPermi("system:user:create") ? "button" : "",
btnName: "新增",
name: "addNew",
color: "success",
plain: true,
},
{
type: this.$auth.hasPermi("system:user:import") ? "button" : "",
btnName: "导入",
name: "import",
color: "warning",
plain: true,
},
{
type: this.$auth.hasPermi("system:user:export") ? "button" : "",
btnName: "导出",
name: "export",
color: "primary",
plain: true,
},
],
tableBtn: [
this.$auth.hasPermi("system:user:update")
? {
type: "edit",
btnName: "修改",
}
: undefined,
this.$auth.hasPermi("system:user:delete")
? {
type: "delete",
btnName: "删除",
}
: undefined,
this.$auth.hasPermi("system:user:update-password")
? {
type: "reset",
btnName: "重置密码",
}
: undefined,
this.$auth.hasPermi("system:permission:assign-user-role")
? {
type: "role",
btnName: "分配角色",
}
: undefined,
].filter((v) => v),
tableProps,
// 遮罩层
loading: true,
// 导出遮罩层
@@ -498,7 +673,7 @@ export default {
// 总条数
total: 0,
// 用户表格数据
userList: null,
userList: [],
// 弹出层标题
title: "",
// 部门树选项
@@ -607,6 +782,37 @@ export default {
// });
},
methods: {
handleClick(val) {
switch (val.type) {
case "edit":
this.handleUpdate(val.data);
break;
case "delete":
this.handleDelete(val.data);
break;
case "reset":
this.handleResetPwd(val.data);
break;
default:
this.handleRole(val.data);
}
},
buttonClick(val) {
console.log(val);
switch (val.btnName) {
case "search":
this.handleQuery();
break;
case "addNew":
this.handleAdd();
break;
case "import":
this.handleImport();
break;
default:
this.handleExport();
}
},
// 更多操作
handleCommand(command, index, row) {
switch (command) {
@@ -660,21 +866,9 @@ export default {
},
// 用户状态修改
handleStatusChange(row) {
let text = row.status === CommonStatusEnum.ENABLE ? "启用" : "停用";
this.$modal
.confirm('确认要"' + text + '""' + row.username + '"用户吗?')
.then(function () {
return changeUserStatus(row.id, row.status);
})
.then(() => {
this.$modal.msgSuccess(text + "成功");
})
.catch(function () {
row.status =
row.status === CommonStatusEnum.ENABLE
? CommonStatusEnum.DISABLE
: CommonStatusEnum.ENABLE;
});
changeUserStatus(row.id, row.status).then((res) => {
this.$modal.msgSuccess("操作成功");
});
},
// 取消按钮
cancel() {
@@ -709,11 +903,6 @@ export default {
this.queryParams.pageNo = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();