add assessment
This commit is contained in:
parent
a9d261b57e
commit
df32c85521
@ -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<IStudent[]>([])
|
||||
const goals = ref<IGoal[]>([])
|
||||
|
||||
// 平时
|
||||
const normalStage = ref<IAssessment>({ method: [], weight: 0, stage: '' })
|
||||
// 过程
|
||||
const processStage = ref<IAssessment>({ method: [], weight: 0, stage: '' })
|
||||
// 期末
|
||||
const finalStage = ref<IAssessment>({ 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<boolean> {
|
||||
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
|
||||
}
|
||||
})
|
||||
|
@ -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 // 比重
|
||||
}
|
||||
|
||||
|
@ -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<ICourse>({ ...store.courseInfo! })
|
||||
const tempGoal = ref<IGoal>({ importance: 'H', indicator: '', target: '' })
|
||||
const tempGoalList = ref<IGoal[]>(store.goals)
|
||||
const tempAssessmentMethod = ref<IAssessmentMethod>({ method: '', weight: 0 })
|
||||
const tempAssessment = ref<IAssessment>({ 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
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@ -76,9 +126,9 @@ const handleEditCourse = (action: 'save' | 'cancel') => {
|
||||
>
|
||||
<p>课程信息:{{ courseInfo.name }}</p>
|
||||
<div class="flex items-center">
|
||||
<el-button type="primary" :icon="InfoFilled" @click="showEditCourse = true"
|
||||
>编辑课程信息</el-button
|
||||
>
|
||||
<el-button type="primary" :icon="InfoFilled" @click="showEditCourse = true">
|
||||
编辑课程信息
|
||||
</el-button>
|
||||
<el-button :icon="Plus" @click="handleAddNewGoal">添加课程目标</el-button>
|
||||
</div>
|
||||
</div>
|
||||
@ -148,29 +198,117 @@ const handleEditCourse = (action: 'save' | 'cancel') => {
|
||||
<el-button @click="handleEditCourse('cancel')">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog v-model="showEditStage" title="编辑考核方式">
|
||||
<el-form v-model="tempAssessment" label-width="auto">
|
||||
<el-form-item label="考核方式">
|
||||
<el-autocomplete v-model="tempAssessment.stage" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="权重">
|
||||
<el-input v-model="tempAssessment.weight" type="number" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleEditAssessmentSubmit('save', assessmentParent ?? 'n')"
|
||||
>
|
||||
保存
|
||||
</el-button>
|
||||
<el-button @click="handleEditAssessmentSubmit('cancel', assessmentParent ?? 'n')">
|
||||
取消
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
<el-dialog
|
||||
v-model="showAddAssessmentMethod"
|
||||
title="添加考核方式"
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<el-form v-model="tempAssessmentMethod" label-width="auto">
|
||||
<el-form-item label="考核方式">
|
||||
<el-autocomplete v-model="tempAssessmentMethod.method" clearable />
|
||||
</el-form-item>
|
||||
<el-form-item label="权重">
|
||||
<el-input v-model="tempAssessmentMethod.weight" type="number" clearable />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button
|
||||
:disabled="addAssessmentMethodSubmit"
|
||||
type="primary"
|
||||
@click="handleAddAssessmentMethod('save')"
|
||||
>
|
||||
添加
|
||||
</el-button>
|
||||
<el-button @click="handleAddAssessmentMethod('cancel')">取消</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-descriptions title="平时考核" class="px-8">
|
||||
<template #extra>
|
||||
<el-button :icon="Plus" type="primary">添加</el-button>
|
||||
<el-descriptions title="平时考核" class="px-8 pb-4" border :column="3">
|
||||
<template #title>
|
||||
<p>
|
||||
平时考核
|
||||
<span v-if="!normalStage.stage">(待编辑)</span>
|
||||
<span v-else>(通过 {{ normalStage.stage }},占比 {{ normalStage.weight }}%)</span>
|
||||
</p>
|
||||
</template>
|
||||
<el-descriptions-item>
|
||||
<el-empty description="无数据" image-size="0" />
|
||||
<template #extra>
|
||||
<el-button :icon="Plus" type="primary" @click="handleShowAddAssessmentMethodDialog('n')"
|
||||
>添加</el-button
|
||||
>
|
||||
<el-button :icon="Edit" @click="handleEditAssessment('n')">编辑</el-button>
|
||||
</template>
|
||||
<div v-for="method in normalStage.method" :key="method.method">
|
||||
<el-descriptions-item label="考核方式">{{ method.method }}</el-descriptions-item>
|
||||
<el-descriptions-item label="占比">{{ method.weight }}%</el-descriptions-item>
|
||||
<el-descriptions-item label="操作">
|
||||
<el-button>修改</el-button>
|
||||
<el-button type="danger">删除</el-button>
|
||||
</el-descriptions-item>
|
||||
</div>
|
||||
|
||||
<el-descriptions-item v-if="!normalStage.method">
|
||||
<el-empty description="无数据" :image-size="1" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-descriptions title="过程考核" class="px-8">
|
||||
<template #title>
|
||||
<p>
|
||||
过程考核
|
||||
<span v-if="!processStage.stage">(待编辑)</span>
|
||||
<span v-else>(通过 {{ processStage.stage }},占比 {{ processStage.weight }}%)</span>
|
||||
</p>
|
||||
</template>
|
||||
<template #extra>
|
||||
<el-button :icon="Plus" type="primary">添加</el-button>
|
||||
<el-button :icon="Plus" type="primary" @click="handleShowAddAssessmentMethodDialog('p')"
|
||||
>添加</el-button
|
||||
>
|
||||
<el-button :icon="Edit" @click="handleEditAssessment('p')">编辑</el-button>
|
||||
</template>
|
||||
<el-descriptions-item>
|
||||
<el-empty description="无数据" image-size="0" />
|
||||
<el-empty description="无数据" :image-size="1" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
<el-descriptions title="期末考核" class="px-8">
|
||||
<template #title>
|
||||
<p>
|
||||
期末考核
|
||||
<span v-if="!finalStage.stage">(待编辑)</span>
|
||||
<span v-else>(通过 {{ finalStage.stage }},占比 {{ finalStage.weight }}%)</span>
|
||||
</p>
|
||||
</template>
|
||||
<template #extra>
|
||||
<el-button :icon="Plus" type="primary">添加</el-button>
|
||||
<el-button :icon="Plus" type="primary" @click="handleShowAddAssessmentMethodDialog('f')"
|
||||
>添加</el-button
|
||||
>
|
||||
<el-button :icon="Edit" @click="handleEditAssessment('f')">编辑</el-button>
|
||||
</template>
|
||||
<el-descriptions-item>
|
||||
<el-empty description="无数据" image-size="0" />
|
||||
<el-empty description="无数据" :image-size="1" />
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user