Administrator
2022-01-22 1c20912d0335724b648679e6b2b7bda93f332ecc
考试情况统计新增导出
1 files modified
360 ■■■■ changed files
src/views/trainExam/examStatistics.vue 360 ●●●● patch | view | raw | blame | history
src/views/trainExam/examStatistics.vue
@@ -77,8 +77,13 @@
      :modal-append-to-body="true"
      :append-to-body="true"
      direction="rtl"
      size="60%">
      <avue-crud
      size="60%"
    >
      <div style="position: absolute;top: 3.5rem;left: 1rem;">
          <el-button type="warning" icon="el-icon-download" plain size="mini" @click="exportExamInfo">导出</el-button>
      </div>
      <div style="height: 40%">
        <!-- <avue-crud
            v-model="formDetail"
            :option="option"
            v-if="dialog"
@@ -107,15 +112,143 @@
                >详情
              </el-button>
            </template>
          </avue-crud>
        </avue-crud> -->
        <el-table
          :data="data"
          stripe="true"
          border
          show-summary
          :summary-method="getSummaries"
          style="width: 98%; margin: 0 auto; margin-top: 1rem"
          size="small"
          header-align="center"
          height="22rem"
        >
          <el-table-column label="理论考试成绩统计" align="center">
            <el-table-column
              type="index"
              width="50"
              label="序号"
              align="center"
            ></el-table-column>
            <el-table-column
              prop="deptName"
              label="企业名称"
              minWidth="160"
              show-overflow-tooltip="true"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="znum" label="报名人数" align="center">
            </el-table-column>
            <el-table-column prop="ycnum" label="审查异常人数" align="center">
            </el-table-column>
            <el-table-column
              prop="qknum"
              label="缺考人数"
              align="center"
            >
            </el-table-column>
            <el-table-column
              prop="absentProportion"
              label="缺考人数占比(%)"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="yknum" label="及格人数" align="center">
            </el-table-column>
            <el-table-column
              prop="qualifiedProportion"
              label="及格人数占比(%)"
              align="center"
            >
            </el-table-column>
          </el-table-column>
        </el-table>
      </div>
      <div style="height: 60%">
        <el-table
          :data="dataDetail"
          stripe="true"
          border
          height="25rem"
          style="width: 98%; margin: 0 auto"
          size="small"
          header-align="center"
        >
          <el-table-column label="考试成绩明细" align="center">
            <el-table-column
              type="index"
              width="50"
              label="序号"
              align="center"
            ></el-table-column>
            <el-table-column prop="securityName" label="姓名" align="center">
            </el-table-column>
            <el-table-column
              prop="companyName"
              label="企业名称"
              minWidth="160"
              show-overflow-tooltip="true"
              align="center"
            >
            </el-table-column>
            <el-table-column prop="theoryGrade" label="理论成绩" align="center">
              <template slot-scope="scope">
                {{ scope.row.theoryGrade == -1 ? "" : scope.row.theoryGrade }}
              </template>
            </el-table-column>
            <el-table-column prop="learnGrade" label="实操成绩" align="center">
              <template slot-scope="scope">
                {{ scope.row.learnGrade == -1 ? "" : scope.row.learnGrade }}
              </template>
            </el-table-column>
            <el-table-column prop="allGrade" label="平均分" align="center">
            </el-table-column>
            <el-table-column prop="isExam" label="考试成绩状态" align="center">
              <template slot-scope="scope">
                {{
                  scope.row.isExam == 2
                    ? "发布成绩"
                    : scope.row.isExam == 3
                    ? "考试中"
                    : scope.row.isExam == 4
                    ? "缺考"
                    : scope.row.isExam == 5
                    ? "纸质考试"
                    : ""
                }}
              </template>
            </el-table-column>
          </el-table-column>
        </el-table>
        <el-pagination
          style="margin-top: 1rem; margin-left: 25rem"
          background
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="page.currentPage"
          :page-sizes="[10, 20, 30, 50, 100]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="page.total"
        >
        </el-pagination>
      </div>
    </el-drawer>
  </el-row>
</template>
<script>
import {getExamStatistics,getExamInfoByExamId} from "@/api/examapi/examination";
import {
  getExamStatistics,
  getExamInfoByExamId,
} from "@/api/examapi/examination";
import { mapGetters } from "vuex";
import Qs from "qs";
import { getToken } from "@/util/auth";
import { getList } from "@/api/examapi/performance";
import Legend from "@/components/liu-legend/Legend";
export default {
  components: {
@@ -123,9 +256,10 @@
  },
  data() {
    return {
      startTime:"",
      title:"",
      trainUnitId:null,
      startTime: "",
      title: "",
      companyName: "",
      trainUnitId: null,
      dialog: false,
      form: {},
      formDetail: {},
@@ -157,9 +291,9 @@
            label: "培训学校名称",
            prop: "schoolName",
            slot: true,
            search:true,
            searchSpan:5,
            searchLabelWidth:110,
            search: true,
            searchSpan: 5,
            searchLabelWidth: 110,
            overHidden: true,
            // width:180,
          },
@@ -169,8 +303,8 @@
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            search:true,
            searchSpan:4,
            search: true,
            searchSpan: 4,
            hide: true,
            rules: [
              {
@@ -237,7 +371,7 @@
            slot: true,
            // search:true,
            // searchSpan:5,
            searchLabelWidth:110,
            searchLabelWidth: 110,
            overHidden: true,
          },
          {
@@ -266,39 +400,39 @@
          },
        ],
        sumColumnList: [
            {
              label:'合计:',
              name: 'deptName',
            },
            {
              name: 'znum',
              type: 'sum'
            },
            {
              name: 'ycnum',
              type: 'sum'
            },
            {
              name: 'qknum',
              type: 'sum'
            },
            {
              name: 'absentProportion',
              type: 'avg'
            },
            {
              name: 'yknum',
              type: 'sum'
            },
            {
              name: 'qualifiedProportion',
              type: 'avg'
            },
            {
              name: 'znum',
              type: 'sum'
            },
          ],
          {
            label: "合计:",
            name: "deptName",
          },
          {
            name: "znum",
            type: "sum",
          },
          {
            name: "ycnum",
            type: "sum",
          },
          {
            name: "qknum",
            type: "sum",
          },
          {
            name: "absentProportion",
            type: "avg",
          },
          {
            name: "yknum",
            type: "sum",
          },
          {
            name: "qualifiedProportion",
            type: "avg",
          },
          {
            name: "znum",
            type: "sum",
          },
        ],
      },
      questionBankSearch: {},
      search: {},
