Blame view

src/views/examinationPaper/add.vue 30.8 KB
4c4f7640   梁保满   路由表,路由前端文件
1
  <template>
13b58a42   梁保满   备题组卷部分前端页面基本完成
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    <div>
      <back-box>
        <template slot="title">
          <span>{{ "创建答题卡" }}</span>
        </template>
      </back-box>
      <div class="content">
        <el-steps
          :active="step"
          finish-status="success"
          simple
          style="margin: 20px 0"
        >
          <el-step title="基础信息" icon="el-icon-edit"></el-step>
          <el-step title="题目编辑" icon="el-icon-tickets"></el-step>
          <el-step title="设置答案" icon="el-icon-edit-outline"></el-step>
        </el-steps>
        <div v-show="step == 0">
          <el-form
            ref="forms"
            :model="form"
            :rules="formRules"
            label-width="140px"
          >
            <el-form-item label="答题卡名称:" prop="title">
              <el-col :span="10"
                ><el-input
                  type="text"
                  placeholder="请输入答题卡名称"
                  v-model.trim="form.title"
                  maxlength="30"
                  size="45"
                  show-word-limit
                >
                </el-input
              ></el-col>
            </el-form-item>
            <el-form-item label="测验类型:">
ee6e7628   梁保满   备题组卷借口数据对接调整
40
              <el-select v-model="form.tagId" placeholder="选择测验类型">
13b58a42   梁保满   备题组卷部分前端页面基本完成
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
                <el-option
                  v-for="item in answerTypeList"
                  :key="item.id"
                  :label="item.typeName"
                  :value="item.id"
                  >{{ item.typeName }}</el-option
                >
              </el-select>
              <el-button
                class="ml-20"
                type="primary"
                round
                circle
                icon="el-icon-plus"
                @click="dialogVisible = true"
              ></el-button>
            </el-form-item>
            <el-form-item label="年级:" prop="gradeName">
              <el-select
                class="sel"
                v-model="form.gradeName"
                placeholder=""
                @change="changeGrade"
              >
                <el-option
                  v-for="item in gradeList"
                  :key="item"
                  :label="item"
                  :value="item"
                >
                </el-option>
              </el-select>
            </el-form-item>
ee6e7628   梁保满   备题组卷借口数据对接调整
74
75
            <el-form-item label="科目:" prop="subjectName">
              <el-select class="sel" v-model="form.subjectName" placeholder="">
13b58a42   梁保满   备题组卷部分前端页面基本完成
76
77
78
79
80
                <el-option
                  v-for="item in subjectList"
                  :key="item.value"
                  :label="item.label"
                  :value="item.value"
8f573b82   阿宝   组卷接口联调
81
                  >{{ item.label }}
13b58a42   梁保满   备题组卷部分前端页面基本完成
82
83
84
85
86
87
88
89
90
91
92
93
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="考试时长:" prop="examsDuration">
              <el-input-number
                size="medium"
                :min="1"
                :max="240"
                v-model="form.examsDuration"
                label="考试时长"
              ></el-input-number>
            </el-form-item>
ee6e7628   梁保满   备题组卷借口数据对接调整
94
95
            <el-form-item label="分享范围:" prop="sharingType">
              <el-radio-group v-model="form.sharingType">
13b58a42   梁保满   备题组卷部分前端页面基本完成
96
97
98
99
100
101
102
103
104
105
106
107
                <el-radio :label="1">任课班级分享</el-radio>
                <el-radio :label="2">全年级分享</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-form>
          <div class="btn-box">
            <el-button type="danger" plain round @click="linkBack"
              >取消</el-button
            >
            <el-button type="primary" round @click="setStep1">下一步</el-button>
          </div>
          <el-dialog
ee6e7628   梁保满   备题组卷借口数据对接调整
108
            title="添加测验类型"
13b58a42   梁保满   备题组卷部分前端页面基本完成
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
            :visible.sync="dialogVisible"
            width="500px"
          >
            <div class="dia-content">
              <p class="add-type">
                <el-input
                  type="text"
                  placeholder="请输入答题卡类型名称"
                  v-model.trim="answerTypeName"
                  maxlength="10"
                  show-word-limit
                >
                </el-input>
              </p>
            </div>
            <div class="" slot="footer">
ee6e7628   梁保满   备题组卷借口数据对接调整
125
              <el-button type="primary" @click="addPaperType">确 定</el-button>
