xiangpei
2024-03-26 dd36e59f6ef5057dc6334ebb2a8e492c9786b04c
1
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
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
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
138
139
140
141
142
143
144
<template>
  <div style="margin-top: 10px" class="app-contain">
    <div style="display: flex;flex-direction: row">
      <div style="width: 400px;margin-right: 30px">
        <el-card style="width: 400px;padding: 20px;">
          <el-form label-width="90px">
            <el-form-item label="学科:">
              <el-select v-model="buildParam.subjectId" clearable>
                <el-option v-for="item in subjectList" :key="item.id" :value="item.id" :label="item.name"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="单选题:">
              <el-slider v-model="buildParam.singleChoice" :step="1" :min="0" :max="20" show-stops></el-slider>
            </el-form-item>
            <el-form-item label="多选题:">
              <el-slider v-model="buildParam.multipleChoice" :step="1" :min="0" :max="20" show-stops></el-slider>
            </el-form-item>
            <el-form-item label="判断题:">
              <el-slider v-model="buildParam.trueFalse" :step="1" :min="0" :max="20" show-stops></el-slider>
            </el-form-item>
            <el-form-item label="难度:" class="smart-rate">
              <el-rate v-model="buildParam.difficult"></el-rate>
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="buildPaper">生成试卷</el-button>
            </el-form-item>
          </el-form>
        </el-card>
      </div>
      <div style="flex: 1">
        <el-card>
          <el-table v-loading="listLoading" :data="tableData" fit highlight-current-row style="width: 100%">
            <el-table-column prop="name" label="名称"  />
            <el-table-column prop="subjectName" label="学科" width="70"/>
            <el-table-column prop="createTime" label="创建时间" width="170"/>
            <el-table-column align="right" width="70">
              <template slot-scope="{row}">
                <router-link target="_blank" :to="{path:'/do',query:{id:row.id}}">
                  <el-button type="text" class="button">开始做题</el-button>
                </router-link>
              </template>
            </el-table-column>
          </el-table>
          <pagination v-show="total>0" :total="total" :background="false" :page.sync="queryParam.pageIndex"
                      :limit.sync="queryParam.pageSize"
                      @pagination="search" style="margin-top: 20px"/>
        </el-card>
      </div>
    </div>
  </div>
</template>
 
<script>
import { mapState, mapGetters } from 'vuex'
import Pagination from '@/components/Pagination'
import { scrollTo } from '@/utils/scroll-to'
import subjectApi from '@/api/subject'
import examPaperApi from '@/api/examPaper'
 
export default {
  components: { Pagination },
  data () {
    return {
      buildParam: {
        subjectId: null,
        singleChoice: 5,
        multipleChoice: 5,
        trueFalse: 5,
        difficult: 3
      },
      queryParam: {
        paperType: 7,
        subjectId: null,
        pageIndex: 1,
        pageSize: 10
      },
      listLoading: false,
      tableData: [],
      total: 0,
      subjectList: []
    }
  },
  created () {
    this.initSubject()
  },
  methods: {
    initSubject () {
      let _this = this
      subjectApi.list().then(re => {
        _this.subjectList = re.response
        let subjectId = _this.subjectList[0].id
        _this.buildParam.subjectId = subjectId
        _this.search()
        scrollTo(0, 800)
      })
    },
    search () {
      this.listLoading = true
      let _this = this
      examPaperApi.pageList(this.queryParam).then(data => {
        const re = data.response
        _this.tableData = re.list
        _this.total = re.total
        _this.queryParam.pageIndex = re.pageNum
        _this.listLoading = false
      })
    },
    buildPaper () {
      let _this = this
      examPaperApi.build(this.buildParam).then(function (result) {
        if (result && result.code === 1) {
          _this.$message.success(result.response)
          _this.search()
        } else {
          _this.$message.error(result.message)
        }
      })
    },
    statusTagFormatter (status) {
      return this.enumFormat(this.statusTag, status)
    },
    statusTextFormatter (status) {
      return this.enumFormat(this.statusEnum, status)
    }
  },
  computed: {
    ...mapGetters('enumItem', [
      'enumFormat'
    ]),
    ...mapState('enumItem', {
      statusEnum: state => state.exam.examPaperAnswer.statusEnum,
      statusTag: state => state.exam.examPaperAnswer.statusTag
    })
  }
}
</script>
 
<style lang="scss">
  .smart-rate {
    .el-rate {
      line-height: 2.3 !important;
    }
  }
</style>