diff --git a/src/renderer/src/store/index.ts b/src/renderer/src/store/index.ts index 1d5fbac..2549feb 100644 --- a/src/renderer/src/store/index.ts +++ b/src/renderer/src/store/index.ts @@ -19,7 +19,7 @@ import { defineStore } from 'pinia' import { ref } from 'vue' -import { ICourse, IGoal, IStudent } from '@renderer/types' +import { IAssessment, IAssessmentMethod, ICourse, IGoal, IStudent } from '@renderer/types' import { ElMessage } from 'element-plus' export const useGlobalStore = defineStore('global', () => { @@ -27,6 +27,13 @@ export const useGlobalStore = defineStore('global', () => { const studentList = ref([]) const goals = ref([]) + // 平时 + const normalStage = ref({ method: [], weight: 0, stage: '' }) + // 过程 + const processStage = ref({ method: [], weight: 0, stage: '' }) + // 期末 + const finalStage = ref({ method: [], weight: 0, stage: '' }) + function saveCourseInfo(new_course: ICourse) { courseInfo.value = new_course } @@ -35,6 +42,16 @@ export const useGlobalStore = defineStore('global', () => { courseInfo.value = null } + function addMethodToStage(method: IAssessmentMethod, stage: 'n' | 'p' | 'f') { + if (stage === 'n') { + normalStage.value.method.push(method) + } else if (stage === 'p') { + processStage.value.method.push(method) + } else if (stage === 'f') { + finalStage.value.method.push(method) + } + } + async function createCourseFromXlsx(): Promise { const wb = await window.electron.readXLSX() if (wb === null) { @@ -114,5 +131,16 @@ export const useGlobalStore = defineStore('global', () => { return true } - return { courseInfo, saveCourseInfo, clearCourseInfo, createCourseFromXlsx, studentList, goals } + return { + courseInfo, + saveCourseInfo, + clearCourseInfo, + createCourseFromXlsx, + studentList, + goals, + addMethodToStage, + normalStage, + processStage, + finalStage + } }) diff --git a/src/renderer/src/types/index.ts b/src/renderer/src/types/index.ts index 2eba3a6..92c9438 100644 --- a/src/renderer/src/types/index.ts +++ b/src/renderer/src/types/index.ts @@ -18,15 +18,16 @@ */ // 考核方式 -export interface IAssmentMethod { +export interface IAssessmentMethod { method: string // 方式 weight: number // 权重 } // 考核阶段 -export interface IAssment { - method: IAssmentMethod[] // 方式 +export interface IAssessment { + method: IAssessmentMethod[] // 方式 weight: number // 权重 + stage: string // 考核方式(阶段) } // 学生 @@ -51,7 +52,7 @@ export interface ICourse { // 课程目标比重 export interface IGoalWeight { - stage: IAssment // 阶段 + stage: IAssessment // 阶段 weight: number // 比重 } diff --git a/src/renderer/src/views/panel/PanelIndex.vue b/src/renderer/src/views/panel/PanelIndex.vue index b2880fb..9294e03 100644 --- a/src/renderer/src/views/panel/PanelIndex.vue +++ b/src/renderer/src/views/panel/PanelIndex.vue @@ -21,19 +21,27 @@ import { useGlobalStore } from '@renderer/store' import { storeToRefs } from 'pinia' import { computed, ref } from 'vue' -import { IGoal, ICourse } from '@renderer/types' -import { InfoFilled, Plus } from '@element-plus/icons-vue' +import { IGoal, ICourse, IAssessmentMethod, IAssessment } from '@renderer/types' +import { InfoFilled, Plus, Edit } from '@element-plus/icons-vue' const store = useGlobalStore() -const { courseInfo } = storeToRefs(store) +const { courseInfo, normalStage, processStage, finalStage } = storeToRefs(store) const tempCourseInfo = ref({ ...store.courseInfo! }) const tempGoal = ref({ importance: 'H', indicator: '', target: '' }) const tempGoalList = ref(store.goals) +const tempAssessmentMethod = ref({ method: '', weight: 0 }) +const tempAssessment = ref({ method: [], stage: '', weight: 0 }) const showAddGoal = ref(false) const showEditCourse = ref(false) +const showEditStage = ref(false) +const showAddAssessmentMethod = ref(false) +let assessmentParent: 'n' | 'p' | 'f' | null = null const addGoalSubmit = computed(() => !Object.values(tempGoal.value).every((v) => v)) +const addAssessmentMethodSubmit = computed( + () => !Object.values(tempAssessmentMethod.value).every((v) => v) +) const handleAddNewGoal = () => { showAddGoal.value = true @@ -67,6 +75,48 @@ const handleEditCourse = (action: 'save' | 'cancel') => { } showEditCourse.value = false } + +const handleShowAddAssessmentMethodDialog = (parent: 'n' | 'p' | 'f') => { + assessmentParent = parent + showAddAssessmentMethod.value = true +} + +const handleAddAssessmentMethod = (action: 'save' | 'cancel') => { + if (action === 'save') { + store.addMethodToStage(tempAssessmentMethod.value, assessmentParent ?? 'n') + } + tempAssessmentMethod.value = { method: '', weight: 0 } + showAddAssessmentMethod.value = false +} + +const handleEditAssessment = (stage: 'n' | 'p' | 'f') => { + showEditStage.value = true + if (stage === 'n') { + tempAssessment.value = { ...store.normalStage } + assessmentParent = 'n' + } else if (stage === 'p') { + tempAssessment.value = { ...store.processStage } + assessmentParent = 'p' + } else if (stage === 'f') { + tempAssessment.value = { ...store.finalStage } + assessmentParent = 'f' + } +} + +const handleEditAssessmentSubmit = (action: 'save' | 'cancel', stage: 'n' | 'p' | 'f') => { + if (action === 'save') { + if (stage === 'n') { + normalStage.value = tempAssessment.value + } else if (stage === 'p') { + processStage.value = tempAssessment.value + } else if (stage === 'f') { + finalStage.value = tempAssessment.value + } + } + + tempAssessment.value = { method: [], weight: 0, stage: '' } + showEditStage.value = false +} + + + + + + + + + + + + + + + + + + + + + + - -