Files
ba_web/src/views/securityManagement/personnelManagement/applicantPersonnel/components/addTrainerDialog.vue

129 lines
4.4 KiB
Vue
Raw Normal View History

2025-09-22 17:25:44 +08:00
<template>
<div class="dialog" v-if="dialogVisible">
<div class="head_box">
<span class="title">{{ title }}</span>
<div>
<el-button v-if="!disabled" size="small" @click="save" type="primary" :loading="loading">保存</el-button>
<el-button size="small" @click="close">关闭</el-button>
</div>
</div>
<div class="cntinfo">
<FormMessage ref="FormRef" :disabled="disabled" v-model="formData" :rules="rules" :formList="formList" :labelWidth='120'>
2025-09-26 12:02:25 +08:00
<template #sqrq>
<el-date-picker type="datetime" v-model="formData.sqrq" placeholder="请输入申请时间" />
2025-09-26 11:24:25 +08:00
</template>
2025-09-22 17:25:44 +08:00
</FormMessage>
</div>
</div>
</template>
<script setup>
2025-09-26 16:08:38 +08:00
import * as rule from "@/utils/rules.js";
import { ref, reactive, getCurrentInstance } from 'vue'
2025-09-22 17:25:44 +08:00
import { qcckPost } from "@/api/qcckApi.js";
import FormMessage from '@/components/aboutTable/FormMessage.vue'
const { proxy } = getCurrentInstance()
2025-09-25 11:59:44 +08:00
const { D_BAXX_GWLX } = proxy.$dict("D_BAXX_GWLX")
2025-09-22 17:25:44 +08:00
const title = ref('新增培训人员')
const loading = ref(false)
const disabled = ref(false)
const FormRef = ref(null)
const props = defineProps({
dic: {
type: Object,
default: () => ({})
}
})
2025-09-26 16:08:38 +08:00
const formData = ref({})
const dialogVisible = ref(false)
const emits = defineEmits(['refresh'])
2025-09-22 17:25:44 +08:00
const formList = reactive([
[
{ label: "姓名", prop: "xm", type: "input" },
{ label: "证件号码", prop: "zjhm", type: "input"},
2025-09-22 17:25:44 +08:00
{ label: "联系电话", prop: "lxdh", type: "input" },
],
[
{ label: "居住地址", prop: "jzdz", type: "input" },
2025-09-26 12:02:25 +08:00
{ label: "申请时间", prop: "sqrq", type: "slot" },
2025-09-25 11:59:44 +08:00
{ label: "岗位", prop: "gw", type: "select", options: D_BAXX_GWLX },
2025-09-22 17:25:44 +08:00
],
[
{ label: "身份证正面", prop: "ryzpzm", type: "upload", limit: 1 },
{ label: "身份证反面", prop: "ryzpfm", type: "upload", limit: 1 },
2025-09-22 17:25:44 +08:00
],
[
2025-09-24 20:32:05 +08:00
{ label: "体检报告", prop: "tjbg", type: "upload", limit: 3 },
2025-09-22 17:25:44 +08:00
],
[
{ label: "无犯罪记录证明", prop: "wfzzmjl", type: "upload", limit: 1 },
2025-09-22 17:25:44 +08:00
]
])
const rules = {
2025-09-24 17:35:24 +08:00
ryzpzm: [{ required: true, message: "请上传身份证正面", trigger: "change" }],
ryzpfm: [{ required: true, message: "请上传身份证反面", trigger: "change" }],
2025-09-24 20:32:05 +08:00
tjbg: [{ required: true, message: "请上传体检报告", trigger: "change" }],
2025-09-24 17:35:24 +08:00
wfzzmjl: [{ required: true, message: "请上传无犯罪记录证明", trigger: "change" }],
2025-09-22 17:25:44 +08:00
xm: [{ required: true, message: "请输入姓名", trigger: "change" }],
2025-09-26 16:08:38 +08:00
...rule.phoneRule({ validator: true,message: "请输入联系电话",require: true }, "lxdh"), // 是否必填 是否进行校验`
...rule.identityCardRule({ validator: true,message: "请输入身份证号" ,require: true}, "zjhm"), // 是否必填 是否进行校验
2025-09-22 17:25:44 +08:00
jzdz: [{ required: true, message: "请输入居住地址", trigger: "change" }],
rzsj: [{ required: true, message: "请选择入职时间", trigger: "change" }],
pxgs: [{ required: true, message: "请选择所属保安公司", trigger: "change" }],
gw: [{ required: true, message: "请输入岗位", trigger: "change" }],
2025-09-22 17:25:44 +08:00
}
const close = () => {
2025-09-24 20:32:05 +08:00
FormRef.value?.reset()
2025-09-26 16:08:38 +08:00
dialogVisible.value = false;
2025-09-22 17:25:44 +08:00
}
const open = (row = {}, type = 'add') => {
2025-09-26 10:50:15 +08:00
const fieldsToSplit = ['ryzpzm', 'ryzpfm', 'tjbg', 'wfzzmjl'];
fieldsToSplit.forEach(field => {
2025-09-26 16:08:38 +08:00
row[field] = typeof row[field] === 'string' ? row[field].split(',') : row[field];
2025-09-26 10:50:15 +08:00
});
2025-09-22 17:25:44 +08:00
formData.value = { ...row }
2025-09-26 16:08:38 +08:00
title.value = type === 'add' ? '新增申请人员' : (type === 'upload' ? '上传资料' : '查看详情')
disabled.value = title.value === '查看详情' ? true : false;
dialogVisible.value = true;
2025-09-22 17:25:44 +08:00
}
// 新增、编辑
2025-09-22 17:25:44 +08:00
const save = () => {
FormRef.value.submit(() => {
loading.value = true;
const url = !formData.value?.id ? `/mosty-base/baxx/basq/add` : `/mosty-base/baxx/basq/edit`;
2025-09-26 10:50:15 +08:00
const params = { ...formData.value }
const fieldsToSplit = ['ryzpzm', 'ryzpfm', 'tjbg', 'wfzzmjl'];
2025-09-26 16:08:38 +08:00
fieldsToSplit.forEach(field => { params[field] = params[field] ? params[field].join(',') : ''; });
2025-09-26 10:50:15 +08:00
qcckPost(params, url).then(() => {
2025-09-22 17:25:44 +08:00
loading.value = false;
proxy.$message.success("保存成功");
emits("refresh");
close();
}).catch(() => {
loading.value = false;
})
});
}
defineExpose({ open })
</script>
<style lang="scss" scoped>
@import "@/assets/css/layout.scss";
.cntinfo{
height: calc(100% - 70px);
overflow: hidden;
overflow-y: auto;
}
.mapBox {
width: 100%;
height: 400px;
overflow: hidden;
}
</style>