Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/trainExam/singleperformance.vue
@@ -1,60 +1,82 @@
/*
 * @Author: Morpheus
 * @Date: 2021-07-05 16:31:54
 * @Last Modified by: Morpheus
 * @Last Modified time: 2021-07-18 21:02:10
 * menu-name 成绩查看
 */
/* * @Author: Morpheus * @Date: 2021-07-05 16:31:54 * @Last Modified by: liu *
@Last Modified time: 2021-12-10 10:01:11 * menu-name 成绩查看 */
<template>
  <el-row class="morpheus-box-score">
    <el-col :span="24">
      <el-card>
        <div class="exam-card-body">
          <avue-crud
            v-model="obj"
            class="company-box"
            :option="questionBankOption"
            :search.sync="questionBankSearch"
            :table-loading="questionBankLoading"
            :data="questionBankData"
            ref="questionBankCrud"
            :permission="permissionList"
            :page.sync="questionBankPage"
            @on-load="questionBankOnLoad"
            @selection-change="questionBankSelectionChange"
            @search-change="questionBankSearchChange"
            @search-reset="questionBankSearchReset"
            @current-change="questionBankCurrentChange"
            @size-change="questionBankSizeChange"
            @row-update="questionBankRowUpdate"
          >
            <template slot-scope="{ row }" slot="learnGrade">
              {{ row.learnGrade == -1 ? "暂未录入" : row.learnGrade }}
            </template>
            <template slot-scope="{ row }" slot="theoryGrade">
              {{ row.learnGrade == -1 ? "" : row.theoryGrade }}
            </template>
            <template slot-scope="{ row }" slot="allGrade">
              {{ row.learnGrade == -1 ? "" : row.allGrade }}
            </template>
            <template slot-scope="{ row }" slot="qualified">
              {{ row.qualified == -1 ? "" : row.qualified==0?"合格":row.qualified==1?"不合格":row.qualified==3?"缺考,成绩无效":'' }}
            </template>
  <basic-container
    :class="[
      'exam-card-body',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      v-model="obj"
      class="company-box tablesss"
      :option="questionBankOption"
      :search.sync="questionBankSearch"
      :table-loading="questionBankLoading"
      :data="questionBankData"
      ref="questionBankCrud"
      @sort-change="sortChange"
      :permission="permissionList"
      :page.sync="questionBankPage"
      @on-load="questionBankOnLoad"
      @selection-change="questionBankSelectionChange"
      @search-change="questionBankSearchChange"
      @search-reset="questionBankSearchReset"
      @current-change="questionBankCurrentChange"
      @size-change="questionBankSizeChange"
      @row-update="questionBankRowUpdate"
      @refresh-change="refreshChange"
    >
      <template slot-scope="{ row }" slot="learnGrade">
        {{ row.learnGrade == -1 ? "暂未录入" : row.learnGrade }}
      </template>
      <template slot-scope="{ row }" slot="theoryGrade">
        {{ row.theoryGrade == -1 ? "" : row.theoryGrade }}
      </template>
      <template slot-scope="{ row }" slot="allGrade">
        {{ row.allGrade == -1 ? "" : row.allGrade }}
      </template>
      <template slot-scope="{ row }" slot="qualified">
        {{
          row.qualified == -1
            ? ""
            : row.qualified == 0
            ? "合格"
            : row.qualified == 1
            ? "不合格"
            : row.qualified == 3
            ? "缺考,成绩无效"
            : ""
        }}
      </template>
            <template slot-scope="{ row }" slot="menu">
              <el-button
                type="text"
                size="mini"
                icon="el-icon-collection"
                class="start-kaoshi"
                :disabled="row.qualified==1"
                @click="securityPrint(row)"
                >保安证打印
              </el-button>
            </template>
      <!-- 自定义按钮 -->
      <template slot="menuLeft">
        <el-button
          type="warning"
          size="small"
          plain
          icon="el-icon-download"
          v-if="permission.trainExam_singleperformance_export"
          @click="handleExport"
          >成绩导出
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="menu">
        <el-button
          type="text"
          size="mini"
          icon="el-icon-collection"
          class="start-kaoshi"
          :disabled="row.qualified == 1"
          @click="securityPrint(row)"
          >保安证打印
        </el-button>
      </template>
            <!-- 自定义按钮 -->
            <!-- <template slot="menuLeft">
      <!-- 自定义按钮 -->
      <!-- <template slot="menuLeft">
                            <el-button type="danger"
                                       size="mini"
                                       icon="el-icon-delete"
