|
|
@@ -1770,6 +1770,9 @@ import { apiBaseUrl } from '@/common/config.js';
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ // 在提交前检查并自动保存所有未保存的表单
|
|
|
+ this.autoSaveAllUnsavedForms();
|
|
|
+
|
|
|
// 验证所有必填字段
|
|
|
const allRequired = [
|
|
|
'name', 'gender', 'phone', 'idCard', 'ethnic', 'currentAddress'
|
|
|
@@ -2234,6 +2237,15 @@ import { apiBaseUrl } from '@/common/config.js';
|
|
|
break;
|
|
|
|
|
|
case 3: // 家庭成员
|
|
|
+ // 检查是否有未保存的家庭成员表单
|
|
|
+ if (this.hasUnsavedFamilyMemberForm()) {
|
|
|
+ // 尝试自动保存
|
|
|
+ if (!this.autoSaveFamilyMember()) {
|
|
|
+ isValid = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
console.log(this.familyMembers.length);
|
|
|
if (this.familyMembers.length == 0) {
|
|
|
uni.showToast({
|
|
|
@@ -2245,6 +2257,15 @@ import { apiBaseUrl } from '@/common/config.js';
|
|
|
break;
|
|
|
|
|
|
case 5: // 教育经历
|
|
|
+ // 检查是否有未保存的教育经历表单
|
|
|
+ if (this.hasUnsavedEducationForm()) {
|
|
|
+ // 尝试自动保存
|
|
|
+ if (!this.autoSaveEducation()) {
|
|
|
+ isValid = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (this.educationList.length === 0) {
|
|
|
uni.showToast({
|
|
|
title: '请至少添加一项教育经历',
|
|
|
@@ -2266,6 +2287,15 @@ import { apiBaseUrl } from '@/common/config.js';
|
|
|
break;
|
|
|
|
|
|
case 8: // 工作经历
|
|
|
+ // 检查是否有未保存的工作经历表单
|
|
|
+ if (this.hasUnsavedWorkForm()) {
|
|
|
+ // 尝试自动保存
|
|
|
+ if (!this.autoSaveWork()) {
|
|
|
+ isValid = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
if (this.workList.length === 0) {
|
|
|
uni.showToast({
|
|
|
title: '请至少添加一项工作经历',
|
|
|
@@ -2614,6 +2644,251 @@ import { apiBaseUrl } from '@/common/config.js';
|
|
|
} else {
|
|
|
this.formErrors.phone = '';
|
|
|
}
|
|
|
+ },
|
|
|
+
|
|
|
+ // 检查是否有未保存的家庭成员表单
|
|
|
+ hasUnsavedFamilyMemberForm() {
|
|
|
+ return this.familyMemberForm.relation ||
|
|
|
+ this.familyMemberForm.name ||
|
|
|
+ this.familyMemberForm.workplaceOrAddress ||
|
|
|
+ this.familyMemberForm.position ||
|
|
|
+ this.familyMemberForm.phone;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 检查是否有未保存的教育经历表单
|
|
|
+ hasUnsavedEducationForm() {
|
|
|
+ return this.educationForm.startTime ||
|
|
|
+ this.educationForm.endTime ||
|
|
|
+ this.educationForm.schoolName ||
|
|
|
+ this.educationForm.major ||
|
|
|
+ this.educationForm.degree;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 检查是否有未保存的工作经历表单
|
|
|
+ hasUnsavedWorkForm() {
|
|
|
+ return this.workForm.startTime ||
|
|
|
+ this.workForm.endTime ||
|
|
|
+ this.workForm.companyName ||
|
|
|
+ this.workForm.department ||
|
|
|
+ this.workForm.position ||
|
|
|
+ this.workForm.employeeCount ||
|
|
|
+ this.workForm.monthlySalary ||
|
|
|
+ this.workForm.supervisor ||
|
|
|
+ this.workForm.supervisorPhone;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 自动保存家庭成员
|
|
|
+ autoSaveFamilyMember() {
|
|
|
+ // 重置错误信息
|
|
|
+ this.resetFamilyMemberErrors();
|
|
|
+
|
|
|
+ // 验证必填字段
|
|
|
+ let isValid = true;
|
|
|
+
|
|
|
+ // 只验证显示的字段
|
|
|
+ if (this.shouldValidateField('relation', 'family') && !this.familyMemberForm.relation) {
|
|
|
+ this.familyMemberErrors.relation = '请输入称谓';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('name', 'family') && !this.familyMemberForm.name) {
|
|
|
+ this.familyMemberErrors.name = '请输入姓名';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isValid) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请完善家庭成员必填信息',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动保存逻辑
|
|
|
+ if (this.isEditing) {
|
|
|
+ this.familyMembers[this.editingIndex] = {...this.familyMemberForm};
|
|
|
+ this.isEditing = false;
|
|
|
+ this.editingIndex = -1;
|
|
|
+ } else {
|
|
|
+ this.familyMembers.push({...this.familyMemberForm});
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置表单
|
|
|
+ this.resetFamilyMemberForm();
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: '已自动保存',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 自动保存教育经历
|
|
|
+ autoSaveEducation() {
|
|
|
+ // 重置错误信息
|
|
|
+ this.resetEducationErrors();
|
|
|
+
|
|
|
+ // 验证必填字段
|
|
|
+ let isValid = true;
|
|
|
+
|
|
|
+ // 只验证显示的字段
|
|
|
+ if (this.shouldValidateField('startTime', 'education') && !this.educationForm.startTime) {
|
|
|
+ this.educationErrors.startTime = '请选择开始时间';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('endTime', 'education') && !this.educationForm.endTime) {
|
|
|
+ this.educationErrors.endTime = '请选择结束时间';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('schoolName', 'education') && !this.educationForm.schoolName) {
|
|
|
+ this.educationErrors.schoolName = '请输入学校名称';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('major', 'education') && !this.educationForm.major) {
|
|
|
+ this.educationErrors.major = '请输入专业';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('degree', 'education') && !this.educationForm.degree) {
|
|
|
+ this.educationErrors.degree = '请选择学历';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isValid) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请完善教育经历必填信息',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动保存逻辑
|
|
|
+ if (this.isEditingEducation) {
|
|
|
+ this.educationList[this.editingEducationIndex] = {...this.educationForm};
|
|
|
+ this.isEditingEducation = false;
|
|
|
+ this.editingEducationIndex = -1;
|
|
|
+ } else {
|
|
|
+ this.educationList.push({...this.educationForm});
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置表单
|
|
|
+ this.educationForm = {
|
|
|
+ startTime: '',
|
|
|
+ endTime: '',
|
|
|
+ schoolName: '',
|
|
|
+ major: '',
|
|
|
+ degree: ''
|
|
|
+ };
|
|
|
+ this.degreeIndex = -1;
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: '已自动保存',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 自动保存工作经历
|
|
|
+ autoSaveWork() {
|
|
|
+ // 重置所有工作经历相关的错误信息
|
|
|
+ this.workErrors = {
|
|
|
+ startTime: '',
|
|
|
+ endTime: '',
|
|
|
+ companyName: '',
|
|
|
+ department: '',
|
|
|
+ position: '',
|
|
|
+ employeeCount: '',
|
|
|
+ monthlySalary: '',
|
|
|
+ supervisor: '',
|
|
|
+ supervisorPhone: ''
|
|
|
+ };
|
|
|
+
|
|
|
+ // 验证必填字段
|
|
|
+ let isValid = true;
|
|
|
+
|
|
|
+ // 只验证显示的字段
|
|
|
+ if (this.shouldValidateField('startTime', 'work') && !this.workForm.startTime) {
|
|
|
+ this.workErrors.startTime = '请选择开始时间';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('endTime', 'work') && !this.workForm.endTime) {
|
|
|
+ this.workErrors.endTime = '请选择结束时间';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('companyName', 'work') && !this.workForm.companyName) {
|
|
|
+ this.workErrors.companyName = '请输入单位名称';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (this.shouldValidateField('employeeCount', 'work') && !this.workForm.employeeCount) {
|
|
|
+ this.workErrors.employeeCount = '请输入单位人数';
|
|
|
+ isValid = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!isValid) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请完善工作经历必填信息',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 自动保存逻辑
|
|
|
+ if (this.isEditingWork) {
|
|
|
+ this.workList[this.editingWorkIndex] = {...this.workForm};
|
|
|
+ this.isEditingWork = false;
|
|
|
+ this.editingWorkIndex = -1;
|
|
|
+ } else {
|
|
|
+ this.workList.push({...this.workForm});
|
|
|
+ }
|
|
|
+
|
|
|
+ // 重置表单
|
|
|
+ this.workForm = {
|
|
|
+ startTime: '',
|
|
|
+ endTime: '',
|
|
|
+ companyName: '',
|
|
|
+ department: '',
|
|
|
+ employeeCount: '',
|
|
|
+ position: '',
|
|
|
+ monthlySalary: '',
|
|
|
+ supervisor: '',
|
|
|
+ supervisorPhone: ''
|
|
|
+ };
|
|
|
+
|
|
|
+ uni.showToast({
|
|
|
+ title: '已自动保存',
|
|
|
+ icon: 'success',
|
|
|
+ duration: 1500
|
|
|
+ });
|
|
|
+
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+
|
|
|
+ // 自动保存所有未保存的表单
|
|
|
+ autoSaveAllUnsavedForms() {
|
|
|
+ // 检查并自动保存家庭成员表单
|
|
|
+ if (this.hasUnsavedFamilyMemberForm()) {
|
|
|
+ this.autoSaveFamilyMember();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查并自动保存教育经历表单
|
|
|
+ if (this.hasUnsavedEducationForm()) {
|
|
|
+ this.autoSaveEducation();
|
|
|
+ }
|
|
|
+
|
|
|
+ // 检查并自动保存工作经历表单
|
|
|
+ if (this.hasUnsavedWorkForm()) {
|
|
|
+ this.autoSaveWork();
|
|
|
+ }
|
|
|
}
|
|
|
},
|
|
|
// 添加监听器来清除错误信息
|