<template>
|
<div class="box-card" v-loading="loading" element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading">
|
<div class="box-content">
|
<!-- 搜索操作 -->
|
<div class="search-input-box">
|
<div class="fl-co">
|
<h3 class="mr-b-20">行业分中心管理</h3>
|
<div class="fl-al mr-b-10">
|
<el-input clearable style="width: 400px" v-model.trim="searchVal.keyWord"
|
placeholder="请输入行业分中心名称、调解室电话进行查找" @keyup.enter="handleAction('search')"></el-input>
|
<div class="fl-al">
|
<!-- <div class="fz-7 label-width-search"></div> -->
|
<el-button class="mr-l-20" type="primary" @click="handleAction('search')">搜索</el-button>
|
<el-button @click="handleAction('reset')">重置</el-button>
|
</div>
|
</div>
|
</div>
|
</div>
|
<!-- 列表 -->
|
<div class="table-content">
|
<!-- 新增按钮 -->
|
<div class="fl-al mr-b-10">
|
<el-button type="primary" @click="handleAction('add')">新增</el-button>
|
</div>
|
<!-- 列表 -->
|
<TablePro :tableLsit="tableLsit" :columnList="columnList">
|
<template v-slot:status="scope">
|
<el-tag v-if="scope.row.status === 1">启用</el-tag>
|
<el-tag type="info" v-if="scope.row.status === 0">禁用</el-tag>
|
</template>
|
<template v-slot:btn="scope">
|
<el-button type="text" @click="handleAction('setPassword', scope.row)">密码重置</el-button>
|
<el-button type="text" @click="handleAction('edit', scope.row)">编辑</el-button>
|
<el-button type="text" @click="handleAction('delete', scope.row)">删除</el-button>
|
</template>
|
</TablePro>
|
<!-- 分页 -->
|
<div class="bottom-page">
|
<el-pagination @size-change="handleSizeChange" @current-change="handleCurrentChange"
|
:current-page="pageNum" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize" background
|
layout="total, sizes, prev, pager, next, jumper" :total="total">
|
</el-pagination>
|
</div>
|
</div>
|
<!-- 新增编辑弹框 -->
|
<el-dialog :close-on-click-modal="false" :title="dialogTitle" :visible.sync="dialogVisible"
|
:before-close="handleClose" center append-to-body>
|
<el-form :model="formInfo" :rules="rules" label-position="right" ref="ruleForm" label-width="130px"
|
class="demo-ruleForm">
|
<div v-if="!setPasswordType">
|
<div class="fl-fw">
|
<el-form-item label="行业分中心名称" prop="name">
|
<el-input class="input-width" maxlength="30" placeholder="请输入,30字以内"
|
v-model.trim="formInfo.name"></el-input>
|
</el-form-item>
|
<el-form-item label="调解室电话" prop="phone">
|
<el-input class="input-width" maxlength="11" placeholder="请输入联系电话,座机请加上区号"
|
v-model.trim="formInfo.phone"></el-input>
|
</el-form-item>
|
</div>
|
<el-form-item label="登录账号" prop="account">
|
<el-input style="width:300px" :disabled="dialogTitle==='编辑'" class="input-width"
|
maxlength="16" placeholder="请输入4-16位字母的组合" v-model.trim="formInfo.account"></el-input>
|
</el-form-item>
|
<el-form-item :disabled="dialogTitle==='编辑'" label="登录密码" prop="password">
|
<el-input type="password" style="width:300px" :disabled="dialogTitle==='编辑'"
|
class="input-width" maxlength="20" placeholder="请输入8-16位,且包含字母、数字、字符"
|
v-model.trim="formInfo.password">
|
</el-input>
|
</el-form-item>
|
<el-form-item label="确认密码" prop="confirmPssword" v-if="dialogTitle!='编辑'">
|
<el-input type="password" style="width:300px" maxlength="20"
|
placeholder="请输入8-16位,且包含字母、数字、字符" v-model.trim="formInfo.confirmPssword"></el-input>
|
</el-form-item>
|
<el-form-item label="账号状态" prop="pushStatus">
|
<div class="input-width">
|
<el-radio v-model="formInfo.status" :label="1">启用</el-radio>
|
<el-radio v-model="formInfo.status" :label="0">禁用</el-radio>
|
</div>
|
</el-form-item>
|
</div>
|
<div v-else>
|
<el-form-item label="登录密码" prop="password">
|
<el-input type="password" style="width:300px" class="input-width" maxlength="20"
|
placeholder="请输入8-16位,且包含字母、数字、字符" v-model.trim="formInfo.password"></el-input>
|
</el-form-item>
|
<el-form-item label="确认密码" prop="confirmPssword">
|
<el-input type="password" style="width:300px" class="input-width" maxlength="20"
|
placeholder="请输入8-16位,且包含字母、数字、字符" v-model.trim="formInfo.confirmPssword"></el-input>
|
</el-form-item>
|
</div>
|
</el-form>
|
<div class="fl-cen">
|
<el-button @click="handleClose">取 消</el-button>
|
<el-button type="primary" @click="handleAction('submit')" :loading="btnloading">提交</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</div>
|
</template>
|
<script>
|
import { objCopyPro, showToast, dateTime } from "../../../utils/common";
|
const REX_VAL = /^(?![a-zA-Z]+$)(?![A-Z0-9]+$)(?![A-Z\W_!@#$%^&*.`~()-+=]+$)(?![a-z0-9]+$)(?![a-z\W_!@#$%^&.*`~()-+=]+$)(?![0-9\W_!@#$%^.&*`~()-+=]+$)[a-zA-Z0-9\W_!@#$%^&.*`~()-+=]{8,16}$/;
|
export default {
|
data() {
|
const USER_NAME = (rule, value, callback) => {
|
const regExp = /^[A-Za-z]{4,16}$/
|
if (!value) return callback(new Error('不能为空'));
|
if (regExp.test(value) === false) {
|
callback(new Error('请输入4-16位字母的组合'))
|
} else {
|
callback()
|
}
|
}
|
const VALIDATE_PASSWOID = (rule, value, callback) => {
|
const regExp = REX_VAL
|
if (!value) return callback(new Error('不能为空'));
|
if (regExp.test(value) === false) {
|
callback(new Error('请输入4-请输入8-16位,且包含字母、数字、字符'))
|
} else {
|
callback()
|
}
|
};
|
const COMFIRM_PASSWOID = (rule, value, callback) => {
|
if (!value) return callback(new Error('不能为空'));
|
if (value !== this.formInfo.password) {
|
callback(new Error('两次密码不一样'))
|
} else {
|
callback()
|
}
|
};
|
return {
|
loading: false, // 页面loading
|
btnloading: false, // 提交按钮loading
|
tableLsit: [], // 列表
|
columnList: [
|
{ type: "index" },
|
{ label: "行业分中心名称", key: "name" },
|
{ label: "调解室电话", key: "phone" },
|
{ label: "创建人", key: "createBy" },
|
{ label: "创建时间", key: "createTime" },
|
{ type: "custom", label: "状态", slot: "status" },
|
{
|
type: "custom",
|
label: "操作",
|
width: "250",
|
slot: "btn",
|
},
|
], // 列表属性
|
dialogTitle: "", // 弹框标题
|
dialogVisible: false, // 弹框状态
|
pageNum: 1, // 当前页
|
pageSize: 10, // 当前条数
|
total: 0, // 总数
|
formInfo: {
|
name: "",
|
phone: "",
|
account: '',
|
password: '',
|
confirmPssword: '',
|
status: 1
|
}, // 表单
|
rules: {
|
name: [
|
{
|
required: true,
|
message: "请输入姓名",
|
trigger: "blur",
|
},
|
],
|
phone: [
|
{
|
required: true,
|
message: "请输入调解室电话",
|
trigger: "blur",
|
},
|
],
|
account: [
|
{
|
required: true,
|
trigger: "blur",
|
validator: USER_NAME,
|
},
|
],
|
password: [
|
{
|
required: true,
|
trigger: "blur",
|
validator: VALIDATE_PASSWOID,
|
},
|
],
|
confirmPssword: [
|
{
|
required: true,
|
trigger: "blur",
|
validator: COMFIRM_PASSWOID,
|
},
|
],
|
}, // 表单验证
|
searchVal: {
|
keyWord: "",
|
},
|
setPasswordType: false
|
};
|
},
|
mounted() {
|
this.getTable();
|
},
|
methods: {
|
// 获取列表
|
getTable() {
|
this.loading = true;
|
const requestData = Object.assign(
|
{
|
page: this.pageNum,
|
size: this.pageSize,
|
},
|
this.searchVal
|
);
|
this.$api.get("sanshuo/industryCenter/backList", requestData, (res) => {
|
this.loading = false;
|
this.tableLsit = res.data.records;
|
this.tableLsit.forEach(item => {
|
item.createTime = dateTime(item.createTime)
|
})
|
this.total = res.data.total;
|
});
|
},
|
// 切换条数
|
handleSizeChange(val) {
|
this.pageSize = val;
|
this.getTable();
|
},
|
// 切换页
|
handleCurrentChange(val) {
|
this.pageNum = val;
|
this.getTable();
|
},
|
// 页面操作
|
async handleAction(type, row) {
|
switch (type) {
|
// 新增
|
case "add": {
|
this.dialogTitle = "新增";
|
this.dialogVisible = true;
|
break;
|
}
|
// 编辑
|
case "edit": {
|
this.dialogTitle = "编辑";
|
this.$api.get(`sanshuo/industryCenter/${row.id}`, {}, (res) => {
|
this.formInfo = objCopyPro(this.formInfo, res);
|
this.dialogVisible = true;
|
});
|
break;
|
}
|
// 重置
|
case "reset": {
|
this.pageNum = 1;
|
this.pageSize = 10;
|
this.searchVal = { keyWord: "" };
|
this.getTable();
|
break;
|
}
|
// 重置
|
case "setPassword": {
|
this.dialogTitle = "重置密码";
|
this.formInfo.id = row.id
|
this.dialogVisible = true;
|
this.setPasswordType = true;
|
break;
|
}
|
// 删除
|
case "delete": {
|
this.$confirm("确定要删除该分类吗?", {
|
confirmButtonText: "确定",
|
cancelButtonText: "取消",
|
type: "info",
|
}).then(() => {
|
this.$api.get("sanshuo/industryCenter/remove/" + row.id, {}, () => {
|
showToast("删除成功");
|
this.getTable();
|
});
|
});
|
break;
|
}
|
// 提交
|
case "submit": {
|
this.$refs.ruleForm.validate((val) => {
|
if (val) {
|
this.btnloading = true;
|
if (this.setPasswordType) {
|
this.$api.post("sanshuo/industryCenter/resetPassword", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
// this.getTable();
|
});
|
} else {
|
if (this.dialogTitle === "新增") {
|
this.$api.post("sanshuo/industryCenter", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
this.getTable();
|
});
|
} else {
|
this.$api.put("sanshuo/industryCenter", this.formInfo, () => {
|
this.btnloading = false;
|
showToast(this.dialogTitle + "成功");
|
this.handleClose();
|
this.getTable();
|
});
|
}
|
}
|
}
|
});
|
break;
|
}
|
// 搜索
|
case "search": {
|
this.pageNum = 1;
|
this.pageSize = 10;
|
this.getTable();
|
break;
|
}
|
default: {
|
break;
|
}
|
}
|
},
|
// 关闭弹框
|
handleClose() {
|
this.$refs.ruleForm.resetFields(); // 重置form表单
|
this.formInfo = {
|
name: "",
|
phone: "",
|
account: '',
|
password: '',
|
confirmPssword: '',
|
status: 1
|
};
|
this.setPasswordType = false;
|
this.dialogVisible = false;
|
this.btnloading = false;
|
},
|
},
|
};
|
</script>
|
<style>
|
.el-dialog {
|
width: 800px !important;
|
}
|
</style>
|
<style scoped>
|
|
</style>
|