提交 ead3ac8b authored 作者: 王鹏飞's avatar 王鹏飞

chore: update

上级 a54bd8f3
......@@ -34,9 +34,21 @@ export function checkExperimentRecord(data: {
return httpRequest.post('/api/lab/v1/teacher/record/check', data)
}
// 批量导入实验记录评分
export function uploadCheckExperimentRecord(data: { file: File }) {
return httpRequest.post('/api/lab/v1/teacher/record/upload', data, {
// 同步1+X考试成绩
export function syncExam(data: { competition_id: string; detail_id: string }) {
return httpRequest.post('/api/lab/v1/expert/check/sync-exam', data)
}
// 批量导入考试成绩
export function importExam(data: { competition_id: string; file: File }) {
return httpRequest.post('/api/lab/v1/expert/check/import-exam', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
// 批量导入完整评分
export function importScore(data: { competition_id: string; file: File }) {
return httpRequest.post('/api/lab/v1/expert/check/import-score', data, {
headers: { 'Content-Type': 'multipart/form-data' }
})
}
......@@ -2,16 +2,25 @@
import { Upload } from '@element-plus/icons-vue'
import { useFileDialog } from '@vueuse/core'
import { ElMessage } from 'element-plus'
import { uploadCheckExperimentRecord } from '../api'
import { useFilterList } from '../composables/useFilterList'
import { importExam } from '../api'
const emit = defineEmits<{
(e: 'update'): void
}>()
// 批量导入
const { competitions } = useFilterList()
const form = reactive<any>({
competition_id: ''
})
const templateUrl = $computed(() => {
return form.competition_id ? `/api/lab//v1/expert/check/import-exam?competition_id=${form.competition_id}` : ''
})
// 批量导入考试成绩
const { files, open } = useFileDialog()
function handleImport() {
if (!form.competition_id) return
open({
accept: '.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel',
multiple: false
......@@ -20,7 +29,7 @@ function handleImport() {
watchEffect(() => {
if (!files.value?.length) return
const [file] = files.value
uploadCheckExperimentRecord({ file }).then(() => {
importExam({ competition_id: form.competition_id, file }).then(() => {
ElMessage({ message: '导入成功', type: 'success' })
emit('update')
})
......@@ -28,32 +37,25 @@ watchEffect(() => {
</script>
<template>
<el-dialog title="批量导入" :close-on-click-modal="false" width="400px">
<div class="box">
<el-button type="primary" round :icon="Upload" @click="handleImport">本地上传</el-button>
<p>
<a
href="https://webapp-pub.ezijing.com/project/saas-lab/%E5%AE%9E%E9%AA%8C%E6%88%90%E7%BB%A9%E5%AF%BC%E5%85%A5%E6%A8%A1%E6%9D%BF.xlsx"
download
>下载模板</a
<el-dialog title="批量导入考试成绩" :close-on-click-modal="false" width="400px">
<el-form label-width="70px">
<el-form-item label="赛项名称">
<el-select v-model="form.competition_id">
<el-option v-for="item in competitions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<a :href="templateUrl" download style="margin-left: 10px" v-if="templateUrl">下载模板</a>
</el-form-item>
<el-form-item>
<el-button
type="primary"
round
:icon="Upload"
@click="handleImport"
:disabled="!form.competition_id"
style="width: 195px"
>本地上传</el-button
>
</p>
</div>
</el-form-item>
</el-form>
</el-dialog>
</template>
<style lang="scss" scoped>
.box {
padding: 20px 0;
display: flex;
align-items: center;
justify-content: center;
.el-button {
width: 220px;
}
p {
color: #999;
margin-left: 20px;
}
}
</style>
<script setup lang="ts">
import { Upload } from '@element-plus/icons-vue'
import { useFileDialog } from '@vueuse/core'
import { ElMessage } from 'element-plus'
import { useFilterList } from '../composables/useFilterList'
import { importScore } from '../api'
const emit = defineEmits<{
(e: 'update'): void
}>()
const { competitions } = useFilterList()
const form = reactive<any>({
competition_id: ''
})
const templateUrl = $computed(() => {
return form.competition_id ? `/api/lab//v1/expert/check/import-score?competition_id=${form.competition_id}` : ''
})
// 批量导入考试成绩
const { files, open } = useFileDialog()
function handleImport() {
if (!form.competition_id) return
open({
accept: '.csv,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel',
multiple: false
})
}
watchEffect(() => {
if (!files.value?.length) return
const [file] = files.value
importScore({ competition_id: form.competition_id, file }).then(() => {
ElMessage({ message: '导入成功', type: 'success' })
emit('update')
})
})
</script>
<template>
<el-dialog title="批量导入考试成绩" :close-on-click-modal="false" width="400px">
<el-form label-width="70px">
<el-form-item label="赛项名称">
<el-select v-model="form.competition_id">
<el-option v-for="item in competitions" :key="item.id" :label="item.name" :value="item.id"></el-option>
</el-select>
<a :href="templateUrl" download style="margin-left: 10px" v-if="templateUrl">下载模板</a>
</el-form-item>
<el-form-item>
<el-button
type="primary"
round
:icon="Upload"
@click="handleImport"
:disabled="!form.competition_id"
style="width: 195px"
>本地上传</el-button
>
</el-form-item>
</el-form>
</el-dialog>
</template>
<script setup lang="ts">
import { ElMessage } from 'element-plus'
import { useFilterList } from '../composables/useFilterList'
import { syncExam } from '../api'
const emit = defineEmits<{
(e: 'update'): void
}>()
const { competitions } = useFilterList()
const form = reactive<any>({
competition: undefined
})
// 同步
function handleSync(row: any) {
syncExam({ competition_id: form.competition?.id, detail_id: row.id }).then(() => {
ElMessage.success('同步成功')
emit('update')
})
}
</script>
<template>
<el-dialog title="同步1+X考试成绩" :close-on-click-modal="false">
<el-form>
<el-form-item label="赛项名称">
<el-select v-model="form.competition" value-key="id">
<el-option v-for="item in competitions" :key="item.id" :label="item.name" :value="item"></el-option>
</el-select>
</el-form-item>
</el-form>
<el-table :data="form.competition?.rules">
<el-table-column label="评分方法" prop="type" align="center" width="200"></el-table-column>
<el-table-column label="考试名称" prop="exam_name" align="center"></el-table-column>
<el-table-column label="实考人数/应考人数" align="center" width="160">
<template #default="{ row }"> {{ row.finish_count }}/{{ row.all_count }} </template>
</el-table-column>
<el-table-column label="操作" align="center" width="160">
<template #default="{ row }">
<el-button round type="primary" @click="handleSync(row)">同步导入成绩</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
</template>
<script setup lang="ts">
import type { RecordItem } from '../types'
import { Refresh, Upload } from '@element-plus/icons-vue'
import AppList from '@/components/base/AppList.vue'
import { getExperimentRecordList } from '../api'
import { useFilterList } from '../composables/useFilterList'
const ScoreDialog = defineAsyncComponent(() => import('../components/ScoreDialog.vue'))
const ImportDialog = defineAsyncComponent(() => import('../components/ImportDialog.vue'))
const SyncExamDialog = defineAsyncComponent(() => import('../components/SyncExamDialog.vue'))
const ImportExamDialog = defineAsyncComponent(() => import('../components/ImportExamDialog.vue'))
const ImportScoreDialog = defineAsyncComponent(() => import('../components/ImportScoreDialog.vue'))
const { competitions, schools, status } = useFilterList()
......@@ -75,14 +75,11 @@ const listOptions = $computed(() => {
]
}
})
const importVisible = $ref(false)
let dialogVisible = $ref(false)
const rowData = ref<RecordItem>()
// 评分
function handleScore(row: RecordItem) {
rowData.value = row
dialogVisible = true
}
const syncDialogVisible = $ref(false)
const importExamVisible = $ref(false)
const importScoreVisible = $ref(false)
function onUpdateSuccess() {
appList?.refetch()
}
......@@ -96,7 +93,7 @@ function onUpdateSuccess() {
type="primary"
round
:icon="Refresh"
@click="importVisible = true"
@click="syncDialogVisible = true"
v-permission="'v1-teacher-record-upload'"
>系统同步考试成绩</el-button
>
......@@ -104,7 +101,7 @@ function onUpdateSuccess() {
type="primary"
round
:icon="Upload"
@click="importVisible = true"
@click="importExamVisible = true"
v-permission="'v1-teacher-record-upload'"
>批量导入考试成绩</el-button
>
......@@ -112,7 +109,7 @@ function onUpdateSuccess() {
type="primary"
round
:icon="Upload"
@click="importVisible = true"
@click="importScoreVisible = true"
v-permission="'v1-teacher-record-upload'"
>批量导入完整评分</el-button
>
......@@ -122,25 +119,19 @@ function onUpdateSuccess() {
<span :class="{ 'is-info': row.score !== '--' }">{{ row.score }}</span>
</template>
<template #table-x="{ row }">
<el-button
text
type="primary"
v-if="row.checked_flag"
@click="handleScore(row)"
v-permission="'v1-teacher-record-check'"
>评分</el-button
>
<el-button text type="primary" v-if="row.checked_flag" v-permission="'v1-teacher-record-check'">评分</el-button>
</template>
</AppList>
</AppCard>
<!-- 评分 -->
<ScoreDialog
v-model="dialogVisible"
:data="rowData"
<!-- 系统同步考试成绩 -->
<SyncExamDialog v-model="syncDialogVisible" @update="onUpdateSuccess" v-if="syncDialogVisible"></SyncExamDialog>
<!-- 批量导入考试成绩 -->
<ImportExamDialog v-model="importExamVisible" @update="onUpdateSuccess" v-if="importExamVisible"></ImportExamDialog>
<!-- 批量导入完整评分 -->
<ImportScoreDialog
v-model="importScoreVisible"
@update="onUpdateSuccess"
v-if="dialogVisible && rowData"></ScoreDialog>
<!-- 批量导入 -->
<ImportDialog v-model="importVisible" @update="onUpdateSuccess" v-if="importVisible"></ImportDialog>
v-if="importScoreVisible"></ImportScoreDialog>
</template>
<style lang="scss" scoped>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论