提交1
This commit is contained in:
parent
253ac80c88
commit
50de9f5794
@ -118,7 +118,7 @@ const schema = reactive<FormsSchema[]>([
|
|||||||
const formIndex = attrs.index;
|
const formIndex = attrs.index;
|
||||||
if (formIndex !== undefined && education.xl[formIndex]) {
|
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);
|
console.log("当前表单项数据:", education.xl[formIndex].value);
|
||||||
// 计算任岗年限
|
// 计算任岗年限
|
||||||
const years = calculatePositionYears(e.value, endTime);
|
const years = calculatePositionYears(e.value, endTime);
|
||||||
@ -142,7 +142,7 @@ const schema = reactive<FormsSchema[]>([
|
|||||||
const formIndex = attrs.index;
|
const formIndex = attrs.index;
|
||||||
if (formIndex !== undefined && education.xl[formIndex]) {
|
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);
|
console.log("当前表单项数据:", education.xl[formIndex].value);
|
||||||
if (startTime) {
|
if (startTime) {
|
||||||
// 计算任岗年限
|
// 计算任岗年限
|
||||||
@ -211,25 +211,15 @@ if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
|||||||
return {value: item};
|
return {value: item};
|
||||||
});
|
});
|
||||||
|
|
||||||
// 回显数据后,重新计算所有任岗年限
|
// 回显数据后,直接使用数据库返回的gwrznx值,不重新计算
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
education.xl.forEach((item: any, index: number) => {
|
education.xl.forEach((item: any, index: number) => {
|
||||||
if (item.value.gwrztime) {
|
console.log(`回显数据-表单项${index}数据:`, {
|
||||||
const years = calculatePositionYears(
|
gwrzkstime: item.value.gwrzkstime,
|
||||||
item.value.gwrztime,
|
gwrzjstime: item.value.gwrzjstime,
|
||||||
item.value.gwpyjssj
|
gwrznx: item.value.gwrznx, // 直接使用数据库返回的值
|
||||||
);
|
来源: "数据库回显"
|
||||||
item.value.gwrznx = years;
|
|
||||||
console.log(`回显数据-表单项${index}计算结果:`, {
|
|
||||||
gwrztime: item.value.gwrztime,
|
|
||||||
gwpyjssj: item.value.gwpyjssj,
|
|
||||||
gwrznx: years,
|
|
||||||
是否为0: years === "0"
|
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
// 没有开始时间时,清空任岗年限
|
|
||||||
item.value.gwrznx = "";
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
// 强制重新渲染确保界面更新
|
// 强制重新渲染确保界面更新
|
||||||
forceUpdateKey.value++;
|
forceUpdateKey.value++;
|
||||||
@ -239,15 +229,15 @@ if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
|||||||
// 手动触发计算所有项目的任岗年限
|
// 手动触发计算所有项目的任岗年限
|
||||||
const calculateAllPositionYears = () => {
|
const calculateAllPositionYears = () => {
|
||||||
education.xl.forEach((item: any, index: number) => {
|
education.xl.forEach((item: any, index: number) => {
|
||||||
if (item.value.gwrztime) {
|
if (item.value.gwrzkstime) {
|
||||||
const years = calculatePositionYears(
|
const years = calculatePositionYears(
|
||||||
item.value.gwrztime,
|
item.value.gwrzkstime,
|
||||||
item.value.gwpyjssj
|
item.value.gwrzjstime
|
||||||
);
|
);
|
||||||
item.value.gwrznx = years;
|
item.value.gwrznx = years;
|
||||||
console.log(`表单项${index}计算结果:`, {
|
console.log(`表单项${index}计算结果:`, {
|
||||||
gwrztime: item.value.gwrztime,
|
gwrzkstime: item.value.gwrzkstime,
|
||||||
gwpyjssj: item.value.gwpyjssj,
|
gwrzjstime: item.value.gwrzjstime,
|
||||||
gwrznx: years,
|
gwrznx: years,
|
||||||
是否为0: years === "0"
|
是否为0: years === "0"
|
||||||
});
|
});
|
||||||
@ -285,11 +275,19 @@ function submit() {
|
|||||||
|
|
||||||
// 组件挂载完成后处理回显数据
|
// 组件挂载完成后处理回显数据
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
// 如果有回显数据,再次确保计算正确
|
// 如果有回显数据,直接使用数据库返回的gwrznx值,不重新计算
|
||||||
if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
console.log("组件挂载后处理回显数据");
|
console.log("组件挂载后处理回显数据,直接使用数据库返回的gwrznx值");
|
||||||
calculateAllPositionYears();
|
education.xl.forEach((item: any, index: number) => {
|
||||||
|
console.log(`挂载后-表单项${index}数据:`, {
|
||||||
|
gwrzkstime: item.value.gwrzkstime,
|
||||||
|
gwrzjstime: item.value.gwrzjstime,
|
||||||
|
gwrznx: item.value.gwrznx, // 直接使用数据库返回的值
|
||||||
|
来源: "数据库回显-挂载后"
|
||||||
|
});
|
||||||
|
});
|
||||||
|
forceUpdateKey.value++;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user