自选实验项目教师代选
This commit is contained in:
1 parent
1c488d70e5
commit
68be9dfc3d
3 files changed
+224
No files matched your search
@@ -78,6 +78,11 @@ const participantsDialog = ref(false)
|
||||
const participantSession = ref<any>(null)
|
||||
const participants = ref<any[]>([])
|
||||
const participantsLoading = ref(false)
|
||||
const proxyBookingDialog = ref(false)
|
||||
const proxyBookingStudents = ref<any[]>([])
|
||||
const proxyBookingLoading = ref(false)
|
||||
const proxyBookingKeyword = ref('')
|
||||
const proxyBookingStudentId = ref('')
|
||||
|
||||
const selectedTask = computed(() =>
|
||||
options.tasks.find((task) => task.id === projectForm.teachingTaskIds[0]),
|
||||
@@ -613,6 +618,46 @@ async function showParticipants(project: any, session: any) {
|
||||
}
|
||||
}
|
||||
|
||||
async function loadProxyBookingStudents() {
|
||||
if (!participantSession.value) return
|
||||
proxyBookingLoading.value = true
|
||||
try {
|
||||
proxyBookingStudents.value = (await http.get(
|
||||
`/experiments/sessions/${participantSession.value.id}/eligible-students`,
|
||||
{ params: { keyword: proxyBookingKeyword.value || undefined } },
|
||||
)).data
|
||||
} catch (error) {
|
||||
proxyBookingStudents.value = []
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
} finally {
|
||||
proxyBookingLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function openProxyBooking() {
|
||||
proxyBookingStudentId.value = ''
|
||||
proxyBookingKeyword.value = ''
|
||||
proxyBookingDialog.value = true
|
||||
await loadProxyBookingStudents()
|
||||
}
|
||||
|
||||
async function saveProxyBooking() {
|
||||
if (!participantSession.value || !proxyBookingStudentId.value) {
|
||||
ElMessage.warning('请选择需要代选场次的学生')
|
||||
return
|
||||
}
|
||||
try {
|
||||
await http.post(`/experiments/sessions/${participantSession.value.id}/proxy-bookings`, {
|
||||
studentId: proxyBookingStudentId.value,
|
||||
})
|
||||
ElMessage.success('已为该学生代选实验场次')
|
||||
proxyBookingDialog.value = false
|
||||
await showParticipants(participantSession.value.project, participantSession.value)
|
||||
} catch (error) {
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
}
|
||||
}
|
||||
|
||||
async function book(project: any, session: any) {
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
@@ -1452,6 +1497,40 @@ onMounted(async () => {
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-empty v-if="!participantsLoading && !participants.length" description="当前没有学生名单" />
|
||||
<template #footer>
|
||||
<el-button
|
||||
v-if="participantSession?.project?.arrangementMode === 'SelfScheduled'"
|
||||
type="primary"
|
||||
@click="openProxyBooking"
|
||||
>教师代选</el-button>
|
||||
<el-button @click="participantsDialog = false">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog v-model="proxyBookingDialog" title="教师代选实验场次" width="620px">
|
||||
<el-alert
|
||||
title="代选不受学生自主预约时间窗口限制,但仍校验教学任务名单、场次容量和学生课表/其他实验冲突。"
|
||||
type="info"
|
||||
:closable="false"
|
||||
show-icon
|
||||
/>
|
||||
<div class="proxy-booking-search">
|
||||
<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-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" />
|
||||
</el-table>
|
||||
<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>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
Reference in new issue
Block a user