|
@@ -1,39 +1,16 @@
|
|
<template>
|
|
<template>
|
|
<div class="h-full bg-white">
|
|
<div class="h-full bg-white">
|
|
<fs-crud ref="crudRef" v-bind="crudBinding" />
|
|
<fs-crud ref="crudRef" v-bind="crudBinding" />
|
|
-
|
|
|
|
- <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="uploadFile"
|
|
|
|
- :max="1"
|
|
|
|
- @before-upload="beforeUpload"
|
|
|
|
- @finish="handleFinish"
|
|
|
|
- >
|
|
|
|
- <n-upload-dragger>
|
|
|
|
- <div>
|
|
|
|
- <svg-icon icon="material-symbols:upload" class="w-30 h-30" style="margin: 0 auto" />
|
|
|
|
- </div>
|
|
|
|
- <n-text style="font-size: 16px"> 点击或者拖动文件到该区域来上传 </n-text>
|
|
|
|
- <n-p depth="3" style="margin: 8px 0 0 0">
|
|
|
|
- 请不要上传敏感数据,比如你的银行卡号和密码,信用卡号有效期和安全码 上传成功后, 后台会自动解析
|
|
|
|
- 学员的成绩分数, 并录入成绩库
|
|
|
|
- </n-p>
|
|
|
|
- </n-upload-dragger>
|
|
|
|
- </n-upload>
|
|
|
|
- </n-drawer-content>
|
|
|
|
|
|
+ <n-drawer v-model:show="importActive" default-width="100%" placement="right" resizable>
|
|
|
|
+ <ImportScores
|
|
|
|
+ :subject-id="subjectId"
|
|
|
|
+ @close-emits="
|
|
|
|
+ () => {
|
|
|
|
+ importActive = false;
|
|
|
|
+ }
|
|
|
|
+ "
|
|
|
|
+ />
|
|
</n-drawer>
|
|
</n-drawer>
|
|
-
|
|
|
|
<n-drawer v-model:show="viewActive" default-width="100%" placement="left" resizable>
|
|
<n-drawer v-model:show="viewActive" default-width="100%" placement="left" resizable>
|
|
<n-drawer-content title="查看科目学员成绩">
|
|
<n-drawer-content title="查看科目学员成绩">
|
|
<ScoresView
|
|
<ScoresView
|
|
@@ -51,21 +28,17 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { onMounted, ref } from 'vue';
|
|
import { onMounted, ref } from 'vue';
|
|
-import type { UploadFileInfo } from 'naive-ui';
|
|
|
|
import { useFs } from '@fast-crud/fast-crud';
|
|
import { useFs } from '@fast-crud/fast-crud';
|
|
-import importScores from '@/public/分数导入.xlsx';
|
|
|
|
-import { getServiceEnvConfig } from '~/.env-config';
|
|
|
|
import createCrudOptions from './crud';
|
|
import createCrudOptions from './crud';
|
|
-import ScoresView from './component/index.vue';
|
|
|
|
|
|
+import ScoresView from './component/viewScores.vue';
|
|
|
|
+import ImportScores from './component/importScores.vue';
|
|
const importActive = ref<boolean>(false);
|
|
const importActive = ref<boolean>(false);
|
|
const viewActive = ref<boolean>(false);
|
|
const viewActive = ref<boolean>(false);
|
|
const subjectId = ref<number>(0);
|
|
const subjectId = ref<number>(0);
|
|
-const { url, proxyPattern } = getServiceEnvConfig(import.meta.env);
|
|
|
|
const context: any = {
|
|
const context: any = {
|
|
importActiveFunc: (id: number) => {
|
|
importActiveFunc: (id: number) => {
|
|
- if (id > 0) {
|
|
|
|
- importActive.value = true;
|
|
|
|
- }
|
|
|
|
|
|
+ subjectId.value = id;
|
|
|
|
+ importActive.value = true;
|
|
},
|
|
},
|
|
viewActiveFunc: (id: number) => {
|
|
viewActiveFunc: (id: number) => {
|
|
subjectId.value = id;
|
|
subjectId.value = id;
|
|
@@ -74,29 +47,9 @@ const context: any = {
|
|
};
|
|
};
|
|
const { crudRef, crudBinding, crudExpose } = useFs({ createCrudOptions, context });
|
|
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(() => {
|
|
onMounted(() => {
|
|
crudExpose.doRefresh();
|
|
crudExpose.doRefresh();
|
|
});
|
|
});
|
|
</script>
|
|
</script>
|
|
|
|
|
|
<style scoped></style>
|
|
<style scoped></style>
|
|
-./component/scoreCrud
|
|
|