实验成绩 Excel 流程
This commit is contained in:
@@ -2,14 +2,17 @@
|
||||
import { computed, onMounted, reactive, ref } from 'vue'
|
||||
import {
|
||||
Check,
|
||||
Download,
|
||||
EditPen,
|
||||
Plus,
|
||||
Promotion,
|
||||
Refresh,
|
||||
Setting,
|
||||
Upload,
|
||||
} from '@element-plus/icons-vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import http, { apiErrorMessage } from '../api/http'
|
||||
import { downloadApiFile, importExcel } from '../api/excel'
|
||||
import { useAuthStore } from '../stores/auth'
|
||||
import {
|
||||
academicTermLabel,
|
||||
@@ -44,6 +47,7 @@ const recordKeyword = ref('')
|
||||
const schemeDialog = ref(false)
|
||||
const editingScheme = ref(false)
|
||||
const schemeProject = ref<any | null>(null)
|
||||
const importFileInput = ref<HTMLInputElement>()
|
||||
|
||||
const schemeForm = reactive({
|
||||
contributionWeight: 1,
|
||||
@@ -290,6 +294,38 @@ async function saveRecords() {
|
||||
}
|
||||
}
|
||||
|
||||
function downloadTemplate() {
|
||||
if (!detail.value) return
|
||||
downloadApiFile(
|
||||
`/experiment-grades/sheets/${detail.value.id}/template`,
|
||||
'实验成绩导入模板.xlsx',
|
||||
)
|
||||
}
|
||||
|
||||
function chooseImportFile() {
|
||||
importFileInput.value?.click()
|
||||
}
|
||||
|
||||
async function handleImport(event: Event) {
|
||||
const input = event.target as HTMLInputElement
|
||||
const file = input.files?.[0]
|
||||
if (!file || !detail.value) return
|
||||
saving.value = true
|
||||
try {
|
||||
const result = await importExcel(
|
||||
`/experiment-grades/sheets/${detail.value.id}/import`,
|
||||
file,
|
||||
)
|
||||
ElMessage.success(`导入完成:已更新 ${result.data.updated} 条实验成绩记录`)
|
||||
await loadDetail()
|
||||
} catch (error) {
|
||||
ElMessage.error(apiErrorMessage(error))
|
||||
} finally {
|
||||
input.value = ''
|
||||
saving.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function syncParticipants() {
|
||||
if (!detail.value) return
|
||||
try {
|
||||
@@ -777,12 +813,16 @@ onMounted(async () => {
|
||||
@size-change="recordPage = 1; loadDetail()"
|
||||
/>
|
||||
|
||||
<input ref="importFileInput" type="file" accept=".xlsx" style="display:none" @change="handleImport" />
|
||||
|
||||
<footer class="workbench-actions">
|
||||
<div>
|
||||
<b v-if="detail.reviewComment">审核意见:{{ detail.reviewComment }}</b>
|
||||
<span>开课学院:{{ detail.courseCollegeName }}</span>
|
||||
</div>
|
||||
<div>
|
||||
<el-button v-if="detail.canEdit" :icon="Download" @click="downloadTemplate">下载模板</el-button>
|
||||
<el-button v-if="detail.canEdit" :icon="Upload" :loading="saving" @click="chooseImportFile">Excel 导入</el-button>
|
||||
<el-button v-if="detail.canEdit" :icon="EditPen" :loading="saving" @click="saveRecords">保存本页</el-button>
|
||||
<el-button v-if="detail.canEdit" type="primary" :icon="Promotion" @click="submitSheet">提交审核</el-button>
|
||||
<el-button v-if="detail.canReview" type="danger" plain @click="returnSheet">退回修改</el-button>
|
||||
|
||||
Reference in New Issue
Block a user