|
|
@@ -0,0 +1,311 @@
|
|
|
+<template>
|
|
|
+ <v-container>
|
|
|
+ <page-header title="创建考试" :breadcrumb="breadcrumb"> </page-header>
|
|
|
+ <!--创建的表格-->
|
|
|
+ <v-container class="grey lighten-5 pa-6" v-if="!isExamCreated">
|
|
|
+ <v-form ref="form" lazy-validation>
|
|
|
+ <v-text-field
|
|
|
+ v-model="examName"
|
|
|
+ :counter="10"
|
|
|
+ label="考试名称"
|
|
|
+ required
|
|
|
+ class="ma-4"
|
|
|
+ ></v-text-field>
|
|
|
+
|
|
|
+ <v-text-field
|
|
|
+ v-model="position"
|
|
|
+ :counter="10"
|
|
|
+ label="招聘职位"
|
|
|
+ required
|
|
|
+ class="ma-4"
|
|
|
+ ></v-text-field>
|
|
|
+
|
|
|
+ <v-select
|
|
|
+ v-model="skills"
|
|
|
+ :items="skillList"
|
|
|
+ chips
|
|
|
+ label="技能点"
|
|
|
+ multiple
|
|
|
+ outlined
|
|
|
+ class="ma-4"
|
|
|
+ ></v-select>
|
|
|
+
|
|
|
+ <v-subheader class="ma-2 sm">
|
|
|
+ 预期难度
|
|
|
+ </v-subheader>
|
|
|
+ <v-slider
|
|
|
+ v-model="difficulty"
|
|
|
+ thumb-label="always"
|
|
|
+ class="ml-4 mr-4 mt-8"
|
|
|
+ ></v-slider>
|
|
|
+
|
|
|
+ <!--开始日期/时间-->
|
|
|
+ <v-row class="ma-4">
|
|
|
+ <v-menu
|
|
|
+ v-model="menu1"
|
|
|
+ :close-on-content-click="false"
|
|
|
+ transition="scale-transition"
|
|
|
+ offset-y
|
|
|
+ max-width="290px"
|
|
|
+ min-width="290px"
|
|
|
+ >
|
|
|
+ <template v-slot:activator="{ on, attrs }">
|
|
|
+ <v-text-field
|
|
|
+ v-model="startDateFormatted"
|
|
|
+ label="开始日期"
|
|
|
+ prepend-icon="mdi-calendar"
|
|
|
+ readonly
|
|
|
+ v-bind="attrs"
|
|
|
+ v-on="on"
|
|
|
+ ></v-text-field>
|
|
|
+ </template>
|
|
|
+ <v-date-picker
|
|
|
+ v-model="startDate"
|
|
|
+ no-title
|
|
|
+ @input="menu1 = false"
|
|
|
+ ></v-date-picker>
|
|
|
+ </v-menu>
|
|
|
+
|
|
|
+ <v-menu
|
|
|
+ v-model="menu2"
|
|
|
+ ref="menu2"
|
|
|
+ :close-on-content-click="false"
|
|
|
+ :nudge-right="40"
|
|
|
+ :return-value.sync="startTime"
|
|
|
+ transition="scale-transition"
|
|
|
+ offset-y
|
|
|
+ max-width="290px"
|
|
|
+ min-width="290px"
|
|
|
+ >
|
|
|
+ <template v-slot:activator="{ on, attrs }">
|
|
|
+ <v-text-field
|
|
|
+ v-model="startTime"
|
|
|
+ label="开始时间"
|
|
|
+ prepend-icon="mdi-clock-time-four-outline"
|
|
|
+ readonly
|
|
|
+ v-bind="attrs"
|
|
|
+ v-on="on"
|
|
|
+ ></v-text-field>
|
|
|
+ </template>
|
|
|
+ <v-time-picker
|
|
|
+ v-if="menu2"
|
|
|
+ v-model="startTime"
|
|
|
+ full-width
|
|
|
+ @click:minute="$refs.menu2.save(startTime)"
|
|
|
+ ></v-time-picker>
|
|
|
+ </v-menu>
|
|
|
+ </v-row>
|
|
|
+
|
|
|
+ <!--结束日期/时间-->
|
|
|
+ <v-row class="ma-4">
|
|
|
+ <v-menu
|
|
|
+ v-model="menu3"
|
|
|
+ :close-on-content-click="false"
|
|
|
+ transition="scale-transition"
|
|
|
+ offset-y
|
|
|
+ max-width="290px"
|
|
|
+ min-width="290px"
|
|
|
+ >
|
|
|
+ <template v-slot:activator="{ on, attrs }">
|
|
|
+ <v-text-field
|
|
|
+ v-model="endDateFormatted"
|
|
|
+ label="结束日期"
|
|
|
+ prepend-icon="mdi-calendar"
|
|
|
+ readonly
|
|
|
+ v-bind="attrs"
|
|
|
+ v-on="on"
|
|
|
+ ></v-text-field>
|
|
|
+ </template>
|
|
|
+ <v-date-picker
|
|
|
+ v-model="endDate"
|
|
|
+ no-title
|
|
|
+ @input="menu3 = false"
|
|
|
+ ></v-date-picker>
|
|
|
+ </v-menu>
|
|
|
+
|
|
|
+ <v-menu
|
|
|
+ v-model="menu4"
|
|
|
+ ref="menu4"
|
|
|
+ :close-on-content-click="false"
|
|
|
+ :nudge-right="40"
|
|
|
+ :return-value.sync="endTime"
|
|
|
+ transition="scale-transition"
|
|
|
+ offset-y
|
|
|
+ max-width="290px"
|
|
|
+ min-width="290px"
|
|
|
+ >
|
|
|
+ <template v-slot:activator="{ on, attrs }">
|
|
|
+ <v-text-field
|
|
|
+ v-model="endTime"
|
|
|
+ label="结束时间"
|
|
|
+ prepend-icon="mdi-clock-time-four-outline"
|
|
|
+ readonly
|
|
|
+ v-bind="attrs"
|
|
|
+ v-on="on"
|
|
|
+ ></v-text-field>
|
|
|
+ </template>
|
|
|
+ <v-time-picker
|
|
|
+ v-if="menu4"
|
|
|
+ v-model="endTime"
|
|
|
+ full-width
|
|
|
+ @click:minute="$refs.menu4.save(endTime)"
|
|
|
+ ></v-time-picker>
|
|
|
+ </v-menu>
|
|
|
+ </v-row>
|
|
|
+
|
|
|
+ <v-text-field
|
|
|
+ v-model="comment"
|
|
|
+ label="备注"
|
|
|
+ class="ma-4 mb-8"
|
|
|
+ ></v-text-field>
|
|
|
+
|
|
|
+ <v-btn color="success" class="ma-4" @click="onCreateExam">
|
|
|
+ 提交创建
|
|
|
+ </v-btn>
|
|
|
+ </v-form>
|
|
|
+ </v-container>
|
|
|
+
|
|
|
+ <!--创建成功后显示-->
|
|
|
+ <v-container v-else>
|
|
|
+ <v-card class="px-3 mb-5">
|
|
|
+ <v-card-title>考试「{{ createdExamInfo.title }}」创建成功</v-card-title>
|
|
|
+ <v-card-subtitle>考试ID: {{ createdExamInfo.id }}</v-card-subtitle>
|
|
|
+ <v-row no-gutters align-content="start">
|
|
|
+ <v-col>
|
|
|
+ <v-card-text class="pa-0 pb-3"
|
|
|
+ >考试邀请码:{{ createdExamInfo.inviteCode }}</v-card-text
|
|
|
+ >
|
|
|
+ </v-col>
|
|
|
+ <v-col>
|
|
|
+ <v-card-text class="pa-0 pb-5"
|
|
|
+ >当前难度值:{{ createdExamInfo.difficulty }}</v-card-text
|
|
|
+ >
|
|
|
+ </v-col>
|
|
|
+ </v-row>
|
|
|
+ </v-card>
|
|
|
+
|
|
|
+ <v-container class="grey lighten-5 pa-6">
|
|
|
+ <v-card-title>样卷</v-card-title>
|
|
|
+ </v-container>
|
|
|
+ </v-container>
|
|
|
+ </v-container>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script lang="ts">
|
|
|
+import Vue from 'vue'
|
|
|
+import PageHeader from '@/components/PageHeader.vue'
|
|
|
+import { createExam } from '@/api/exam'
|
|
|
+import { ExamSerializer } from '@/api/types'
|
|
|
+
|
|
|
+export default Vue.extend({
|
|
|
+ name: 'ExamCreate',
|
|
|
+ components: {
|
|
|
+ PageHeader
|
|
|
+ },
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ breadcrumb: [
|
|
|
+ {
|
|
|
+ text: '主页',
|
|
|
+ disabled: false,
|
|
|
+ href: '/'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ text: '创建考试',
|
|
|
+ disabled: true,
|
|
|
+ href: '/'
|
|
|
+ }
|
|
|
+ ],
|
|
|
+ skillList: [
|
|
|
+ 'Java',
|
|
|
+ 'C++',
|
|
|
+ 'Python',
|
|
|
+ 'JavaScript',
|
|
|
+ 'Go',
|
|
|
+ 'MySQL',
|
|
|
+ 'Redis',
|
|
|
+ 'React',
|
|
|
+ 'Vue'
|
|
|
+ ],
|
|
|
+ isExamCreated: false,
|
|
|
+ createdExamInfo: {} as ExamSerializer,
|
|
|
+ menu1: false,
|
|
|
+ menu2: false,
|
|
|
+ menu3: false,
|
|
|
+ menu4: false,
|
|
|
+ examName: '',
|
|
|
+ position: '',
|
|
|
+ skills: [],
|
|
|
+ difficulty: 1,
|
|
|
+ startDate: '',
|
|
|
+ startDateFormatted: '',
|
|
|
+ startTime: '',
|
|
|
+ endDate: '',
|
|
|
+ endDateFormatted: '',
|
|
|
+ endTime: '',
|
|
|
+ comment: ''
|
|
|
+ }
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ computedStartDateFormatted(): string {
|
|
|
+ return this.formatDate(this.startDate)
|
|
|
+ },
|
|
|
+ computedEndDateFormatted(): string {
|
|
|
+ return this.formatDate(this.endDate)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ startDate(val) {
|
|
|
+ this.startDateFormatted = this.formatDate(this.startDate)
|
|
|
+ },
|
|
|
+ endDate(val) {
|
|
|
+ this.endDateFormatted = this.formatDate(this.endDate)
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ methods: {
|
|
|
+ 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() {
|
|
|
+ const obj = {
|
|
|
+ userId: 'userId1',
|
|
|
+ examName: this.examName,
|
|
|
+ position: this.position,
|
|
|
+ skills: this.skills,
|
|
|
+ difficulty: this.difficulty,
|
|
|
+ startTime: this.startDateFormatted + ' ' + this.startTime + ':00',
|
|
|
+ endTime: this.endDateFormatted + ' ' + this.endTime + ':00',
|
|
|
+ comment: this.comment
|
|
|
+ }
|
|
|
+ console.log('创建考试', obj)
|
|
|
+ createExam(obj).then(({ data }) => {
|
|
|
+ console.log(data.res)
|
|
|
+ this.isExamCreated = data.res ? true : false
|
|
|
+ this.createdExamInfo = data.res || {}
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ mounted() {
|
|
|
+ this.startDateFormatted = this.formatDate(
|
|
|
+ new Date().toISOString().substr(0, 10)
|
|
|
+ )
|
|
|
+ this.endDateFormatted = this.formatDate(
|
|
|
+ new Date().toISOString().substr(0, 10)
|
|
|
+ )
|
|
|
+ }
|
|
|
+})
|
|
|
+</script>
|
|
|
+
|
|
|
+<style scoped></style>
|