feat(imports): 成绩/名单表格导入 + ClassIsland 时间配置导入 + 安装版增量迁移
服务端:
- 新增 imports 模块: 模板下载(csv/xlsx)、表格解析预览、字段映射导入(append/upsert)、
错误行号与结果统计; ClassIsland 时间配置容错解析 + replace/merge 导入 + 失败回滚(400 不写库)
- TimeLayout 模型 + 迁移; 修复 contentBase64 空值被 422 拦截, 改由 service 返回 IMPORT_EMPTY_FILE
- merge 语义改为按开始时间槽位覆盖, 同开始时间的旧节次不再被静默丢弃
- db-bootstrap 增加 _ch_migrations 账本: 覆盖安装升级也能自动补跑新增迁移(旧库实测通过)
Web 管理端:
- TableImportDialog(成绩/名单): 模板下载、预览、字段映射、重复处理模式、结果统计与错误行
- TimeLayoutImportDialog: 粘贴/选 .json、解析预览、覆盖/合并、已导入列表与删除
- 成绩录入/学生管理/课表管理接入入口(按权限矩阵显示)
验证: verify:e2e 107/107(新增导入 22 项) verify:web 18/18(新增时间配置导入弹窗真实点击)
verify:desktop 40/40
文档: README 新增导入章节、增量迁移说明、API 表与验收对照更新
This commit is contained in:
1 parent
0dcab6f369
commit
8b85079d81
23 files changed
+2735
-108
No files matched your search
@@ -14,6 +14,7 @@ import {
|
||||
type StudentDto,
|
||||
} from '@classhelper/shared';
|
||||
import { classApi, courseApi, gradeApi } from '@/api';
|
||||
import TableImportDialog from '@/components/TableImportDialog.vue';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useRealtimeStore } from '@/stores/realtime';
|
||||
|
||||
@@ -214,6 +215,22 @@ async function submitBulk(): Promise<void> {
|
||||
await loadGrades();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ 表格导入 */
|
||||
|
||||
const importVisible = ref(false);
|
||||
|
||||
function openImport(): void {
|
||||
if (!filter.classId) {
|
||||
ElMessage.warning('请先选择班级');
|
||||
return;
|
||||
}
|
||||
importVisible.value = true;
|
||||
}
|
||||
|
||||
async function onImported(): Promise<void> {
|
||||
await loadGrades();
|
||||
}
|
||||
|
||||
async function removeGrade(row: GradeDto): Promise<void> {
|
||||
await ElMessageBox.confirm(`删除 ${row.student?.name ?? ''} 的「${row.examName}」成绩?`, '确认', {
|
||||
type: 'warning',
|
||||
@@ -280,6 +297,7 @@ onUnmounted(() => {
|
||||
</el-select>
|
||||
<el-button v-if="isAdmin" type="primary" :icon="'Plus'" @click="openSingle">单条录入</el-button>
|
||||
<el-button v-if="isAdmin" type="success" :icon="'Upload'" @click="openBulk">批量录入</el-button>
|
||||
<el-button v-if="isAdmin" type="warning" :icon="'Document'" @click="openImport">导入表格</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -415,6 +433,14 @@ onUnmounted(() => {
|
||||
<el-button type="primary" @click="submitBulk">提交并广播</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 表格导入(xlsx/xls/csv:模板下载 + 预览 + 字段映射 + 结果统计) -->
|
||||
<TableImportDialog
|
||||
v-model="importVisible"
|
||||
kind="grades"
|
||||
:class-id="filter.classId"
|
||||
@imported="onImported"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
type ScheduleWeekView,
|
||||
} from '@classhelper/shared';
|
||||
import { classApi, courseApi, dashboardApi, scheduleApi } from '@/api';
|
||||
import TimeLayoutImportDialog from '@/components/TimeLayoutImportDialog.vue';
|
||||
import { useAuthStore } from '@/stores/auth';
|
||||
import { useRealtimeStore } from '@/stores/realtime';
|
||||
|
||||
@@ -194,6 +195,18 @@ function onScheduleEvent(): void {
|
||||
void loadSchedules();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ ClassIsland 时间配置导入 */
|
||||
|
||||
const timeLayoutVisible = ref(false);
|
||||
|
||||
function openTimeLayoutImport(): void {
|
||||
if (!query.classId) {
|
||||
ElMessage.warning('请先选择班级');
|
||||
return;
|
||||
}
|
||||
timeLayoutVisible.value = true;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
await loadBase();
|
||||
await loadSchedules();
|
||||
@@ -228,6 +241,9 @@ onUnmounted(() => {
|
||||
<el-button v-if="canManageSchedule" type="primary" :icon="'Plus'" @click="openCreate">
|
||||
新增课表
|
||||
</el-button>
|
||||
<el-button v-if="canManageSchedule" type="warning" :icon="'Upload'" @click="openTimeLayoutImport">
|
||||
导入时间配置
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -313,5 +329,12 @@ onUnmounted(() => {
|
||||
<el-button type="primary" @click="submitForm">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- ClassIsland 时间配置导入(覆盖 / 合并,失败不改动原配置) -->
|
||||
<TimeLayoutImportDialog
|
||||
v-model="timeLayoutVisible"
|
||||
:class-id="query.classId"
|
||||
:class-name="classes.find((item) => item.id === query.classId)?.name"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
@@ -1,4 +1,4 @@
|
||||
<script setup lang="ts">
|
||||
<script setup lang="ts">
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { ElMessage, ElMessageBox, type FormInstance, type FormRules } from 'element-plus';
|
||||
import {
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
type StudentDto,
|
||||
} from '@classhelper/shared';
|
||||
import { callApi, classApi, studentApi } from '@/api';
|
||||
import TableImportDialog from '@/components/TableImportDialog.vue';
|
||||
|
||||
const loading = ref(false);
|
||||
const students = ref<StudentDto[]>([]);
|
||||
@@ -33,6 +34,16 @@ async function loadStudents(): Promise<void> {
|
||||
|
||||
/* ------------------------------------------------------------ 新建 / 编辑 */
|
||||
|
||||
/** 名单导入(表格):需要先选定班级,避免导入到错误的班级 */
|
||||
const importVisible = ref(false);
|
||||
function openImport(): void {
|
||||
if (!filter.classId) {
|
||||
ElMessage.warning('请先选择要导入的班级');
|
||||
return;
|
||||
}
|
||||
importVisible.value = true;
|
||||
}
|
||||
|
||||
const formVisible = ref(false);
|
||||
const formRef = ref<FormInstance>();
|
||||
const editingId = ref<string | null>(null);
|
||||
@@ -180,6 +191,7 @@ async function submitCall(): Promise<void> {
|
||||
/>
|
||||
<el-button :icon="'Search'" @click="loadStudents">查询</el-button>
|
||||
<el-button type="primary" :icon="'Plus'" @click="openCreate">新建学生</el-button>
|
||||
<el-button type="warning" :icon="'Document'" @click="openImport">导入名单</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -284,6 +296,14 @@ async function submitCall(): Promise<void> {
|
||||
<el-button type="primary" @click="submitForm">保存</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<!-- 学生名单导入(xlsx/xls/csv,仅管理员可见;后端同样强校验权限) -->
|
||||
<TableImportDialog
|
||||
v-model="importVisible"
|
||||
kind="students"
|
||||
:class-id="filter.classId"
|
||||
@imported="loadStudents"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in new issue
Block a user