|
@@ -65,7 +65,7 @@
|
|
|
>
|
|
>
|
|
|
<template v-slot:activator="{ on, attrs }">
|
|
<template v-slot:activator="{ on, attrs }">
|
|
|
<v-text-field
|
|
<v-text-field
|
|
|
- v-model="startDateFormatted"
|
|
|
|
|
|
|
+ v-model="startDate"
|
|
|
label="开始日期"
|
|
label="开始日期"
|
|
|
prepend-icon="mdi-calendar"
|
|
prepend-icon="mdi-calendar"
|
|
|
readonly
|
|
readonly
|
|
@@ -159,9 +159,6 @@
|
|
|
>
|
|
>
|
|
|
创建评测
|
|
创建评测
|
|
|
</v-btn>
|
|
</v-btn>
|
|
|
- <!-- <v-btn color="primary" class="ma-4" @click="selectQuestion = true">-->
|
|
|
|
|
- <!-- 手动选择试题-->
|
|
|
|
|
- <!-- </v-btn>-->
|
|
|
|
|
</v-form>
|
|
</v-form>
|
|
|
</v-container>
|
|
</v-container>
|
|
|
<v-snackbar>
|
|
<v-snackbar>
|
|
@@ -176,7 +173,7 @@ import PageHeader from '@/views/components/PageHeader.vue'
|
|
|
import { createExam } from '@/api/exam'
|
|
import { createExam } from '@/api/exam'
|
|
|
import { ExamSerializer, ID } from '@/api/types'
|
|
import { ExamSerializer, ID } from '@/api/types'
|
|
|
import { mapGetters } from 'vuex'
|
|
import { mapGetters } from 'vuex'
|
|
|
-import dayjs from 'dayjs'
|
|
|
|
|
|
|
+import dayjs, { Dayjs } from 'dayjs'
|
|
|
import { TIME_FORMAT } from '@/utils/common'
|
|
import { TIME_FORMAT } from '@/utils/common'
|
|
|
|
|
|
|
|
export default Vue.extend({
|
|
export default Vue.extend({
|
|
@@ -226,14 +223,8 @@ export default Vue.extend({
|
|
|
skills: [],
|
|
skills: [],
|
|
|
difficulty: 50,
|
|
difficulty: 50,
|
|
|
startDate: '',
|
|
startDate: '',
|
|
|
- startDateFormatted: '',
|
|
|
|
|
startTime: '',
|
|
startTime: '',
|
|
|
- endDate: '',
|
|
|
|
|
- endDateFormatted: '',
|
|
|
|
|
- endTime: '',
|
|
|
|
|
comment: '',
|
|
comment: '',
|
|
|
- selectedQuestions: [] as Array<ID>,
|
|
|
|
|
- selectQuestion: false,
|
|
|
|
|
antiCheating: false,
|
|
antiCheating: false,
|
|
|
isPrivate: false,
|
|
isPrivate: false,
|
|
|
valid: true,
|
|
valid: true,
|
|
@@ -251,28 +242,39 @@ export default Vue.extend({
|
|
|
'3 小时'
|
|
'3 小时'
|
|
|
],
|
|
],
|
|
|
examLength: 0,
|
|
examLength: 0,
|
|
|
- minStartTime: '',
|
|
|
|
|
- minStartDate: ''
|
|
|
|
|
|
|
+ minStartDate: '',
|
|
|
|
|
+ nowDateTimeFormatted: '',
|
|
|
|
|
+ nowDatetime: (null as unknown) as Dayjs
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
computed: {
|
|
computed: {
|
|
|
...mapGetters(['getId']),
|
|
...mapGetters(['getId']),
|
|
|
|
|
+ minStartTime(): string {
|
|
|
|
|
+ const nowDate = this.nowDateTimeFormatted.substr(0, 10)
|
|
|
|
|
+ const min = this.nowDatetime.add(5, 'minute').format('HH:mm') // bad
|
|
|
|
|
+
|
|
|
|
|
+ if (this.startDate === nowDate) {
|
|
|
|
|
+ return min
|
|
|
|
|
+ }
|
|
|
|
|
+ return ''
|
|
|
|
|
+ },
|
|
|
|
|
+
|
|
|
computedEndDate(): string {
|
|
computedEndDate(): string {
|
|
|
if (this.startTime === '') {
|
|
if (this.startTime === '') {
|
|
|
- return this.startDateFormatted
|
|
|
|
|
|
|
+ return this.startDate
|
|
|
}
|
|
}
|
|
|
- return this.computedExamEndTime.substr(0, 10)
|
|
|
|
|
|
|
+ return this.computedExamEndDateTime.substr(0, 10)
|
|
|
},
|
|
},
|
|
|
computedEndTime(): string {
|
|
computedEndTime(): string {
|
|
|
if (this.startTime === '') {
|
|
if (this.startTime === '') {
|
|
|
return ''
|
|
return ''
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- return this.computedExamEndTime.substr(11, 5)
|
|
|
|
|
|
|
+ return this.computedExamEndDateTime.substr(11, 5)
|
|
|
},
|
|
},
|
|
|
- computedExamEndTime(): string {
|
|
|
|
|
|
|
+ computedExamEndDateTime(): string {
|
|
|
const startTime = dayjs(
|
|
const startTime = dayjs(
|
|
|
- this.startDateFormatted + ' ' + this.startTime + ':00',
|
|
|
|
|
|
|
+ this.startDate + ' ' + this.startTime + ':00',
|
|
|
TIME_FORMAT
|
|
TIME_FORMAT
|
|
|
)
|
|
)
|
|
|
|
|
|
|
@@ -285,43 +287,16 @@ export default Vue.extend({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
- watch: {
|
|
|
|
|
- startDate(val) {
|
|
|
|
|
- this.startDateFormatted = this.formatDate(this.startDate)
|
|
|
|
|
- }
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
- saveSelectedQuestions(questions: Array<ID>) {
|
|
|
|
|
- console.log(questions)
|
|
|
|
|
- this.selectedQuestions = questions
|
|
|
|
|
- },
|
|
|
|
|
- formatDate(date: string): string {
|
|
|
|
|
- if (!date) return ''
|
|
|
|
|
-
|
|
|
|
|
- const [year, month, day] = date.split('-')
|
|
|
|
|
- return `${year}-${month}-${day}`
|
|
|
|
|
- },
|
|
|
|
|
- parseDate(date: string): string {
|
|
|
|
|
- if (!date) return ''
|
|
|
|
|
-
|
|
|
|
|
- const [month, day, year] = date.split('-')
|
|
|
|
|
- return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`
|
|
|
|
|
- },
|
|
|
|
|
onCreateExam() {
|
|
onCreateExam() {
|
|
|
- // if (!this.$refs.form.validate()) {
|
|
|
|
|
- // return
|
|
|
|
|
- // }
|
|
|
|
|
- console.log(this.valid)
|
|
|
|
|
-
|
|
|
|
|
const obj = {
|
|
const obj = {
|
|
|
creatorId: this.getId,
|
|
creatorId: this.getId,
|
|
|
examName: this.examName,
|
|
examName: this.examName,
|
|
|
position: this.position,
|
|
position: this.position,
|
|
|
skills: this.skills,
|
|
skills: this.skills,
|
|
|
difficulty: this.difficulty,
|
|
difficulty: this.difficulty,
|
|
|
- startTime: this.startDateFormatted + ' ' + this.startTime + ':00',
|
|
|
|
|
- endTime: this.computedExamEndTime,
|
|
|
|
|
|
|
+ startTime: this.startDate + ' ' + this.startTime + ':00',
|
|
|
|
|
+ endTime: this.computedExamEndDateTime,
|
|
|
comment: this.comment,
|
|
comment: this.comment,
|
|
|
antiCheating: this.antiCheating,
|
|
antiCheating: this.antiCheating,
|
|
|
isPublic: !this.isPrivate
|
|
isPublic: !this.isPrivate
|
|
@@ -340,11 +315,10 @@ export default Vue.extend({
|
|
|
}
|
|
}
|
|
|
},
|
|
},
|
|
|
mounted() {
|
|
mounted() {
|
|
|
- const now = dayjs()
|
|
|
|
|
- this.startDateFormatted = now.format(TIME_FORMAT).substr(0, 10)
|
|
|
|
|
-
|
|
|
|
|
- this.minStartTime = now.add(5, 'minute').format('HH:mm') // bad
|
|
|
|
|
- this.minStartDate = this.startDateFormatted
|
|
|
|
|
|
|
+ this.nowDatetime = dayjs()
|
|
|
|
|
+ this.nowDateTimeFormatted = this.nowDatetime.format(TIME_FORMAT)
|
|
|
|
|
+ this.startDate = this.nowDateTimeFormatted.substr(0, 10)
|
|
|
|
|
+ this.minStartDate = this.startDate
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
</script>
|
|
</script>
|