Blame view

src/views/examinationPaper/edit.vue 10.2 KB
4c4f7640   梁保满   路由表,路由前端文件
1
  <template>
65f592b6   梁保满   答题卡列表页
2
3
4
5
6
7
    <div>
      <back-box>
        <template slot="title">
          <span>修改答案</span>
        </template>
      </back-box>
13b58a42   梁保满   备题组卷部分前端页面基本完成
8
      <div class="content">
4ad1ef07   阿宝   类型添加验证
9
        <p class="tips" v-if="paperModifyLog.modifiedTime">
f26ecfa4   阿宝   测试bug
10
          <i class="fa fa-bell-o"></i>
4ad1ef07   阿宝   类型添加验证
11
12
13
          {{
            `${paperModifyLog.modifiedTime} ${paperModifyLog.realName}`
          }}老师修改了答案
13b58a42   梁保满   备题组卷部分前端页面基本完成
14
15
16
17
18
19
20
21
        </p>
        <div class="answer-title">
          <p class="name">{{ form.title }}</p>
          <p class="totals">卷面总分:{{ allScore }}分</p>
        </div>
        <div v-for="(question, index) in form.questionList" :key="index">
          <p class="question-title">
            <span>{{ setBigNum(index) }}、</span>
6fffbd55   阿宝   组卷接口调整
22
23
24
            <el-input
              class="ipt"
              v-model.trim="question.questionTitle"
75a5cc20   阿宝   测试用逻辑删除
25
              maxlength="30"
6fffbd55   阿宝   组卷接口调整
26
27
              placeholder="填写大题名称"
            ></el-input>
13b58a42   梁保满   备题组卷部分前端页面基本完成
28
29
30
31
32
            <span>共 {{ setScore(question) }} 分</span>
          </p>
          <ul class="questions-ul">
            <li class="sub-questions">
              <div class="qs-num">题号</div>
b769660c   梁保满   备课组题细节调整,随堂问列表页面开发完成
33
              <div class="qs-type">题型</div>
13b58a42   梁保满   备题组卷部分前端页面基本完成
34
              <div class="qs-score">分数</div>
ca39cc52   阿宝   飞书问题处理
35
               <div class="qs-partScore">漏选得分</div>
13b58a42   梁保满   备题组卷部分前端页面基本完成
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
              <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">{{ subQuestions.questionIndex }}</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>
ca39cc52   阿宝   飞书问题处理
58
59
60
61
62
63
64
65
66
67
68
69
70
71
              <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>
13b58a42   梁保满   备题组卷部分前端页面基本完成
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
              <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">
aed43d3a   阿宝   即时测修改答案
89
                  <template
5424ef82   梁保满   接口调整
90
                    v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
91
                  >
aed43d3a   阿宝   即时测修改答案
92
93
94
95
96
97
98
99
100
101
102
103
104
                    <span
                      v-if="option"
                      class="answer-s"
                      :class="
                        subQuestions.correctAnswer.includes(option)
                          ? 'active'
                          : ''
                      "
                      :key="option"
                      @click="changAnswer(subQuestions, option)"
                      >{{ option }}</span
                    >
                  </template>
13b58a42   梁保满   备题组卷部分前端页面基本完成
105
106
                </p>
                <p v-if="subQuestions.questionType == 2" class="answer-box">
aed43d3a   阿宝   即时测修改答案
107
                  <template
5424ef82   梁保满   接口调整
108
                    v-for="option in subQuestions.answerOptions.split(',')"
13b58a42   梁保满   备题组卷部分前端页面基本完成
109
                  >
aed43d3a   阿宝   即时测修改答案
110
111
112
113
114
115
116
117
118
119
120
                    <span
                      class="answer-s"
                      v-if="option"
                      :class="
                        subQuestions.correctAnswer == option ? 'active' : ''
                      "
                      :key="option"
                      @click="subQuestions.correctAnswer = option"
                      >{{ option }}</span
                    >
                  </template>
13b58a42   梁保满   备题组卷部分前端页面基本完成
121
122
123
124
125
126
127
128
129
130
                </p>
              </div>
            </li>
          </ul>
        </div>
        <div class="btn-box">
          <el-button type="danger" plain round @click="linkBack">取消</el-button>
          <el-button type="primary" round @click="save">保存</el-button>
        </div>
      </div>
65f592b6   梁保满   答题卡列表页
131
    </div>
4c4f7640   梁保满   路由表,路由前端文件
132
133
134
  </template>
  
  <script>
5424ef82   梁保满   接口调整
135
  import { deepClone } from "utils";
