龚焕茏
2024-07-11 c6b7d277ca7f0449155d544d5bfdf57b5ec0fa7e
feat:答卷次数列表
4个文件已修改
1个文件已添加
106 ■■■■■ 已修改文件
src/api/examPaperAnswer.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router.js 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/answer/info.vue 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/answer/list.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/answer/user.vue 75 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/examPaperAnswer.js
@@ -3,5 +3,6 @@
export default {
  page: query => post('/api/admin/examPaperAnswer/page', query),
  pageExamPaper: query => post('/api/admin/examPaperAnswer/pageExamPaper', query),
  pageUser: query => post('/api/admin/examPaperAnswer/pageUser', query),
  read: id => post('/api/admin/examPaperAnswer/read/' + id)
}
src/router.js
@@ -305,13 +305,13 @@
    alwaysShow: true,
    children: [
      {
        path: 'list',
        path: 'answer-list',
        component: () => import('@/views/answer/list'),
        name: 'AnswerPageList',
        meta: { title: '答卷列表', noCache: true }
      },
      {
        path: 'answer-list',
        path: 'answer-info',
        component: () => import('@/views/answer/info'),
        name: 'answerList',
        meta: { title: '答卷信息', noCache: true },
@@ -323,6 +323,12 @@
        name: 'answerDetail',
        meta: { title: '答卷详情', noCache: true },
        hidden: true
      },
      {
        path: 'answer-user',
        component: () => import('@/views/answer/user'),
        name: 'AnswerPageList',
        meta: { title: '答卷次数', noCache: true }
      }
    ]
  },
src/views/answer/info.vue
@@ -10,6 +10,9 @@
          <div>
            <el-form :inline="true" :model="queryParam" class="demo-form-inline" label-width="80px">
              <el-form-item>
                <el-input v-model="queryParam.examName" placeholder="请输入考试名称" clearable></el-input>
              </el-form-item>
              <el-form-item>
                <el-input v-model="queryParam.userName" placeholder="请输入用户名称" clearable></el-input>
              </el-form-item>
              <el-form-item>
@@ -69,6 +72,7 @@
      listLoading: true,
      queryParam: {
        examId: '',
        userId: '',
        userName: '',
        pageIndex: 1,
        pageSize: 10
@@ -81,8 +85,9 @@
    };
  },
  created() {
    this.queryParam.examId = this.$route.query.id
    this.search()
    this.queryParam.examId = this.$route.query.id;
    this.queryParam.userId = this.$route.query.userId;
    this.search();
  },
  methods: {
    // 获取列表
@@ -101,7 +106,9 @@
    },
    handleExport() {
      let that = this
      let url = '/api/admin/examPaperAnswer/exportExcel?examId=' + this.queryParam.examId + '&userName=' + this.queryParam.userName
      let url = '/api/admin/examPaperAnswer/exportExcel?userName=' + this.queryParam.userName;
      if (this.queryParam.userId) url += '&userId=' + this.queryParam.userId;
      if (this.queryParam.examId) url += '&examId=' + this.queryParam.examId;
      var x = new XMLHttpRequest();
      x.open("POST", url, true);
      x.responseType = "blob";
@@ -109,7 +116,8 @@
        var url = window.URL.createObjectURL(x.response);
        var a = document.createElement("a");
        a.href = url;
        a.download = that.tableData[0].examName + '.xlsx';
        if (that.queryParam.examId) a.download = that.tableData[0].examName + '.xlsx';
        if (that.queryParam.userId) a.download = that.tableData[0].userName + '.xlsx';
        a.click();
      };
      x.send();
src/views/answer/list.vue
@@ -20,7 +20,7 @@
    <el-table v-loading="listLoading" :data="tableData" border style="width: 100%;">
      <el-table-column align="center" prop="examName" label="考试名称" />
      <el-table-column align="center" prop="paperName" label="试卷名称" />
      <el-table-column align="center" prop="subjectName" label="科目" />
      <!-- <el-table-column align="center" prop="subjectName" label="科目" /> -->
      <el-table-column align="center" prop="paperType" label="试卷类型" width="150px">
        <template slot-scope="{row}">
          <span v-if="row.paperType === 1">固定试卷</span>
@@ -87,7 +87,7 @@
      })
    },
    view(row) {
      this.$router.push({ path: '/answer/answer-list', query: { id: row.id } });
      this.$router.push({ path: '/answer/answer-info', query: { id: row.id } });
    },
    ...mapActions('exam', { initSubject: 'initSubject' })
  },
src/views/answer/user.vue
New file
@@ -0,0 +1,75 @@
<template>
  <div class="app-container">
    <el-form :inline="true" :model="queryParam" class="demo-form-inline" label-width="80px">
      <el-form-item>
        <el-input v-model="queryParam.name" placeholder="请输入姓名" clearable></el-input>
      </el-form-item>
      <el-form-item>
        <el-button style="width:100px;" type="primary" size="small" @click="search()">查询</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="listLoading" :data="tableData" border style="width: 100%;">
      <el-table-column align="center" prop="userName" label="姓名" />
      <el-table-column align="center" prop="examCount" label="考试次数" />
      <el-table-column label="操作" align="center">
        <template slot-scope="{row}">
          <el-button size="mini" @click="view(row)">查看</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParam.pageIndex"
      :limit.sync="queryParam.pageSize" @pagination="search" />
  </div>
</template>
<script>
import { mapGetters, mapState, mapActions } from 'vuex'
import Pagination from '@/components/Pagination'
import examPaperAnswerApi from '@/api/examPaperAnswer'
export default {
  components: { Pagination },
  data () {
    return {
      listLoading: true,
      queryParam: {
        name: '',
        pageIndex: 1,
        pageSize: 10
      },
      formLoading: false,
      total: 0,
      tableData: [],
      visible: false
    };
  },
  created () {
    this.initSubject()
    this.search()
  },
  methods: {
    // 获取列表
    search() {
      this.listLoading = true
      examPaperAnswerApi.pageUser(this.queryParam).then(re => {
        this.tableData = re.data.list
        this.total = re.data.total
        this.queryParam.pageSize = re.data.pageSize
        this.queryParam.pageIndex = re.data.pageNum
        this.listLoading = false
      })
    },
    view(row) {
      this.$router.push({ path: '/answer/answer-info', query: { userId: row.id } });
    },
    ...mapActions('exam', { initSubject: 'initSubject' })
  },
  computed: {
    ...mapGetters('enumItem', ['enumFormat']),
    ...mapGetters('exam', ['subjectEnumFormat']),
    ...mapState('exam', { subjects: state => state.subjects })
  }
}
</script>