diff --git a/src/components/FilterBar.vue b/src/components/FilterBar.vue index 8dd2c95..d89e175 100644 --- a/src/components/FilterBar.vue +++ b/src/components/FilterBar.vue @@ -183,7 +183,7 @@ onUnmounted(() => { diff --git a/src/components/ScoreForm.vue b/src/components/ScoreForm.vue index 9fe9ebc..e633d20 100644 --- a/src/components/ScoreForm.vue +++ b/src/components/ScoreForm.vue @@ -42,6 +42,9 @@ const scores = ref({ english: '', // 英语 }) +// Dynamic sub-major scores +const subMajorScores = ref>({}) + // Errors state const errors = ref({ examType: '', @@ -54,6 +57,7 @@ const errors = ref({ chinese: '', english: '', }, + subMajorScores: {} as Record, }) // --- Computed Properties using Dict System --- @@ -81,6 +85,25 @@ const majorCategoryOptions = computed(() => { ] }) +function getSubMajorOptions() { + switch (majorCategory.value) { + case '表演类': + return [ + { label: '服装表演', value: '服装表演', formKey: '服装表演' }, + { label: '戏剧影视导演', value: '戏剧影视导演', formKey: '戏剧影视导演' }, + { label: '戏剧影视表演', value: '戏剧影视表演', formKey: '戏剧影视表演' }, + ] + case '音乐类': + return [ + { label: '音乐表演声乐', value: '音乐表演声乐', formKey: '音乐表演声乐', disabled: selectedSubMajors.value.includes('音乐表演器乐') }, + { label: '音乐表演器乐', value: '音乐表演器乐', formKey: '音乐表演器乐', disabled: selectedSubMajors.value.includes('音乐表演声乐') }, + { label: '音乐教育', value: '音乐教育', formKey: '音乐教育' }, + ] + default: + return [] + } +} + function handleElectiveChange(value: string) { console.warn('handleElectiveChange', value) const index = selectedElectives.value.indexOf(value) @@ -103,10 +126,35 @@ function handleMajorCategoryChange(val: any) { errors.value.majorCategory = '' } +function getSubMajorFormKey(subMajorValue: string): string { + const options = getSubMajorOptions() + const option = options.find(opt => opt.value === subMajorValue) + return option?.formKey || '' +} + function handleSubMajorChange(val: any) { // 可以在这里处理额外的逻辑 console.warn(val) errors.value.subMajors = '' + + // 获取当前选中的子专业选项 + const options = getSubMajorOptions() + const selectedOptions = options.filter(opt => val.includes(opt.value)) + + // 初始化新选中的子专业成绩输入框 + selectedOptions.forEach(opt => { + if (!subMajorScores.value[opt.formKey]) { + subMajorScores.value[opt.formKey] = '' + } + }) + + // 移除未选中的子专业成绩 + const currentFormKeys = selectedOptions.map(opt => opt.formKey) + Object.keys(subMajorScores.value).forEach(key => { + if (!currentFormKeys.includes(key)) { + delete subMajorScores.value[key] + } + }) } // --- Validation Logic --- @@ -190,6 +238,11 @@ function validateForm() { // --- Submit --- async function handleSubmit() { if (validateForm()) { + if (getSubMajorOptions().length == 0){ + selectedSubMajors.value = [] + subMajorScores.value = {} + } + // 组装数据 const formData: ScoreFormData = { examType: examType.value, @@ -205,7 +258,7 @@ async function handleSubmit() { subjectList: selectedElectives.value, professionalCategory: majorCategory.value, professionalCategoryChildren: selectedSubMajors.value, - professionalCategoryChildrenScore: {}, + professionalCategoryChildrenScore: subMajorScores.value, professionalScore: Number(scores.value.unified) || 0, culturalScore: Number(scores.value.culture) || 0, englishScore: Number(scores.value.english) || 0, @@ -243,6 +296,11 @@ function initForm() { scores.value.culture = info.culturalScore?.toString() || '' scores.value.chinese = info.chineseScore?.toString() || '' scores.value.english = info.englishScore?.toString() || '' + + // 回显子专业成绩 + if (info.professionalCategoryChildrenScore) { + subMajorScores.value = { ...info.professionalCategoryChildrenScore } + } } } @@ -278,6 +336,7 @@ defineExpose({ majorCategory.value = '' selectedSubMajors.value = [] scores.value = { unified: '', culture: '', chinese: '', english: '' } + subMajorScores.value = {} }, }) @@ -367,6 +426,30 @@ defineExpose({ 成绩输入 + +
+
+
+ + +
+ {{ errors.subMajorScores[getSubMajorFormKey(subMajor)] }} +
+
+
+
+
diff --git a/src/pages/major/[majorCode].vue b/src/pages/major/[majorCode].vue new file mode 100644 index 0000000..a695e70 --- /dev/null +++ b/src/pages/major/[majorCode].vue @@ -0,0 +1,245 @@ + + + \ No newline at end of file diff --git a/src/pages/school/[schoolCode].vue b/src/pages/school/[schoolCode].vue index c546b6b..1e97964 100644 --- a/src/pages/school/[schoolCode].vue +++ b/src/pages/school/[schoolCode].vue @@ -112,6 +112,18 @@ const stopCarousel = () => { } } +// 关注按钮点击事件 +const handleFollow = () => { + console.log('关注学校:', schoolCode.value) + // TODO: 实现关注逻辑 +} + +// 加入对比按钮点击事件 +const handleCompare = () => { + console.log('加入对比:', schoolCode.value) + // TODO: 实现对比逻辑 +} + onMounted(() => { startCarousel() }) @@ -133,29 +145,50 @@ useHead({
-
-
-
+
+
+
Logo
-

+

中国石油大学(华东)

-
+
公办|理工类|教育部直属
+ +
+ + +
-