Files
ba_web/src/views/securityManagement/personnelManagement/practitioner/components/addPractitionerDialog.vue

177 lines
5.2 KiB
Vue
Raw Normal View History

2025-09-22 09:01:41 +08:00
<template>
<div class="dialog" v-if="dialogVisible">
<div class="head_box">
<span class="title">{{ title }}</span>
<div>
2025-09-22 19:00:02 +08:00
<el-button size="small" @click="save" type="primary" v-if="!disabled" :loading="loading">保存</el-button>
2025-09-22 09:01:41 +08:00
<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'>
<template #lzsj>
<el-input v-model="formData.lzsj" disabled placeholder="请选择离职时间"></el-input>
</template>
2025-09-22 09:01:41 +08:00
</FormMessage>
</div>
</div>
</template>
<script setup>
import { ref, computed, reactive, getCurrentInstance } from 'vue'
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_BZ_WHCD, D_BAXX_GWLX } = proxy.$dict("D_BZ_WHCD", "D_BAXX_GWLX");
2025-09-22 09:01:41 +08:00
const title = ref('新增从业人员')
const loading = ref(false)
const disabled = ref(false)
const FormRef = ref(null)
const props = defineProps({
modelValue: {
type: Boolean,
default: false
},
})
2025-09-24 20:32:05 +08:00
const emits = defineEmits(['update:modelValue', 'refresh'])
2025-09-22 09:01:41 +08:00
const dialogVisible = computed({
get() {
return props.modelValue
},
set(val) {
emits('update:modelValue', val)
}
})
const formList = reactive([
[
{ label: "姓名", prop: "xm", type: "input" },
2025-09-22 19:00:02 +08:00
{ label: "证件号码", prop: "sfzh", type: "input"},
2025-09-22 09:01:41 +08:00
{ label: "联系电话", prop: "lxdh", type: "input" },
{ label: "居住地址", prop: "jzdz", type: "input" },
],
[
{ label: "入职时间", prop: "rzsj", type: "date" },
{ label: "离职时间", prop: "lzsj", type: "slot" },
{ label: "文化程度", prop: "whcd", type: "select", options: D_BZ_WHCD },
2025-09-22 09:01:41 +08:00
{ label: "资格证编号", prop: "zgzbh", type: "input" },
],
[
2025-09-22 19:00:02 +08:00
{ label: "资格证类型", prop: "zgzlx", type: "input" },
2025-09-22 09:01:41 +08:00
{ label: "资格证起始日期", prop: "zgzKssj", type: "date" },
{ label: "资格证截至日期", prop: "zgzJssj", type: "date" },
2025-09-25 11:59:44 +08:00
{ label: "岗位", prop: "gw", type: "select", options: D_BAXX_GWLX },
2025-09-22 09:01:41 +08:00
],
[
{ label: "外派单位", prop: "wpdw", type: "input" },
2025-09-22 09:01:41 +08:00
],
2025-09-24 20:32:05 +08:00
{ label: "从业人员照片", prop: "tp", type: "upload", limit: 2 },
2025-09-22 19:00:02 +08:00
{ label: "保安证件", prop: "bazzp", type: "upload", limit: 1 },
2025-09-22 09:01:41 +08:00
])
const rules = {
xm: [{ required: true, message: "请输入姓名", trigger: "change" }],
sfzh: [
{ required: true, message: "请输入证件号码", trigger: "change" },
{
validator: (rule, value, callback) => {
if (!value) {
callback()
} else {
const reg = /^(\d{15}|\d{17}[\dXx])$/;
if (!reg.test(value)) {
callback(new Error("请输入正确的身份证号码"))
} else {
callback()
}
}
}
}
],
lxdh: [
{ required: true, message: "请输入联系电话", trigger: "change" },
{
validator: (rule, value, callback) => {
if (!value) {
callback()
} else {
const reg = /^1[34578]\d{9}$/
if (!reg.test(value)) {
callback(new Error("请输入正确的手机号"))
} else {
callback()
}
}
}
}
],
2025-09-22 09:01:41 +08:00
jzdz: [{ required: true, message: "请输入居住地址", trigger: "change" }],
rzsj: [{ required: true, message: "请选择入职时间", trigger: "change" }],
zgzbh: [{ required: true, message: "请输入资格证编号", trigger: "change" }],
gw: [{ required: true, message: "请输入岗位", trigger: "change" }],
wpdw: [{ required: true, message: "请输入外派单位", trigger: "change" }],
2025-09-22 09:01:41 +08:00
zgzlx: [{ required: true, message: "请输入资格证类型", trigger: "change" }],
zgzKssj: [{ required: true, message: "请选择资格证起始日期", trigger: "change" }],
zgzJssj: [{ required: true, message: "请选择资格证截至日期", trigger: "blur" }],
whcd: [{ required: true, message: "请选择文化程度", trigger: "change" }],
2025-09-22 09:01:41 +08:00
}
const formData = ref({})
const close = () => {
FormRef.value?.reset();
2025-09-22 09:01:41 +08:00
dialogVisible.value = false
}
const open = (row = {}, type = 'add') => {
dialogVisible.value = true
2025-09-22 18:11:34 +08:00
disabled.value = false
2025-09-22 09:01:41 +08:00
formData.value = { ...row }
if (type === 'add') {
title.value = '新增从业人员'
} else if (type === 'edit') {
title.value = '编辑从业人员'
} else {
2025-09-22 18:11:34 +08:00
disabled.value = true
2025-09-22 09:01:41 +08:00
title.value = '查看详情'
}
}
const save = () => {
FormRef.value.submit(() => {
loading.value = true;
const url = !formData.value?.id ? `/mosty-base/baxx/cyry/add` : `/mosty-base/baxx/cyry/edit`;
qcckPost(formData.value, url).then(() => {
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>