diff --git a/src/api/base/server.ts b/src/api/base/server.ts
index 75bea65..74c7f14 100644
--- a/src/api/base/server.ts
+++ b/src/api/base/server.ts
@@ -30,3 +30,13 @@ export const jsConfirmJsDataApi = async (params: any) => {
export const jsdFindPageTaskApi = async (params: any) => {
return await get("/api/jsd/findPageTask", params);
};
+export const fractionRuleApi = async () => {
+ return await get(
+ "/api/fractionRule/findAllByItemId?itemId=CDFDED2A704F46E2A4D7E8816968BD23"
+ );
+};
+export const fractionRuleApi1 = async () => {
+ return await get(
+ "/api/fractionRule/findAllByItemId?itemId=B96A0FA22C414F71A3E1CDCA7E206B10"
+ );
+};
diff --git a/src/components/BasicForm/Form.vue b/src/components/BasicForm/Form.vue
index 4c8b17d..6a54fe3 100644
--- a/src/components/BasicForm/Form.vue
+++ b/src/components/BasicForm/Form.vue
@@ -1,137 +1,161 @@
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ />
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/pages/view/hr/teacherProfile/EmergencyContact.vue b/src/pages/view/hr/teacherProfile/EmergencyContact.vue
index 4f25f67..ff870fa 100644
--- a/src/pages/view/hr/teacherProfile/EmergencyContact.vue
+++ b/src/pages/view/hr/teacherProfile/EmergencyContact.vue
@@ -29,7 +29,7 @@
-
+
diff --git a/src/pages/view/hr/teacherProfile/ExperienceInfo.vue b/src/pages/view/hr/teacherProfile/ExperienceInfo.vue
index e1cf624..fbf7fbe 100644
--- a/src/pages/view/hr/teacherProfile/ExperienceInfo.vue
+++ b/src/pages/view/hr/teacherProfile/ExperienceInfo.vue
@@ -31,7 +31,7 @@
@@ -30,7 +32,7 @@
import { dicApi } from "@/api/system/dic";
-import { useForm } from "@/components/BasicForm/hooks/useForm";
import { useDataStore } from "@/store/modules/data";
-import { navigateTo, navigateBack } from "@/utils/uniapp";
+import { navigateBack, navigateTo, showModal, showToast } from "@/utils/uniapp";
import { cloneDeep, map } from "lodash";
+import { fractionRuleApi } from "@/api/base/server";
-const schema = reactive([
+// 主数据
+const education = reactive({
+ xl: [{ value: {} }],
+});
+
+// 荣誉类别数据缓存
+const honorCategories = ref([]);
+
+// 每个表单项对应的获奖级别数据
+const awardLevelsMap = reactive>({});
+
+// 强制重新渲染的键
+const forceUpdateKey = ref(0);
+
+// 基础表单配置
+const baseSchema = [
+ {
+ field: "rymc",
+ label: "荣誉名称",
+ component: "BasicInput",
+ componentProps: {},
+ },
+ {
+ field: "hilb_id",
+ label: "荣誉类别",
+ component: "BasicPicker",
+ componentProps: {
+ api: fractionRuleApi,
+ rangeKey: "inspectStandard",
+ savaKey: "id",
+ ok: (selectedIndex: number, form: any, list: any, attrs: any) => {
+ const selectedCategory = list[selectedIndex];
+ const formIndex = attrs.index;
+
+ // 更新当前表单项的获奖级别选项
+ updateAwardLevels(formIndex, selectedCategory);
+
+ // 清空已选择的获奖级别(如果之前有选择的话)
+ if (education.xl[formIndex].value.hjjbId) {
+ education.xl[formIndex].value.hjjbId = "";
+ }
+ // 强制重新渲染
+ forceUpdateKey.value++;
+ },
+ },
+ },
{
field: "hjjbId",
label: "获奖级别",
component: "BasicPicker",
componentProps: {
- api: dicApi,
- param: { pid: 1472324538 },
- rangeKey: "dictionaryValue",
- savaKey: "dictionaryCode",
+ range: [],
+ rangeKey: "name",
+ savaKey: "id",
+ open: (value: any, attrs: any, model: any) => {
+ const formIndex = attrs.index;
+ // 检查是否已选择荣誉类别
+ if (!model?.hilb_id) {
+ showToast({
+ title: "请先选择荣誉类别",
+ icon: "none",
+ });
+ return false;
+ }
+
+ // 检查是否有对应的获奖级别数据
+ const awardLevels = awardLevelsMap[formIndex] || [];
+
+ if (awardLevels.length === 0) {
+ showToast({
+ title: "该荣誉类别暂无获奖级别数据",
+ icon: "none",
+ });
+ return false;
+ }
+
+ return true;
+ },
},
},
{
@@ -71,24 +141,18 @@ const schema = reactive([
component: "BasicInput",
componentProps: {},
},
- // {
- // field: "bjdw",
- // label: "获奖内容",
- // component: "BasicInput",
- // itemProps: {
- // labelPosition: "top",
- // },
- // componentProps: {
- // type: "textarea",
- // rows: 3,
- // },
- // },
{
field: "hjtime",
label: "获奖时间",
component: "BasicDateTimes",
componentProps: {},
},
+ {
+ field: "jf",
+ label: "积分",
+ component: "BasicInput",
+ componentProps: {},
+ },
{
field: "hjfjId",
label: "上传证书",
@@ -98,29 +162,101 @@ const schema = reactive([
},
componentProps: {},
},
-]);
+];
-const education = reactive({
- xl: [{ value: {} }],
-});
+// 为每个表单项生成动态的schema
+const getSchemaForIndex = (index: number) => {
+ const schema = cloneDeep(baseSchema);
-function addEducation() {
- education.xl.push({ value: {} });
-}
+ // 更新获奖级别的选项数据
+ const hjjbField = schema.find((item) => item.field === "hjjbId");
+ if (hjjbField) {
+ hjjbField.componentProps.range = awardLevelsMap[index] || [];
+ }
-const { getFile, setFile } = useDataStore();
-if (getFile.grRyList && getFile.grRyList.length > 0) {
- education.xl = map(getFile.grRyList, (item) => {
- return { value: item };
+ return schema;
+};
+
+// 更新指定表单项的获奖级别选项
+const updateAwardLevels = (formIndex: number, category: any) => {
+ if (category?.ruleItemList && category.ruleItemList.length > 0) {
+ awardLevelsMap[formIndex] = category.ruleItemList;
+ } else {
+ awardLevelsMap[formIndex] = [];
+ }
+};
+
+// 初始化荣誉类别数据
+const initHonorCategories = async () => {
+ try {
+ const result = await fractionRuleApi();
+ honorCategories.value = result.result || result || [];
+ } catch (error) {
+ console.error("获取荣誉类别数据失败:", error);
+ }
+};
+
+// 初始化回显数据
+const initEchoData = async () => {
+ await initHonorCategories();
+
+ // 为每个已有数据的表单项初始化获奖级别选项
+ education.xl.forEach((formItem: any, index: number) => {
+ if (formItem.value?.hilb_id) {
+ const category = honorCategories.value.find(
+ (cat: any) => cat.id === formItem.value.hilb_id
+ );
+
+ if (category) {
+ // 更新获奖级别选项
+ updateAwardLevels(index, category);
+ } else {
+ console.log(`未找到荣誉类别 ID: ${formItem.value.hilb_id}`);
+ }
+ } else {
+ console.log(`表单项 ${index} 没有荣誉类别 ID`);
+ }
});
+
+ // 强制重新渲染以确保获奖级别能正确显示
+ forceUpdateKey.value++;
+};
+
+// 添加新的教育项
+function addEducation() {
+ const newIndex = education.xl.length;
+ education.xl.push({ value: {} });
+
+ // 为新项初始化空的获奖级别选项
+ awardLevelsMap[newIndex] = [];
}
+// 删除教育项
function deleteMemberFamily(index: number, item: any) {
- const list = cloneDeep(education.xl);
- list.splice(index, 1);
- education.xl = list;
+ // 删除对应的获奖级别数据
+ delete awardLevelsMap[index];
+
+ // 重新整理awardLevelsMap的键值
+ const newAwardLevelsMap: Record = {};
+ education.xl.forEach((_: any, i: number) => {
+ if (i < index) {
+ newAwardLevelsMap[i] = awardLevelsMap[i] || [];
+ } else if (i > index) {
+ newAwardLevelsMap[i - 1] = awardLevelsMap[i] || [];
+ }
+ });
+
+ // 删除表单项
+ education.xl.splice(index, 1);
+
+ // 更新awardLevelsMap
+ Object.keys(awardLevelsMap).forEach(
+ (key: string) => delete awardLevelsMap[Number(key)]
+ );
+ Object.assign(awardLevelsMap, newAwardLevelsMap);
}
+// 提交数据
function submit() {
setFile({
...getFile,
@@ -130,7 +266,31 @@ function submit() {
});
navigateTo("/pages/view/hr/teacherProfile/PublicClassAwards");
}
+
+// 初始化数据
+const { getFile, setFile } = useDataStore();
+
+// 处理回显数据
+if (getFile.grRyList && getFile.grRyList.length > 0) {
+ education.xl = map(getFile.grRyList, (item) => {
+ return { value: item };
+ });
+}
+
+// 页面加载时初始化
+onMounted(() => {
+ if (getFile.grRyList && getFile.grRyList.length > 0) {
+ // 有回显数据时,延迟初始化确保数据正确加载
+ nextTick(() => {
+ initEchoData();
+ });
+ } else {
+ // 无回显数据时,只需要初始化荣誉类别
+ initHonorCategories();
+ }
+});
+