2025-04-22 10:22:33 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<BasicLayout>
|
|
|
|
|
|
<view class="p-15">
|
|
|
|
|
|
<view v-if="education.xl.length > 0">
|
|
|
|
|
|
<template v-for="(item, index) in education.xl" :key="index">
|
|
|
|
|
|
<view class="po-re mb-15">
|
|
|
|
|
|
<BasicForm
|
2025-06-16 11:05:17 +08:00
|
|
|
|
:index="index"
|
|
|
|
|
|
v-model="item.value"
|
|
|
|
|
|
:schema="schema"
|
|
|
|
|
|
:key="`form-${index}-${forceUpdateKey}`"
|
|
|
|
|
|
:formsProps="{ labelWidth: 100 }"
|
2025-04-22 10:22:33 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<view
|
2025-06-16 11:05:17 +08:00
|
|
|
|
@click="deleteMemberFamily(index, item.value)"
|
|
|
|
|
|
class="delete-icon"
|
2025-04-22 10:22:33 +08:00
|
|
|
|
>
|
2025-06-16 11:05:17 +08:00
|
|
|
|
<BasicIcon type="clear" size="30"/>
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<view
|
2025-06-16 11:05:17 +08:00
|
|
|
|
class="flex-row items-center justify-center pb-10 pt-5"
|
|
|
|
|
|
style="border: 1px solid #e8e8e8"
|
|
|
|
|
|
@click="addEducation"
|
2025-04-22 10:22:33 +08:00
|
|
|
|
>
|
|
|
|
|
|
<uni-icons type="plus" size="16" color="#447ADE"></uni-icons>
|
|
|
|
|
|
<view class="ml-5 cor-447ADE">新增</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
</view>
|
|
|
|
|
|
<template #bottom>
|
|
|
|
|
|
<view class="flex-row items-center pb-10 pt-5">
|
2025-06-15 21:39:54 +08:00
|
|
|
|
<u-button
|
2025-06-16 11:05:17 +08:00
|
|
|
|
text="测试计算"
|
|
|
|
|
|
class="ml-15 mr-7"
|
|
|
|
|
|
:plain="true"
|
|
|
|
|
|
@click="calculateAllPositionYears"
|
2025-06-15 21:39:54 +08:00
|
|
|
|
/>
|
2025-05-13 15:39:44 +08:00
|
|
|
|
<u-button
|
2025-06-16 11:05:17 +08:00
|
|
|
|
text="上一步"
|
|
|
|
|
|
class="ml-15 mr-7"
|
|
|
|
|
|
:plain="true"
|
|
|
|
|
|
@click="navigateBack"
|
2025-05-13 15:39:44 +08:00
|
|
|
|
/>
|
|
|
|
|
|
<u-button
|
2025-06-16 11:05:17 +08:00
|
|
|
|
text="下一步"
|
|
|
|
|
|
class="mr-15 mr-7"
|
|
|
|
|
|
type="primary"
|
|
|
|
|
|
@click="submit"
|
2025-05-13 15:39:44 +08:00
|
|
|
|
/>
|
|
|
|
|
|
</view>
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</template>
|
|
|
|
|
|
</BasicLayout>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script lang="ts" setup>
|
2025-06-16 11:05:17 +08:00
|
|
|
|
import {dicApi} from "@/api/system/dic";
|
|
|
|
|
|
import {useDataStore} from "@/store/modules/data";
|
|
|
|
|
|
import {navigateBack, navigateTo} from "@/utils/uniapp";
|
|
|
|
|
|
import {cloneDeep, map} from "lodash";
|
2025-06-15 21:39:54 +08:00
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
|
|
|
|
|
|
|
|
// 计算任岗年限
|
|
|
|
|
|
const calculatePositionYears = (startDate: string, endDate?: string) => {
|
|
|
|
|
|
if (!startDate) return "";
|
|
|
|
|
|
const start = dayjs(startDate);
|
|
|
|
|
|
const end = endDate ? dayjs(endDate) : dayjs();
|
|
|
|
|
|
const years = end.diff(start, "year");
|
2025-06-16 11:05:17 +08:00
|
|
|
|
console.log("计算任岗年限:", {startDate, endDate, years});
|
2025-06-15 21:39:54 +08:00
|
|
|
|
// 确保0值也能显示,转换为字符串
|
|
|
|
|
|
return years.toString();
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// 强制重新渲染的键
|
|
|
|
|
|
const forceUpdateKey = ref(0);
|
|
|
|
|
|
|
|
|
|
|
|
// 更新指定项的任岗年限
|
|
|
|
|
|
const updatePositionYears = (itemValue: any) => {
|
2025-06-16 11:05:17 +08:00
|
|
|
|
const {gwrztime, gwpyjssj} = itemValue;
|
2025-06-15 21:39:54 +08:00
|
|
|
|
if (gwrztime) {
|
|
|
|
|
|
const years = calculatePositionYears(gwrztime, gwpyjssj);
|
|
|
|
|
|
itemValue.gwrznx = years;
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
2025-04-22 10:22:33 +08:00
|
|
|
|
|
|
|
|
|
|
const schema = reactive<FormsSchema[]>([
|
|
|
|
|
|
{
|
2025-06-17 13:25:27 +08:00
|
|
|
|
field: "gwlbId",
|
2025-06-10 16:27:34 +08:00
|
|
|
|
label: "岗位类别",
|
2025-05-13 15:39:44 +08:00
|
|
|
|
component: "BasicPicker",
|
|
|
|
|
|
componentProps: {
|
2025-06-04 20:52:34 +08:00
|
|
|
|
api: dicApi,
|
2025-06-16 11:05:17 +08:00
|
|
|
|
param: {pid: 260783972},
|
|
|
|
|
|
rangeKey: "dictionaryValue",
|
|
|
|
|
|
savaKey: "dictionaryCode",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-06-17 13:25:27 +08:00
|
|
|
|
field: "gwjbId",
|
2025-06-16 11:05:17 +08:00
|
|
|
|
label: "岗位级别",
|
|
|
|
|
|
component: "BasicPicker",
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
api: dicApi,
|
|
|
|
|
|
param: {pid: 434953981},
|
2025-06-04 20:52:34 +08:00
|
|
|
|
rangeKey: "dictionaryValue",
|
|
|
|
|
|
savaKey: "dictionaryCode",
|
2025-05-13 15:39:44 +08:00
|
|
|
|
},
|
2025-04-22 10:22:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-06-17 13:25:27 +08:00
|
|
|
|
field: "gwrzkstime",
|
2025-06-11 23:35:00 +08:00
|
|
|
|
label: "岗位聘用开始时间",
|
|
|
|
|
|
component: "BasicDateTime",
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
mode: "year-month",
|
2025-06-15 21:39:54 +08:00
|
|
|
|
ok: (e: any, attrs: any) => {
|
|
|
|
|
|
console.log("岗位聘用开始时间选择:", e, attrs);
|
|
|
|
|
|
const formIndex = attrs.index;
|
|
|
|
|
|
if (formIndex !== undefined && education.xl[formIndex]) {
|
|
|
|
|
|
// 获取当前表单项的结束时间
|
|
|
|
|
|
const endTime = education.xl[formIndex].value.gwpyjssj;
|
|
|
|
|
|
console.log("当前表单项数据:", education.xl[formIndex].value);
|
|
|
|
|
|
// 计算任岗年限
|
|
|
|
|
|
const years = calculatePositionYears(e.value, endTime);
|
|
|
|
|
|
// 更新任岗年限
|
|
|
|
|
|
education.xl[formIndex].value.gwrznx = years;
|
|
|
|
|
|
console.log("更新后的任岗年限:", education.xl[formIndex].value.gwrznx);
|
|
|
|
|
|
// 强制重新渲染
|
|
|
|
|
|
forceUpdateKey.value++;
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-06-11 23:35:00 +08:00
|
|
|
|
},
|
2025-06-15 21:39:54 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-06-17 13:25:27 +08:00
|
|
|
|
field: "gwrzjstime",
|
2025-06-11 23:35:00 +08:00
|
|
|
|
label: "岗位聘用结束时间",
|
|
|
|
|
|
component: "BasicDateTime",
|
|
|
|
|
|
componentProps: {
|
|
|
|
|
|
mode: "year-month",
|
2025-06-15 21:39:54 +08:00
|
|
|
|
ok: (e: any, attrs: any) => {
|
|
|
|
|
|
console.log("岗位聘用结束时间选择:", e, attrs);
|
|
|
|
|
|
const formIndex = attrs.index;
|
|
|
|
|
|
if (formIndex !== undefined && education.xl[formIndex]) {
|
|
|
|
|
|
// 获取当前表单项的开始时间
|
|
|
|
|
|
const startTime = education.xl[formIndex].value.gwrztime;
|
|
|
|
|
|
console.log("当前表单项数据:", education.xl[formIndex].value);
|
|
|
|
|
|
if (startTime) {
|
|
|
|
|
|
// 计算任岗年限
|
|
|
|
|
|
const years = calculatePositionYears(startTime, e.value);
|
|
|
|
|
|
// 更新任岗年限
|
|
|
|
|
|
education.xl[formIndex].value.gwrznx = years;
|
|
|
|
|
|
console.log("更新后的任岗年限:", education.xl[formIndex].value.gwrznx);
|
|
|
|
|
|
// 强制重新渲染
|
|
|
|
|
|
forceUpdateKey.value++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2025-06-11 23:35:00 +08:00
|
|
|
|
},
|
2025-04-22 10:22:33 +08:00
|
|
|
|
},
|
|
|
|
|
|
{
|
2025-05-13 15:39:44 +08:00
|
|
|
|
field: "gwrznx",
|
2025-04-22 10:22:33 +08:00
|
|
|
|
label: "岗位任职年限",
|
|
|
|
|
|
component: "BasicInput",
|
2025-06-15 21:39:54 +08:00
|
|
|
|
componentProps: {
|
|
|
|
|
|
disabled: true,
|
|
|
|
|
|
placeholder: "请选择岗位聘用时间",
|
|
|
|
|
|
},
|
2025-04-22 10:22:33 +08:00
|
|
|
|
},
|
2025-06-04 20:52:34 +08:00
|
|
|
|
// {
|
|
|
|
|
|
// field: "zrxk",
|
|
|
|
|
|
// label: "主任学科",
|
|
|
|
|
|
// component: "BasicInput",
|
|
|
|
|
|
// componentProps: {},
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// field: "jrxk",
|
|
|
|
|
|
// label: "兼任学科",
|
|
|
|
|
|
// component: "BasicInput",
|
|
|
|
|
|
// componentProps: {},
|
|
|
|
|
|
// },
|
|
|
|
|
|
// {
|
|
|
|
|
|
// field: "bzrBjId",
|
|
|
|
|
|
// label: "班主任班级",
|
|
|
|
|
|
// component: "BasicDataPicker",
|
|
|
|
|
|
// componentProps: {
|
|
|
|
|
|
// api: findAllNjBjTreeApi,
|
|
|
|
|
|
// rangeKey: "title",
|
|
|
|
|
|
// savaKey: "key",
|
|
|
|
|
|
// },
|
|
|
|
|
|
// },
|
2025-06-16 11:05:17 +08:00
|
|
|
|
/*{
|
2025-06-04 20:52:34 +08:00
|
|
|
|
field: "dzzw",
|
|
|
|
|
|
label: "职务",
|
2025-05-13 15:39:44 +08:00
|
|
|
|
component: "BasicPicker",
|
|
|
|
|
|
componentProps: {
|
2025-06-04 20:52:34 +08:00
|
|
|
|
api: dicApi,
|
|
|
|
|
|
param: { pid: 1063530116 },
|
|
|
|
|
|
rangeKey: "dictionaryValue",
|
|
|
|
|
|
savaKey: "dictionaryCode",
|
2025-05-13 15:39:44 +08:00
|
|
|
|
},
|
2025-06-16 11:05:17 +08:00
|
|
|
|
},*/
|
2025-04-22 10:22:33 +08:00
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
|
|
const education = reactive<any>({
|
2025-06-16 11:05:17 +08:00
|
|
|
|
xl: [{value: {}}],
|
2025-04-22 10:22:33 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2025-06-16 11:05:17 +08:00
|
|
|
|
const {getFile, setFile} = useDataStore();
|
2025-05-13 15:39:44 +08:00
|
|
|
|
if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
|
|
|
|
|
education.xl = map(getFile.rgqkList, (item) => {
|
2025-06-16 11:05:17 +08:00
|
|
|
|
return {value: item};
|
2025-05-13 15:39:44 +08:00
|
|
|
|
});
|
2025-06-16 11:05:17 +08:00
|
|
|
|
|
2025-06-15 21:39:54 +08:00
|
|
|
|
// 回显数据后,重新计算所有任岗年限
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
education.xl.forEach((item: any, index: number) => {
|
|
|
|
|
|
if (item.value.gwrztime) {
|
|
|
|
|
|
const years = calculatePositionYears(
|
2025-06-16 11:05:17 +08:00
|
|
|
|
item.value.gwrztime,
|
|
|
|
|
|
item.value.gwpyjssj
|
2025-06-15 21:39:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
item.value.gwrznx = years;
|
2025-06-16 11:05:17 +08:00
|
|
|
|
console.log(`回显数据-表单项${index}计算结果:`, {
|
2025-06-15 21:39:54 +08:00
|
|
|
|
gwrztime: item.value.gwrztime,
|
|
|
|
|
|
gwpyjssj: item.value.gwpyjssj,
|
|
|
|
|
|
gwrznx: years,
|
|
|
|
|
|
是否为0: years === "0"
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 没有开始时间时,清空任岗年限
|
|
|
|
|
|
item.value.gwrznx = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
// 强制重新渲染确保界面更新
|
|
|
|
|
|
forceUpdateKey.value++;
|
|
|
|
|
|
});
|
2025-05-13 15:39:44 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-06-15 21:39:54 +08:00
|
|
|
|
// 手动触发计算所有项目的任岗年限
|
|
|
|
|
|
const calculateAllPositionYears = () => {
|
|
|
|
|
|
education.xl.forEach((item: any, index: number) => {
|
|
|
|
|
|
if (item.value.gwrztime) {
|
|
|
|
|
|
const years = calculatePositionYears(
|
2025-06-16 11:05:17 +08:00
|
|
|
|
item.value.gwrztime,
|
|
|
|
|
|
item.value.gwpyjssj
|
2025-06-15 21:39:54 +08:00
|
|
|
|
);
|
|
|
|
|
|
item.value.gwrznx = years;
|
2025-06-16 11:05:17 +08:00
|
|
|
|
console.log(`表单项${index}计算结果:`, {
|
2025-06-15 21:39:54 +08:00
|
|
|
|
gwrztime: item.value.gwrztime,
|
|
|
|
|
|
gwpyjssj: item.value.gwpyjssj,
|
|
|
|
|
|
gwrznx: years,
|
|
|
|
|
|
是否为0: years === "0"
|
|
|
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
|
|
|
// 没有开始时间时,清空任岗年限
|
|
|
|
|
|
item.value.gwrznx = "";
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
forceUpdateKey.value++;
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-22 10:22:33 +08:00
|
|
|
|
function addEducation() {
|
2025-06-16 11:05:17 +08:00
|
|
|
|
education.xl.push({value: {}});
|
2025-06-15 21:39:54 +08:00
|
|
|
|
// 强制重新渲染
|
|
|
|
|
|
forceUpdateKey.value++;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function deleteMemberFamily(index: number, item: any) {
|
|
|
|
|
|
const list = cloneDeep(education.xl);
|
|
|
|
|
|
list.splice(index, 1);
|
|
|
|
|
|
education.xl = list;
|
2025-06-15 21:39:54 +08:00
|
|
|
|
// 强制重新渲染
|
|
|
|
|
|
forceUpdateKey.value++;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function submit() {
|
2025-05-13 15:39:44 +08:00
|
|
|
|
setFile({
|
|
|
|
|
|
...getFile,
|
|
|
|
|
|
rgqkList: map(education.xl, (item) => {
|
|
|
|
|
|
return item.value;
|
|
|
|
|
|
}),
|
|
|
|
|
|
});
|
2025-06-04 20:52:34 +08:00
|
|
|
|
navigateTo("/pages/view/hr/teacherProfile/ExperienceInfo");
|
2025-04-22 10:22:33 +08:00
|
|
|
|
}
|
2025-06-15 21:39:54 +08:00
|
|
|
|
|
|
|
|
|
|
// 组件挂载完成后处理回显数据
|
|
|
|
|
|
onMounted(() => {
|
|
|
|
|
|
// 如果有回显数据,再次确保计算正确
|
|
|
|
|
|
if (getFile.rgqkList && getFile.rgqkList.length > 0) {
|
|
|
|
|
|
nextTick(() => {
|
|
|
|
|
|
console.log("组件挂载后处理回显数据");
|
|
|
|
|
|
calculateAllPositionYears();
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
2025-04-22 10:22:33 +08:00
|
|
|
|
</script>
|
|
|
|
|
|
<style>
|
|
|
|
|
|
.delete-icon {
|
|
|
|
|
|
position: absolute;
|
2025-05-13 15:39:44 +08:00
|
|
|
|
right: -13px;
|
|
|
|
|
|
top: -14px;
|
2025-04-22 10:22:33 +08:00
|
|
|
|
z-index: 1;
|
|
|
|
|
|
}
|
|
|
|
|
|
</style>
|