gz-att-web/src/views/system/userInfo/index.vue

314 lines
10 KiB
Vue
Raw Normal View History

2024-10-10 14:05:31 +08:00
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
2024-10-16 15:09:57 +08:00
<el-form-item label="姓名" prop="userName">
2024-10-10 14:05:31 +08:00
<el-input
2024-10-16 15:09:57 +08:00
v-model="queryParams.userName"
2024-10-10 14:05:31 +08:00
placeholder="请输入姓名"
clearable
style="width: 240px"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="部门名称" prop="dictType">
2024-10-16 15:09:57 +08:00
<treeselect v-model="queryParams.orgId" :options="deptOptions" :normalizer="normalizer" placeholder="选择部门" style="width: 240px"/>
2024-10-10 14:05:31 +08:00
</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">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="warning"
plain
icon="el-icon-download"
size="mini"
@click="handleExport"
>导出</el-button>
</el-col>
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
<el-table v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
2024-10-16 15:09:57 +08:00
<el-table-column label="序号" align="center" width="80" type="index">
<template slot-scope="scope">
<span>{{ (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1 }}</span>
</template>
</el-table-column>
2024-10-10 14:05:31 +08:00
<el-table-column label="姓名" align="center" prop="dictId" />
2024-10-16 15:09:57 +08:00
<el-table-column label="所属部门" align="center" prop="userName" :show-overflow-tooltip="true" />
<el-table-column label="岗位" align="center" prop="userName" :show-overflow-tooltip="true"/>
2024-10-10 14:05:31 +08:00
<el-table-column label="人员角色" align="center" prop="status" :show-overflow-tooltip="true" />
<el-table-column label="手机号(登录名称)" align="center" prop="remark" :show-overflow-tooltip="true" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button
size="mini"
2024-10-16 15:09:57 +08:00
type="primary"
2024-10-10 14:05:31 +08:00
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
2024-10-16 15:09:57 +08:00
type="danger"
2024-10-10 14:05:31 +08:00
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
2024-10-16 15:09:57 +08:00
2024-10-10 14:05:31 +08:00
<!-- 添加或修改参数配置对话框 -->
2024-10-16 15:09:57 +08:00
<el-dialog :title="title" :visible.sync="open" width="800px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-row>
<el-col :span="12">
<el-form-item label="姓名" prop="userName">
<el-input v-model="form.userName" placeholder="请输入姓名" maxlength="20"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="所属部门" prop="orgId">
2024-10-16 18:54:28 +08:00
<treeselect v-model="form.orgId" :options="deptOptions" :normalizer="normalizer" placeholder="选择所属部门"/>
2024-10-16 15:09:57 +08:00
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="岗位名称" prop="postName">
<el-input v-model="form.postName" placeholder="请输入岗位名称" maxlength="20"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="人员角色" prop="roles">
<el-input v-model="form.roles" placeholder="请输入人员角色" maxlength="20"/>
<!-- <el-select v-model="form.roles" placeholder="人员角色" clearable>
<el-option
v-for="item in statusList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select> -->
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="12">
<el-form-item label="手机号码" prop="phone">
<el-input v-model="form.phone" placeholder="请输入手机号码" maxlength="11"/>
</el-form-item>
</el-col>
</el-row>
2024-10-10 14:05:31 +08:00
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listType, getType, delType, addType, updateType, refreshCache } from "@/api/system/dict/type";
import { listUser } from "@/api/system/userInfo";
2024-10-16 15:09:57 +08:00
import { listDept } from "@/api/system/dept";
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
2024-10-10 14:05:31 +08:00
export default {
name: "Dict",
dicts: ['sys_normal_disable'],
2024-10-16 15:09:57 +08:00
components: { Treeselect },
2024-10-10 14:05:31 +08:00
data() {
return {
// 遮罩层
loading: false,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 字典表格数据
userList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
2024-10-16 15:09:57 +08:00
deptOptions:[],
2024-10-10 14:05:31 +08:00
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
2024-10-16 15:09:57 +08:00
userName: undefined,
orgId: undefined,
2024-10-10 14:05:31 +08:00
},
// 表单参数
form: {},
// 表单校验
rules: {
2024-10-16 15:09:57 +08:00
userName: [
{ required: true, message: "人员姓名不能为空", trigger: "blur" }
],
orgId: [
{ required: true, message: "所属部门不能为空", trigger: "blur" }
],
postName: [
{ required: true, message: "岗位名称不能为空", trigger: "blur" }
],
roles: [
{ required: true, message: "人员角色不能为空", trigger: "blur" }
],
phone: [
{
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码",
trigger: "blur"
}
2024-10-10 14:05:31 +08:00
],
}
};
},
created() {
// this.getList();
2024-10-16 15:09:57 +08:00
this.getDeptList();
2024-10-10 14:05:31 +08:00
},
methods: {
2024-10-16 15:09:57 +08:00
getDeptList(){
listDept().then(response => {
this.deptOptions = this.handleTree(response.data, "id");
});
},
/** 转换部门数据结构 */
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children;
}
return {
id: node.id,
label: node.orgName,
children: node.children
};
},
2024-10-10 14:05:31 +08:00
/** 查询列表 */
getList() {
this.loading = true;
listUser(this.queryParams).then(response => {
this.userList = response.rows;
this.total = response.total;
this.loading = false;
}
);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
dictId: undefined,
2024-10-16 15:09:57 +08:00
userName: undefined,
2024-10-10 14:05:31 +08:00
dictType: undefined,
status: "0",
remark: undefined
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
2024-10-16 15:09:57 +08:00
this.title = "新增人员";
2024-10-10 14:05:31 +08:00
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.dictId)
this.single = selection.length!=1
this.multiple = !selection.length
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const dictId = row.dictId || this.ids
getType(dictId).then(response => {
this.form = response.data;
this.open = true;
2024-10-16 15:09:57 +08:00
this.title = "编辑人员";
2024-10-10 14:05:31 +08:00
});
},
/** 提交按钮 */
submitForm: function() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.dictId != undefined) {
updateType(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
});
} else {
addType(this.form).then(response => {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const dictIds = row.dictId || this.ids;
2024-10-16 15:09:57 +08:00
this.$modal.confirm('是否确认删除?').then(function() {
2024-10-10 14:05:31 +08:00
return delType(dictIds);
}).then(() => {
this.getList();
this.$modal.msgSuccess("删除成功");
}).catch(() => {});
},
/** 导出按钮操作 */
handleExport() {
this.download('system/dict/type/export', {
...this.queryParams
}, `type_${new Date().getTime()}.xlsx`)
},
}
};
</script>