zhouwx
2024-07-17 246f7b6fd81cf2ba620b8f9bf7cf24b61d7cf521
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<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>
    <!-- 表格数据 -->
    <el-table v-loading="loading" :data="dataList" :border="true">
      <el-table-column label="编号" prop="code" align="center" width="135" />
      <el-table-column label="考试名称" prop="name" align="center"  />
      <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"  width="135">
        <template #default="scope">
          <span>{{scope.row.paperStudentInfoVO.finishCount}}/{{scope.row.paperStudentInfoVO.studentCount}}</span>
        </template>
      </el-table-column>
      <el-table-column label="合格人数" prop="" align="center">
        <template #default="scope">
          <span>{{scope.row.paperStudentInfoVO.passStudentCount}}</span>
        </template>
      </el-table-column>
      <el-table-column label="平均分数" prop="" align="center" >
        <template #default="scope">
          <span>{{scope.row.paperStudentInfoVO.avgScore}}</span>
        </template>
      </el-table-column>
      <el-table-column label="合格率" prop="passRate" align="center" />
      <el-table-column label="限制时长" prop="limitTime" align="center"  >
        <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">
        <template #default="scope">
          <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>
        </template>
      </el-table-column>
    </el-table>
 
    <pagination
        v-show="total > 0"
        :total="total"
        v-model:page="queryParams.pageNum"
        v-model:limit="queryParams.pageSize"
        @pagination="getList"
    />
    <exam-dialog ref="dialogRef" @getList=getList></exam-dialog>
<!--    <class-hour-change ref="classHourRef" @getList=getList></class-hour-change>-->
  </div>
</template>
 
<script setup>
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 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";
 
 
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const classHourRef = ref();
const data = reactive({
  queryParams: {
    pageNum: 1,
    pageSize: 10,
  },
  total: 0,
  dataList: [],
  isAdmin: false,
  companyName: '',
  remainPeriod: null
 
});
 
const { queryParams, total, dataList } = toRefs(data);
 
onMounted(async ()=>{
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  console.log("userInfo",userInfo)
  if(userInfo.userType === 0){
    data.isAdmin = true;
  }else {
    data.isAdmin = false;
    data.companyName = userInfo.companyName
  }
  await getList()
})
onUnmounted(()=>{
 
})
 
const getList = async () => {
  loading.value = true
  const res = await getExam(data.queryParams)
  if(res.code == 200){
    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 + '%'
      }
    })
 
    data.total = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const openDialog = (type, value) => {
  dialogRef.value.openDialog(type, value);
}
 
/** 重置新增的表单以及其他数据  */
function reset() {
  proxy.resetForm("roleRef");
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delExam(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
const toStuChoose = (val) => {
  const v = JSON.stringify(val)
  router.push({ path: "/examStu", query: { val: v } });
}
 
const openDetail = () => {
  classHourRef.value.openDialog()
}
</script>