Blame view

src/views/examinationPaper/index.vue 16.1 KB
77ebf04d   梁保满   个人版
1
2
3
4
5
6
7
  <template>
    <div>
      <back-box>
        <template slot="title">
          <span>备题组卷</span>
        </template>
        <template slot="btns">
1fa74ed0   梁保满   班级 不加归档入口, 班级、答题卡...
8
          <!-- <el-tooltip
47a01cb6   梁保满   v1.3测试问题
9
            v-if="!code && gdClass"
e5e4a3e6   梁保满   v1.3
10
11
12
13
14
15
16
17
18
19
20
21
            effect="dark"
            content="已归档试卷"
            placement="bottom"
          >
            <el-button
              type="primary"
              icon="fa fa-archive"
              size="mini"
              plain
              circle
              @click="toArchiving"
            ></el-button>
1fa74ed0   梁保满   班级 不加归档入口, 班级、答题卡...
22
          </el-tooltip> -->
77ebf04d   梁保满   个人版
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-plus"
            plain
            @click="toAdd({})"
          >
            添加答题卡</el-button
          >
        </template>
      </back-box>
  
      <div class="answer-header">
        <div class="sel-box">
          <el-select
            class="sel"
            v-model="query.classId"
            placeholder="选择班级"
            @change="changClazz"
          >
            <el-option
              v-for="item in classList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-select
            class="sel"
            v-model="query.subjectName"
            placeholder="选择科目"
            @change="_QueryData()"
          >
            <el-option
              v-for="item in subjectList"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <el-select
            class="sel"
            v-model="query.tagId"
            placeholder="选择类型"
            @change="_QueryData()"
          >
            <el-option
              v-for="item in typeList"
              :key="item.label"
              :label="item.label"
              :value="item.value"
              >{{ item.label }}
            </el-option>
          </el-select>
          <el-input
            placeholder="试卷名称"
            v-model="query.title"
            class="input-with-select"
            @keyup.enter.native="_QueryData(true)"
          >
            <el-button
              slot="append"
              icon="el-icon-search"
              @click="_QueryData(true)"
            ></el-button>
          </el-input>
        </div>
      </div>
      <p class="tips" v-show="archivedTotal">
cffc1a98   梁保满   3-8BUG
94
        <span>回收站内已有{{ archivedTotal }}份答题卡,</span>
77ebf04d   梁保满   个人版
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
        <router-link to="/examinationPaperRecycle">点击查看&gt;&gt;</router-link>
      </p>
      <ul class="content" v-if="tableData && tableData.length">
        <li class="item" v-for="item in tableData" :key="item.id">
          <div class="pic-box">
            <p class="i-box"><i class="fa fa-map-o"></i></p>
            <p class="ids">{{ item.id }}</p>
          </div>
          <div class="info">
            <p class="title">
              {{ item.title }}
              <span class="label" v-if="!!item.tag">{{ item.tag }}</span>
            </p>
            <p class="num">
              总题数:{{ item.questionNum }}
              <em class="s-line">|</em>
              预计时长:{{ item.examsDuration }}
              <em class="s-line">|</em>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
              <template v-if="role != 'ROLE_PERSONAL'">
                授课端同步:
                <span
                  class="clazz"
                  v-for="(clazzChild, indexs) in item.classList"
                  :key="clazzChild.classId"
                  :class="clazzChild.keepStatus == 1 ? 'active' : ''"
                  >{{
                    `${clazzChild.className}${
                      indexs != item.classList.length - 1 ? "、" : ""
                    }`
                  }}
                  <i v-if="clazzChild.keepStatus == 1" class="el-icon-success"></i
                ></span>
                <el-tooltip
                  effect="dark"
                  content="刷新同步状态"
                  placement="right"
                >
                  <i
                    class="icon-refresh el-icon-refresh"
                    @click="refreshStic"
                  ></i>
                </el-tooltip>
              </template>
77ebf04d   梁保满   个人版
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
            </p>
            <p class="person">
              {{ item.realName }}<em class="s-line">|</em
              ><span class="date">{{ item.modifiedTime }}</span>
            </p>
          </div>
          <div class="btn-box">
            <el-tooltip effect="dark" content="修改答案" placement="bottom">
              <el-button
                class="edit"
                type="primary"
                size="mini"
                circle
                icon="el-icon-edit"
                @click="toEdit(item)"
              ></el-button>
            </el-tooltip>
            <el-dropdown
              trigger="click"
              @command="handleDropdownClick($event, item)"
            >
              <el-button
                type="info"
                size="mini"
                circle
                icon="el-icon-more"
              ></el-button>
              <el-dropdown-menu slot="dropdown">
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
166
167
168
169
170
                <el-dropdown-item
                  :command="1"
                  v-if="userName == item.realName && role != 'ROLE_PERSONAL'"
                  >修改分享范围</el-dropdown-item
                >
