<template>
|
<div class="app-container">
|
<el-row :gutter="20">
|
<!--用户数据-->
|
<el-col :span="24" :xs="24">
|
<el-form
|
:model="topqueryParams"
|
ref="queryForm"
|
size="small"
|
:inline="true"
|
v-show="showSearch"
|
label-width="98px"
|
>
|
<el-form-item label="标签名称" prop="userName">
|
<el-input
|
v-model="topqueryParams.userName"
|
placeholder="请输入"
|
clearable
|
style="width: 200px"
|
@keyup.enter.native="handleQuery"
|
/>
|
</el-form-item>
|
|
<el-form-item>
|
<el-button
|
type="primary"
|
icon="el-icon-search"
|
size="medium"
|
@click="handleQuery"
|
>搜索</el-button
|
>
|
<el-button icon="el-icon-refresh" size="medium" @click="resetQuery"
|
>重置</el-button
|
>
|
</el-form-item>
|
</el-form>
|
<el-divider></el-divider>
|
<el-row :gutter="10" class="mb8">
|
<el-col :span="1.5">
|
<el-button
|
type="primary"
|
plain
|
icon="el-icon-plus"
|
size="medium"
|
@click="handleAdd"
|
v-hasPermi="['system:user:add']"
|
>新增</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="success"
|
plain
|
icon="el-icon-edit"
|
size="medium"
|
:disabled="single"
|
@click="handleUpdate"
|
v-hasPermi="['system:user:edit']"
|
>修改</el-button
|
>
|
</el-col>
|
<el-col :span="1.5">
|
<el-button
|
type="danger"
|
plain
|
icon="el-icon-delete"
|
size="medium"
|
:disabled="multiple"
|
@click="handleDelete"
|
v-hasPermi="['system:user:remove']"
|
>删除</el-button
|
>
|
</el-col>
|
<el-col :span="19">
|
<div class="documentf">
|
<div class="document">
|
<el-button
|
type="warning"
|
plain
|
icon="el-icon-download"
|
size="medium"
|
@click="handleExport"
|
v-hasPermi="['system:user:export']"
|
>导出</el-button
|
>
|
</div>
|
</div>
|
</el-col>
|
<!-- <el-col :span="1.5"> </el-col> -->
|
</el-row>
|
<!-- <right-toolbar
|
:showSearch.sync="showSearch"
|
@queryTable="getList"
|
:columns="columns"
|
></right-toolbar> -->
|
<el-table
|
v-loading="loading"
|
:data="userList"
|
@selection-change="handleSelectionChange"
|
>
|
<el-table-column type="selection" width="50" align="center" />
|
<el-table-column
|
label="序号"
|
align="center"
|
key="userId"
|
prop="userId"
|
/>
|
|
<el-table-column
|
label="标签名称"
|
align="center"
|
key="userName"
|
prop="userName"
|
:show-overflow-tooltip="true"
|
/>
|
<el-table-column
|
label="账号"
|
align="center"
|
key="types"
|
prop="types"
|
/>
|
<el-table-column
|
label="密码"
|
align="center"
|
key="nickName"
|
prop="nickName"
|
/>
|
<el-table-column
|
label="备注"
|
align="center"
|
key="phonenumber"
|
prop="phonenumber"
|
width="120"
|
/>
|
<el-table-column label="是否启用" align="center" key="status">
|
<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="160"
|
>
|
<template slot-scope="scope">
|
<span>{{ parseTime(scope.row.createTime) }}</span>
|
</template>
|
</el-table-column>
|
<el-table-column
|
label="操作"
|
align="center"
|
width="160"
|
class-name="small-padding fixed-width"
|
>
|
<template slot-scope="scope">
|
<el-button
|
size="medium"
|
type="text"
|
icon="el-icon-edit"
|
@click="handleUpdate(scope.row)"
|
v-hasPermi="['system:user:edit']"
|
>编辑</el-button
|
>
|
<el-button
|
size="medium"
|
type="text"
|
@click="handleDelete(scope.row)"
|
><span style="color: rgb(236, 55, 55)"
|
><i class="el-icon-delete-solid"></i>删除</span
|
></el-button
|
>
|
</template>
|
</el-table-column>
|
</el-table>
|
|
<pagination
|
v-show="total > 0"
|
:total="total"
|
:page.sync="topqueryParams.pageNum"
|
:limit.sync="topqueryParams.pageSize"
|
@pagination="getList"
|
/>
|
</el-col>
|
</el-row>
|
|
<!-- 添加或修改标签配置对话框 -->
|
<el-dialog
|
:title="title"
|
:visible.sync="addalteropen"
|
width="900px"
|
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="nickName">
|
<el-input
|
v-model="form.nickName"
|
placeholder="请输入"
|
maxlength="30"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="短信平台账号" prop="email">
|
<el-input
|
v-model="form.nickName"
|
placeholder="请输入"
|
maxlength="30"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="短信平台密码" prop="email">
|
<el-input
|
v-model="form.nickName"
|
placeholder="请输入"
|
maxlength="30"
|
/>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="12">
|
<el-form-item label="是否启用">
|
<el-radio-group v-model="form.qystatus">
|
<el-radio
|
v-for="item in qyoptions"
|
:key="item.value"
|
:label="item.value"
|
>{{ item.label }}</el-radio
|
>
|
</el-radio-group>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
<el-row>
|
<el-col :span="24">
|
<el-form-item label="备注">
|
<el-input
|
v-model="form.remark"
|
type="textarea"
|
placeholder="请输入内容"
|
></el-input>
|
</el-form-item>
|
</el-col>
|
</el-row>
|
</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 {
|
listUser,
|
getUser,
|
delUser,
|
addUser,
|
updateUser,
|
resetUserPwd,
|
changeUserStatus,
|
} from "@/api/system/user";
|
import Treeselect from "@riophae/vue-treeselect";
|
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
|
|
export default {
|
name: "User",
|
dicts: ["sys_normal_disable", "sys_user_sex"],
|
components: { Treeselect },
|
data() {
|
return {
|
// 遮罩层
|
loading: true,
|
// 选中数组
|
ids: [],
|
// 非单个禁用
|
single: true,
|
// 非多个禁用
|
multiple: true,
|
// 显示搜索条件
|
showSearch: true,
|
// 总条数
|
total: 0,
|
// 用户表格数据
|
userList: null,
|
// 弹出层标题
|
title: "",
|
// 是否显示修改、添加弹出层
|
addalteropen: false,
|
// 部门名称
|
deptName: undefined,
|
// 默认密码
|
initPassword: undefined,
|
// 日期范围
|
dateRange: [],
|
// 岗位选项
|
postOptions: [],
|
// 角色选项
|
roleOptions: [],
|
dynamicTags: ["选项一", "选项二", "选项三"], //选项
|
inputVisible: false,
|
inputValue: "",
|
previewVisible: false, //标签预览弹框
|
radio: "",
|
radios: [],
|
previewtype: 2, //预览标签类型
|
total: 0, // 总条数
|
ImportQuantity: 999, //导标签数量
|
//预览标签信息
|
previewvalue: {
|
username: "这个医生对你怎么样",
|
},
|
// 表单参数
|
form: {
|
phonenumber: "",
|
totagid: "",
|
types: "",
|
nickName: "",
|
qystatus: "",
|
btstatus: "",
|
},
|
|
// 查询参数
|
topqueryParams: {
|
pageNum: 1,
|
},
|
propss: { multiple: true },
|
optionss: [
|
{
|
value: 1,
|
label: "东南",
|
},
|
{
|
value: 2,
|
label: "西北",
|
},
|
{
|
value: 3,
|
label: "仨仨仨",
|
},
|
{
|
value: 4,
|
label: "六飒飒飒",
|
},
|
],
|
qyoptions: [
|
{
|
value: 1,
|
label: "启用",
|
},
|
{
|
value: 2,
|
label: "关闭",
|
},
|
],
|
btoptions: [
|
{
|
value: 1,
|
label: "必填",
|
},
|
{
|
value: 2,
|
label: "非必填",
|
},
|
],
|
topicoptions: [
|
{
|
value: 1,
|
label: "单选",
|
},
|
{
|
value: 2,
|
label: "多选",
|
},
|
{
|
value: 3,
|
label: "填空",
|
},
|
],
|
// 表单校验
|
rules: {
|
userName: [
|
{ required: true, message: "用户名称不能为空", trigger: "blur" },
|
{
|
min: 2,
|
max: 20,
|
message: "用户名称长度必须介于 2 和 20 之间",
|
trigger: "blur",
|
},
|
],
|
nickName: [
|
{ required: true, message: "用户昵称不能为空", trigger: "blur" },
|
],
|
password: [
|
{ required: true, message: "用户密码不能为空", trigger: "blur" },
|
{
|
min: 5,
|
max: 20,
|
message: "用户密码长度必须介于 5 和 20 之间",
|
trigger: "blur",
|
},
|
],
|
email: [
|
{
|
type: "email",
|
message: "请输入正确的邮箱地址",
|
trigger: ["blur", "change"],
|
},
|
],
|
phonenumber: [
|
{
|
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
|
message: "请输入正确的手机号码",
|
trigger: "blur",
|
},
|
],
|
IDnumber: [
|
{
|
pattern:
|
/^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/,
|
message: "请输入正确的身份证号码",
|
trigger: "blur",
|
},
|
],
|
},
|
};
|
},
|
watch: {},
|
created() {
|
this.getList();
|
this.getConfigKey("sys.user.initPassword").then((response) => {
|
this.initPassword = response.msg;
|
});
|
},
|
methods: {
|
/** 查询标签列表 */
|
getList() {
|
this.loading = true;
|
listUser(this.addDateRange(this.topqueryParams, this.dateRange)).then(
|
(response) => {
|
this.userList = response.rows;
|
this.total = response.total;
|
this.loading = false;
|
}
|
);
|
},
|
|
// 标签状态修改
|
handleStatusChange(row) {
|
let text = row.status === "0" ? "启用" : "停用";
|
this.$modal
|
.confirm('确认要"' + text + '""' + row.userName + '"用户吗?')
|
.then(function () {
|
return changeUserStatus(row.userId, row.status);
|
})
|
.then(() => {
|
this.$modal.msgSuccess(text + "成功");
|
})
|
.catch(function () {
|
row.status = row.status === "0" ? "1" : "0";
|
});
|
},
|
// 取消按钮
|
cancel() {
|
this.addalteropen = false;
|
this.reset();
|
},
|
// 表单重置
|
reset() {
|
this.form = {
|
userId: undefined,
|
deptId: undefined,
|
userName: undefined,
|
nickName: undefined,
|
password: undefined,
|
phonenumber: undefined,
|
email: undefined,
|
sex: undefined,
|
status: "0",
|
remark: undefined,
|
postIds: [],
|
roleIds: [],
|
};
|
this.resetForm("form");
|
},
|
/** 搜索按钮操作 */
|
handleQuery() {
|
this.topqueryParams.pageNum = 1;
|
this.getList();
|
},
|
/** 重置按钮操作 */
|
resetQuery() {
|
this.dateRange = [];
|
this.resetForm("queryForm");
|
this.topqueryParams.deptId = undefined;
|
this.$refs.tree.setCurrentKey(null);
|
this.handleQuery();
|
},
|
// 多选框选中数据
|
handleSelectionChange(selection) {
|
this.ids = selection.map((item) => item.userId);
|
this.single = selection.length != 1;
|
this.multiple = !selection.length;
|
},
|
//删除选项
|
handleClose(tag) {
|
this.dynamicTags.splice(this.dynamicTags.indexOf(tag), 1);
|
},
|
//触发新增输入
|
showInput() {
|
this.inputVisible = true;
|
this.$nextTick((_) => {
|
this.$refs.saveTagInput.$refs.input.focus();
|
});
|
},
|
//获取失去焦点触发
|
handleInputConfirm() {
|
let inputValue = this.inputValue;
|
if (inputValue) {
|
this.dynamicTags.push(inputValue);
|
}
|
this.inputVisible = false;
|
this.inputValue = "";
|
},
|
/** 新增按钮操作 */
|
handleAdd() {
|
this.reset();
|
this.title = "新增标签";
|
this.addalteropen = true;
|
},
|
/** 修改按钮操作 */
|
handleUpdate(row) {
|
this.reset();
|
this.title = "修改标签";
|
this.addalteropen = true;
|
// const userId = row.userId || this.ids;
|
// getUser(userId).then((response) => {
|
// this.form = response.data;
|
// this.postOptions = response.posts;
|
// this.roleOptions = response.roles;
|
// this.$set(this.form, "postIds", response.postIds);
|
// this.$set(this.form, "roleIds", response.roleIds);
|
// this.addalteropen = true;
|
// this.form.password = "";
|
// });
|
},
|
/** 重置密码按钮操作 */
|
handleResetPwd(row) {
|
this.$prompt('请输入"' + row.userName + '"的新密码', "提示", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
closeOnClickModal: false,
|
inputPattern: /^.{5,20}$/,
|
inputErrorMessage: "用户密码长度必须介于 5 和 20 之间",
|
})
|
.then(({ value }) => {
|
resetUserPwd(row.userId, value).then((response) => {
|
this.$modal.msgSuccess("修改成功,新密码是:" + value);
|
});
|
})
|
.catch(() => {});
|
},
|
|
/** 提交按钮 */
|
submitForm: function () {
|
this.$refs["form"].validate((valid) => {
|
if (valid) {
|
if (this.form.userId != undefined) {
|
updateUser(this.form).then((response) => {
|
this.$modal.msgSuccess("修改成功");
|
this.open = false;
|
this.getList();
|
});
|
} else {
|
addUser(this.form).then((response) => {
|
this.$modal.msgSuccess("新增成功");
|
this.open = false;
|
this.getList();
|
});
|
}
|
}
|
});
|
},
|
/** 删除按钮操作 */
|
handleDelete(row) {
|
const userIds = row.userId || this.ids;
|
this.$modal
|
.confirm('是否确认删除用户编号为"' + userIds + '"的数据项?')
|
.then(function () {
|
return delUser(userIds);
|
})
|
.then(() => {
|
this.getList();
|
this.$modal.msgSuccess("删除成功");
|
})
|
.catch(() => {});
|
},
|
/** 导出按钮操作 */
|
handleExport() {
|
this.download(
|
"system/user/export",
|
{
|
...this.topqueryParams,
|
},
|
`user_${new Date().getTime()}.xlsx`
|
);
|
},
|
},
|
};
|
</script>
|
|
<style lang="scss" scoped>
|
.el-button--primary.is-plain {
|
color: #ffffff;
|
background: #409eff;
|
border-color: #4fabe9;
|
}
|
.document {
|
width: 100px;
|
height: 50px;
|
}
|
.documentf {
|
display: flex;
|
justify-content: flex-end;
|
}
|
.download {
|
text-align: center;
|
.el-upload__tip {
|
font-size: 23px;
|
}
|
.el-upload__text {
|
font-size: 23px;
|
}
|
}
|
.uploading {
|
margin-top: 20px;
|
margin: 20px;
|
padding: 30px;
|
background: #ffffff;
|
border: 1px solid #dcdfe6;
|
-webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
|
0 0 6px 0 rgba(0, 0, 0, 0.04);
|
}
|
.el-tag + .el-tag {
|
margin-left: 10px;
|
}
|
.button-new-tag {
|
margin-left: 10px;
|
height: 32px;
|
line-height: 30px;
|
padding-top: 0;
|
padding-bottom: 0;
|
}
|
.input-new-tag {
|
width: 90px;
|
margin-left: 10px;
|
vertical-align: bottom;
|
}
|
.drexamine {
|
display: flex;
|
align-items: center;
|
justify-content: center;
|
padding: 30px;
|
background: #daeaf5;
|
img {
|
width: 100px;
|
height: 100px;
|
}
|
}
|
.qrcode-dialo {
|
// text-align: center;
|
// display: flex;
|
margin: 20px;
|
padding: 30px;
|
background: #edf1f7;
|
border: 1px solid #dcdfe6;
|
-webkit-box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.12),
|
0 0 6px 0 rgba(0, 0, 0, 0.04);
|
.topic-dev {
|
margin-bottom: 25px;
|
font-size: 20px !important;
|
.dev-text {
|
margin-bottom: 10px;
|
}
|
}
|
}
|
::v-deep.el-radio-group {
|
span {
|
font-size: 24px;
|
}
|
}
|
::v-deep.el-checkbox-group {
|
span {
|
font-size: 24px;
|
}
|
}
|
</style>
|