bug
lohir
2024-10-16 eb010c8d0f12c4861d2fde556f8ca441ba5e10d9
src/views/answer/info.vue
@@ -4,7 +4,7 @@
    <div class="bg">
      <div class="main">
        <!-- 待返回的标题 -->
        <TitleIndex title="答卷管理" />
        <TitleIndex title="答卷管理"/>
        <div class="content">
          <!-- 搜索 -->
          <div>
@@ -23,9 +23,9 @@
          </div>
          <!-- 表格 -->
          <el-table v-loading="listLoading" :data="tableData" border fit highlight-current-row>
            <el-table-column prop="examName" label="考试名称" align="center" />
            <el-table-column prop="paperName" label="试卷名称" align="center" />
            <el-table-column prop="userName" width="150" label="参考人" align="center" />
            <el-table-column prop="examName" label="考试名称" align="center"/>
            <el-table-column prop="paperName" label="试卷名称" align="center"/>
            <el-table-column prop="userName" width="150" label="参考人" align="center"/>
            <el-table-column label="得分" width="150px" align="center">
              <template slot-scope="{row}">
                {{ row.score }} / {{ row.totalScore }}
@@ -36,7 +36,11 @@
                {{ row.questionCorrect }} / {{ row.questionCount }}
              </template>
            </el-table-column>
            <el-table-column prop="doTime" label="耗时" width="80px" align="center" />
            <el-table-column prop="doTime" label="耗时" width="100px" align="center">
              <template slot-scope="{row}">
                {{ formattedDoTime(row) }}
              </template>
            </el-table-column>
            <el-table-column prop="submitTime" label="提交时间" width="240px" align="center">
              <template slot-scope="{row}">
                <span :style="row.status === 0 ? '' : 'color: red'">
@@ -51,7 +55,7 @@
            </el-table-column>
          </el-table>
          <pagination v-show="total > 0" :total="total" :page.sync="queryParam.pageIndex"
            :limit.sync="queryParam.pageSize" @pagination="search" />
                      :limit.sync="queryParam.pageSize" @pagination="search"/>
        </div>
      </div>
    </div>
@@ -67,7 +71,7 @@
  components: {
    Pagination
  },
  data() {
  data () {
    return {
      listLoading: true,
      queryParam: {
@@ -82,16 +86,22 @@
      tableData: [],
      visible: false,
      subjects: []
    };
    }
  },
  created() {
    this.queryParam.examId = this.$route.query.id;
    this.queryParam.userId = this.$route.query.userId;
    this.search();
  created () {
    this.queryParam.examId = this.$route.query.id
    this.queryParam.userId = this.$route.query.userId
    this.search()
  },
  methods: {
    formattedDoTime (row) {
      const totalSeconds = row.doTime
      const minutes = Math.floor(totalSeconds / 60)
      const seconds = totalSeconds % 60
      return `${minutes}分${seconds < 10 ? '0' + seconds : seconds}秒`
    },
    // 获取列表
    search() {
    search () {
      this.listLoading = true
      examPaperAnswerApi.page(this.queryParam).then(re => {
        this.tableData = re.data.list
@@ -101,29 +111,29 @@
        this.listLoading = false
      })
    },
    view(row) {
      this.$router.push({ path: '/answer/answer-detail', query: { id: row.id } });
    view (row) {
      this.$router.push({ path: '/answer/answer-detail', query: { id: row.id } })
    },
    handleExport() {
    handleExport () {
      let that = this
      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";
      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'
      x.onload = function () {
        var url = window.URL.createObjectURL(x.response);
        var a = document.createElement("a");
        a.href = url;
        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();
        var url = window.URL.createObjectURL(x.response)
        var a = document.createElement('a')
        a.href = url
        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()
    }
  }
};
}
</script>
<style scoped lang="scss">
.flex {