13b58a42   梁保满   备题组卷部分前端页面基本完成
126
127
128
129
130
131
132
133
134
135
136
              <el-button @click="dialogVisible = false">取 消</el-button>
            </div>
          </el-dialog>
        </div>
        <div v-show="step == 1">
          <div v-for="(question, index) in form.questionList" :key="index">
            <p class="question-title">
              <span>{{ setBigNum(index) }}、</span>
              <el-input
                class="ipt"
                v-model.trim="question.questionTitle"
75a5cc20   阿宝   测试用逻辑删除
137
                maxlength="30"
13b58a42   梁保满   备题组卷部分前端页面基本完成
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
                placeholder="填写大题名称"
              ></el-input>
              <el-popconfirm
                title="确定删除这道大题吗?"
                @confirm="form.questionList.splice(index, 1)"
              >
                <el-button
                  slot="reference"
                  class="delete"
                  type="danger"
                  size="mini"
                  circle
                  icon="el-icon-delete"
                ></el-button>
              </el-popconfirm>
  
              <span>总分数:{{ setScore(question) }}分</span>
            </p>
            <ul class="questions-ul">
              <li class="sub-questions">
                <div class="qs-num">题号</div>
                <div class="qs-type">题型</div>
                <div class="qs-score">分数</div>
                <div class="qs-partScore">部分分值</div>
                <div class="qs-options">选项设置</div>
                <div class="qs-set">操作</div>
              </li>
              <li
                class="sub-questions"
                v-for="(subQuestions, indexs) in question.subQuestions"
                :key="indexs"
              >
                <div class="qs-num">{{ setNum(index, indexs) }}</div>
                <div class="qs-type">
                  <el-select
                    v-model="subQuestions.questionType"
                    placeholder="选择答题卡类型"
                    @change="changeSubQuestions($event, subQuestions)"
                  >
                    <el-option label="单选题" :value="2"></el-option>
                    <el-option label="多选题" :value="3"></el-option>
                    <el-option label="判断题" :value="4"></el-option>
                    <el-option label="主观题" :value="5"></el-option>
                  </el-select>
                </div>
                <div class="qs-score">
                  <el-input-number
                    class="number-ipt"
                    size="medium"
                    :min="1"
                    :max="200"
                    :precision="2"
                    v-model="subQuestions.score"
                    label="单题分值"
                  ></el-input-number>
                </div>
                <div class="qs-partScore">
                  <p v-if="subQuestions.questionType != 3">--</p>
                  <el-input-number
                    class="number-ipt"
                    v-else
                    size="medium"
                    :min="0"
                    :precision="2"
                    :max="subQuestions.score"
                    :step="0.5"
                    v-model="subQuestions.partScore"
                    label="部分分值"
                  ></el-input-number>
                </div>
                <div class="qs-options">
                  <p v-if="subQuestions.questionType == 5">--</p>
                  <p
                    v-else-if="subQuestions.questionType == 4"
                    class="answer-box"
                  >
                    <span class="answer-s">✓</span>
                    <span class="answer-s">✗</span>
                  </p>
                  <p v-else class="answer-box">
                    <span
                      class="answer-s"