77ebf04d   梁保满   个人版
171
                <el-dropdown-item :command="2">复制</el-dropdown-item>
cffc1a98   梁保满   3-8BUG
172
                <el-dropdown-item :command="3">放入回收站</el-dropdown-item>
77ebf04d   梁保满   个人版
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
              </el-dropdown-menu>
            </el-dropdown>
          </div>
        </li>
      </ul>
      <div class="pagination-box">
        <el-pagination
          small=""
          layout="total,prev, pager, next"
          :hide-on-single-page="true"
          :total="total"
          @current-change="changePage"
          :current-page="page"
          :page-size="size"
        >
        </el-pagination>
      </div>
      <el-empty
        v-if="!loading && tableData.length == 0"
        content="没有更多数据"
        :image-size="100"
      ></el-empty>
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
195
196
197
198
199
200
201
202
203
204
205
206
207
208
      <el-dialog title="选择分享范围" :visible.sync="dialogVisible" width="400">
        <el-form :model="shareForm" :rules="shareRulesForm" label-width="160px">
          <el-form-item prop="share" label="分享范围:">
            <el-radio-group v-model="shareForm.sharingType">
              <el-radio :label="0">任课班级分享</el-radio>
              <el-radio :label="1">全年级分享</el-radio>
            </el-radio-group>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button type="primary" @click="saveShare">确 定</el-button>
          <el-button @click="dialogVisible = false">取 消</el-button>
        </div>
      </el-dialog>
