|
|
@@ -22,6 +22,16 @@
|
|
|
:rules="nameRules"
|
|
|
></v-text-field>
|
|
|
|
|
|
+ <v-select
|
|
|
+ v-model="course"
|
|
|
+ :items="courseList"
|
|
|
+ :item-text="'name'"
|
|
|
+ :item-value="'id'"
|
|
|
+ label="所属课程"
|
|
|
+ class="ma-4"
|
|
|
+ :rules="courseRules"
|
|
|
+ ></v-select>
|
|
|
+
|
|
|
<v-text-field
|
|
|
v-model="position"
|
|
|
:counter="20"
|
|
|
@@ -229,10 +239,11 @@
|
|
|
import Vue from 'vue'
|
|
|
import PageHeader from '@/views/components/PageHeader.vue'
|
|
|
import { createExam } from '@/api/exam'
|
|
|
-import { ExamSerializer, ID } from '@/api/types'
|
|
|
+import { ExamSerializer } from '@/api/types'
|
|
|
import { mapGetters } from 'vuex'
|
|
|
import dayjs, { Dayjs } from 'dayjs'
|
|
|
import { TIME_FORMAT } from '@/utils/common'
|
|
|
+import { getCoursesByTeacher } from '@/api/course'
|
|
|
|
|
|
export default Vue.extend({
|
|
|
name: 'ExamCreate',
|
|
|
@@ -259,6 +270,8 @@ export default Vue.extend({
|
|
|
href: '/'
|
|
|
}
|
|
|
],
|
|
|
+ courseList: [] as any[],
|
|
|
+ course: '',
|
|
|
skillList: [
|
|
|
'Java',
|
|
|
'C++',
|
|
|
@@ -292,6 +305,7 @@ export default Vue.extend({
|
|
|
(v: string) => !!v || '该项为必填项',
|
|
|
(v: string) => v.length <= 25 || '字数过多'
|
|
|
],
|
|
|
+ courseRules: [(v: string) => !!v || '该项为必填项'],
|
|
|
arrayRules: [(v: [] | string) => v.length > 0 || '该项为必填项'],
|
|
|
examLengthTicks: [
|
|
|
'0.5 小时',
|
|
|
@@ -358,6 +372,11 @@ export default Vue.extend({
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
+ getCourses() {
|
|
|
+ getCoursesByTeacher().then(({ data }) => {
|
|
|
+ this.courseList = data.result
|
|
|
+ })
|
|
|
+ },
|
|
|
onCreateExam() {
|
|
|
const obj = {
|
|
|
creatorId: this.getId,
|
|
|
@@ -370,7 +389,8 @@ export default Vue.extend({
|
|
|
comment: this.comment,
|
|
|
antiCheating: this.antiCheating,
|
|
|
isPublic: !this.isPrivate,
|
|
|
- isHidden: false
|
|
|
+ isHidden: false,
|
|
|
+ courseId: this.course
|
|
|
} as ExamSerializer
|
|
|
console.log('创建评测', obj)
|
|
|
createExam(obj).then(({ data }) => {
|
|
|
@@ -386,6 +406,7 @@ export default Vue.extend({
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.getCourses()
|
|
|
this.nowDatetime = dayjs()
|
|
|
this.nowDateTimeFormatted = this.nowDatetime.format(TIME_FORMAT)
|
|
|
this.startDate = this.nowDateTimeFormatted.substr(0, 10)
|