@@ -74,18 +96,16 @@
                                       @click="handleDelete">导出
                            </el-button>
                        </template> -->
          </avue-crud>
        </div>
      </el-card>
    </el-col>
  </el-row>
    </avue-crud>
  </basic-container>
</template>
<script>
import { getList, update } from "@/api/examapi/performance";
import { mapGetters } from "vuex";
import { getRoleDetail } from "@/api/system/role";
import Qs from "qs";
import { getToken } from "@/util/auth";
export default {
  data() {
    var validatePass = (rule, value, callback) => {
@@ -106,7 +126,7 @@
    return {
      obj: {
        name: "张三",
        name: "张三"
      },
      questionBankOption: {
        // 操作栏多余按钮去除
@@ -115,13 +135,14 @@
        addBtn: false,
        selection: false,
        // 导出按钮
        excelBtn: true,
        excelBtnText: "成绩导出",
        // excelBtn: true,
        // excelBtnText: "成绩导出",
        viewBtn: false,
        // title: '成绩',
        align: "center",
        height: "auto",
        sort: "",
        sortName: "",
        calcHeight: 80,
        tip: false,
        searchShow: true,
@@ -134,14 +155,41 @@
        menu: false,
        menuWidth: 136,
        labelWidth: 120,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "考试名称",
            prop: "examName",
            search: true,
            searchSpan: 5,
            label: "考试时间",
            prop: "examDate",
            type: "date",
            hide: true,
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            width: 140,
            slot: true,
            viewDisplay:false,
            search: true,
            searchSpan: 4,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: false,
            // 表单编辑时是否为查看模式
            editDetail: false,
            viewDisplay: false
          },
          {
            label: "考试时间",
            prop: "startTime",
            type: "datetime",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            width: 90,
            viewDisplay: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
@@ -150,22 +198,53 @@
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            viewDisabled: true,
            // 表单编辑时是否可见
            editDisplay: false,
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请输入考试时间",
                trigger: "blur"
              }
            ],
            overHidden: true
          },
          {
            label: "姓名",
            prop: "securityName",
            search: true,
            searchSpan: 3,
            searchLabelWidth: 50,
            slot: true,
            viewDisplay: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            viewDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请输入试卷名称",
                trigger: "blur",
              },
                trigger: "blur"
              }
            ],
            width: 80
            // overHidden:true,
             width:250,
          },
          {
            label: "用户名",
            label: "身份证号",
            prop: "account",
            search: true,
            searchSpan: 4,
@@ -186,15 +265,43 @@
              {
                required: true,
                message: "请输入保安姓名",
                trigger: "blur",
              },
                trigger: "blur"
              }
            ],
             width:160,
            width: 160
          },
          {
            label: "准考证号",
            prop: "candidateNo",
            search: true,
            searchSpan: 4,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: true,
                message: "请输入保安姓名",
                trigger: "blur"
              }
            ],
            width: 140
          },
          {
            label: "所属公司",
            prop: "companyName",
            search: true,
            sortable: true,
            searchSpan: 4,
            // dicUrl: '/api/blade-system/dept/tree',
            // props: {
@@ -214,14 +321,15 @@
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            overHidden: true,
            rules: [
              {
                required: true,
                message: "请输入所属公司",
                trigger: "blur",
              },
                trigger: "blur"
              }
            ],
             width:230,
            minWidth: 230
          },
          {
            label: "考试开始时间",
@@ -230,7 +338,7 @@
            // span: 24,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            width: 160,
            width: 140,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
@@ -243,7 +351,7 @@
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            editDetail: false
          },
          {
            label: "考试结束时间",
@@ -252,7 +360,7 @@
            // span: 24,
            format: "yyyy-MM-dd HH:mm:ss",
            valueFormat: "yyyy-MM-dd HH:mm:ss",
            width: 160,
            width: 140,
            slot: true,
            // 表单新增时是否禁止
            addDisabled: false,
@@ -265,10 +373,10 @@
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            editDetail: false
          },
          {
            label: "状态",
            label: "考试状态",
            prop: "isExam",
            type: "select",
            slot: true,
@@ -277,13 +385,22 @@
            dicData: [
              {
                label: "发布成绩",
                value: 2,
                value: 2
              },
              {
                label: "考试中",
                value: 3,
                value: 3
              },
              {
                label: "纸质考试",
                value: 5
              },
              {
                label: "缺考",
                value: 4
              }
            ],
            width: 90,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
@@ -300,14 +417,15 @@
              {
                required: true,
                message: "请输入考试名称",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "理论成绩",
            prop: "theoryGrade",
            slot: true,
            sortable: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
@@ -320,11 +438,13 @@
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            width: 95
          },
          {
            label: "实操成绩",
            prop: "learnGrade",
            slot: true,
            sortable: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
@@ -337,52 +457,59 @@
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            width: 95,
            rules: [
              { validator: validatePass, required: true, trigger: "blur" },
            ],
              { validator: validatePass, required: true, trigger: "blur" }
            ]
          },
          {
              label: "总成绩",
              prop: "allGrade",
              slot: true,
              // 表单新增时是否禁止
              addDisabled: false,
              // 表单新增时是否可见
              addDisplay: true,
              // 表单新增时是否为查看模式
              addDetail: false,
              // 表单编辑时是否禁止
              editDisabled: true,
              // 表单编辑时是否可见
              editDisplay: true,
              // 表单编辑时是否为查看模式
              editDetail: false,
              rules: [{
                  required: true,
                  message: "请输入考试名称",
                  trigger: "blur"
              }]
            label: "总成绩",
            prop: "allGrade",
            slot: true,
            sortable: true,
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: true,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: true,
            // 表单编辑时是否可见
            editDisplay: true,
            // 表单编辑时是否为查看模式
            editDetail: false,
            width: 80,
            rules: [
              {
                required: true,
                message: "请输入考试名称",
                trigger: "blur"
              }
            ]
          },
          {
            label: "是否合格",
            prop: "qualified",
            type: "select",
            sortable: true,
            slot: true,
            search: true,
            searchSpan: 3,
            searchSpan: 4,
            width: 120,
            dicData: [
              {
                label: "合格",
                value: 0,
                value: 0
              },
              {
                label: "不合格",
                value: 1,
                value: 1
              },
              {
                label: "暂未录实操成绩",
                value: 2,
              },
                value: 2
              }
            ],
            // 表单新增时是否禁止
            addDisabled: false,
