feat(web): 增加日课表编辑与学期设备管理界面

This commit is contained in:
LoveChengke committed 2026-10-17 09:38:29 +08:00
1 parent 4dc824c283
commit 35b252249d
16 files changed
+1014 -112

No files matched your search

@@ -0,0 +1,77 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { ElMessageBox } from 'element-plus';
import { api } from '@/api/http';
type Status = {
config: { month: number; day: number; hour: number; classCount: number };
year: number;
pending: boolean;
runs: {
year: number;
status: string;
message: string;
classCount: number;
studentCount: number;
snapshotPath: string;
}[];
};
const status = ref<Status>();
async function load() {
status.value = await api.get('/term/promotion');
}
async function save() {
if (status.value) await api.put('/term/promotion', status.value.config);
await load();
}
async function catchUp() {
if (!status.value) return;
const preview = await api.post<{ classCount: number; studentCount: number }>('/term/promotion/run', {
year: status.value.year,
dryRun: true,
});
await ElMessageBox.confirm(
`将影响 ${preview.classCount} 个班、${preview.studentCount} 名学生。执行前自动保存全库快照;高三归档,其余升一级,新建高一骨架。`,
'补跑学年升级',
{ type: 'warning' },
);
await api.post('/term/promotion/run', { year: status.value.year, dryRun: false });
await load();
}
onMounted(load);
</script>
<template>
<el-card v-if="status">
<h3>每年自动学年升级</h3>
<el-form inline>
<el-form-item label="月">
<el-input-number v-model="status.config.month" :min="1" :max="12" />
</el-form-item>
<el-form-item label="日">
<el-input-number v-model="status.config.day" :min="1" :max="31" />
</el-form-item>
<el-form-item label="时">
<el-input-number v-model="status.config.hour" :min="0" :max="23" />
</el-form-item>
<el-form-item label="新高一班级数">
<el-input-number v-model="status.config.classCount" :min="1" :max="99" />
</el-form-item>
<el-button @click="save">保存升级时间</el-button>
</el-form>
<p>新学年开学日重置为 9 月 1 日,保留总周数上限;新班主任与任课关系由管理员指定。</p>
<el-alert
v-if="status.pending"
title="有尚未执行的学年升级,请预览影响后补跑"
type="warning"
:closable="false"
/>
<el-button v-if="status.pending" @click="catchUp">预览并补跑 {{ status.year }} 学年</el-button>
<el-table :data="status.runs">
<el-table-column prop="year" label="学年" />
<el-table-column prop="status" label="结果" />
<el-table-column prop="classCount" label="班级数" />
<el-table-column prop="studentCount" label="学生数" />
<el-table-column prop="message" label="执行记录" />
<el-table-column prop="snapshotPath" label="执行前快照" />
</el-table>
</el-card>
</template>
@@ -0,0 +1,47 @@
<script setup lang="ts">
import { onMounted, onUnmounted, ref } from 'vue';
import { SOCKET_EVENTS, type ReleaseProgressDto } from '@classhelper/shared';
import { api } from '@/api/http';
import { useRealtimeStore } from '@/stores/realtime';
const progress = ref<ReleaseProgressDto>();
const realtime = useRealtimeStore();
const labels = {
idle: '未开始',
downloading: '下载中',
verifying: '校验中',
ready: '完成',
failed: '失败',
waiting: '等待安装策略',
installing: '安装中',
};
const update = (p: unknown) => {
progress.value = p as ReleaseProgressDto;
};
let timer: ReturnType<typeof setInterval>;
async function load() {
progress.value = await api.get('/update/client/progress');
}
onMounted(() => {
void load();
realtime.on(SOCKET_EVENTS.clientReleaseProgress, update);
timer = setInterval(() => void load(), 3000);
});
onUnmounted(() => {
clearInterval(timer);
realtime.off(SOCKET_EVENTS.clientReleaseProgress, update);
});
</script>
<template>
<div v-if="progress" role="status">
<p>
安装包:{{ labels[progress.stage] }} {{ progress.version }} · {{ progress.downloadedBytes }} /
{{ progress.totalBytes || '未知' }} 字节
</p>
<el-progress
:percentage="progress.percent ?? 0"
:indeterminate="progress.percent === null && progress.stage === 'downloading'"
:status="progress.stage === 'failed' ? 'exception' : undefined"
/>
<p v-if="progress.error">{{ progress.error }}</p>
</div>
</template>
@@ -0,0 +1,31 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue';
import { ElMessageBox } from 'element-plus';
import { api } from '@/api/http';
const students = ref<
{ id: string; studentNo: string; name: string; transferNote: string; class: { name: string } | null }[]
>([]);
async function load() {
students.value = await api.get('/archives/transferred');
}
async function restore(id: string) {
await ElMessageBox.confirm('撤回后学生恢复到原班,转出历史仍保留。', '撤回转出');
await api.post(`/archives/transferred/${id}/restore`);
await load();
}
onMounted(load);
</script>
<template>
<el-card>
<h3>已转出</h3>
<el-table :data="students">
<el-table-column prop="studentNo" label="学号" />
<el-table-column prop="name" label="姓名" />
<el-table-column prop="class.name" label="原班级" />
<el-table-column prop="transferNote" label="转出说明" />
<el-table-column label="操作">
<template #default="{ row }"><el-button link @click="restore(row.id)">撤回转出</el-button></template>
</el-table-column>
</el-table>
</el-card>
</template>