ee6e7628   梁保满   备题组卷借口数据对接调整
220
                      v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
                      :key="option"
                      >{{ option }}</span
                    >
                    <el-button
                      size="mini"
                      type="primary"
                      icon="el-icon-plus"
                      circle
                      @click="addOptions(subQuestions)"
                    ></el-button>
                    <el-button
                      size="mini"
                      type="primary"
                      icon="el-icon-minus"
                      round
                      circle
                      @click="removeOptions(subQuestions)"
                    ></el-button>
                  </p>
                </div>
                <div class="qs-set">
                  <el-popconfirm
                    title="确定删除这道题吗?"
                    @confirm="delTabData(indexs, index)"
                  >
                    <el-button
                      slot="reference"
                      class="delete"
                      type="danger"
                      size="mini"
                      circle
                      icon="el-icon-delete"
                    ></el-button>
                  </el-popconfirm>
                </div>
              </li>
              <li class="sub-questions">
                <div class="qs-num">添加</div>
                <div class="qs-type">
                  <el-select
                    v-model="addSubQuestionsType"
                    placeholder="选择答题卡类型"
                    @change="changeAddSubQuestions($event, question)"
                  >
                    <el-option label="单选题" :value="2"></el-option>
                    <el-option label="多选题" :value="3"></el-option>
                    <el-option label="判断题" :value="4"></el-option>
                    <el-option label="主观题" :value="5"></el-option>
                  </el-select>
                </div>
                <div class="qs-score"></div>
                <div class="qs-partScore"></div>
                <div class="qs-options"></div>
                <div class="qs-set"></div>
              </li>
            </ul>
          </div>
          <div class="add-box">
            <p class="add-question" @click="openQuestion">
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-plus"
                circle
              ></el-button>
              <span class="s1">添加大题</span>
            </p>
          </div>
          <div class="btn-box">
            <el-button type="danger" plain round @click="linkBack"
              >取消</el-button
            >
            <el-button round @click="step = 0">上一步</el-button>
            <el-button type="primary" round @click="setStep2">下一步</el-button>
          </div>
          <el-dialog
            title="添加大题"
            :visible.sync="addQuestionVisible"
            width="600px"
          >
            <div class="dia-content">
              <el-form
                ref="form"
                :model="questionForm"
                :rules="questionFormRules"
                label-width="100px"
              >
                <el-form-item label="标题:" prop="questionTitle">
                  <el-col :span="12">
                    <el-input
                      v-model.trim="questionForm.questionTitle"
                      maxlength="30"
                      placeholder="输入大题名称"
                    ></el-input>
                  </el-col>
                </el-form-item>
                <el-form-item label="选择题型:">
                  <el-select v-model="questionForm.questionType" placeholder="">
                    <el-option
                      v-for="item in questionOptions"
                      :key="item.value"
                      :label="item.label"
                      :value="item.value"
                    >
                    </el-option>
                  </el-select>
                </el-form-item>
                <el-form-item label="默认题数:">
                  <el-input-number
                    v-model="questionForm.number"
                    :min="1"
                    :max="50"
                    label="label"
                  ></el-input-number>
                </el-form-item>
              </el-form>
            </div>
            <div class="dialog-footer" slot="footer">
              <el-button type="primary" @click="addQuestion">确 定</el-button>
              <el-button @click="addQuestionVisible = false">取 消</el-button>
            </div>
          </el-dialog>
        </div>
        <div v-show="step == 2">
          <div v-for="(question, index) in form.questionList" :key="index">
            <p class="question-title">
              <span>{{ setBigNum(index) }}、</span>
              <span class="title-txt">{{ question.questionTitle }}</span>
              <span>共 {{ setScore(question) }} 分</span>
            </p>
            <ul class="questions-ul">
              <li class="sub-questions">
                <div class="qs-num">题号</div>
                <div class="qs-score">分数</div>
                <div class="qs-options qs-options2">选项设置</div>
              </li>
              <li
                class="sub-questions"
                v-for="(subQuestions, indexs) in question.subQuestions"
                :key="indexs"
              >
                <div class="qs-num">{{ setNum(index, indexs) }}</div>
                <div class="qs-type">
                  {{ setSubPro(subQuestions.questionType) }}
                </div>
                <div class="qs-score">
                  <el-input-number
                    class="number-ipt"
                    size="medium"
                    :min="1"
                    :max="200"
                    :precision="2"
                    v-model="subQuestions.score"
                    label="单题分值"
                  ></el-input-number>
                </div>
                <div class="qs-options qs-options2">
                  <p v-if="subQuestions.questionType == 5">--</p>
                  <p v-if="subQuestions.questionType == 4" class="answer-box">
                    <span
                      class="answer-s"
                      :class="subQuestions.correctAnswer == 1 ? 'active' : ''"
                      @click="subQuestions.correctAnswer = 1"
                      >✓</span
                    >
                    <span
                      class="answer-s"
                      :class="subQuestions.correctAnswer == 2 ? 'active' : ''"
                      @click="subQuestions.correctAnswer = 2"
                      >✗</span
                    >
                  </p>
                  <p v-if="subQuestions.questionType == 3" class="answer-box">
                    <span
                      class="answer-s"
ee6e7628   梁保满   备题组卷借口数据对接调整
396
                      v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
397
398
399
400
401
402
403
404
405
406
407
408
409
                      :class="
                        subQuestions.correctAnswer.includes(option)
                          ? 'active'
                          : ''
                      "
                      :key="option"
                      @click="changAnswer(subQuestions, option)"
                      >{{ option }}</span
                    >
                  </p>
                  <p v-if="subQuestions.questionType == 2" class="answer-box">
                    <span
                      class="answer-s"
ee6e7628   梁保满   备题组卷借口数据对接调整
410
                      v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
                      :class="
                        subQuestions.correctAnswer == option ? 'active' : ''
                      "
                      :key="option"
                      @click="subQuestions.correctAnswer = option"
                      >{{ option }}</span
                    >
                  </p>
                </div>
              </li>
            </ul>
          </div>
          <div class="btn-box">
            <el-button type="danger" plain round @click="linkBack"
              >取消</el-button
            >
            <el-button round @click="step = 1">上一步</el-button>
            <el-button type="primary" round @click="save">保存</el-button>
          </div>
        </div>
      </div>
    </div>
