|
@@ -125,10 +125,10 @@ import IeSelect from '@/components/IeSelect/index.vue';
|
|
|
import IeUniversitySelect from '@/components/IeUniversitySelect/index.vue';
|
|
import IeUniversitySelect from '@/components/IeUniversitySelect/index.vue';
|
|
|
import DirectionDialog from './DirectionDialog.vue';
|
|
import DirectionDialog from './DirectionDialog.vue';
|
|
|
import { updateCardUser, getUserByCardId } from '@/api/dz/cards';
|
|
import { updateCardUser, getUserByCardId } from '@/api/dz/cards';
|
|
|
-import { listAllSubject } from '@/api/dz/subject';
|
|
|
|
|
import { getCurrentInstance, nextTick, watch, watchEffect } from 'vue';
|
|
import { getCurrentInstance, nextTick, watch, watchEffect } from 'vue';
|
|
|
import draggable from 'vuedraggable';
|
|
import draggable from 'vuedraggable';
|
|
|
import { Rank, Close } from '@element-plus/icons-vue';
|
|
import { Rank, Close } from '@element-plus/icons-vue';
|
|
|
|
|
+import useProvinceExamTypeSubject from '@/views/dz/hooks/useProvinceExamTypeSubject.js';
|
|
|
|
|
|
|
|
const { proxy } = getCurrentInstance();
|
|
const { proxy } = getCurrentInstance();
|
|
|
|
|
|
|
@@ -140,26 +140,49 @@ const form = ref({
|
|
|
directionStudy: []
|
|
directionStudy: []
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-// 专业类别相关
|
|
|
|
|
-const examMajorList = ref([]);
|
|
|
|
|
-const selectedExamMajor = ref(null);
|
|
|
|
|
-
|
|
|
|
|
|
|
+// 使用通用的省份-考生类型-科目联动 hook(专业类别即科目,只在VHS时显示)
|
|
|
const {
|
|
const {
|
|
|
- reset,
|
|
|
|
|
area,
|
|
area,
|
|
|
getAreaList,
|
|
getAreaList,
|
|
|
|
|
+ selectedExamType,
|
|
|
|
|
+ examTypeList,
|
|
|
|
|
+ selectedSubjectId,
|
|
|
|
|
+ subjectList,
|
|
|
|
|
+ reset: resetProvinceExamTypeSubject,
|
|
|
|
|
+ initData: initProvinceExamTypeSubject
|
|
|
|
|
+} = useProvinceExamTypeSubject({
|
|
|
|
|
+ autoLoadArea: false,
|
|
|
|
|
+ loadExamType: true,
|
|
|
|
|
+ onlyVHS: true // 只在考生类型为 VHS 时加载科目
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+// 专业类别相关(使用 selectedSubjectId 和 subjectList)
|
|
|
|
|
+const examMajorList = computed(() => {
|
|
|
|
|
+ // 转换数据格式,dictValue 对应 subject_id,dictLabel 对应 subject_name
|
|
|
|
|
+ return subjectList.value.map(item => ({
|
|
|
|
|
+ dictValue: Number(item.subjectId),
|
|
|
|
|
+ dictLabel: item.subjectName
|
|
|
|
|
+ }))
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const selectedExamMajor = computed({
|
|
|
|
|
+ get: () => selectedSubjectId.value ? Number(selectedSubjectId.value) : null,
|
|
|
|
|
+ set: (val) => {
|
|
|
|
|
+ selectedSubjectId.value = val ? Number(val) : null
|
|
|
|
|
+ }
|
|
|
|
|
+})
|
|
|
|
|
+
|
|
|
|
|
+const {
|
|
|
schoolList,
|
|
schoolList,
|
|
|
selectedSchool,
|
|
selectedSchool,
|
|
|
classList,
|
|
classList,
|
|
|
selectedClass,
|
|
selectedClass,
|
|
|
- examTypeList,
|
|
|
|
|
- selectedExamType,
|
|
|
|
|
- getExamTypeList,
|
|
|
|
|
campusList,
|
|
campusList,
|
|
|
selectedCampus,
|
|
selectedCampus,
|
|
|
campusClassList,
|
|
campusClassList,
|
|
|
selectedCampusClass,
|
|
selectedCampusClass,
|
|
|
-} = useSchool({ autoLoad: false, loadExamType: true, loadClass: true, loadCampus: true, loadCampusClass: true });
|
|
|
|
|
|
|
+ reset: resetSchool
|
|
|
|
|
+} = useSchool({ autoLoad: false, loadClass: true, loadCampus: true, loadCampusClass: true });
|
|
|
|
|
|
|
|
watchEffect(() => {
|
|
watchEffect(() => {
|
|
|
form.value.examType = selectedExamType.value;
|
|
form.value.examType = selectedExamType.value;
|
|
@@ -175,54 +198,10 @@ watchEffect(() => {
|
|
|
} else {
|
|
} else {
|
|
|
form.value.examMajorName = null;
|
|
form.value.examMajorName = null;
|
|
|
}
|
|
}
|
|
|
|
|
+ // 同步 location
|
|
|
|
|
+ form.value.location = area.selectedItem?.shortName || area.selectedItem?.areaName?.replace('省', '') || null;
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
-// 监听考生类型和省份变化,加载专业类别列表
|
|
|
|
|
-watch([selectedExamType, () => form.value.location], ([examType, location], [oldExamType, oldLocation]) => {
|
|
|
|
|
- // 避免初始化时执行(第一次加载时 oldExamType 和 oldLocation 都是 undefined)
|
|
|
|
|
- if (oldExamType === undefined && oldLocation === undefined) {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- // 只有 location 与 examType 有值或这2个值有变化时才调用
|
|
|
|
|
- if (examType && location) {
|
|
|
|
|
- // 如果考生类型变为 VHS,加载专业类别列表
|
|
|
|
|
- if (examType === 'VHS') {
|
|
|
|
|
- loadExamMajorList(location, examType);
|
|
|
|
|
- } else {
|
|
|
|
|
- // 如果考生类型不是 VHS,清空专业类别相关数据
|
|
|
|
|
- examMajorList.value = [];
|
|
|
|
|
- selectedExamMajor.value = null;
|
|
|
|
|
- form.value.examMajor = null;
|
|
|
|
|
- form.value.examMajorName = null;
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 如果 location 或 examType 为空,清空专业类别相关数据
|
|
|
|
|
- examMajorList.value = [];
|
|
|
|
|
- selectedExamMajor.value = null;
|
|
|
|
|
- form.value.examMajor = null;
|
|
|
|
|
- form.value.examMajorName = null;
|
|
|
|
|
- }
|
|
|
|
|
-});
|
|
|
|
|
-
|
|
|
|
|
-// 加载专业类别列表
|
|
|
|
|
-const loadExamMajorList = async (location, examType) => {
|
|
|
|
|
- try {
|
|
|
|
|
- const res = await listAllSubject({
|
|
|
|
|
- locations: location,
|
|
|
|
|
- examTypes: examType
|
|
|
|
|
- });
|
|
|
|
|
- // 转换数据格式,dictValue 对应 subject_id,dictLabel 对应 subject_name
|
|
|
|
|
- // 确保 dictValue 是 Number 类型,与 examMajor 的 Integer 类型匹配
|
|
|
|
|
- examMajorList.value = (res.data || []).map(item => ({
|
|
|
|
|
- dictValue: Number(item.subjectId),
|
|
|
|
|
- dictLabel: item.subjectName
|
|
|
|
|
- }));
|
|
|
|
|
- } catch (error) {
|
|
|
|
|
- console.error('加载专业类别列表失败:', error);
|
|
|
|
|
- examMajorList.value = [];
|
|
|
|
|
- }
|
|
|
|
|
-};
|
|
|
|
|
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const rules = ref({
|
|
const rules = ref({
|
|
@@ -240,15 +219,12 @@ const rules = ref({
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
const handleBeforeClose = () => {
|
|
const handleBeforeClose = () => {
|
|
|
- reset();
|
|
|
|
|
|
|
+ resetSchool();
|
|
|
|
|
+ resetProvinceExamTypeSubject();
|
|
|
form.value = {
|
|
form.value = {
|
|
|
scores: {},
|
|
scores: {},
|
|
|
directionStudy: []
|
|
directionStudy: []
|
|
|
};
|
|
};
|
|
|
- examMajorList.value = [];
|
|
|
|
|
- selectedExamMajor.value = null;
|
|
|
|
|
- form.value.examMajor = null;
|
|
|
|
|
- form.value.examMajorName = null;
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const open = (cardInfo) => {
|
|
const open = (cardInfo) => {
|
|
@@ -275,23 +251,15 @@ const getUserInfo = (cardInfo) => {
|
|
|
outDate,
|
|
outDate,
|
|
|
directionStudy: res.data.directionStudy || []
|
|
directionStudy: res.data.directionStudy || []
|
|
|
};
|
|
};
|
|
|
- const areaList = await getAreaList();
|
|
|
|
|
- // 只有名称,没有 id,所以需要手动查找赋值
|
|
|
|
|
- const targetArea = areaList.find(item => item.areaName === location + '省');
|
|
|
|
|
- if (targetArea) {
|
|
|
|
|
- area.list = areaList;
|
|
|
|
|
- area.selected = targetArea.areaId;
|
|
|
|
|
- area.selectedItem = targetArea;
|
|
|
|
|
- }
|
|
|
|
|
- // 初始化时设置 examMajor 值(不调用接口,由 watch 监听变化后调用)
|
|
|
|
|
- // 确保类型一致,将 examMajor 转换为 Number 类型
|
|
|
|
|
- if (res.data.examMajor != null) {
|
|
|
|
|
- selectedExamMajor.value = Number(res.data.examMajor);
|
|
|
|
|
- } else {
|
|
|
|
|
- selectedExamMajor.value = null;
|
|
|
|
|
- }
|
|
|
|
|
- // 设置考生类型和省份(这会触发 watch,当 location 和 examType 都有值时会调用接口)
|
|
|
|
|
- selectedExamType.value = res.data.examType;
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 使用通用 hook 的 initData 方法初始化省份、考生类型、科目
|
|
|
|
|
+ await initProvinceExamTypeSubject({
|
|
|
|
|
+ location: location,
|
|
|
|
|
+ examType: res.data.examType,
|
|
|
|
|
+ subjectId: res.data.examMajor
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ // 设置其他字段
|
|
|
selectedCampus.value = res.data.campusSchoolId;
|
|
selectedCampus.value = res.data.campusSchoolId;
|
|
|
selectedCampusClass.value = res.data.campusClassId;
|
|
selectedCampusClass.value = res.data.campusClassId;
|
|
|
selectedSchool.value = res.data.schoolId;
|
|
selectedSchool.value = res.data.schoolId;
|