zhouwx
2024-07-19 1aa6aec8be8351a9bfe2d7629c4a30128eccde44
src/views/onlineEducation/groupExams/index.vue
@@ -1,11 +1,41 @@
<template>
  <div class="app-container">
    <div style="margin-bottom: 10px;display: flex;align-items: center;justify-content: space-between">
      <el-button
          type="primary"
          plain
          @click="openDialog('add',{})"
      >开始组卷考试</el-button>
    <div style="display: flex;justify-content: space-between">
      <el-form :inline="true" style="display: flex;align-items: center;flex-wrap: wrap;" >
        <el-form-item>
          <el-button
              type="primary"
              plain
              @click="openDialog('add',{})"
          >开始组卷考试</el-button>
        </el-form-item>
        <el-form-item label="考试名称:" >
          <el-input v-model="data.queryParams.name" placeholder="请输入考试名称"></el-input>
        </el-form-item>
        <el-form-item label="科目/类别:" >
          <el-cascader
              style="width: 100%"
              ref="classifyRef"
              v-model="data.queryParams.categoryId"
              :options="data.classifyList"
              :props="data.props"
              clearable
              :show-all-levels="false"
              @change="handleChange"
          />
        </el-form-item>
        <el-form-item >
          <el-button
              type="primary"
              @click="getList"
          >查询</el-button>
          <el-button
              type="primary"
              plain
              @click="reset"
          >重置</el-button>
        </el-form-item>
      </el-form>
    </div>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
@@ -14,9 +44,9 @@
      <el-table-column label="企业名称" prop="companyName" align="center"  />
      <el-table-column label="创建账户" prop="createBy" align="center"  />
      <el-table-column label="科目/类别" prop="categoryName" align="center"  />
      <el-table-column label="考生人数" prop="" align="center">
      <el-table-column label="完成人数/总人数" prop="" align="center"  width="135">
        <template #default="scope">
          <span>{{scope.row.paperStudentInfoVO.studentCount}}</span>
          <span>{{scope.row.paperStudentInfoVO.finishCount}}/{{scope.row.paperStudentInfoVO.studentCount}}</span>
        </template>
      </el-table-column>
      <el-table-column label="合格人数" prop="" align="center">
@@ -30,14 +60,17 @@
        </template>
      </el-table-column>
      <el-table-column label="合格率" prop="passRate" align="center" />
      <el-table-column label="限制时长" prop="limitTime" align="center"  >
      <el-table-column label="限制时长/分钟" prop="limitTime" align="center"  width="120" >
        <template #default="scope">
          <span v-if="scope.row.limitTime == 0">不限时</span>
          <span v-else>{{scope.row.limitTime}}</span>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="180">
      <el-table-column label="考试截止时间" prop="deadlineNum" align="center"  width="120" >
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width"  width="260">
        <template #default="scope">
          <el-button link type="primary" @click="viewQuestion(scope.row)">预览</el-button>
          <el-button link type="primary" @click="toStuChoose(scope.row)">学生数据</el-button>
          <el-button link type="primary" @click="openDialog('edit',scope.row)">编辑</el-button>
          <el-button link type="danger" @click="handleDelete(scope.row)">删除</el-button>
@@ -53,7 +86,8 @@
        @pagination="getList"
    />
    <exam-dialog ref="dialogRef" @getList=getList></exam-dialog>
<!--    <class-hour-change ref="classHourRef" @getList=getList></class-hour-change>-->
    <exam-question ref="questionRef" @getList=getList></exam-question>
  </div>
</template>
@@ -61,21 +95,25 @@
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import examDialog from './components/examDialog.vue'
// import classHourChange from './components/classHourChange.vue'
import examQuestion from './components/viewExamQuestion.vue'
import Cookies from "js-cookie";
import {useRouter} from 'vue-router'
const router = useRouter()
import {delQuestionBank, getQuestionBank} from "@/api/onlineEducation/questionBank";
import {delBatch, getBatch} from "@/api/onlineEducation/batch";
import {delExam, getExam} from "@/api/onlineEducation/exam";
import {getClassification} from "@/api/onlineEducation/courseClass";
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const classHourRef = ref();
const questionRef = ref();
const classifyRef = ref(null)
const data = reactive({
  queryParams: {
    name:'',
    categoryId: null,
    pageNum: 1,
    pageSize: 10,
  },
@@ -83,7 +121,11 @@
  dataList: [],
  isAdmin: false,
  companyName: '',
  remainPeriod: null
  remainPeriod: null,
  categoryList: [],
  props: {
    checkStrictly: true,
  },
});
@@ -98,6 +140,7 @@
    data.isAdmin = false;
    data.companyName = userInfo.companyName
  }
  await getClassifyList();
  await getList()
})
onUnmounted(()=>{
@@ -111,7 +154,8 @@
    data.dataList = res.data.list.map(item => {
      return {
        ...item,
        passRate: item.paperStudentInfoVO.passStudentCount ===0 && item.paperStudentInfoVO.studentCount ===0  ? '0%': (item.paperStudentInfoVO.passStudentCount / item.paperStudentInfoVO.studentCount).toFixed(2) *100 + '%'
        passRate: item.paperStudentInfoVO.passStudentCount ===0 && item.paperStudentInfoVO.studentCount ===0  ? '0%': (item.paperStudentInfoVO.passStudentCount / item.paperStudentInfoVO.studentCount).toFixed(2) *100 + '%',
        deadlineNum: item.deadline ? item.deadline.slice(0,10) : ''
      }
    })
@@ -128,7 +172,13 @@
/** 重置新增的表单以及其他数据  */
function reset() {
  proxy.resetForm("roleRef");
  data.queryParams = {
    name:'',
    categoryId: null,
    pageNum: 1,
    pageSize: 10,
  }
  getList()
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
@@ -153,8 +203,44 @@
  const v = JSON.stringify(val)
  router.push({ path: "/examStu", query: { val: v } });
}
const openDetail = () => {
  classHourRef.value.openDialog()
const viewQuestion = (val) => {
  questionRef.value.openDialog(val)
}
const handleChange = ()=> {
  console.log("label====",classifyRef.value.getCheckedNodes()[0].value)
  data.queryParams.categoryId = classifyRef.value.getCheckedNodes()[0].value
  // 我这里只是打印了一下label的值哦,需要赋值的话自己去赋值哦
  if (classifyRef.value.popperVisible) {
    classifyRef.value.togglePopperVisible()
  }
}
const  getClassifyList = async () => {
  const res = await getClassification();
  if(res.code === 200){
    data.classifyList = recursion(res.data)
  }else{
    ElMessage.warning(res.message)
  }
}
const recursion = (data) => {
  let tmp = []
  for (let i = 0; i < data.length; i++) {
    let item = data[i]
    // children为空
    if (item.children&& item.children.length==0) {
      tmp.push({
        value: item.id,
        label: item.name
      })
      // 有children
    } else {
      tmp.push({
        value: item.id,
        label: item.name,
        children:recursion(item.children)
      })
    }
  }
  return tmp;
}
</script>