4c4f7640   梁保满   路由表,路由前端文件
433
434
435
  </template>
  
  <script>
ee6e7628   梁保满   备题组卷借口数据对接调整
436
  import { formatDate, deepClone } from "utils";
13b58a42   梁保满   备题组卷部分前端页面基本完成
437
438
439
440
441
442
443
444
445
446
  const questionForm = {
    questionTitle: "",
    questionType: 2,
    number: 10,
  };
  const subQuesOptions = {
    questionType: 2,
    score: 1,
    partScore: 0,
    selectNum: 4,
ee6e7628   梁保满   备题组卷借口数据对接调整
447
    answerOptions: "A,B,C,D",
13b58a42   梁保满   备题组卷部分前端页面基本完成
448
449
    correctAnswer: "",
  };
4c4f7640   梁保满   路由表,路由前端文件
450
  export default {
13b58a42   梁保满   备题组卷部分前端页面基本完成
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
    data() {
      return {
        type: 1, //1-创建,2-复制答题卡
        dialogVisible: false, //测验类型设置弹窗
        addQuestionVisible: false, //添加大题弹窗
        questionForm: { ...questionForm },
        questionFormRules: {
          questionTitle: [
            { required: true, message: "请输入答题卡名称", trigger: "blur" },
            {
              min: 1,
              max: 30,
              message: "长度在 1 到 30 个字符",
              trigger: "blur",
            },
          ],
        },
        questionOptions: [
          { label: "单选题", value: 2 },
          { label: "多选题", value: 3 },
          { label: "判断题", value: 4 },
          { label: "主观题", value: 5 },
        ],
8f573b82   阿宝   组卷接口联调
474
        rightOptions: ["A", "B", "C", "D", "E", "F", "G"],
13b58a42   梁保满   备题组卷部分前端页面基本完成
475
476
477
478
479
480
481
482
483
        addSubQuestionsType: "",
        step: 0, //步骤
        gradeList: [], //年级
        subjectList: [], //科目
        answerTypeList: [], //测验类型
        answerTypeName: [], //测验类型名称
        form: {
          //答题卡详情
          title: "",
ee6e7628   梁保满   备题组卷借口数据对接调整
484
          tagId: "",
13b58a42   梁保满   备题组卷部分前端页面基本完成
485
          gradeName: "",
ee6e7628   梁保满   备题组卷借口数据对接调整
486
487
488
          subjectName: "",
          examsDuration: 0,
          sharingType: 1,
13b58a42   梁保满   备题组卷部分前端页面基本完成
489
490
491
492
493
494
495
496
497
498
499
500
501
502
          questionList: [],
        },
        formRules: {
          //答题卡验证
          title: [
            { required: true, message: "请输入答题卡名称", trigger: "blur" },
            {
              min: 1,
              max: 30,
              message: "长度在 1 到 30 个字符",
              trigger: "blur",
            },
          ],
          gradeName: [{ required: true, message: "请选择年级", trigger: "blur" }],
ee6e7628   梁保满   备题组卷借口数据对接调整
503
504
505
          subjectName: [
            { required: true, message: "请选择科目", trigger: "blur" },
          ],
13b58a42   梁保满   备题组卷部分前端页面基本完成
506
507
508
509
510
511
          examsDuration: [
            { required: true, message: "请设置考试时长", trigger: "blur" },
          ],
        },
      };
    },
5424ef82   梁保满   接口调整
512
    async created() {
8f573b82   阿宝   组卷接口联调
513
514
515
      await this._GradeList();
      await this._QuerySubjectList(this.gradeList[0]);
      await this._TypeList();
13b58a42   梁保满   备题组卷部分前端页面基本完成
516
517
      this.type = this.$route.query.type ? this.$route.query.type : 1;
      if (this.type == 2) {
ee6e7628   梁保满   备题组卷借口数据对接调整
518
        this._QueryDetail();
13b58a42   梁保满   备题组卷部分前端页面基本完成
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
      }
    },
    methods: {
      linkBack() {
        this.$confirm(
          (this.type == 2 ? "修改复制的" : "组建的") +
            "答题卡未保存,确认退出吗?",
          "提示",
          {
            confirmButtonText: "取消",
            cancelButtonText: "确定",
            confirmButtonClass: "el-button--danger1",
            cancelButtonClass: "el-button--primary",
            showClose: false,
            roundButton: true,
            center: true,
            type: "warning",
          }
        )
          .then(() => {})
          .catch(() => {
            this.$router.push({
              path: "/examinationPaper",
            });
          });
      },
      setSubPro(type) {
        let tit;
        switch (type) {
          case 2:
            tit = "单选题";
            break;
          case 3:
            tit = "多选题";
            break;
          case 4:
            tit = "判断题";
            break;
          case 5:
            tit = "主观题";
            break;
        }
        return tit;
      },
      setNum(index, indexs) {
        let lengths = 0;
        for (let i = 0; i < index; i++) {
          lengths += this.form.questionList[i].subQuestions.length;
        }
        return lengths + indexs + 1;
      },
      setBigNum(num) {
        let txt = "";
        let bigNum = [
          "一",
          "二",
          "三",
          "四",
          "五",
          "六",
          "七",
          "八",
          "九",
          "十",
          "十一",
          "十二",
          "十三",
          "十四",
          "十五",
          "十六",
          "十七",
          "十八",
          "十九",
          "二十",
        ];
        txt = bigNum[num];
4c4f7640   梁保满   路由表,路由前端文件
595
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
        return txt;
      },
      setAddIndex(index) {},
      setStep1() {
        this.$refs["forms"].validate((valid) => {
          // 验证通过:保存
          if (valid) {
            this.step = 1;
          } else {
            this.$message.error("数据有误,请检查!");
            return false;
          }
        });
      },
      setStep2() {
        let valid = true;
        this.form.questionList.map((item) => {
          if (!item.questionTitle) {
            valid = false;
          }
        });
        if (valid) {
          this.step = 2;
        } else {
          this.$message.error("大题名称不能为空,请检查!");
        }
      },
      openQuestion() {
        this.questionForm = { ...questionForm };
        this.addQuestionVisible = true;
      },
      addQuestion() {
        let subQuestions = [];
        let questionsOptions = {
          ...subQuesOptions,
          questionType: this.questionForm.questionType,
        };
        switch (questionsOptions.questionType) {
          case 2:
8f573b82   阿宝   组卷接口联调
635
636
637
            questionsOptions.answerOptions = this.rightOptions
              .slice(0, questionsOptions.selectNum)
              .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
638
639
            break;
          case 3:
8f573b82   阿宝   组卷接口联调
640
641
642
            questionsOptions.answerOptions = this.rightOptions
              .slice(0, questionsOptions.selectNum)
              .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
            questionsOptions.partScore = 0.5;
            break;
          case 4:
          case 5:
            questionsOptions.selectNum = 0;
            break;
        }
        for (let i = 0; i < this.questionForm.number; i++) {
          subQuestions.push({ ...questionsOptions });
        }
        this.form.questionList.push({
          questionTitle: this.questionForm.questionTitle,
          number: this.questionForm.number,
          source: 10,
          subQuestions: [...subQuestions],
        });
        this.addQuestionVisible = false;
      },
      delTabData(subIndex, index) {
        //删除小题
        console.log(subIndex);
        console.log(index);
        this.form.questionList[index].subQuestions.splice(subIndex, 1);
      },
      setScore(question) {
        let score = question.subQuestions.reduce((a, b) => {
          return a + b.score;
        }, 0);
ee6e7628   梁保满   备题组卷借口数据对接调整
671
        return Number(score).toFixed(2);
13b58a42   梁保满   备题组卷部分前端页面基本完成
672
673
674
675
676
677
678
679
680
      },
      changeAddSubQuestions(val, question) {
        if (val) {
          let questionsOptions = {
            ...subQuesOptions,
            questionType: val,
          };
          switch (questionsOptions.questionType) {
            case 2:
8f573b82   阿宝   组卷接口联调
681
682
683
              questionsOptions.answerOptions = this.rightOptions
                .slice(0, questionsOptions.selectNum)
                .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
684
685
              break;
            case 3:
8f573b82   阿宝   组卷接口联调
686
687
688
              questionsOptions.answerOptions = this.rightOptions
                .slice(0, questionsOptions.selectNum)
                .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
              questionsOptions.partScore = 0.5;
              break;
            case 4:
            case 5:
              questionsOptions.selectNum = 0;
              break;
          }
          question.subQuestions.push(questionsOptions);
          this.addSubQuestionsType = "";
        }
      },
      changeSubQuestions(val, subQuestions) {
        //切换多题型-小题题型
        const that = this;
        subQuestions.score = 1;
        subQuestions.partScore = 0;
        subQuestions.correctAnswer = "";
        subQuestions.selectNum = 4;
        switch (val) {
          case 2:
8f573b82   阿宝   组卷接口联调
709
710
711
            subQuestions.answerOptions = that.rightOptions
              .slice(0, subQuestions.selectNum)
              .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
712
713
            break;
          case 3:
8f573b82   阿宝   组卷接口联调
714
715
716
            subQuestions.answerOptions = that.rightOptions
              .slice(0, subQuestions.selectNum)
              .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
717
718
719
720
721
722
723
724
725
726
            subQuestions.partScore = 0.5;
            break;
          case 4:
          case 5:
            subQuestions.selectNum = 0;
            break;
        }
      },
      addOptions(subQuestions) {
        //添加选项
8f573b82   阿宝   组卷接口联调
727
        let length = subQuestions.answerOptions.split(",").length;
13b58a42   梁保满   备题组卷部分前端页面基本完成
728
729
        if (length > 6) return;
        subQuestions.selectNum = length + 1;
8f573b82   阿宝   组卷接口联调
730
731
732
        subQuestions.answerOptions = this.rightOptions
          .slice(0, subQuestions.selectNum)
          .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
733
734
735
      },
      removeOptions(subQuestions) {
        //删除选项
8f573b82   阿宝   组卷接口联调
736
        let length = subQuestions.answerOptions.split(",").length;
13b58a42   梁保满   备题组卷部分前端页面基本完成
737
738
        if (length < 2) return;
        subQuestions.selectNum = length - 1;
8f573b82   阿宝   组卷接口联调
739
740
741
        subQuestions.answerOptions = this.rightOptions
          .slice(0, subQuestions.selectNum)
          .join(",");
13b58a42   梁保满   备题组卷部分前端页面基本完成
742
743
744
745
746
747
748
749
750
751
752
753
      },
      changAnswer(sub, option) {
        //设置多选答案
        let str = new RegExp(option, "g");
        if (sub.correctAnswer?.includes(option)) {
          sub.correctAnswer = sub.correctAnswer.replace(str, "");
        } else {
          let arrs = (sub.correctAnswer && sub.correctAnswer.split("")) || [];
          arrs.push(option);
          sub.correctAnswer = arrs.sort().join("");
        }
      },
ee6e7628   梁保满   备题组卷借口数据对接调整
754
      async addPaperType() {
13b58a42   梁保满   备题组卷部分前端页面基本完成
755
756
757
758
759
760
        //保存测验类型
        if (!this.answerTypeName) {
          this.$message.error("请填写测验名称!");
          return;
        }
        //添加测验类型
6fffbd55   阿宝   组卷接口调整
761
        const { data, status, info } = await this.$request.addPaperType({
8f573b82   阿宝   组卷接口联调
762
          tag: this.answerTypeName,
13b58a42   梁保满   备题组卷部分前端页面基本完成
763
        });
ee6e7628   梁保满   备题组卷借口数据对接调整
764
        if (status == 0) {
8f573b82   阿宝   组卷接口联调
765
          this._TypeList();
13b58a42   梁保满   备题组卷部分前端页面基本完成
766
767
768
769
          this.dialogVisible = false;
          this.answerTypeName = "";
          this.$message.success("添加成功");
        } else {
6fffbd55   阿宝   组卷接口调整
770
          this.$message.error(info);
13b58a42   梁保满   备题组卷部分前端页面基本完成
771
772
773
        }
      },
      async save() {
8f573b82   阿宝   组卷接口联调
774
775
        if (this.saveLoading) return;
        this.saveLoading = true;
ee6e7628   梁保满   备题组卷借口数据对接调整
776
777
778
779
780
781
782
783
784
785
        //添加题目ID、序号
        this.form.questionList.map((item, index) => {
          item.questionId = index + 1;
          item.questionIndex = index + 1;
          item.questionType = 0;
          item.subQuestions.map((items, indexs) => {
            items.questionId = indexs + 1;
            items.questionIndex = indexs + 1;
          });
        });
6fffbd55   阿宝   组卷接口调整
786
        const { data, status, info } = await this.$request.addPaper({
13b58a42   梁保满   备题组卷部分前端页面基本完成
787
788
          ...this.form,
        });
8f573b82   阿宝   组卷接口联调
789
        this.saveLoading = false;
ee6e7628   梁保满   备题组卷借口数据对接调整
790
        if (status == 0) {
13b58a42   梁保满   备题组卷部分前端页面基本完成
791
          this.$router.push({
ee6e7628   梁保满   备题组卷借口数据对接调整
792
793
            path: "/examinationPaper",
          });
13b58a42   梁保满   备题组卷部分前端页面基本完成
794
        } else {
6fffbd55   阿宝   组卷接口调整
795
          this.$message.error(info);
13b58a42   梁保满   备题组卷部分前端页面基本完成
796
797
798
799
800
801
        }
      },
      async changeGrade() {
        //切换年级查询科目
        this._QuerySubjectList(this.form.gradeName);
      },
8f573b82   阿宝   组卷接口联调
802
      async _TypeList() {
13b58a42   梁保满   备题组卷部分前端页面基本完成
803
        //测验类型查询
8f573b82   阿宝   组卷接口联调
804
805
806
807
        const { data, status, info } = await this.$request.fetchTypeNames({
          gradeName: this.form.gradeName,
          type: 1,
        });
ee6e7628   梁保满   备题组卷借口数据对接调整
808
        if (status == 0) {
8f573b82   阿宝   组卷接口联调
809
810
811
812
813
814
815
          this.answerTypeList =
            data.list.map((item) => {
              return {
                typeName: item.tag,
                id: item.tagId,
              };
            }) || [];
13b58a42   梁保满   备题组卷部分前端页面基本完成
816
          if (this.type != 2) {
ee6e7628   梁保满   备题组卷借口数据对接调整
817
            this.form.tagId = this.answerTypeList[0].id || "";
13b58a42   梁保满   备题组卷部分前端页面基本完成
818
819
          }
        } else {
6fffbd55   阿宝   组卷接口调整
820
          this.$message.error(info);
13b58a42   梁保满   备题组卷部分前端页面基本完成
821
822
823
824
        }
      },
      async _GradeList() {
        //查询年级列表
6fffbd55   阿宝   组卷接口调整
825
        const { data, status, info } = await this.$request.fetchGradeList();
ee6e7628   梁保满   备题组卷借口数据对接调整
826
        if (status == 0) {
13b58a42   梁保满   备题组卷部分前端页面基本完成
827
828
829
830
          this.gradeList = [...data.gradeNames] || [];
          if (this.type != 2) {
            this.form.gradeName = this.gradeList[0];
          }
13b58a42   梁保满   备题组卷部分前端页面基本完成
831
        } else {
6fffbd55   阿宝   组卷接口调整
832
          this.$message.error(info);
13b58a42   梁保满   备题组卷部分前端页面基本完成
833
834
        }
      },
5424ef82   梁保满   接口调整
835
      async _QuerySubjectList(grade) {
13b58a42   梁保满   备题组卷部分前端页面基本完成
836
        //查询科目列表
8f573b82   阿宝   组卷接口联调
837
838
839
        const { data, status, info } = await this.$request.fetchSubjectList({
          gradeName: grade,
        });
ee6e7628   梁保满   备题组卷借口数据对接调整
840
        if (status === 0) {
8f573b82   阿宝   组卷接口联调
841
          this.subjectList = data.subjectNames.map((item) => {
13b58a42   梁保满   备题组卷部分前端页面基本完成
842
            return {
8f573b82   阿宝   组卷接口联调
843
844
              value: item,
              label: item,
13b58a42   梁保满   备题组卷部分前端页面基本完成
845
846
            };
          });
8f573b82   阿宝   组卷接口联调
847
          console.log(this.subjectList);
ee6e7628   梁保满   备题组卷借口数据对接调整
848
849
          if (this.subjectList.length) {
            this.form.subjectName = this.subjectList[0].value;
13b58a42   梁保满   备题组卷部分前端页面基本完成
850
          }
8f573b82   阿宝   组卷接口联调
851
          console.log(this.form);
13b58a42   梁保满   备题组卷部分前端页面基本完成
852
        } else {
6fffbd55   阿宝   组卷接口调整
853
          this.$message.error(info);
13b58a42   梁保满   备题组卷部分前端页面基本完成
854
855
        }
      },
ee6e7628   梁保满   备题组卷借口数据对接调整
856
857
      async _QueryDetail() {
        //查询年级列表
6fffbd55   阿宝   组卷接口调整
858
        const { data, status, info } = await this.$request.fetchPaperDetail({
ee6e7628   梁保满   备题组卷借口数据对接调整
859
860
861
          paperId: this.$route.query.paperId,
        });
        if (status == 0) {
8f573b82   阿宝   组卷接口联调
862
          this.form.title = data.title+'_副本';
ee6e7628   梁保满   备题组卷借口数据对接调整
863
864
          this.form.tagId = data.tagId;
          this.form.subjectName = data.subjectName;
8f573b82   阿宝   组卷接口联调
865
          this.form.gradeName = data.gradeName;
ee6e7628   梁保满   备题组卷借口数据对接调整
866
867
868
869
870
871
872
873
874
          this.form.examsDuration = data.examsDuration;
          this.form.sharingType = data.sharingType;
          this.form.questionList = data.questionList?.map((item) => {
            let subQuestions =
              item.subQuestions?.map((items) => {
                return {
                  questionType: items.questionType,
                  score: items.score,
                  partScore: items.partScore,
8f573b82   阿宝   组卷接口联调
875
876
                  selectNum: items.answerOptions.split(",").length,
                  answerOptions: items.answerOptions || "A,B,C,D",
ee6e7628   梁保满   备题组卷借口数据对接调整
877
878
879
880
881
882
883
884
885
                  correctAnswer: items.correctAnswer,
                };
              }) || [];
            return {
              questionTitle: item.questionTitle,
              subQuestions: subQuestions,
            };
          });
        } else {
6fffbd55   阿宝   组卷接口调整
886
          this.$message.error(info);
ee6e7628   梁保满   备题组卷借口数据对接调整
887
888
        }
      },
13b58a42   梁保满   备题组卷部分前端页面基本完成
889
890
891
    },
  };
  </script>
