|
|
@@ -1,25 +1,34 @@
|
|
|
<template>
|
|
|
- <form @submit.prevent="handleSubmit">
|
|
|
- <label>
|
|
|
- 测试名称:
|
|
|
- <input v-model="quiz.name" required placeholder="请输入测试名称" />
|
|
|
- </label>
|
|
|
- <label>
|
|
|
- 测试进行时课件的状态(测试时间):
|
|
|
- <select v-model="quiz.quizTime" required >
|
|
|
- <option value="" disabled selected hidden>请选择测试时间</option>
|
|
|
- <option :key="index" v-for="(item, index) in SlideStateTranslation" :value="index">{{ item }}</option>
|
|
|
- </select>
|
|
|
- </label>
|
|
|
- <div class="mb-16" :key="question.id" v-for="(question, index) in selectedQuestions">
|
|
|
- <div>{{ index + 1 }}.</div>
|
|
|
- <a @click="moveIndexQuestionUp(index)">向上移动</a>
|
|
|
- <a @click="moveIndexQuestionUp(index + 1)">向下移动</a>
|
|
|
- <question-detail-factory :question="question" />
|
|
|
+ <div class="quiz-editor">
|
|
|
+ <div>
|
|
|
+ <back-title>创建测试</back-title>
|
|
|
+ <div class="quiz-form">
|
|
|
+ <div class="sub-title mb-16">测试详情</div>
|
|
|
+ <div class="input-title mb-8">
|
|
|
+ 测试名称:
|
|
|
+ </div>
|
|
|
+ <c-input class="mb-24" v-model="quiz.name" placeholder="请输入测试名称"></c-input>
|
|
|
+ <div class="input-title mb-8">
|
|
|
+ 开放测试所需课件状态:
|
|
|
+ </div>
|
|
|
+ <c-select disabled-display="[ 未选择 ]" v-model="quiz.quizTime" class="mb-24" :list="selectItems"></c-select>
|
|
|
+ <c-button theme="green" icon="check" block @click="handleSubmit">创建测试</c-button>
|
|
|
+ </div>
|
|
|
+ <div class="selected-question-card mt-24 mb-24" :key="question.id" v-for="(question, index) in selectedQuestions">
|
|
|
+ <div class="selected-question-card-header">
|
|
|
+ <div>题号:<span>{{ index + 1 }}</span></div>
|
|
|
+ <div class="spacer"></div>
|
|
|
+ <c-button @click="moveIndexQuestionUp(index)" text theme="blue" icon="arrow_upward">上移</c-button>
|
|
|
+ <c-button @click="moveIndexQuestionUp(index + 1)" :right="-8" text theme="green" icon="arrow_downward">下移</c-button>
|
|
|
+ </div>
|
|
|
+ <question-detail-factory :question="question"/>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
- <question-table v-model="selectedQuestions" selectable />
|
|
|
- <button>提交</button>
|
|
|
- </form>
|
|
|
+ <div>
|
|
|
+ <div class="sub-title">题库</div>
|
|
|
+ <question-table v-model="selectedQuestions" selectable/>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
@@ -28,40 +37,54 @@ import { QuizStateNaming } from '@/server/enums/quiz-state'
|
|
|
import SlideStateTranslation from '@/server/enums/slide-state-translation'
|
|
|
import QuestionTable from '@/views/quiz/components/QuestionTable'
|
|
|
import QuestionDetailFactory from '@/views/quiz/components/QuestionDetailFactory'
|
|
|
+import CInput from '@/components/Basic/CInput'
|
|
|
+import CButton from '@/components/Basic/CButton'
|
|
|
+import CSelect from '@/components/Basic/CSelect'
|
|
|
+import BackTitle from '@/components/Basic/BackTitle'
|
|
|
|
|
|
export default {
|
|
|
name: 'QuizEditor',
|
|
|
- components: { QuestionDetailFactory, QuestionTable },
|
|
|
+ components: { BackTitle, CSelect, CButton, CInput, QuestionDetailFactory, QuestionTable },
|
|
|
props: {
|
|
|
initQuiz: {
|
|
|
type: Object,
|
|
|
default: () => ({})
|
|
|
}
|
|
|
},
|
|
|
- data() {
|
|
|
+ data () {
|
|
|
return {
|
|
|
quiz: { name: '', quizTime: '' },
|
|
|
selectedQuestions: [],
|
|
|
+ unfoldList: {},
|
|
|
|
|
|
QuestionKindNaming,
|
|
|
QuizStateNaming,
|
|
|
SlideStateTranslation
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ selectItems () {
|
|
|
+ return Object.keys(this.SlideStateTranslation).map(key => ({
|
|
|
+ value: key,
|
|
|
+ display: this.SlideStateTranslation[key]
|
|
|
+ }))
|
|
|
+ }
|
|
|
+ },
|
|
|
watch: {
|
|
|
initQuiz: {
|
|
|
immediate: true,
|
|
|
- handler({ id, name, quizTime, questions = [] } = {}) {
|
|
|
+ handler ({ id, name, quizTime, questions = [] } = {}) {
|
|
|
this.quiz = { id, name, quizTime }
|
|
|
this.selectedQuestions = questions
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
- handleSubmit() {
|
|
|
+ handleSubmit () {
|
|
|
+ this.$setInfoMessage('正在上传测试内容')
|
|
|
this.$emit('submit', { ...this.quiz, questions: this.selectedQuestions.map(item => item.id) })
|
|
|
},
|
|
|
- moveIndexQuestionUp(index) {
|
|
|
+ moveIndexQuestionUp (index) {
|
|
|
if (index < this.selectedQuestions.length && index >= 1) {
|
|
|
const nextQuestions = [...this.selectedQuestions]
|
|
|
const before = nextQuestions[index - 1]
|
|
|
@@ -74,6 +97,67 @@ export default {
|
|
|
}
|
|
|
</script>
|
|
|
|
|
|
-<style scoped>
|
|
|
+<style lang="scss" scoped>
|
|
|
+@import "~@/style/theme.scss";
|
|
|
+
|
|
|
+.input-title {
|
|
|
+ font-size: 18px;
|
|
|
+ color: #5a6a7a;
|
|
|
+}
|
|
|
+
|
|
|
+.quiz-editor {
|
|
|
+ display: flex;
|
|
|
+ width: 100%;
|
|
|
+ margin: 0 -24px;
|
|
|
+ align-items: start;
|
|
|
+
|
|
|
+ & > div {
|
|
|
+ margin: 0 24px;
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ .quiz-form {
|
|
|
+ box-sizing: border-box;
|
|
|
+ border: 1px solid #cadaea;
|
|
|
+ border-radius: 6px;
|
|
|
+ padding: 16px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.selected-question-card {
|
|
|
+ border: 1px solid #cadaea;
|
|
|
+ border-radius: 6px;
|
|
|
+ padding: 8px 12px 12px 12px;
|
|
|
+ font-size: 12px;
|
|
|
|
|
|
+ .spacer {
|
|
|
+ flex: 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ &-header {
|
|
|
+ font-size: 16px;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 8px 12px;
|
|
|
+ background-color: $theme-background-grey-darker;
|
|
|
+ margin: -8px -12px 8px -12px;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+@media (max-width: 900px) {
|
|
|
+ .quiz-editor {
|
|
|
+ display: block;
|
|
|
+ margin: 0 auto;
|
|
|
+
|
|
|
+ & > div {
|
|
|
+ margin: unset;
|
|
|
+ }
|
|
|
+
|
|
|
+ & > div:last-child {
|
|
|
+ /*border-top: 1px #cadaea solid;*/
|
|
|
+ padding-top: 16px;
|
|
|
+ margin-top: 24px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
</style>
|