提交1
This commit is contained in:
parent
50de9f5794
commit
3287695f52
@ -5,25 +5,25 @@
|
|||||||
<template v-for="(item, index) in education.xl" :key="index">
|
<template v-for="(item, index) in education.xl" :key="index">
|
||||||
<view class="po-re mb-15">
|
<view class="po-re mb-15">
|
||||||
<BasicForm
|
<BasicForm
|
||||||
:index="index"
|
:index="index"
|
||||||
v-model="item.value"
|
v-model="item.value"
|
||||||
:schema="schema"
|
:schema="schema"
|
||||||
:key="`form-${index}-${forceUpdateKey}`"
|
:key="`form-${index}-${forceUpdateKey}`"
|
||||||
:formsProps="{ labelWidth: 100 }"
|
:formsProps="{ labelWidth: 100 }"
|
||||||
/>
|
/>
|
||||||
<view
|
<view
|
||||||
@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>
|
||||||
</view>
|
</view>
|
||||||
<view
|
<view
|
||||||
class="flex-row items-center justify-center pb-10 pt-5"
|
class="flex-row items-center justify-center pb-10 pt-5"
|
||||||
style="border: 1px solid #e8e8e8"
|
style="border: 1px solid #e8e8e8"
|
||||||
@click="addEducation"
|
@click="addEducation"
|
||||||
>
|
>
|
||||||
<uni-icons type="plus" size="16" color="#447ADE"></uni-icons>
|
<uni-icons type="plus" size="16" color="#447ADE"></uni-icons>
|
||||||
<view class="ml-5 cor-447ADE">新增</view>
|
<view class="ml-5 cor-447ADE">新增</view>
|
||||||
@ -32,22 +32,16 @@
|
|||||||
<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
|
<u-button
|
||||||
text="测试计算"
|
text="上一步"
|
||||||
class="ml-15 mr-7"
|
class="ml-15 mr-7"
|
||||||
:plain="true"
|
:plain="true"
|
||||||
@click="calculateAllPositionYears"
|
@click="navigateBack"
|
||||||
/>
|
/>
|
||||||
<u-button
|
<u-button
|
||||||
text="上一步"
|
text="下一步"
|
||||||
class="ml-15 mr-7"
|
class="mr-15 mr-7"
|
||||||
:plain="true"
|
type="primary"
|
||||||
@click="navigateBack"
|
@click="submit"
|
||||||
/>
|
|
||||||
<u-button
|
|
||||||
text="下一步"
|
|
||||||
class="mr-15 mr-7"
|
|
||||||
type="primary"
|
|
||||||
@click="submit"
|
|
||||||
/>
|
/>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -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,23 +202,23 @@ 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值,不重新计算
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
education.xl.forEach((item: any, index: number) => {
|
education.xl.forEach((item: any, index: number) => {
|
||||||
console.log(`回显数据-表单项${index}数据:`, {
|
console.log(`回显数据-表单项${index}数据:`, {
|
||||||
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++;
|
||||||
}
|
}
|
||||||
@ -283,8 +283,8 @@ onMounted(() => {
|
|||||||
console.log(`挂载后-表单项${index}数据:`, {
|
console.log(`挂载后-表单项${index}数据:`, {
|
||||||
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++;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user