diff --git a/src/pages/view/hr/teacherProfile/PositionInfo.vue b/src/pages/view/hr/teacherProfile/PositionInfo.vue index e3b88db..ebd07cb 100644 --- a/src/pages/view/hr/teacherProfile/PositionInfo.vue +++ b/src/pages/view/hr/teacherProfile/PositionInfo.vue @@ -118,7 +118,7 @@ const schema = reactive([ const formIndex = attrs.index; if (formIndex !== undefined && education.xl[formIndex]) { // 获取当前表单项的结束时间 - const endTime = education.xl[formIndex].value.gwpyjssj; + const endTime = education.xl[formIndex].value.gwrzjstime; console.log("当前表单项数据:", education.xl[formIndex].value); // 计算任岗年限 const years = calculatePositionYears(e.value, endTime); @@ -142,7 +142,7 @@ const schema = reactive([ const formIndex = attrs.index; if (formIndex !== undefined && education.xl[formIndex]) { // 获取当前表单项的开始时间 - const startTime = education.xl[formIndex].value.gwrztime; + const startTime = education.xl[formIndex].value.gwrzkstime; console.log("当前表单项数据:", education.xl[formIndex].value); if (startTime) { // 计算任岗年限 @@ -211,25 +211,15 @@ if (getFile.rgqkList && getFile.rgqkList.length > 0) { return {value: item}; }); - // 回显数据后,重新计算所有任岗年限 + // 回显数据后,直接使用数据库返回的gwrznx值,不重新计算 nextTick(() => { education.xl.forEach((item: any, index: number) => { - if (item.value.gwrztime) { - const years = calculatePositionYears( - item.value.gwrztime, - item.value.gwpyjssj - ); - item.value.gwrznx = years; - console.log(`回显数据-表单项${index}计算结果:`, { - gwrztime: item.value.gwrztime, - gwpyjssj: item.value.gwpyjssj, - gwrznx: years, - 是否为0: years === "0" - }); - } else { - // 没有开始时间时,清空任岗年限 - item.value.gwrznx = ""; - } + console.log(`回显数据-表单项${index}数据:`, { + gwrzkstime: item.value.gwrzkstime, + gwrzjstime: item.value.gwrzjstime, + gwrznx: item.value.gwrznx, // 直接使用数据库返回的值 + 来源: "数据库回显" + }); }); // 强制重新渲染确保界面更新 forceUpdateKey.value++; @@ -239,15 +229,15 @@ if (getFile.rgqkList && getFile.rgqkList.length > 0) { // 手动触发计算所有项目的任岗年限 const calculateAllPositionYears = () => { education.xl.forEach((item: any, index: number) => { - if (item.value.gwrztime) { + if (item.value.gwrzkstime) { const years = calculatePositionYears( - item.value.gwrztime, - item.value.gwpyjssj + item.value.gwrzkstime, + item.value.gwrzjstime ); item.value.gwrznx = years; - console.log(`表单项${index}计算结果:`, { - gwrztime: item.value.gwrztime, - gwpyjssj: item.value.gwpyjssj, + console.log(`表单项${index}计算结果:`, { + gwrzkstime: item.value.gwrzkstime, + gwrzjstime: item.value.gwrzjstime, gwrznx: years, 是否为0: years === "0" }); @@ -285,11 +275,19 @@ function submit() { // 组件挂载完成后处理回显数据 onMounted(() => { - // 如果有回显数据,再次确保计算正确 + // 如果有回显数据,直接使用数据库返回的gwrznx值,不重新计算 if (getFile.rgqkList && getFile.rgqkList.length > 0) { nextTick(() => { - console.log("组件挂载后处理回显数据"); - calculateAllPositionYears(); + console.log("组件挂载后处理回显数据,直接使用数据库返回的gwrznx值"); + education.xl.forEach((item: any, index: number) => { + console.log(`挂载后-表单项${index}数据:`, { + gwrzkstime: item.value.gwrzkstime, + gwrzjstime: item.value.gwrzjstime, + gwrznx: item.value.gwrznx, // 直接使用数据库返回的值 + 来源: "数据库回显-挂载后" + }); + }); + forceUpdateKey.value++; }); } });