13b58a42   梁保满   备题组卷部分前端页面基本完成
136
137
138
  export default {
    data() {
      return {
6fffbd55   阿宝   组卷接口调整
139
        questionList: [],
13b58a42   梁保满   备题组卷部分前端页面基本完成
140
141
142
143
144
145
146
147
        form: {
          //答题卡详情
          title: "",
          tag: "",
          subjectId: "",
          examsDuration: 90,
          gradeName: "",
          share: 1,
4ad1ef07   阿宝   类型添加验证
148
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
149
150
          questionList: [],
        },
4ad1ef07   阿宝   类型添加验证
151
152
153
154
        paperModifyLog: {
          realName: "",
          modifiedTime: "",
        },
13b58a42   梁保满   备题组卷部分前端页面基本完成
155
156
157
158
159
160
161
162
163
164
165
166
167
168
      };
    },
    computed: {
      allScore: function () {
        let score = 0;
        this.form.questionList.map((item) => {
          score += item.subQuestions.reduce((a, b) => {
            return a + Number(b.score);
          }, 0);
        }, 0);
        return Number(score).toFixed(2);
      },
    },
    created() {
6fffbd55   阿宝   组卷接口调整
169
      this._QueryDetail();
13b58a42   梁保满   备题组卷部分前端页面基本完成
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
220
221
222
223
224
225
226
    },
    methods: {
      linkBack() {
        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;
      },
      setBigNum(num) {
        let txt = "";
        let bigNum = [
          "一",
          "二",
          "三",
          "四",
          "五",
          "六",
          "七",
          "八",
          "九",
          "十",
          "十一",
          "十二",
          "十三",
          "十四",
          "十五",
          "十六",
          "十七",
          "十八",
          "十九",
          "二十",
        ];
        txt = bigNum[num];
  
        return txt;
      },
      setScore(question) {
        let score = question.subQuestions.reduce((a, b) => {
          return a + b.score;
        }, 0);
f26ecfa4   阿宝   测试bug
227
        return Number(score).toFixed(2);
13b58a42   梁保满   备题组卷部分前端页面基本完成
228
229
230
231
232
233
234
235
236
237
238
239
      },
      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("");
        }
      },
6fffbd55   阿宝   组卷接口调整
240
      async save() {
503b6063   梁保满   判断题答案选项
241
242
243
244
245
246
247
248
249
250
251
252
        // let valid = "";
        // this.form.questionList.map((item, index) => {
        //   if (!item.questionTitle) {
        //     valid += index + 1 + "、";
        //   }
        // });
        // if (valid) {
        //   this.$message.error(
        //     `大题名称不能为空,请检查第${valid.slice(0, -1)}题!`
        //   );
        //   return;
        // }
6fffbd55   阿宝   组卷接口调整
253
254
        let questionList = this.form.questionList.map((item) => {
          item.score = null;
8f573b82   阿宝   组卷接口联调
255
256
          // item.questionId = "";
          // item.questionIndex = "";
6fffbd55   阿宝   组卷接口调整
257
258
259
260
261
262
263
          return item;
        });
        //更新答题卡
        const { data, status, info } = await this.$request.modifyPaper({
          paperId: this.form.id,
          questionList: questionList,
        });
ee6e7628   梁保满   备题组卷借口数据对接调整
264
        if (status == 0) {
13b58a42   梁保满   备题组卷部分前端页面基本完成
265
          this.$router.push({
6fffbd55   阿宝   组卷接口调整
266
267
            path: "/examinationPaper",
          });
ee6e7628   梁保满   备题组卷借口数据对接调整
268
        } else {
6fffbd55   阿宝   组卷接口调整
269
          this.$message.error(info);
ee6e7628   梁保满   备题组卷借口数据对接调整
270
271
272
273
        }
      },
      async _QueryDetail() {
        //查询年级列表
6fffbd55   阿宝   组卷接口调整
274
275
        const { data, status, info } = await this.$request.fetchPaperDetail({
          paperId: this.$route.query.paperId,
ee6e7628   梁保满   备题组卷借口数据对接调整
276
277
        });
        if (status == 0) {
6fffbd55   阿宝   组卷接口调整
278
279
280
281
          this.form = deepClone(data);
          this.form.questionList.map((item) => {
            item.score = "";
          });
4ad1ef07   阿宝   类型添加验证
282
283
284
285
          this.paperModifyLog = {
            ...this.paperModifyLog,
            ...this.form.paperModifyLog,
          };
ee6e7628   梁保满   备题组卷借口数据对接调整
286
        } else {
6fffbd55   阿宝   组卷接口调整
287
          this.$message.error(info);
ee6e7628   梁保满   备题组卷借口数据对接调整
288
289
        }
      },
13b58a42   梁保满   备题组卷部分前端页面基本完成
290
291
    },
  };
4c4f7640   梁保满   路由表,路由前端文件
292
293
  </script>
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
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
  <style lang="scss" scoped>
  .content {
    width: 100%;
    box-sizing: border-box;
    padding: 0 50px;
    .ml-20 {
      margin-left: 20px;
    }
    .btn-box {
      text-align: right;
      margin-left: 140px;
    }
    .tips {
      height: 48px;
      line-height: 48px;
      padding: 0 16px;
      border: 1px solid #fac7cc;
      background-color: #ffebec;
      font-size: 14px;
      color: #fd9795;
      margin: 10px 0 20px 0;
      .fa-bell-o {
        font-size: 18px;
        margin-right: 5px;
      }
    }
  }
  .answer-title {
    text-align: center;
    font-size: 20px;
    color: #333;
    font-weight: 700;
b769660c   梁保满   备课组题细节调整,随堂问列表页面开发完成
326
    padding-bottom: 20px;
13b58a42   梁保满   备题组卷部分前端页面基本完成
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
    .totals {
      font-size: 16px;
      color: #888;
      font-weight: normal;
    }
  }
  .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;
  }
b769660c   梁保满   备课组题细节调整,随堂问列表页面开发完成
356
  
13b58a42   梁保满   备题组卷部分前端页面基本完成
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
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
  .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   梁保满   路由表,路由前端文件
413
  </style>