Skip to content

Commit

Permalink
perf:优化了绩点计算器内计算课程的分类
Browse files Browse the repository at this point in the history
  • Loading branch information
luolananDR committed Jan 20, 2025
1 parent 8e7ae9c commit 0e4608d
Showing 1 changed file with 77 additions and 2 deletions.
79 changes: 77 additions & 2 deletions src/pages/score/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
</view>
<view v-if="selectTerm.year=='全' && selectTerm.period == '期中'" class="col">
<view class="term-info">
总计成绩
期中成绩
</view>
<view class="relative-term-info">
入学后所有期中成绩
Expand Down Expand Up @@ -204,6 +204,44 @@
</w-panel>
</w-collapse>

<w-button v-if="isEdit" class="lesson-group-btn" @tap="electiveLessonChange()">
任选课
</w-button>
<w-collapse v-if="isEdit" class="score-list-collapse">
<w-panel v-for="item in electiveScoreList" :key="item.lessonID">
<template #header>
<checkbox-group v-if="isEdit" @change="handleCheckboxChange(item)">
<checkbox
class="checkbox"
:checked="item.selected"
/>
</checkbox-group>
<view
v-if="item.selected"
class="score-list-collapse-item-title-selected"
color=""
@tap="handleCheckboxChange(item)"
>
{{ item.lessonName }}
</view>
<view v-if="item.selected" class="score-list-collapse-item-extra-selected" @tap="handleCheckboxChange(item)">
{{ item.score }}
</view>
<view
v-if="!item.selected"
class="score-list-collapse-item-title-unselected"
color=""
@tap="handleCheckboxChange(item)"
>
{{ item.lessonName }}
</view>
<view v-if="!item.selected" class="score-list-collapse-item-extra-unselected" @tap="handleCheckboxChange(item)">
{{ item.score }}
</view>
</template>
</w-panel>
</w-collapse>

<w-button v-if="isEdit" class="lesson-group-btn" @tap="optionalLessonChange()">
选修课
</w-button>
Expand Down Expand Up @@ -358,17 +396,22 @@ const sportsScoreList = computed(() => {
});
const optionalScoreList = computed(() => {
return scoreList.value.filter(item => item.lessonType === "任选课" || item.lessonType === "选修课");
return scoreList.value.filter(item => item.lessonType === "任选课");
});
const limitedScoreList = computed(() => {
return scoreList.value.filter(item => item.lessonType === "限选课");
});
const electiveScoreList = computed(() => {
return scoreList.value.filter(item => item.lessonType === "选修课");
});
const allChosen_1 = ref(false);
const allChosen_2 = ref(false);
const allChosen_3 = ref(false);
const allChosen_4 = ref(false);
const allChosen_5 = ref(false);
const requireLessonChange = () => {
if (!allChosen_1.value) {
Expand Down Expand Up @@ -478,6 +521,33 @@ const limitedLessonChange = () => {
allChosen_4.value = !allChosen_4.value;
};
const electiveLessonChange = () => {
if (!allChosen_5.value) {
electiveScoreList.value.forEach(item => {
if (!item.selected) {
selectedLessonsList.value.push(item);
unSelectedLessonsList.value = unSelectedLessonsList.value.filter(
selected => selected.lessonID !== item.lessonID
);
};
item.selected = true;
store.commit("delUnCalc", item);
});
} else {
electiveScoreList.value.forEach(item => {
if (item.selected) {
selectedLessonsList.value = selectedLessonsList.value.filter(
selected => selected.lessonID !== item.lessonID
);
unSelectedLessonsList.value.push(item);
store.commit("setUnCalc", item);
}
item.selected = false;
});
}
allChosen_5.value = !allChosen_5.value;
};
const selectedLessonsList = ref<Score[]>([]);
const unSelectedLessonsList = ref<Score[]>([]);
const unselectedLessons = serviceStore.score.unCalScore;
Expand Down Expand Up @@ -510,6 +580,7 @@ watch(unSelectedLessonsList, (newUnSelectedLessonsList) => {
allChosen_2.value = true;
allChosen_3.value = true;
allChosen_4.value = true;
allChosen_5.value = true;
newUnSelectedLessonsList.forEach((item) => {
const isFind_1 = requiredScoreList.value.find(
storeItem => item.className === storeItem.className && item.scorePoint === storeItem.scorePoint
Expand All @@ -523,10 +594,14 @@ watch(unSelectedLessonsList, (newUnSelectedLessonsList) => {
const isFind_4 = limitedScoreList.value.find(
storeItem => item.className === storeItem.className && item.scorePoint === storeItem.scorePoint
);
const isFind_5 = electiveScoreList.value.find(
storeItem => item.className === storeItem.className && item.scorePoint === storeItem.scorePoint
);
if (isFind_1)allChosen_1.value = false;
if (isFind_2)allChosen_2.value = false;
if (isFind_3)allChosen_3.value = false;
if (isFind_4)allChosen_4.value = false;
if (isFind_5)allChosen_5.value = false;
});
}, { immediate: true });
Expand Down

0 comments on commit 0e4608d

Please sign in to comment.