4c4f7640   梁保满   路由表,路由前端文件
892
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
  <style lang="scss" scoped>
  .red {
    color: #f30;
  }
  .content {
    width: 100%;
    box-sizing: border-box;
    padding: 0 50px;
    .ml-20 {
      margin-left: 20px;
    }
    .btn-box {
      text-align: right;
      margin-left: 140px;
    }
  }
  .dia-content {
    .dia-tit {
      font-size: 20px;
      color: #333;
      font-weight: 700;
      text-align: center;
    }
    .add-type {
      display: flex;
    }
    .add-btn {
      margin-left: 20px;
    }
  }
  .el-message-box {
    :deep(.el-button--default) {
      color: #fff;
    }
  }
  .add-box {
    display: flex;
    justify-content: center;
    align-items: center;
    .add-question {
      display: flex;
      justify-content: center;
      align-items: center;
      font-size: 16px;
      font-weight: bolder;
      padding: 2px;
      cursor: pointer;
      .s1 {
        margin-left: 6px;
      }
      :deep(.el-icon-plus) {
        font-size: 24px;
        font-weight: 900;
      }
      :deep(.el-button--mini.is-circle) {
        padding: 3px;
      }
    }
  }
  .dialog-footer {
    text-align: center;
    :deep(.el-button) {
      border-radius: 20px;
      padding: 8px 20px 7px;
      margin: 0 12px;
    }
  }
  .question-title {
    line-height: 40px;
    .ipt {
      width: 300px;
      margin: 0 16px 0 10px;
      :deep(.el-input__inner) {
        border-radius: 20px;
        border-color: #667ffd;
        background: rgba($color: #667ffd, $alpha: 0.05);
      }
    }
    .delete {
      margin-right: 8px;
    }
    .title-txt {
      margin-right: 20px;
      font-size: 16px;
      font-weight: 700;
    }
  }
  .el-input-number {
    width: 140px;
  }
  .answer-box {
    .answer-s {
      display: inline-block;
      width: 30px;
      height: 30px;
      border: 1px solid #e2e2e2;
      border-radius: 3px;
      margin: 0 6px;
      font-size: 16px;
      color: #333;
      text-align: center;
      line-height: 30px;
      &.active {
        background: #5e78fa;
        border-color: #5e78fa;
        color: #fff;
      }
    }
  }
  .questions-ul {
    border-left: 1px solid #e2e2e2;
    border-top: 1px solid #e2e2e2;
    margin: 12px 0;
  }
  .sub-questions {
    width: 100%;
    display: flex;
    border-bottom: 1px solid #e2e2e2;
    & > div {
      min-height: 40px;
      padding: 5px;
      flex-shrink: 0;
      border-right: 1px solid #e2e2e2;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .qs-num {
      width: 80px;
    }
    .qs-type {
      width: 160px;
    }
    .qs-score,
    .qs-partScore {
      width: 160px;
    }
    .qs-options {
      flex: 1;
    }
    .qs-set {
      width: 80px;
    }
    .qs-options2 {
      text-align: left;
      justify-content: flex-start;
      padding-left: 20px;
      .answer-s {
        cursor: pointer;
      }
    }
    :deep(.el-select) {
      .el-input__inner {
        border-radius: 20px;
        border-color: #667ffd;
        width: 150px;
        height: 32px;
        line-height: 32px;
        background: rgba($color: #667ffd, $alpha: 0.05);
      }
      .el-input__icon {
        line-height: 32px;
      }
    }
  }
4c4f7640   梁保满   路由表,路由前端文件
1058
  </style>