Add batch proxy booking for self-scheduled experiments
This commit is contained in:
1 parent
1e43d910c0
commit
e6d25791b3
3 files changed
+152
-11
No files matched your search
@@ -82,7 +82,7 @@ const proxyBookingDialog = ref(false)
|
||||
const proxyBookingStudents = ref<any[]>([])
|
||||
const proxyBookingLoading = ref(false)
|
||||
const proxyBookingKeyword = ref('')
|
||||
const proxyBookingStudentId = ref('')
|
||||
const proxyBookingStudentIds = ref<string[]>([])
|
||||
|
||||
const selectedTask = computed(() =>
|
||||
options.tasks.find((task) => task.id === projectForm.teachingTaskIds[0]),
|
||||
@@ -635,22 +635,22 @@ async function loadProxyBookingStudents() {
|
||||
}
|
||||
|
||||
async function openProxyBooking() {
|
||||
proxyBookingStudentId.value = ''
|
||||
proxyBookingStudentIds.value = []
|
||||
proxyBookingKeyword.value = ''
|
||||
proxyBookingDialog.value = true
|
||||
await loadProxyBookingStudents()
|
||||
}
|
||||
|
||||
async function saveProxyBooking() {
|
||||
if (!participantSession.value || !proxyBookingStudentId.value) {
|
||||
if (!participantSession.value || !proxyBookingStudentIds.value.length) {
|
||||
ElMessage.warning('请选择需要代选场次的学生')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await http.post(`/experiments/sessions/${participantSession.value.id}/proxy-bookings`, {
|
||||
studentId: proxyBookingStudentId.value,
|
||||
const { data } = await http.post(`/experiments/sessions/${participantSession.value.id}/proxy-bookings/batch`, {
|
||||
studentIds: proxyBookingStudentIds.value,
|
||||
})
|
||||
ElMessage.success('已为该学生代选实验场次')
|
||||
ElMessage.success(`已为 ${data.bookedCount} 名学生代选实验场次`)
|
||||
proxyBookingDialog.value = false
|
||||
await showParticipants(participantSession.value.project, participantSession.value)
|
||||
} catch (error) {
|
||||
@@ -1518,10 +1518,13 @@ onMounted(async () => {
|
||||
<el-input v-model="proxyBookingKeyword" clearable placeholder="输入学号、姓名或行政班" @keyup.enter="loadProxyBookingStudents" />
|
||||
<el-button @click="loadProxyBookingStudents">查询</el-button>
|
||||
</div>
|
||||
<el-table v-loading="proxyBookingLoading" :data="proxyBookingStudents" max-height="400" @current-change="(row) => proxyBookingStudentId = row?.studentId ?? ''">
|
||||
<el-table-column width="54">
|
||||
<template #default="{ row }"><el-radio v-model="proxyBookingStudentId" :value="row.studentId" /></template>
|
||||
</el-table-column>
|
||||
<el-table
|
||||
v-loading="proxyBookingLoading"
|
||||
:data="proxyBookingStudents"
|
||||
max-height="400"
|
||||
@selection-change="(rows) => proxyBookingStudentIds = rows.map((row) => row.studentId)"
|
||||
>
|
||||
<el-table-column type="selection" width="54" />
|
||||
<el-table-column prop="studentNumber" label="学号" min-width="130" />
|
||||
<el-table-column prop="name" label="姓名" min-width="100" />
|
||||
<el-table-column prop="className" label="行政班" min-width="180" />
|
||||
@@ -1529,7 +1532,9 @@ onMounted(async () => {
|
||||
<el-empty v-if="!proxyBookingLoading && !proxyBookingStudents.length" description="没有可代选的学生" />
|
||||
<template #footer>
|
||||
<el-button @click="proxyBookingDialog = false">取消</el-button>
|
||||
<el-button type="primary" :disabled="!proxyBookingStudentId" @click="saveProxyBooking">确认代选</el-button>
|
||||
<el-button type="primary" :disabled="!proxyBookingStudentIds.length" @click="saveProxyBooking">
|
||||
确认代选({{ proxyBookingStudentIds.length }})
|
||||
</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user