zhouwx
2024-08-02 926fd4d1b89e7e5e6338d8f292edc4f728049856
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
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
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<template>
  <div class="app-container">
    <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
              icon="Plus"
              @click="openDialog()"
          >选择学员</el-button>
        </el-form-item>
        <el-form-item label="学生姓名:" >
          <el-input v-model="data.queryParams.studentName" placeholder="请输入学生姓名"></el-input>
        </el-form-item>
        <el-form-item label="试卷状态:" >
          <el-select
              v-model="data.queryParams.state"
              class="w100"
              style="max-width: 180px"
              clearable
              size="default"
          >
            <el-option v-for="item in data.completeList" :key="item.id" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </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-button
            type="danger"
            plain
            icon="Delete"
            @click="handleDeleteBatch"
        >批量删除</el-button>
        <el-button
            type="primary"
            plain
            @click="back"
        >返回</el-button>
      </div>
 
    </div>
    <!-- 表格数据 -->
    <el-table ref="tableRef" v-loading="loading" :data="dataList" :border="true" :row-key="getRowKey"  @selection-change="handleSelectionChange">
      <el-table-column type="selection" :reserve-selection="true" width="55" align="center" />
      <el-table-column label="序号" type="index" align="center" width="80" />
      <el-table-column label="试卷名称" align="center" >
        <template #default="scope">
          <span>{{scope.row.examPaper.name}}</span>
        </template>
      </el-table-column>
      <el-table-column label="学员名称" prop="studentName" align="center" >
        <template #default="scope">
          <span>{{scope.row.student.name}}</span>
        </template>
      </el-table-column>
      <el-table-column label="手机号" prop="studentPhone" align="center" >
        <template #default="scope">
          <span>{{scope.row.student.phone}}</span>
        </template>
      </el-table-column>
      <el-table-column label="试卷状态" prop="state" align="center" >
        <template #default="scope">
          <span>{{scope.row.state ===0 ? '待考试' : scope.row.state ===1 ? '待批阅':'批阅完成'}}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="考试是否完成" prop="completed" align="center" >-->
<!--        <template #default="scope">-->
<!--          <span>{{scope.row.completed ===0 ? '未完成' : '已完成'}}</span>-->
<!--        </template>-->
<!--      </el-table-column>-->
      <el-table-column label="成绩" prop="score" align="center" >
        <template #default="scope">
          <span>{{scope.row.state ===0 ? '--' : scope.row.score}}</span>
        </template>
      </el-table-column>
      <el-table-column label="是否合格" prop="passed" align="center"  >
        <template #default="scope">
          <span>{{scope.row.state ===0 ? '--' : scope.row.passed === 0 ? '不合格' : '合格'}}</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="correct(scope.row)" v-if="scope.row.state != 0">批阅</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-choose-student ref="dialogRef" @getList=getList></exam-choose-student>
  </div>
</template>
 
<script setup>
import {getCurrentInstance, onMounted, onUnmounted, reactive, ref, toRefs} from "vue";
import {ElMessage, ElMessageBox} from "element-plus";
import Cookies from "js-cookie";
import {delQuestionBank, getQuestionBank} from "@/api/onlineEducation/questionBank";
import {batchDelStudent, delBatchStu, getBatchStudent} from "@/api/onlineEducation/batch";
import {useRoute, useRouter} from 'vue-router'
import {delExamStu, examDelStudent, getExamStudent} from "@/api/onlineEducation/exam";
import ExamChooseStudent from "@/views/onlineEducation/groupExams/components/examChooseStudent.vue";
const route = useRoute()
const router = useRouter();
 
const { proxy } = getCurrentInstance();
const loading = ref(false);
const dialogRef = ref();
const tableRef = ref();
const data = reactive({
  queryParams: {
    paperId: null,
    studentName: '',
    state: null,
    pageNum: 1,
    pageSize: 10,
  },
  total: 0,
  dataList: [],
  isAdmin: false,
  chooseStu: [],
  completeList: [
    {
      id: 0,
      name: '待考试'
    },
    {
      id: 1,
      name: '待批阅'
    },
    {
      id: 2,
      name: '批阅完成'
    },
  ]
 
});
 
const { queryParams, total, dataList } = toRefs(data);
 
const backValue = ref()
onMounted(async ()=>{
 
  if(route.query.val){
    const val = JSON.parse(route.query.val)
    if(val.type == 'index'){
      data.queryParams.pageNum = val.pageNum;
      data.queryParams.pageSize = val.pageSize;
      data.queryParams.paperId = val.id
    }else {
      data.queryParams.paperId = val.paperId
      data.queryParams.pageNum = val.pageNum;
      data.queryParams.pageSize = val.pageSize;
    }
  }
  const userInfo = JSON.parse(Cookies.get('userInfo'))
  console.log("userInfo",userInfo)
  if(userInfo.userType === 0){
    data.isAdmin = true;
  }else {
    data.isAdmin = false;
  }
  await getList()
})
onUnmounted(()=>{
 
})
 
const getRowKey = (row) => {
  return row.id
}
 
const back = () => {
  // router.push("/group");
 
  const obj = {
 
    pageNum: data.queryParams.pageNum,
    pageSize: data.queryParams.pageSize,
  }
  const v = JSON.stringify(obj)
  router.push({ path: "/group", query: { val: v } });
}
const getList = async () => {
  loading.value = true
  const res = await getExamStudent(data.queryParams)
  if(res.code == 200){
    data.dataList = res.data.list
    data.total = res.data.total
  }else{
    ElMessage.warning(res.message)
  }
  loading.value = false
}
 
const openDialog = () => {
  dialogRef.value.openDialog(data);
}
 
/** 重置新增的表单以及其他数据  */
function reset() {
  data.queryParams = {
    paperId: data.queryParams.paperId,
    studentName: '',
    state: null,
    pageNum: 1,
    pageSize: 10,
  }
  getList()
}
const handleSelectionChange = (val) => {
 
  console.log("选中的行", val)
  data.chooseStu = val.map(item => item.id)
}
 
const correct = (val) => {
  const obj = {
    id: val.id,
    paperId: data.queryParams.paperId,
    pageNum: data.queryParams.pageNum,
    pageSize: data.queryParams.pageSize,
  }
  const v = JSON.stringify(obj)
  router.push({ path: "/correctExam", query: { val: v } });
}
const handleDelete = (val) => {
  ElMessageBox.confirm(
      '确定删除此条数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        const res = await delExamStu(val.id)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
          tableRef.value.clearSelection();
        }else{
          ElMessage.warning(res.message)
        }
      })
}
const handleDeleteBatch = () => {
  if(data.chooseStu && data.chooseStu.length <=0){
    ElMessage.warning('请选择要删除的学员');
    return false;
  }
  ElMessageBox.confirm(
      '确定删除选择的所有数据?',
      '提示',
      {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning',
      })
      .then( async() => {
        // const param = {
        //   phaseStudentIds: data.chooseStu
        // }
        const res = await examDelStudent(data.chooseStu)
        if(res.code == 200){
          ElMessage.success('数据删除成功')
          await getList()
        }else{
          ElMessage.warning(res.message)
        }
      })
}
 
</script>