|
@@ -2,16 +2,23 @@
|
|
|
<div class="h-full bg-white">
|
|
|
<fs-crud ref="crudRef" v-bind="crudBinding" />
|
|
|
|
|
|
- <n-drawer v-model:show="importActive" default-width="40%" placement="right" resizable>
|
|
|
+ <n-drawer v-model:show="importActive" default-width="60%" placement="right" resizable>
|
|
|
<n-drawer-content title="导入科目学员成绩">
|
|
|
<n-space> 当前上传操作用于处理 批量导入 学员成绩分数功能 </n-space>
|
|
|
+ <n-space> 上传分数表格前, 请先下载模板表格 填写数据 </n-space>
|
|
|
+ <n-space>
|
|
|
+ 必须使用标准模板导入数据才能被解析,
|
|
|
+ <n-button @click="downloadTemplate">点击我下载分数模板表格</n-button>
|
|
|
+ </n-space>
|
|
|
<n-upload
|
|
|
class="flex-col-center"
|
|
|
style="margin-top: 30%"
|
|
|
multiple
|
|
|
directory-dnd
|
|
|
- action="https://www.mocky.io/v2/5e4bafc63100007100d8b70f"
|
|
|
+ :action="uploadFile"
|
|
|
:max="1"
|
|
|
+ @before-upload="beforeUpload"
|
|
|
+ @finish="handleFinish"
|
|
|
>
|
|
|
<n-upload-dragger>
|
|
|
<div>
|
|
@@ -27,9 +34,16 @@
|
|
|
</n-drawer-content>
|
|
|
</n-drawer>
|
|
|
|
|
|
- <n-drawer v-model:show="viewActive" default-width="50%" placement="left" resizable>
|
|
|
+ <n-drawer v-model:show="viewActive" default-width="100%" placement="left" resizable>
|
|
|
<n-drawer-content title="查看科目学员成绩">
|
|
|
- <ScoresView :subject-id="subjectId" />
|
|
|
+ <ScoresView
|
|
|
+ :subject-id="subjectId"
|
|
|
+ @close-emits="
|
|
|
+ () => {
|
|
|
+ viewActive = false;
|
|
|
+ }
|
|
|
+ "
|
|
|
+ />
|
|
|
</n-drawer-content>
|
|
|
</n-drawer>
|
|
|
</div>
|
|
@@ -37,12 +51,16 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
import { onMounted, ref } from 'vue';
|
|
|
+import type { UploadFileInfo } from 'naive-ui';
|
|
|
import { useFs } from '@fast-crud/fast-crud';
|
|
|
+import importScores from '@/public/分数导入.xlsx';
|
|
|
+import { getServiceEnvConfig } from '~/.env-config';
|
|
|
import createCrudOptions from './crud';
|
|
|
import ScoresView from './component/index.vue';
|
|
|
const importActive = ref<boolean>(false);
|
|
|
const viewActive = ref<boolean>(false);
|
|
|
const subjectId = ref<number>(0);
|
|
|
+const { url, proxyPattern } = getServiceEnvConfig(import.meta.env);
|
|
|
const context: any = {
|
|
|
importActiveFunc: (id: number) => {
|
|
|
if (id > 0) {
|
|
@@ -55,6 +73,26 @@ const context: any = {
|
|
|
}
|
|
|
};
|
|
|
const { crudRef, crudBinding, crudExpose } = useFs({ createCrudOptions, context });
|
|
|
+
|
|
|
+const uploadFile = proxyPattern ? `${proxyPattern}/scores/import` : `${url}/scores/import`;
|
|
|
+function handleFinish() {
|
|
|
+ crudExpose.doRefresh();
|
|
|
+ importActive.value = false;
|
|
|
+ window.$message?.success('上传成功');
|
|
|
+}
|
|
|
+
|
|
|
+function beforeUpload(data: { file: UploadFileInfo; fileList: UploadFileInfo[] }) {
|
|
|
+ if (data.file.file?.type !== 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') {
|
|
|
+ window.$message?.error('只能上传 Excel 格式的表格文件 请重新上传');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+}
|
|
|
+
|
|
|
+function downloadTemplate() {
|
|
|
+ window.location.href = importScores;
|
|
|
+}
|
|
|
+
|
|
|
onMounted(() => {
|
|
|
crudExpose.doRefresh();
|
|
|
});
|