index.vue 8.38 KB
Newer Older
耿迪迪's avatar
耿迪迪 committed
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
<template>
    <div class="testStat">
      <el-form
        :model="queryParams"
        ref="queryForm"
        :inline="true"
        label-width="68px">

        <el-form-item label="考试名称" prop="courseName">
          <el-input
            v-model="queryParams.courseName"
            placeholder="请输入课程名称"
            clearable
            size="small"
          />
        </el-form-item>

        <el-form-item label="类型" prop="dataKind">
          <el-select v-model="queryParams.dataKind">
            <el-option label="培训考试" value="0" />
            <el-option label="随机考试" value="1" />
          </el-select>
        </el-form-item>

        <el-form-item label="发布时间" prop="releaseTimeBegin">
          <el-date-picker
            v-model="releaseTime"
            value-format="yyyy-MM-dd HH:mm:ss"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            @change="dateFormat">
          </el-date-picker>
        </el-form-item>

        <el-form-item>
          <el-button
            type="primary"
            icon="el-icon-search"
            size="mini"
            @click="search"
          >搜索</el-button
          >
          <el-button icon="el-icon-refresh" size="mini" @click="resetClick"
          >重置</el-button
          >
        </el-form-item>
      </el-form>
      <el-table v-loading="loading" :data="testStatData">
        <el-table-column label="序号" width='100' align="center" prop="courseNum"/>
        <el-table-column label="考试名称" align="center" prop="courseName"/>
        <el-table-column label="发布时间" align="center" prop="releaseTime"/>
        <el-table-column label="类型" align="center" prop="dataKind">
          <template slot-scope="scope">
            <span v-if="scope.row.dataKind == '0'">培训考试</span>
            <span v-else>随机考试</span>
          </template>
        </el-table-column>
        <el-table-column label="应参加人数" align="center" prop="count"/>
        <el-table-column label="实际考试人数" align="center" prop="test"/>
        <el-table-column label="合格人数" align="center" prop="pass"/>
吴卿华's avatar
吴卿华 committed
63 64 65 66 67
<!--        <el-table-column label="合格率" align="center" prop="rate">-->
<!--          <template slot-scope="scope">-->
<!--            {{scope.row.rate}}%-->
<!--          </template>-->
<!--        </el-table-column>-->
耿迪迪's avatar
耿迪迪 committed
68 69 70 71 72
        <el-table-column
          label="操作"
          align="center"
          class-name="small-padding fixed-width"
        >
吴卿华's avatar
吴卿华 committed
73
          <template v-slot="{ row: { courseId ,courseName}}">
耿迪迪's avatar
耿迪迪 committed
74 75 76 77
            <el-button
              size="mini"
              type="text"
              icon="el-icon-edit"
吴卿华's avatar
吴卿华 committed
78
              @click="courseDetail(courseId,courseName)"
耿迪迪's avatar
耿迪迪 committed
79 80 81 82 83 84 85 86 87 88 89 90 91
            >查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getTestList"
      />

      <!--考试详情 -->
吴卿华's avatar
吴卿华 committed
92 93 94 95 96 97 98 99 100 101 102 103
      <el-dialog :title="'考试详情:'+courseName" :visible.sync="testStatDetailOpen" append-to-body :close-on-click-modal="false">

        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          :loading="exportLoading"
          @click="handleExport"
          style="position: relative;left: 16px;top: -17px;"
        >导出</el-button>

耿迪迪's avatar
耿迪迪 committed
104 105 106
        <el-table v-loading="loading" :data="testStatDetailData">
          <el-table-column label="序号" width='100' align="center" prop="detailNum"/>
          <el-table-column label="考试人员" align="center" prop="staffName"/>
吴卿华's avatar
吴卿华 committed
107 108 109 110 111 112 113 114 115 116 117 118
          <el-table-column label="所属部门" align="center" prop="deptName">
            <span slot-scope="scope" v-if="scope.row.deptName">{{scope.row.deptName}}</span>
            <span v-else>-</span>
          </el-table-column>
          <el-table-column label="考试时间" align="center" prop="examinationTime">
            <span slot-scope="scope" v-if="scope.row.examinationTime">{{scope.row.examinationTime}}</span>
            <span v-else>-</span>
          </el-table-column>
          <el-table-column label="得分" align="center" prop="examinationResult">
            <span slot-scope="scope" v-if="scope.row.examinationResult">{{scope.row.examinationResult}}</span>
            <span v-else>-</span>
          </el-table-column>
耿迪迪's avatar
耿迪迪 committed
119 120 121 122 123 124 125 126
          <el-table-column label="考试结果" align="center" prop="state">
            <template slot-scope="scope">
              <span v-if="scope.row.state == 0">未考试</span>
              <span v-if="scope.row.state == 1">不合格</span>
              <span v-if="scope.row.state == 2">合格</span>
            </template>
          </el-table-column>
        </el-table>