77ebf04d   梁保满   个人版
209
210
211
212
213
214
215
216
    </div>
  </template>
  
  <script>
  export default {
    name: "examinationPaper",
    data() {
      return {
e5e4a3e6   梁保满   v1.3
217
        code: "",
47a01cb6   梁保满   v1.3测试问题
218
        gdClass: 0, //已归档班级数量
77ebf04d   梁保满   个人版
219
220
        loading: false,
        userName: "",
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
221
        dialogVisible: false,
77ebf04d   梁保满   个人版
222
223
224
225
226
227
228
229
230
231
232
        query: {
          classId: "",
          subjectName: "",
          tagId: "",
          title: "",
        },
        classList: [],
        subjectList: [],
        typeList: [],
        archivedTotal: 0, //已归档答题卡数量
        tableData: null,
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
233
234
235
236
237
238
239
240
241
        shareForm: {
          id: "",
          sharingType: 0, //0-任课班级/1-全年级
        },
        shareRulesForm: {
          sharingType: [
            { required: true, message: "选择分享范围", trigger: "blur" },
          ],
        },
77ebf04d   梁保满   个人版
242
243
244
245
246
247
        total: 0,
        page: 1,
        size: 20,
      };
    },
    async created() {
e5e4a3e6   梁保满   v1.3
248
      this.code = localStorage.getItem("csCode") || "";
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
249
250
251
      this.role =
        this.$store.getters.info.showRole ||
        this.$store.getters.info.permissions[0].role;
77ebf04d   梁保满   个人版
252
      this.userName = this.$store.getters.info.name || "";
47a01cb6   梁保满   v1.3测试问题
253
      this._QueryClassList2()
77ebf04d   梁保满   个人版
254
      await this._QueryClassList();
e5e4a3e6   梁保满   v1.3
255
256
257
      if (!this.query.classId) {
        return;
      }
77ebf04d   梁保满   个人版
258
259
260
261
262
      await this._QuerySubjectList();
      this._QueryData();
      this._QueryTypeList();
    },
    methods: {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
263
264
265
266
267
      refreshStic() {
        setTimeout(function () {
          window.location.reload();
        }, 500);
      },
e5e4a3e6   梁保满   v1.3
268
269
270
271
272
      toArchiving() {
        this.$router.push({
          path: "/examinationPaperArchiving",
        });
      },
77ebf04d   梁保满   个人版
273
      toAdd(query) {
c3cdce9c   梁保满   bug
274
275
276
277
        if (!this.query.classId) {
          this.$message.warning("没有任课班级,请先设置。");
          return;
        }
77ebf04d   梁保满   个人版
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
        let routerItem = {
          path: "/examinationPaperAdd",
        };
        query ? (routerItem["query"] = { ...query }) : "";
        this.$router.push(routerItem);
      },
      toEdit(item) {
        this.$router.push({
          path: "/examinationPaperEdit",
          query: {
            paperId: item.id,
          },
        });
      },
      handleDropdownClick(value, item) {
        //更多
        const that = this;
        switch (value) {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
296
297
298
299
300
301
          case 1:
            //修改分享范围
            that.shareForm.id = item.id;
            that.shareForm.sharingType = item.sharingType;
            that.dialogVisible = true;
            break;
77ebf04d   梁保满   个人版
302
303
304
305
306
307
308
309
310
311
312
313
314
315
          case 2:
            //复制
            that.toAdd({ type: 2, paperId: item.id });
            break;
          case 3:
            //归档
            that.recovery(item);
            break;
        }
      },
      changePage(page) {
        this.page = page;
        this._QueryData(this.query.title);
      },
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
      async saveShare() {
        //修改分享范围
        const { data, status, info } = await this.$request.modifyPaper({
          paperId: this.shareForm.id,
          sharingType: this.shareForm.sharingType,
        });
        if (status === 0) {
          this.shareForm.id = "";
          this.shareForm.sharingType = 1;
          this.dialogVisible = false;
          this.$message.success(info);
          this._QueryData(this.query.title == "");
        } else {
          this.$message.error(info);
        }
      },
77ebf04d   梁保满   个人版
332
333
      async recovery(item) {
        //归档
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
334
335
336
337
338
        let modifyPaper =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pModifyPaper
            : this.$request.modifyPaper;
        const { data, status, info } = await modifyPaper({
77ebf04d   梁保满   个人版
339
340
341
342
343
344
345
346
347
348
349
350
351
352
          paperId: item.id,
          status: 2,
        });
        if (status === 0) {
          let type = this.query.title ? 1 : 0;
          this.page = 1;
          this._QueryData(type);
        } else {
          this.$message.error(info);
        }
      },
      //切换班级
      async changClazz() {
        await this._QuerySubjectList();
77ebf04d   梁保满   个人版
353
354
355
356
        this._QueryData(false);
      },
      // 查找答题卡类型
      async _QueryTypeList() {
34b574e0   梁保满   细节优化
357
        if (!this.query.classId) return;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
358
359
360
361
362
363
        let fetchTypeNames =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pPaperTagList
            : this.$request.fetchTypeNames;
  
        const { data, status, info } = await fetchTypeNames({
77ebf04d   梁保满   个人版
364
365
366
367
368
369
370
371
372
373
374
375
376
          classId: this.query.classId,
          type: 0,
        });
        if (status === 0) {
          this.typeList =
            data.list.map((item) => {
              return {
                value: item.tagId,
                label: item.tag,
              };
            }) || [];
          this.typeList.unshift({
            value: "",
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
377
            label: "请选择标签",
77ebf04d   梁保满   个人版
378
379
380
          });
        } else {
          this.$message.error(info);
47a01cb6   梁保满   v1.3测试问题
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
        }
      },
      // 查找班级
      async _QueryClassList2() {
        this.loading = true;
        let fetchClassList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pClassList
            : this.$request.fetchClassList;
  
        const { data, status, info } = await fetchClassList({ status: 1 });
        if (status === 0) {
          this.gdClass = data?.list?.length || 0;
        } else {
          this.$message.error(info);
77ebf04d   梁保满   个人版
396
397
398
399
400
        }
      },
      // 查找班级
      async _QueryClassList() {
        this.loading = true;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
401
402
403
404
405
406
        let fetchClassList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pClassList
            : this.$request.fetchClassList;
  
        const { data, status, info } = await fetchClassList();
77ebf04d   梁保满   个人版
407
408
409
410
411
        if (status === 0) {
          if (!!data.list) {
            this.classList =
              data.list?.map((item) => {
                return {
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
412
                  value: this.role == "ROLE_PERSONAL" ? item.id : item.classId,
77ebf04d   梁保满   个人版
413
414
415
416
417
418
419
420
421
422
423
                  label: item.className,
                };
              }) || [];
            this.query.classId = this.classList[0]?.value;
          }
        } else {
          this.$message.error(info);
        }
      },
      // 查找科目
      async _QuerySubjectList() {
34b574e0   梁保满   细节优化
424
        if (!this.query.classId) return;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
425
426
427
428
429
430
        let fetchSubjectList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pSubjectList
            : this.$request.fetchSubjectList;
  
        const { data, status, info } = await fetchSubjectList({
77ebf04d   梁保满   个人版
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
          classId: this.query.classId,
        });
        if (status === 0) {
          this.subjectList =
            data.subjectNames?.map((item) => {
              return {
                value: item,
                label: item,
              };
            }) || [];
          this.query.subjectName = this.subjectList[0]?.value;
        } else {
          this.$message.error(info);
        }
      },
      async _QueryData(type) {
34b574e0   梁保满   细节优化
447
        if (!this.query.classId) return;
77ebf04d   梁保满   个人版
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
        this.loading = true;
        //获取答题卡列表
        let query = {};
        if (!type) {
          this.query.title = "";
          query = { ...this.query };
        } else {
          query = { title: this.query.title };
          this.query.tagId = "";
          // this.query.subjectName = "";
        }
        query.classId = this.query.classId;
        query.subjectName = this.query.subjectName;
        for (let key in query) {
          if (!query[key]) {
            query[key] = null;
          }
        }
        if (!query.classId) {
          this.total = 0;
          this.tableData = [];
          this.loading = false;
          return;
        }
        this.loading = true;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
473
474
475
476
477
478
        let fetchPaperList =
          this.role == "ROLE_PERSONAL"
            ? this.$request.pPaperList
            : this.$request.fetchPaperList;
  
        const { data, status, info } = await fetchPaperList({
77ebf04d   梁保满   个人版
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
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
595
          ...query,
          status: 1,
          page: this.page,
          size: this.size,
        });
        this.loading = false;
        if (status === 0) {
          this.archivedTotal = data.archivedTotal;
          this.total = data.total;
          this.tableData = (data.list && [...data.list]) || [];
        } else {
          this.$message.error(info);
        }
      },
    },
  };
  </script>
  
  <style scoped lang="scss">
  .tips {
    display: flex;
    padding-left: 30px;
    line-height: 16px;
    font-size: 14px;
    color: #999;
    margin-bottom: 10px;
  }
  .content {
    margin: 0 20px;
    background: #f8f8f8;
    padding: 12px;
    border-radius: 20px;
    .item {
      display: flex;
      align-items: center;
      width: 100%;
      overflow: hidden;
      box-sizing: border-box;
      padding: 12px;
      border-radius: 20px;
      background: #fff;
      margin-bottom: 12px;
      &:last-of-type {
        margin-bottom: 0;
      }
      .pic-box {
        width: 80px;
        height: 80px;
        border-radius: 10px;
        margin-right: 10px;
        flex-shrink: 0;
        background: #667ffd;
        text-align: center;
        color: #fff;
        font-weight: 500;
        .i-box {
          padding-top: 10px;
          font-size: 32px;
          margin-bottom: 3px;
        }
      }
      .info {
        min-height: 80px;
        flex: 1;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        .s-line {
          padding: 0 5px;
          color: #e2e2e2;
        }
        .title {
          font-size: 16px;
          color: #222;
          font-weight: 500;
          .label {
            display: inline-block;
            font-size: 12px;
            color: #2e9afe;
            line-height: 16px;
            padding: 0 10px;
            border: 1px solid #2e9afe;
            border-radius: 10px;
            transform: translateY(-2px);
          }
        }
        .person {
          color: #666;
        }
      }
      .clazz {
        font-size: 14px;
        font-weight: 500;
        position: relative;
        position: relative;
        &.active {
          color: #667ffd;
        }
        .el-icon-success {
          position: absolute;
          right: 0;
          top: -5px;
          color: #667ffd;
        }
        &:last-of-type {
          .el-icon-success {
            right: -18px;
          }
        }
      }
      .btn-box {
        flex-shrink: 0;
        .edit {
          margin-right: 12px;
        }
      }
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
596
597
      .icon-refresh {
        margin-left: 20px;
77ebf04d   梁保满   个人版
598
        cursor: pointer;
e371f2dc   梁保满   软件下载,学校,班级老师等报表导入...
599
600
        &:hover {
          color: #2e9afe;
77ebf04d   梁保满   个人版
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
        }
      }
    }
  }
  .answer-header {
    .sel-box {
      .sel {
        min-width: 160px;
      }
      :deep(.el-cascader__tags) {
        flex-wrap: nowrap;
      }
    }
  }
  .dialog-footer {
    text-align: center;
    :deep(.el-button) {
      border-radius: 20px;
      padding: 8px 20px 7px;
      margin: 0 12px;
    }
  }
  </style>