This commit is contained in:
Net 2025-06-17 14:21:13 +08:00
parent 50de9f5794
commit 3287695f52

View File

@ -15,7 +15,7 @@
@click="deleteMemberFamily(index, item.value)" @click="deleteMemberFamily(index, item.value)"
class="delete-icon" class="delete-icon"
> >
<BasicIcon type="clear" size="30"/> <BasicIcon type="clear" size="30" />
</view> </view>
</view> </view>
</template> </template>
@ -31,12 +31,6 @@
</view> </view>
<template #bottom> <template #bottom>
<view class="flex-row items-center pb-10 pt-5"> <view class="flex-row items-center pb-10 pt-5">
<u-button
text="测试计算"
class="ml-15 mr-7"
:plain="true"
@click="calculateAllPositionYears"
/>
<u-button <u-button
text="上一步" text="上一步"
class="ml-15 mr-7" class="ml-15 mr-7"
@ -55,10 +49,10 @@
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import {dicApi} from "@/api/system/dic"; import { dicApi } from "@/api/system/dic";
import {useDataStore} from "@/store/modules/data"; import { useDataStore } from "@/store/modules/data";
import {navigateBack, navigateTo} from "@/utils/uniapp"; import { navigateBack, navigateTo } from "@/utils/uniapp";
import {cloneDeep, map} from "lodash"; import { cloneDeep, map } from "lodash";
import dayjs from "dayjs"; import dayjs from "dayjs";
// //
@ -67,7 +61,7 @@ const calculatePositionYears = (startDate: string, endDate?: string) => {
const start = dayjs(startDate); const start = dayjs(startDate);
const end = endDate ? dayjs(endDate) : dayjs(); const end = endDate ? dayjs(endDate) : dayjs();
const years = end.diff(start, "year"); const years = end.diff(start, "year");
console.log("计算任岗年限:", {startDate, endDate, years}); console.log("计算任岗年限:", { startDate, endDate, years });
// 0 // 0
return years.toString(); return years.toString();
}; };
@ -77,7 +71,7 @@ const forceUpdateKey = ref(0);
// //
const updatePositionYears = (itemValue: any) => { const updatePositionYears = (itemValue: any) => {
const {gwrztime, gwpyjssj} = itemValue; const { gwrztime, gwpyjssj } = itemValue;
if (gwrztime) { if (gwrztime) {
const years = calculatePositionYears(gwrztime, gwpyjssj); const years = calculatePositionYears(gwrztime, gwpyjssj);
itemValue.gwrznx = years; itemValue.gwrznx = years;
@ -91,7 +85,7 @@ const schema = reactive<FormsSchema[]>([
component: "BasicPicker", component: "BasicPicker",
componentProps: { componentProps: {
api: dicApi, api: dicApi,
param: {pid: 260783972}, param: { pid: 260783972 },
rangeKey: "dictionaryValue", rangeKey: "dictionaryValue",
savaKey: "dictionaryCode", savaKey: "dictionaryCode",
}, },
@ -102,7 +96,7 @@ const schema = reactive<FormsSchema[]>([
component: "BasicPicker", component: "BasicPicker",
componentProps: { componentProps: {
api: dicApi, api: dicApi,
param: {pid: 434953981}, param: { pid: 434953981 },
rangeKey: "dictionaryValue", rangeKey: "dictionaryValue",
savaKey: "dictionaryCode", savaKey: "dictionaryCode",
}, },
@ -124,7 +118,10 @@ const schema = reactive<FormsSchema[]>([
const years = calculatePositionYears(e.value, endTime); const years = calculatePositionYears(e.value, endTime);
// //
education.xl[formIndex].value.gwrznx = years; education.xl[formIndex].value.gwrznx = years;
console.log("更新后的任岗年限:", education.xl[formIndex].value.gwrznx); console.log(
"更新后的任岗年限:",
education.xl[formIndex].value.gwrznx
);
// //
forceUpdateKey.value++; forceUpdateKey.value++;
} }
@ -149,7 +146,10 @@ const schema = reactive<FormsSchema[]>([
const years = calculatePositionYears(startTime, e.value); const years = calculatePositionYears(startTime, e.value);
// //
education.xl[formIndex].value.gwrznx = years; education.xl[formIndex].value.gwrznx = years;
console.log("更新后的任岗年限:", education.xl[formIndex].value.gwrznx); console.log(
"更新后的任岗年限:",
education.xl[formIndex].value.gwrznx
);
// //
forceUpdateKey.value++; forceUpdateKey.value++;
} }
@ -202,13 +202,13 @@ const schema = reactive<FormsSchema[]>([
]); ]);
const education = reactive<any>({ const education = reactive<any>({
xl: [{value: {}}], xl: [{ value: {} }],
}); });
const {getFile, setFile} = useDataStore(); const { getFile, setFile } = useDataStore();
if (getFile.rgqkList && getFile.rgqkList.length > 0) { if (getFile.rgqkList && getFile.rgqkList.length > 0) {
education.xl = map(getFile.rgqkList, (item) => { education.xl = map(getFile.rgqkList, (item) => {
return {value: item}; return { value: item };
}); });
// 使gwrznx // 使gwrznx
@ -218,7 +218,7 @@ if (getFile.rgqkList && getFile.rgqkList.length > 0) {
gwrzkstime: item.value.gwrzkstime, gwrzkstime: item.value.gwrzkstime,
gwrzjstime: item.value.gwrzjstime, gwrzjstime: item.value.gwrzjstime,
gwrznx: item.value.gwrznx, // 使 gwrznx: item.value.gwrznx, // 使
来源: "数据库回显" 来源: "数据库回显",
}); });
}); });
// //
@ -239,7 +239,7 @@ const calculateAllPositionYears = () => {
gwrzkstime: item.value.gwrzkstime, gwrzkstime: item.value.gwrzkstime,
gwrzjstime: item.value.gwrzjstime, gwrzjstime: item.value.gwrzjstime,
gwrznx: years, gwrznx: years,
是否为0: years === "0" 是否为0: years === "0",
}); });
} else { } else {
// //
@ -250,7 +250,7 @@ const calculateAllPositionYears = () => {
}; };
function addEducation() { function addEducation() {
education.xl.push({value: {}}); education.xl.push({ value: {} });
// //
forceUpdateKey.value++; forceUpdateKey.value++;
} }
@ -284,7 +284,7 @@ onMounted(() => {
gwrzkstime: item.value.gwrzkstime, gwrzkstime: item.value.gwrzkstime,
gwrzjstime: item.value.gwrzjstime, gwrzjstime: item.value.gwrzjstime,
gwrznx: item.value.gwrznx, // 使 gwrznx: item.value.gwrznx, // 使
来源: "数据库回显-挂载后" 来源: "数据库回显-挂载后",
}); });
}); });
forceUpdateKey.value++; forceUpdateKey.value++;