Files
cmanager/src/views/manage/station/inviteCode.vue

446 lines
12 KiB
Vue
Raw Normal View History

2024-03-17 15:19:08 +08:00
<template>
<basic-container>
<avue-crud
ref="crud"
2024-04-18 17:52:13 +08:00
:table-loading="loading"
2024-03-17 20:25:26 +08:00
@date-change="dateChange"
2024-03-17 15:19:08 +08:00
@current-change="currentChange"
@size-change="sizeChange"
2024-03-17 20:25:26 +08:00
@on-load="onLoad"
:option="option"
:data="inviteCodeList"
:page.sync="page"
2024-03-29 16:02:57 +08:00
@row-del="rowDel"
2024-03-17 15:19:08 +08:00
@search-change="searchChange"
2024-03-17 20:25:26 +08:00
@refresh-change="refreshChange"
2024-03-17 15:19:08 +08:00
@search-reset="searchReset"
2024-04-18 17:52:13 +08:00
@selection-change="selectionChange"
2024-03-17 15:19:08 +08:00
>
<template slot="menuLeft">
<el-button
size="small"
2024-03-29 16:02:57 +08:00
@click.stop="distributionCodeDialog = true; isEdit = false; inviteCodeForm = {}"
2024-03-17 15:19:08 +08:00
type="primary"
2024-03-28 09:40:13 +08:00
v-show="vaildData(permission.manage_station_inviteCode_edituser, false)"
2024-04-18 17:52:13 +08:00
>新增用户
</el-button>
<el-button
size="small"
@click.stop="handleCheck"
type="primary"
>审核
</el-button>
2024-03-17 15:19:08 +08:00
</template>
2024-03-29 16:02:57 +08:00
<template slot="menu" slot-scope="{row}">
2024-04-19 14:58:16 +08:00
<el-button type="text" size="small" @click="rowUpdate(row)">编辑</el-button>
<el-button type="text" size="small" @click="rowDel(row)">删除</el-button>
2024-03-29 16:02:57 +08:00
</template>
2024-03-17 20:25:26 +08:00
<template slot="isEnabled" slot-scope="{ row }">
<el-switch
:value="row.isEnabled"
:active-value="1"
:inactive-value="0"
active-color="#13ce66"
inactive-color="#ff4949"
@change="changeEnabled(row)">
</el-switch>
2024-03-17 15:19:08 +08:00
</template>
2024-03-17 20:25:26 +08:00
</avue-crud>
2024-04-19 16:40:19 +08:00
<el-drawer
2024-03-22 09:59:56 +08:00
title="新增用户"
2024-03-17 15:19:08 +08:00
:visible.sync="distributionCodeDialog"
append-to-body
2024-04-19 16:40:19 +08:00
width="40%"
>
<div class="drawer_content">
<el-form :model="inviteCodeForm" :rules="inviteCodeRules" filterable ref="inviteCode" label-width="100px"
class="demo-ruleForm">
<el-form-item label="企业名称:" prop="companyId">
<el-select v-model="inviteCodeForm.inviteCompanyId" :disabled="isEdit" filterable placeholder="请选择企业"
style="width: 260px">
<el-option
v-for="item in enterpriseList"
:key="item.id"
:label="item.comname"
:value="item.id">
</el-option>
</el-select>
</el-form-item>
<el-form-item label="绑定用户:" prop="realName">
<el-input style="width: 260px" v-model="inviteCodeForm.realName" placeholder="请输入姓名"></el-input>
</el-form-item>
<el-form-item label="身份证:" prop="idNumber">
<el-input style="width: 260px" v-model="inviteCodeForm.idNumber" placeholder="请输入身份证"></el-input>
</el-form-item>
<el-form-item label="手机号:" prop="phone">
<el-input style="width: 260px" v-model="inviteCodeForm.phone" placeholder="请输入手机号"></el-input>
</el-form-item>
<el-form-item label="备注:" prop="remarks">
<el-input type="textarea" style="width: 260px" v-model="inviteCodeForm.remarks"
placeholder="请输入备注"></el-input>
</el-form-item>
</el-form>
<span class="dialog-footer footer_btns">
2024-03-17 20:25:26 +08:00
<el-button @click="distributionCodeDialog = false"> </el-button>
2024-03-17 15:19:08 +08:00
<el-button type="primary" @click="inviteCodeSubmit"> </el-button>
</span>
2024-04-19 16:40:19 +08:00
</div>
</el-drawer>
2024-03-17 15:19:08 +08:00
</basic-container>
</template>
<script>
2024-04-18 17:52:13 +08:00
import {mapGetters} from "vuex";
import {check18IdCardNo, isExcel, isMobile} from "@/util/validate";
import {deepClone} from "@/util/util";
2024-03-17 20:25:26 +08:00
import {
getEnterpriseList,
saveEnterpriseItem,
getInvitationCodeList,
2024-04-18 17:52:13 +08:00
getInvitationStatusUpdate,
getInviteApproval
2024-03-17 20:25:26 +08:00
} from "@/api/manage/station";
2024-04-18 17:52:13 +08:00
import {Message} from "element-ui";
import lodash from "lodash";
import {recruitStatus} from "@/common/dic";
import {Auditing} from "@/api/manage/mission";
2024-03-17 20:25:26 +08:00
const inviteCodeRules = {
stationId: [
2024-04-18 17:52:13 +08:00
{required: true, message: '请选择企业', trigger: 'blur'}
2024-03-17 20:25:26 +08:00
],
realName: [
2024-04-18 17:52:13 +08:00
{required: true, message: '请输入名称', trigger: 'blur'}
2024-03-17 20:25:26 +08:00
],
phone: [
2024-04-18 17:52:13 +08:00
{required: true, message: '请输入手机号', trigger: 'blur', pattern: /^1[3-9]{1}\d{9}/}
2024-03-17 20:25:26 +08:00
],
idNumber: [
2024-04-18 17:52:13 +08:00
{
required: true,
message: '请输入身份证',
trigger: 'blur',
pattern: /^[1-9]\d{5}(19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[1-2]\d|3[0-1])\d{3}[\dX]$/
}
2024-03-17 20:25:26 +08:00
],
}
const curdOptions = {
dateBtn: false,
addBtn: false,
2024-04-18 17:52:13 +08:00
tip: false,
2024-03-17 20:25:26 +08:00
editBtn: false,
delBtn: false,
height: "auto",
2024-04-19 14:58:16 +08:00
viewBtn: true,
2024-03-17 21:31:39 +08:00
border: true,
2024-03-17 20:25:26 +08:00
searchMenuSpan: 48,
2024-04-18 17:52:13 +08:00
selection: true,
2024-03-17 20:25:26 +08:00
index: true,
indexLabel: "序号",
2024-04-19 14:58:16 +08:00
dialogType: "drawer",
align: 'center',
2024-03-17 20:25:26 +08:00
column: [{
2024-03-31 18:53:57 +08:00
label: '机构名称',
2024-03-17 20:25:26 +08:00
prop: 'companyName',
search: true,
2024-04-18 17:52:13 +08:00
}, {
2024-03-31 18:53:57 +08:00
label: '企业名称',
prop: 'comname',
2024-03-17 20:25:26 +08:00
search: true,
2024-04-19 14:58:16 +08:00
}, {
label: '统一信用代码',
prop: 'companyId',
hide: true,
2024-04-18 17:52:13 +08:00
}, {
2024-03-31 18:53:57 +08:00
label: '绑定用户',
prop: 'realName',
},
2024-04-18 17:52:13 +08:00
{
label: '手机号',
prop: 'phone',
search: true,
}, {
label: '身份证',
prop: 'idNumber',
search: true,
formatter: (_, value, label) => value
},
2024-04-19 14:58:16 +08:00
{
label: '驳回原因',
prop: 'reviewMsg',
},
2024-04-18 17:52:13 +08:00
{
label: '启用状态',
prop: 'isEnabled',
2024-04-19 16:40:19 +08:00
type: 'select',
dicData: [
{label: '否', value: 0},
{label: '是', value: 1},
],
2024-04-18 17:52:13 +08:00
slot: true,
width: 100
2024-04-19 16:40:19 +08:00
},
{
2024-04-18 17:52:13 +08:00
label: '审核状态',
prop: 'reviewStatus',
width: 100,
type: 'select',
dicData: recruitStatus,
display: false,
2024-04-19 14:58:16 +08:00
},
{
label: '创建时间',
prop: 'createTime',
hide: true,
},
{
label: '创建用户',
prop: 'createUser',
hide: true,
}
]
2024-03-17 20:25:26 +08:00
}
const page = {
pageSize: 10,
currentPage: 1,
total: 0,
}
2024-04-18 17:52:13 +08:00
const message = lodash.throttle(
function (options) {
Message(options);
},
3000,
{trailing: false}
);
2024-03-17 15:19:08 +08:00
export default {
name: "manage_station_inviteCode",
2024-04-18 17:52:13 +08:00
data() {
2024-03-17 15:19:08 +08:00
return {
distributionCodeDialog: false,
2024-03-17 20:25:26 +08:00
inviteCodeRules: Object.assign({}, inviteCodeRules),
enterpriseList: [], // 企业列表
inviteCodeForm: {},
2024-04-18 17:52:13 +08:00
inviteCodeList: [],
selectionList: [],
2024-03-17 20:25:26 +08:00
option: Object.assign({}, curdOptions),
page: Object.assign({}, page),
searchData: {},
2024-03-29 16:02:57 +08:00
isEdit: false,
2024-04-18 17:52:13 +08:00
loading: false,
2024-03-17 20:25:26 +08:00
}
2024-03-17 15:19:08 +08:00
},
2024-04-10 15:36:23 +08:00
activated() {
2024-03-17 20:25:26 +08:00
this.getList() // 企业
2024-03-17 15:19:08 +08:00
},
2024-03-28 09:40:13 +08:00
computed: {
...mapGetters(["permission"]),
},
2024-04-18 17:52:13 +08:00
methods: {
handleCheck() {
let self = this
if (this.selectionList.length < 1) {
message({
type: "warning",
message: "请至少选择一条数据",
});
return;
}
let idList = this.selectionList.filter((item) => item.reviewStatus === 0).map((v) => v.id)
if (idList.length == 0) {
this.$message.error("只能提交【审核中】的任务");
} else {
let h = this.$createElement;
this.$prompt(
h("p", {style: "color: #F56C6C"}, "一旦驳回无法进行后续操作"),
2024-04-18 20:55:02 +08:00
"请核对企业信息后再进行审核通过",
2024-04-18 17:52:13 +08:00
{
distinguishCancelAndClose: true,
confirmButtonText: "通 过",
cancelButtonText: "驳 回",
type: "warning",
center: true,
inputType: "textarea",
inputPlaceholder: "备注驳回原因",
beforeClose: function (action, instance, done) {
if (action === 'cancel') {
if (!instance.inputValue) {
return this.$message({
type: "info",
message: "请输入驳回原因!",
});
}
self.handelFetchAuditing(idList, 9, instance.inputValue, "成功驳回, 操作成功!").then(() => done())
} else if (action === 'confirm') {
self.handelFetchAuditing(idList, 1, instance.inputValue).then(() => done())
} else {
done()
}
}
}
)
}
},
handelFetchAuditing(idList, reviewState, msg, message) {
return new Promise((resolve, reject) => {
let arr = idList.map((item) => ({
id: item,
reviewStatus: reviewState,
reviewMsg: msg || '',
}))
this.loading = true;
getInviteApproval(arr).then(() => {
this.loading = false;
this.onLoad();
this.$message({
type: message ? "info" : "success",
message: message || "审核通过,操作成功!",
});
resolve()
}).catch(() => {
this.loading = false;
reject()
});
})
},
2024-03-29 16:02:57 +08:00
rowUpdate(row) {
this.isEdit = true
this.distributionCodeDialog = true
this.inviteCodeForm = deepClone({
inviteCompanyId: row.inviteCompanyId,
phone: row.phone,
remarks: row.remarks,
id: row.id
})
},
rowDel(row) {
const h = this.$createElement;
this.$confirm(
h("div", null, [
2024-04-18 17:52:13 +08:00
h("p", {style: "font-size: 16px"}, "您确定要删除此消息吗? "),
h("p", {style: "color: red"}, "一旦删除则无法找回"),
2024-03-29 16:02:57 +08:00
]),
{
type: "warning",
showClose: false,
showCancelButton: true,
confirmButtonText: "确定",
cancelButtonText: "取消",
}
)
.then(() => {
2024-04-18 17:52:13 +08:00
return getInvitationStatusUpdate({id: row.id, isDeleted: 1});
2024-03-29 16:02:57 +08:00
})
.then(() => {
this.$message({
type: "success",
message: "操作成功!",
});
this.refreshChange();
})
2024-04-18 17:52:13 +08:00
.catch(() => {
});
},
selectionChange(list) {
this.selectionList = list;
2024-03-29 16:02:57 +08:00
},
2024-03-17 20:25:26 +08:00
async onLoad() {
this.getInvitationCode()
},
currentChange(page) {
this.page.currentPage = page
},
sizeChange(size) {
this.page.pageSize = size
},
async changeEnabled(row) {
const isEnabled = row.isEnabled ? 0 : 1
2024-04-18 17:52:13 +08:00
let params = {id: row.id, isEnabled}
2024-03-17 20:25:26 +08:00
console.log(params)
let resData = await getInvitationStatusUpdate(params)
2024-04-18 17:52:13 +08:00
if (resData.data.code === 200) {
2024-03-17 20:25:26 +08:00
this.$message.success('状态修改成功');
this.getInvitationCode()
}
2024-03-17 15:19:08 +08:00
},
2024-04-18 17:52:13 +08:00
refreshChange() {
2024-03-17 20:25:26 +08:00
this.getInvitationCode('refresh')
2024-03-17 15:19:08 +08:00
},
2024-03-17 20:25:26 +08:00
searchReset() {
this.searchData = {};
this.getInvitationCode('refresh')
2024-03-17 15:19:08 +08:00
},
2024-03-17 20:25:26 +08:00
searchChange(params, done) {
this.searchData = params;
this.getInvitationCode('refresh').then(() => done())
2024-03-17 15:19:08 +08:00
},
2024-03-17 20:25:26 +08:00
getInvitationCode(type = 'add') {
return new Promise(async (resolve, reject) => {
2024-04-18 17:52:13 +08:00
if (type === 'refresh') {
2024-03-17 20:25:26 +08:00
this.page.currentPage = 1
}
let params = {
...this.searchData,
current: this.page.currentPage,
size: this.page.pageSize,
}
2024-04-18 17:52:13 +08:00
this.loading = true
2024-03-17 20:25:26 +08:00
let resData = await getInvitationCodeList(params)
2024-04-18 17:52:13 +08:00
this.loading = false
if (resData.data.code === 200) {
const {size, records, current, total} = resData.data.data
2024-03-17 20:25:26 +08:00
this.inviteCodeList = records
2024-04-18 17:52:13 +08:00
this.page = {pageSize: size, currentPage: current, total}
2024-03-17 20:25:26 +08:00
resolve()
2024-03-17 15:19:08 +08:00
} else {
2024-03-17 20:25:26 +08:00
reject()
this.$message.error('拉取失败');
2024-03-17 15:19:08 +08:00
}
2024-03-17 20:25:26 +08:00
})
2024-03-17 15:19:08 +08:00
},
2024-03-17 20:25:26 +08:00
async inviteCodeSubmit() {
2024-03-29 16:02:57 +08:00
const companyName = this.enterpriseList.filter((item) => item.id === this.inviteCodeForm.inviteCompanyId)[0].comname;
2024-03-17 20:25:26 +08:00
let params = {
...this.inviteCodeForm,
2024-03-17 20:47:46 +08:00
companyName
2024-03-17 15:19:08 +08:00
}
2024-03-29 16:02:57 +08:00
let resData = null
2024-04-18 17:52:13 +08:00
if (this.isEdit) {
2024-03-29 16:02:57 +08:00
resData = await getInvitationStatusUpdate(params)
} else {
resData = await saveEnterpriseItem(params)
}
2024-04-18 17:52:13 +08:00
if (resData.data.code === 200) {
const {code, data} = resData.data
2024-03-17 20:25:26 +08:00
this.distributionCodeDialog = false
this.getInvitationCode('refresh')
this.$message.success('提交成功');
2024-03-17 15:19:08 +08:00
} else {
2024-03-17 20:25:26 +08:00
this.$message.error('创建失败');
2024-03-17 15:19:08 +08:00
}
},
2024-03-17 20:25:26 +08:00
async getList() {
let params = {}
let resData = await getEnterpriseList(params)
2024-04-18 17:52:13 +08:00
if (resData.data.code === 200) {
const {code, data} = resData.data
2024-03-17 20:25:26 +08:00
this.enterpriseList = data
}
}
}
}
2024-03-17 15:19:08 +08:00
</script>
2024-04-19 16:40:19 +08:00
<style scoped>
.drawer_content {
height: 100%;
width: 100%;
display: flex;
flex-direction: column;
justify-content: space-between;
}
2024-03-17 20:25:26 +08:00
2024-04-19 16:40:19 +08:00
.footer_btns {
display: flex;
justify-content: flex-end;
}
2024-03-17 15:19:08 +08:00
</style>