龚焕茏
2024-07-03 68b8ed3b4b7ddbb5fe113c1d7df3aa909dc66fb6
src/views/answer/dataStatistics.vue
@@ -8,6 +8,7 @@
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="submitForm">查询</el-button>
        <el-button type="danger"  @click="handleExport" class="link-left">导出</el-button>
      </el-form-item>
    </el-form>
@@ -134,7 +135,8 @@
      chartLoading: false,
      queryParam: {
        id: '',
        type: 1
        type: 1,
        name: '分数统计'
      },
      admin: true
    };
@@ -148,14 +150,31 @@
      this.examPaperList = res.response;
      this.queryParam.id = this.examPaperList[0].id;
      this.queryParam.type = this.examPaperList[0].paperType;
      this.queryParam.name = this.examPaperList[0].name;
      this.getChartData();
      this.observe();
    });
  },
  methods: {
    handleExport(){
      let that = this
      let url ='/api/admin/examPaperAnswer/export?id=' +this.queryParam.id + '&type=' + this.queryParam.type
      var x = new XMLHttpRequest();
      x.open("GET", url, true);
      x.responseType = "blob";
      x.onload = function () {
        var url = window.URL.createObjectURL(x.response);
        var a = document.createElement("a");
        a.href = url;
        a.download = that.queryParam.name;
        a.click();
      };
      x.send();
    },
    getType(val) {
      const selectedItem = this.examPaperList.find(item => item.id === val);
      this.queryParam.type = selectedItem.paperType;
      this.queryParam.name = selectedItem.name;
      this.getChartData();
    },
    getChartData() {