吴卿华's avatar
吴卿华 committed
127

耿迪迪's avatar
耿迪迪 committed
128 129 130 131 132 133 134 135 136 137 138 139
        <pagination
          v-show="totalDetail > 0"
          :total="totalDetail"
          :page.sync="queryDetailParams.pageNum"
          :limit.sync="queryDetailParams.pageSize"
          @pagination="getTestStatDetails"
        />
      </el-dialog>
    </div>
</template>

<script>
吴卿华's avatar
吴卿华 committed
140
  import {statisticsTrainCourse,testPersonDetailByCourseId,exportDeviceInfo} from "@/api/educationPlanExam/lessonsProgram.js";
耿迪迪's avatar
耿迪迪 committed
141 142 143 144 145 146 147 148 149
  export default {
    name: "testStat",
    data(){
        return{
          // 遮罩层
          loading: false,
          // 总条数
          total: 0,
          releaseTime: "",
吴卿华's avatar
吴卿华 committed
150
          courseName:"",
耿迪迪's avatar
耿迪迪 committed
151 152 153 154 155 156 157 158
          queryParams:{
            pageNum: 1,
            pageSize: 10,
            courseName: "",
            dataKind: "",
            releaseTimeBegin: "",
            releaseTimeEnd: ""
          },
吴卿华's avatar
吴卿华 committed
159 160
          // 导出遮罩层
          exportLoading: false,
耿迪迪's avatar
耿迪迪 committed
161 162 163 164 165 166 167
          testStatData:[],
          testStatDetailOpen: false,
          testStatDetailData: [],
          totalDetail: 0,
          queryDetailParams:{
            pageNum: 1,
            pageSize: 10,
吴卿华's avatar
吴卿华 committed
168
            courseId: 0
耿迪迪's avatar
耿迪迪 committed
169 170 171 172 173 174 175
          }
        }
    },
    created(){
      this.getTestList();
    },
    methods: {
吴卿华's avatar
吴卿华 committed
176 177 178 179 180 181 182 183 184 185 186 187 188 189
      /** 导出按钮操作 */
      handleExport() {
        this.$confirm('是否确认导出所有考试详细数据项?', "警告", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning"
        }).then(() => {
          this.exportLoading = true;
          return exportDeviceInfo(this.queryDetailParams);
        }).then(response => {
          this.download(response.msg);
          this.exportLoading = false;
        }).catch(() => {});
      },
耿迪迪's avatar
耿迪迪 committed
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
      getTestList(){
        console.log("this.queryParams:",this.queryParams)
        statisticsTrainCourse(this.queryParams).then(res=>{
          this.testStatData = res.rows.map((item, index) => {
            return {
              courseNum:
                index +
                1 +
                (this.queryParams.pageNum - 1) * this.queryParams.pageSize,
                ...item,
            };
          });
          this.total = res.total;
        }) .finally(() => {
            this.loading = false;
        });
      },
      dateFormat(picker){
        this.queryParams.releaseTimeBegin = picker[0];
        this.queryParams.releaseTimeEnd = picker[1];
      },
      search(){
        this.getTestList();
      },
      resetClick(){
        this.releaseTime = "";
        this.queryParams={
            pageNum: 1,
            pageSize: 10,
            courseName: "",
            dataKind: "",
            releaseTimeBegin: "",
            releaseTimeEnd: ""
223 224
        };
        this.getTestList();
耿迪迪's avatar
耿迪迪 committed
225
      },
吴卿华's avatar
吴卿华 committed
226
      courseDetail(courseId,courseName){
耿迪迪's avatar
耿迪迪 committed
227
        this.testStatDetailOpen = true;
吴卿华's avatar
吴卿华 committed
228 229
        this.courseName=courseName;
        this.queryDetailParams.courseId=courseId;
230
        this.getTestStatDetails();
耿迪迪's avatar
耿迪迪 committed
231
      },
232 233
      getTestStatDetails(){
        //this.queryDetailParams.courseId = courseId;
耿迪迪's avatar
耿迪迪 committed
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
        testPersonDetailByCourseId(this.queryDetailParams).then(res =>{
          this.testStatDetailData = res.rows.map((item, index) => {
            return {
              detailNum:
              index +
              1 +
              (this.queryParams.pageNum - 1) * this.queryParams.pageSize,
              ...item,
          };
        });
          this.totalDetail = res.total;
        }) .finally(() => {
            this.loading = false;
        });
      }
    }
  }
</script>

<style scoped lang="scss">
  .testStat{
    margin: 10px;
  }
</style>