修复相关bug
This commit is contained in:
@@ -256,7 +256,7 @@
|
|||||||
<span class="block-subtitle">勾选入职时要求候选人必须或可选上传的证件材料(如身份证、毕业证、体检表等)</span>
|
<span class="block-subtitle">勾选入职时要求候选人必须或可选上传的证件材料(如身份证、毕业证、体检表等)</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-table :data="materialTypes" border stripe height="240px" class="mt-2">
|
<el-table :data="enabledMaterialTypes" border stripe height="240px" class="mt-2">
|
||||||
<el-table-column label="选择要求" width="85" align="center">
|
<el-table-column label="选择要求" width="85" align="center">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-checkbox :model-value="hasMaterial(scope.row.id)"
|
<el-checkbox :model-value="hasMaterial(scope.row.id)"
|
||||||
@@ -293,7 +293,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { onMounted, reactive, ref } from "vue";
|
import { computed, onMounted, reactive, ref } from "vue";
|
||||||
import { ElMessage, ElMessageBox } from "element-plus";
|
import { ElMessage, ElMessageBox } from "element-plus";
|
||||||
import {
|
import {
|
||||||
OnboardingCompany,
|
OnboardingCompany,
|
||||||
@@ -324,6 +324,9 @@ const departments = ref<OnboardingDepartmentOption[]>([]);
|
|||||||
const positions = ref<OnboardingPosition[]>([]);
|
const positions = ref<OnboardingPosition[]>([]);
|
||||||
const contractTemplates = ref<OnboardingContractTemplate[]>([]);
|
const contractTemplates = ref<OnboardingContractTemplate[]>([]);
|
||||||
const materialTypes = ref<OnboardingMaterialType[]>([]);
|
const materialTypes = ref<OnboardingMaterialType[]>([]);
|
||||||
|
const enabledMaterialTypes = computed(() =>
|
||||||
|
materialTypes.value.filter(item => item.status === "enable")
|
||||||
|
);
|
||||||
const versionOptions = reactive<Record<number, OnboardingContractVersion[]>>({});
|
const versionOptions = reactive<Record<number, OnboardingContractVersion[]>>({});
|
||||||
|
|
||||||
const query = reactive({
|
const query = reactive({
|
||||||
@@ -597,6 +600,17 @@ async function openEdit(row: OnboardingTemplate) {
|
|||||||
}))
|
}))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const enabledMaterialIds = new Set(enabledMaterialTypes.value.map(item => item.id));
|
||||||
|
const disabledMaterials = materialTypes.value.filter(item =>
|
||||||
|
item.status !== "enable" && form.materials.some(config => config.materialTypeId === item.id)
|
||||||
|
);
|
||||||
|
form.materials = form.materials.filter(item => enabledMaterialIds.has(item.materialTypeId));
|
||||||
|
if (disabledMaterials.length > 0) {
|
||||||
|
ElMessage.warning(
|
||||||
|
`该模板原来关联的停用资料“${disabledMaterials.map(item => item.materialName).join("、")}”已从本次配置中移除,保存后生效`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (form.companyId) {
|
if (form.companyId) {
|
||||||
const departmentRes = await onboardingTaskApi.listDepartments(form.companyId);
|
const departmentRes = await onboardingTaskApi.listDepartments(form.companyId);
|
||||||
departments.value = departmentRes.data || [];
|
departments.value = departmentRes.data || [];
|
||||||
|
|||||||
@@ -714,6 +714,7 @@ const contracts = ref<any[]>([]);
|
|||||||
const materialRequirements = ref<any[]>([]);
|
const materialRequirements = ref<any[]>([]);
|
||||||
const uploadedMaterials = ref<any[]>([]);
|
const uploadedMaterials = ref<any[]>([]);
|
||||||
const contractVariables = ref<any[]>([]);
|
const contractVariables = ref<any[]>([]);
|
||||||
|
const formFieldRequirements = ref<any[]>([]);
|
||||||
|
|
||||||
const regFormRef = ref<FormInstance>();
|
const regFormRef = ref<FormInstance>();
|
||||||
|
|
||||||
@@ -878,7 +879,7 @@ function validateBirthday(_rule: any, value: unknown, callback: (error?: Error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function validateBankCardNumber(_rule: any, value: unknown, callback: (error?: Error) => void) {
|
function validateBankCardNumber(_rule: any, value: unknown, callback: (error?: Error) => void) {
|
||||||
if (!isBankCardNumber(value)) {
|
if (value && !isBankCardNumber(value)) {
|
||||||
return callback(new Error("请输入12至19位银行卡号"));
|
return callback(new Error("请输入12至19位银行卡号"));
|
||||||
}
|
}
|
||||||
callback();
|
callback();
|
||||||
@@ -912,23 +913,83 @@ function validateOptionalContactPhone(_rule: any, value: unknown, callback: (err
|
|||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 固定登记表字段在前端即时校验;后端仍会执行相同的核心规则作为安全兜底。
|
/** 将 employee.EmployeeName 转为登记表模型使用的 employeeName。 */
|
||||||
const regRules: FormRules = {
|
function getRegistrationFieldKey(fieldCode: unknown) {
|
||||||
employeeName: [{ required: true, validator: validateEmployeeName, trigger: "blur" }],
|
const code = String(fieldCode || "").trim();
|
||||||
gender: [{ required: true, message: "请选择性别", trigger: "change" }],
|
if (!code.toLowerCase().startsWith("employee.")) {
|
||||||
birthday: [{ validator: validateBirthday, trigger: "change" }],
|
return "";
|
||||||
height: [{ validator: validateOptionalHeight, trigger: "blur" }],
|
}
|
||||||
weight: [{ validator: validateOptionalWeight, trigger: "blur" }],
|
|
||||||
phone: [{ required: true, validator: validatePhone, trigger: "blur" }],
|
const propertyName = code.substring(code.lastIndexOf(".") + 1);
|
||||||
email: [{ validator: validateOptionalEmail, trigger: "blur" }],
|
return propertyName
|
||||||
idCardNumber: [{ required: true, validator: validateIdCardNumber, trigger: "blur" }],
|
? propertyName.charAt(0).toLowerCase() + propertyName.slice(1)
|
||||||
bankCardNumber: [{ required: true, validator: validateBankCardNumber, trigger: "blur" }],
|
: "";
|
||||||
bankName: [
|
}
|
||||||
{ required: true, message: "请输入开户银行名称", trigger: "blur" },
|
|
||||||
{ max: 100, message: "开户银行名称不能超过100个字符", trigger: "blur" }
|
const requiredRegistrationFields = computed(() => {
|
||||||
],
|
const result = new Map<string, any>();
|
||||||
emergencyPhone: [{ validator: validateOptionalContactPhone, trigger: "blur" }]
|
formFieldRequirements.value.forEach(requirement => {
|
||||||
};
|
const fieldKey = getRegistrationFieldKey(requirement.fieldCode);
|
||||||
|
if (!fieldKey || !(fieldKey in form)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const existing = result.get(fieldKey);
|
||||||
|
if (!existing || requirement.required) {
|
||||||
|
result.set(fieldKey, requirement);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
});
|
||||||
|
|
||||||
|
function appendRegistrationRule(rules: FormRules, fieldKey: string, rule: any) {
|
||||||
|
const existingRules = rules[fieldKey];
|
||||||
|
const fieldRules = Array.isArray(existingRules)
|
||||||
|
? existingRules
|
||||||
|
: existingRules
|
||||||
|
? [existingRules]
|
||||||
|
: [];
|
||||||
|
rules[fieldKey] = [...fieldRules, rule];
|
||||||
|
}
|
||||||
|
|
||||||
|
// 固定登记表必填状态读取任务快照;姓名、身份证和手机号仍是电子签约的系统必填项。
|
||||||
|
const regRules = computed<FormRules>(() => {
|
||||||
|
const rules: FormRules = {};
|
||||||
|
const changeTriggerFields = new Set(["gender", "birthday", "maritalStatus", "education"]);
|
||||||
|
|
||||||
|
requiredRegistrationFields.value.forEach((requirement, fieldKey) => {
|
||||||
|
if (!requirement.required) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const useChangeTrigger = changeTriggerFields.has(fieldKey);
|
||||||
|
rules[fieldKey] = [{
|
||||||
|
required: true,
|
||||||
|
message: `${useChangeTrigger ? "请选择" : "请填写"}${requirement.fieldName || fieldKey}`,
|
||||||
|
trigger: useChangeTrigger ? "change" : "blur"
|
||||||
|
}];
|
||||||
|
});
|
||||||
|
|
||||||
|
rules.employeeName = [{ required: true, validator: validateEmployeeName, trigger: "blur" }];
|
||||||
|
rules.phone = [{ required: true, validator: validatePhone, trigger: "blur" }];
|
||||||
|
rules.idCardNumber = [{ required: true, validator: validateIdCardNumber, trigger: "blur" }];
|
||||||
|
appendRegistrationRule(rules, "birthday", { validator: validateBirthday, trigger: "change" });
|
||||||
|
appendRegistrationRule(rules, "height", { validator: validateOptionalHeight, trigger: "blur" });
|
||||||
|
appendRegistrationRule(rules, "weight", { validator: validateOptionalWeight, trigger: "blur" });
|
||||||
|
appendRegistrationRule(rules, "email", { validator: validateOptionalEmail, trigger: "blur" });
|
||||||
|
appendRegistrationRule(rules, "bankCardNumber", { validator: validateBankCardNumber, trigger: "blur" });
|
||||||
|
appendRegistrationRule(rules, "bankName", {
|
||||||
|
max: 100,
|
||||||
|
message: "开户银行名称不能超过100个字符",
|
||||||
|
trigger: "blur"
|
||||||
|
});
|
||||||
|
appendRegistrationRule(rules, "emergencyPhone", {
|
||||||
|
validator: validateOptionalContactPhone,
|
||||||
|
trigger: "blur"
|
||||||
|
});
|
||||||
|
|
||||||
|
return rules;
|
||||||
|
});
|
||||||
|
|
||||||
/** 根据当前 Token 的实际有效期实时锁定已打开的填写页面。 */
|
/** 根据当前 Token 的实际有效期实时锁定已打开的填写页面。 */
|
||||||
const isLinkExpired = computed(() => {
|
const isLinkExpired = computed(() => {
|
||||||
@@ -1286,6 +1347,7 @@ async function load(silent = false) {
|
|||||||
materialRequirements.value = data.materialRequirements || [];
|
materialRequirements.value = data.materialRequirements || [];
|
||||||
uploadedMaterials.value = data.materials || [];
|
uploadedMaterials.value = data.materials || [];
|
||||||
contractVariables.value = data.contractVariables || [];
|
contractVariables.value = data.contractVariables || [];
|
||||||
|
formFieldRequirements.value = data.formFields || [];
|
||||||
contractVariables.value.forEach((variable: any) => {
|
contractVariables.value.forEach((variable: any) => {
|
||||||
if (!(variable.variableCode in customVariables) && variable.defaultValue != null) {
|
if (!(variable.variableCode in customVariables) && variable.defaultValue != null) {
|
||||||
customVariables[variable.variableCode] = String(variable.defaultValue);
|
customVariables[variable.variableCode] = String(variable.defaultValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user