@@ -306,6 +440,7 @@
      loading: true,
      questionBankData: [],
      data: [],
      dataDetail: [],
      questionBankPage: {
        pageSize: 10,
        currentPage: 1,
@@ -315,8 +450,7 @@
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 16,
        ...this.$store.state.control.changePageSize,
        total: 0,
      },
      questionBankQuery: {},
      query: {},
@@ -345,19 +479,66 @@
  },
  watch: {},
  methods: {
    //导出考试统计数据
    exportExamInfo(){
      this.$confirm("是否导出考试统计情况数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //获取查询条件
        var data = {
          companyName: this.companyName,
          examDate: this.startTime,
          trainUnitId: this.trainUnitId,
          examType: 2,
        };
        console.log(data,11225111);
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/exampaper/export-examStatistics?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    //合计
    summaryMethod({ columns, data }){
    getSummaries(param) {
      const { columns, data } = param;
      const sums = [];
      if (columns.length > 0) {
        columns.forEach((column, index) => {
          if ([0,1,6].includes(index) ) {
            sums[index] = '-'
          } else {
            let values = this.selectList.map(item => Number(item[column.property]));
            sums[index] = values;
          }
        });
      }
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = sums[index];
          return;
        }
        if (index === 1) {
          sums[index] = "合计";
          return;
        }
        if (index === 5) {
          sums[index] = (sums[4]/sums[2]*100).toFixed(2);
          return;
        }
        if (index === 7) {
          sums[index] = (sums[6]/sums[2]*100).toFixed(2);
          return;
        }
        const values = data.map((item) => Number(item[column.property]));
        if (!values.every((value) => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index];
        } else {
          sums[index] = "N/A";
        }
      });
      return sums;
    },
    questionBankOnLoad(page, params = {}) {
@@ -379,24 +560,39 @@
      });
    },
    onLoad(page, params = {}) {
      this.loading = false;
      //如果是培训公司管理员,则只能看到当前培训公司申请的考试
      if (this.userInfo.role_name == "培训公司管理员") {
        params["deptId"] = this.userInfo.dept_id;
      }
      params['startTime'] = this.startTime;
      params['trainUnitId'] = this.trainUnitId;
      getExamInfoByExamId(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
        this.selectionClear();
      });
      params["startTime"] = this.startTime;
      params["trainUnitId"] = this.trainUnitId;
      getExamInfoByExamId(1, 20, Object.assign(params, this.query)).then(
        (res) => {
          const data = res.data.data;
          this.data = data.records;
        }
      );
    },
    //明细table
    onLoadDetail(page, params = {}) {
      //判断角色,如果是保安公司管理员或保安,只能查看当前公司的考试成绩
      var that = this;
      params["examDate"] = this.startTime;
      params["trainUnitId"] = this.trainUnitId;
      params["examType"] = 2;
      getList(page.currentPage, page.pageSize, Object.assign(params)).then(
        (res) => {
          const data = res.data.data;
          that.page.total = data.total;
          that.dataDetail = data.records;
        }
      );
    },
    //每页数值改变
    handleSizeChange(val) {
      this.page.pageSize = val;
      this.onLoadDetail(this.page);
    },
    //页数切换
    handleCurrentChange(val) {
      this.page.currentPage = val;
      this.onLoadDetail(this.page);
    },
    questionBankSelectionClear() {
      this.questionBankSelectionList = [];
@@ -430,16 +626,20 @@
      this.dialog = true;
      this.trainUnitId = row.trainUnitId;
      this.startTime = row.startTime;
      this.title = row.schoolName+row.startTime+"考试明细";
      this.companyName = row.schoolName;
      this.title = row.schoolName + row.startTime + "考试情况";
      this.onLoad(this.page);
      this.onLoadDetail(this.page);
    },
    //行单击详情弹窗
    handleRowClick(row) {
      this.dialog = true;
      this.trainUnitId = row.trainUnitId;
      this.startTime = row.startTime;
      this.title = row.schoolName+row.startTime+"考试明细";
      this.companyName = row.schoolName;
      this.title = row.schoolName + row.startTime + "考试情况";
      this.onLoad(this.page);
      this.onLoadDetail(this.page);
    },
  },
};