@@ -400,11 +527,11 @@
              {
                required: true,
                message: "请输入考试名称",
                trigger: "blur",
              },
            ],
          },
        ],
                trigger: "blur"
              }
            ]
          }
        ]
      },
      questionBankSearch: {},
      questionBankLoading: true,
@@ -412,18 +539,22 @@
      questionBankPage: {
        pageSize: 10,
        currentPage: 1,
        total: 16,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      questionBankQuery: {},
      questionBankSelectionList: [],
      questionBankSelectionList: []
    };
  },
  created() {
    // console.log(this.$route.query,111);
    this.questionBankSearch['examName'] = this.$route.query.examName;
    this.questionBankSearch["examId"] = this.$route.query.id;
    // console.log(this.$route.query,111);
  },
  mounted() {},
  computed:{
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  computed: {
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
@@ -431,9 +562,12 @@
        viewBtn: this.vaildData(null, false),
        delBtn: this.vaildData(null, false),
        editBtn: this.vaildData(null, false),
        excelBtn: this.vaildData(this.permission.trainExam_performance_export, false),
        excelBtn: this.vaildData(
          this.permission.trainExam_performance_export,
          false
        )
      };
    },
    }
  },
  methods: {
    //保安证证查看
@@ -442,8 +576,32 @@
      obj["name"] = "保安证";
      this.$router.push({
        path: `/exam/papers`,
        query: obj,
        query: obj
      });
    },
    //排序
    sortChange(value) {
      if (value.order == "ascending") {
        this.sort = "asc";
      }
      if (value.order == "descending") {
        this.sort = "desc";
      }
      this.sortName = value.prop;
      //字段匹配
      if (value.prop == "theoryGrade") {
        this.sortName = "theory_grade";
      }
      if (value.prop == "learnGrade") {
        this.sortName = "learn_grade";
      }
      if (value.prop == "allGrade") {
        this.sortName = "all_grade";
      }
      if (value.prop == "companyName") {
        this.sortName = "companyName";
      }
      this.questionBankOnLoad(this.questionBankPage);
    },
    questionBankOnLoad(page, params = {}) {
      //判断角色,如果是保安公司管理员或保安,只能查看当前公司的考试成绩
@@ -451,38 +609,47 @@
      //获取当前登录人员的角色信息
      var roleIds = this.userInfo.role_id.split(",");
      params = this.questionBankSearch;
      roleIds.forEach((roleId) => {
        getRoleDetail(roleId).then((res) => {
            var roleAlias = res.data.data.roleAlias;
            if (
              roleAlias == "保安公司管理员" ||
              roleAlias == "保安"
            ) {
              //如果是保安公司管理员
              params["deptId"] = that.userInfo.dept_id;
            }
            if (
              roleAlias == "培训公司管理员"
            ) {
              //如果是培训公司管理员
              params["trainUnitId"] = that.userInfo.dept_id;
            }
      roleIds.forEach(roleId => {
        getRoleDetail(roleId).then(res => {
          var roleAlias = res.data.data.roleAlias;
          if (
            roleAlias == "保安公司管理员" ||
            roleAlias == "保安" ||
            roleAlias == "分公司管理员"
          ) {
            //如果是保安公司管理员
            params["deptId"] = that.userInfo.dept_id;
          }
          if (roleAlias == "培训公司管理员") {
            //如果是培训公司管理员
            params["trainUnitId"] = that.userInfo.dept_id;
          }
          if (roleAlias == "公安管理员" || roleAlias == "民警") {
            //如果公安
            params["jurisdiction"] = that.userInfo.jurisdiction;
          }
          that.questionBankLoading = false;
          params["examType"] = 2;
          if (this.sort) {
            params["sort"] = this.sort;
          }
          if (this.sortName) {
            params["sortName"] = this.sortName;
          }
          getList(
            page.currentPage,
            page.pageSize,
            Object.assign(params, this.questionBankQuery)
          ).then(res => {
            const data = res.data.data;
            that.questionBankPage.total = data.total;
            that.questionBankData = data.records;
            that.questionBankLoading = false;
            params["examType"] = 2;
            getList(
              page.currentPage,
              page.pageSize,
              Object.assign(params, this.query)
            ).then((res) => {
              const data = res.data.data;
              that.questionBankPage.total = data.total;
              that.questionBankData = data.records;
              that.questionBankLoading = false;
              that.questionBankSelectionClear();
            });
        })
            this.$store.commit("setWindowSizeHeightAdd");
            that.questionBankSelectionClear();
          });
        });
      });
    },
    questionBankSelectionClear() {
      this.questionBankSelectionList = [];
@@ -512,25 +679,68 @@
      update({
        theoryGrade: row.theoryGrade,
        learnGrade: row.learnGrade,
        id: row.id,
        id: row.id
      }).then(
        () => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
  },
    refreshChange() {
      this.questionBankOnLoad(this.questionBankPage, this.questionBankQuery);
    },
    //成绩导出
    handleExport() {
      this.$confirm("是否导出成绩数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning"
      }).then(() => {
        //获取查询条件
        // console.log(this.questionBankSearch,456);
        var data = {
          account: this.questionBankSearch.account,
          companyName: this.questionBankSearch.companyName,
          examDate: this.questionBankSearch.examDate,
          isExam: this.questionBankSearch.isExam,
          qualified: this.questionBankSearch.qualified,
          securityName: this.questionBankSearch.securityName,
          examId: this.questionBankSearch.examId
        };
        //导出
        if (
          this.userInfo.role_name == "保安公司管理员" ||
          this.userInfo.role_name == "保安"
        ) {
          //如果是保安公司管理员
          data["deptId"] = this.userInfo.dept_id;
        }
        if (this.userInfo.role_name == "培训公司管理员") {
          //如果是培训公司管理员
          data["trainUnitId"] = this.userInfo.dept_id;
        }
        data["examType"] = 2;
        console.log(data, 1234567989);
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/examScore/export-examScore?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    }
  }
};
</script>
<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>