feat(M5-P4): mock V2 化 + 伪接口清理 + vite 代理 + 走查修复
- mock 整体重写为「V2 单一存储 + V1 适配层」:教师 19 / 学生 6 / 通知 3 全端点,
V1 冻结 7 端点由同一存储派生(与后端同一张 homework 表一致);
提交内核对齐后端 doSubmit(版本翻转/逾期分流/附件 dataURL 拒绝/
仅查阅拒绝),submit/action 返回 {submissionId} 契约对齐
- 删除伪接口 mock 与客户端方法:Submissions/SubmissionDetail/Grade/Remind/
MyHomeworks/MySubmission/Submit/Create/Edit/InitializeRed/UserPull/
SetTopmost/Expedite/ReceiveUsers/List/GetClassTree(真实环境必 404)
- types/homework.ts 收敛为 V1 冻结契约(删 11 个孤儿类型)
- 删除被切换孤儿化的组件:HomeworkUpload/ClassCheckInput/UserCheckModal
- vite 代理指向本地 8102(M5 联调目标,远程测试环境保留注释)
- 走查修复:TeacherHomeworks 操作列改模板插槽(render 函数 Dropdown 插槽
在 view-ui-plus 下失效导致菜单内联);ReviewModal :value/@input 改
modelValue(Vue2 API 残留导致弹窗打不开);StudentHomeworks 重新提交
按钮补 canSubmit 门控(已截止且不允许补交时后端必拒)
- 验收:dev:mock 冒烟 58/58 PASS;构建 EXIT=0;tsc 47 条均为存量(基线 65)
且无引用已删符号;浏览器走查 9 页面 + 批阅保存闭环 + 3 秒阅读上报通过
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import { createAlova } from 'alova';
|
||||
import { createApis, withConfigType, mountApis } from './createApis';
|
||||
|
||||
export const alovaInstance = createAlova({
|
||||
baseURL: 'http://base.yunhaixingtong.com/homework',
|
||||
requestAdapter: GlobalFetch(),
|
||||
beforeRequest: method => {},
|
||||
responded: res => {
|
||||
return res.json();
|
||||
}
|
||||
});
|
||||
|
||||
export const $$userConfigMap = withConfigType({});
|
||||
|
||||
const Apis = createApis(alovaInstance, $$userConfigMap);
|
||||
|
||||
mountApis(Apis);
|
||||
|
||||
export default Apis;
|
||||
+13
-116
@@ -4,45 +4,30 @@ import conf from "@/assets/config/host.config";
|
||||
import type {
|
||||
HomeworkVo,
|
||||
HomeworkDetailVo,
|
||||
HomeworkPageResult,
|
||||
BasePageResult,
|
||||
UpFileResultVo,
|
||||
UpFileVo,
|
||||
InitializeRedVo,
|
||||
NextPrevVo,
|
||||
ReadGroup,
|
||||
HomeworkStatisticsVo,
|
||||
HomeworkRequest,
|
||||
HomeworkQuery,
|
||||
SchoolTreeNode,
|
||||
ClassTreeNode,
|
||||
SubmissionsResultVo,
|
||||
SubmissionDetailVo,
|
||||
GradeRequest,
|
||||
MyHomeworksVo,
|
||||
MySubmissionVo,
|
||||
SubmitRequest,
|
||||
} from "@/types/homework";
|
||||
|
||||
/**
|
||||
* 课程作业接口封装(P0 标准化后新契约,P1-7 TS 契约化)。
|
||||
* 课程作业 V1 冻结接口封装(M5 后待评估退役)。
|
||||
*
|
||||
* 仅保留后端真实存在的 /api/homework/* 端点,服务未切换页面:
|
||||
* - /homeworklist 全部作业(HomeworkList.vue,SendList)
|
||||
* - /homeworklist/detail 管理视角详情(HomeworkDetails.vue V1 分支)
|
||||
* - /stats 作业统计(HomeworkStats.vue,Statis)
|
||||
* - /list/new?fid= 转发回显(GetDetail)
|
||||
* 原 v1 伪接口(Submissions/SubmissionDetail/Grade/Remind/MyHomeworks/MySubmission/
|
||||
* Submit,后端不存在、真实环境必 404)已随 M5 页面切换删除,见 m5-plan §1.2。
|
||||
*
|
||||
* 前缀说明:conf.serviceHost 本地为空(走 vite 代理),线上为基础平台域名;
|
||||
* platform 固定使用 "api",与后端 Config.API_PATH 中的 api 匹配。
|
||||
* 统一响应由 alova-iview 解包为 data(code==0),页面直接使用返回值。
|
||||
*
|
||||
* 变更要点(P0):
|
||||
* 1. 作业域去掉 Homework_list 二级段(/api/homework/Homework_list/List → /api/homework/List)
|
||||
* 2. 文件域从 base/ 迁移到 file/(/api/base/FileDown → /api/file/Down)
|
||||
* 3. 字典域与联系组域(发文部门管理、自定义联系组)随「应用设置」功能下线整体移除
|
||||
* (见 classwork-frontend-m5-plan.md §7),本文件不再封装 /api/dict/* 与 /api/contacts/*
|
||||
* 4. postJSON 用于 @RequestBody 接口;postForm 用于 @RequestParam 接口(表单提交)
|
||||
* 5. 参数更名:chaoSend→fileIds、topmost→smsFlag
|
||||
* 6. Delete 入参从 ids 逗号串改为 List<Integer> JSON 数组
|
||||
*
|
||||
* 变更要点(P1-7):
|
||||
* 7. 全部方法加返回值泛型标注,替换 Record<string, any>
|
||||
* 8. 列表分页 content 字段对齐后端 BasePageResult(非旧 list)
|
||||
*/
|
||||
|
||||
const HOMEWORK = "/api/homework";
|
||||
@@ -65,24 +50,6 @@ function postJSON<T = any>(url: string, data?: Record<string, any> | any[]): Met
|
||||
);
|
||||
}
|
||||
|
||||
/** POST 表单(与后端 @RequestParam 对齐,application/x-www-form-urlencoded),T 为返回数据类型 */
|
||||
function postForm<T = any>(url: string, data?: Record<string, any>): Method<T> {
|
||||
const pairs = data
|
||||
? Object.entries(data).filter(([, v]) => v !== undefined && v !== null)
|
||||
: [];
|
||||
const form = pairs.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`).join("&");
|
||||
// 同时把参数拼到 URL query:后端 @RequestParam 表单/查询参数都能接收,
|
||||
// 且本地 vite-plugin-mock 不解析 urlencoded body,靠 query 才能拿到参数(不影响线上)。
|
||||
const fullUrl = form ? `${url}${url.includes("?") ? "&" : "?"}${form}` : url;
|
||||
return new Method<T>(
|
||||
"POST",
|
||||
alovaInstance,
|
||||
fullUrl,
|
||||
{ headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" } },
|
||||
form || undefined
|
||||
);
|
||||
}
|
||||
|
||||
/** 附件下载直链(浏览器 location.href 跳转) */
|
||||
function fileDownUrl(fileId: number): string {
|
||||
return `${conf.serviceHost}${FILE}/Down?id=${fileId}`;
|
||||
@@ -103,34 +70,20 @@ class BaseApi {
|
||||
getUserMod() {
|
||||
return get<SchoolTreeNode[]>(`${BASE}/GetUserMod`);
|
||||
}
|
||||
/** 年级→班级树(学生场景:选择通知对象到班级一级) */
|
||||
getClassTree() {
|
||||
return get<ClassTreeNode[]>(`${BASE}/GetClassTree`);
|
||||
}
|
||||
/** 端分离入口:切换当前视角(teacher / student / parent),需在拉取用户信息前调用 */
|
||||
/** 端分离入口(仅 mock):切换当前视角(teacher / student / parent),需在拉取用户信息前调用 */
|
||||
setRole(as: "teacher" | "student" | "parent") {
|
||||
return postJSON<{ role: string }>(`${BASE}/SetRole`, { as });
|
||||
}
|
||||
}
|
||||
|
||||
class HomeworkApi {
|
||||
// ========== 收件箱 ==========
|
||||
/** 已收作业列表 */
|
||||
list(params: HomeworkQuery) {
|
||||
return get<HomeworkPageResult<HomeworkVo>>(`${HOMEWORK}/List`, params);
|
||||
}
|
||||
/** 清单:一键全部已读 */
|
||||
initializeRed() {
|
||||
return postForm<InitializeRedVo>(`${HOMEWORK}/InitializeRed`);
|
||||
}
|
||||
|
||||
// ========== 已发/全部作业 ==========
|
||||
// ========== 全部作业(/homeworklist 管理页) ==========
|
||||
/** 已发/全部作业列表(scope="user" 只看自己,不传=全部) */
|
||||
sendList(params: HomeworkQuery) {
|
||||
return get<BasePageResult<HomeworkVo>>(`${HOMEWORK}/SendList`, params);
|
||||
}
|
||||
|
||||
// ========== 详情 ==========
|
||||
// ========== 详情(/homeworklist/detail 管理视角 + /list/new?fid= 转发回显) ==========
|
||||
/** 查看详情(type=1 标读;type=0 编辑不标读) */
|
||||
modify(serid: number, type = 1) {
|
||||
return get<HomeworkDetailVo>(`${HOMEWORK}/Detail`, { serid, type });
|
||||
@@ -147,70 +100,14 @@ class HomeworkApi {
|
||||
orgizeModify(serid: number) {
|
||||
return get<ReadGroup[]>(`${HOMEWORK}/ReadDetail`, { serid });
|
||||
}
|
||||
/** 追加接收人 */
|
||||
receiveUsers(serid: number, users: string) {
|
||||
return postForm<void>(`${HOMEWORK}/ReceiveUsers`, { serid, users });
|
||||
}
|
||||
|
||||
// ========== 发布/编辑/删除 ==========
|
||||
/** 新建作业(JSON body,fileIds 为附件ID逗号串,smsFlag 为短信标记) */
|
||||
create(data: HomeworkRequest) {
|
||||
return postJSON<number>(`${HOMEWORK}/Create`, data);
|
||||
}
|
||||
/** 编辑作业(JSON body,含 id) */
|
||||
editHomework(data: HomeworkRequest) {
|
||||
return postJSON<void>(`${HOMEWORK}/Edit`, data);
|
||||
}
|
||||
// ========== 维护(管理页) ==========
|
||||
/** 删除作业(ids 数组,支持批量) */
|
||||
deleteHomework(ids: number | string) {
|
||||
// 兼容页面传单个 id 或逗号串,统一转成数组
|
||||
const idArr = String(ids).split(",").map(Number).filter(Boolean);
|
||||
return postJSON<void>(`${HOMEWORK}/Delete`, idArr);
|
||||
}
|
||||
/** 撤回 */
|
||||
userPull(serid: number) {
|
||||
return postForm<void>(`${HOMEWORK}/UserPull`, { serid });
|
||||
}
|
||||
/** 置顶/取消置顶 */
|
||||
setTopmost(serid: number, topmost = 1) {
|
||||
return postForm<void>(`${HOMEWORK}/SetTopmost`, { serid, topmost });
|
||||
}
|
||||
/** 催收未读 */
|
||||
expedite(serid: number) {
|
||||
return postForm<void>(`${HOMEWORK}/Expedite`, { serid });
|
||||
}
|
||||
|
||||
// ========== 课程作业 v1:提交情况 / 批改 / 催交 ==========
|
||||
/** 某作业的提交名单(按班级分组)+ 汇总;submitStatus: all/unsubmitted/submitted/pending/graded/needRedo */
|
||||
submissions(serid: number, submitStatus = "all") {
|
||||
return get<SubmissionsResultVo>(`${HOMEWORK}/Submissions`, { serid, submitStatus });
|
||||
}
|
||||
/** 单份提交详情(批改工作台右侧) */
|
||||
submissionDetail(subId: number) {
|
||||
return get<SubmissionDetailVo>(`${HOMEWORK}/SubmissionDetail`, { subId });
|
||||
}
|
||||
/** 批改(JSON body):action=grade/redo/excellent */
|
||||
grade(data: GradeRequest) {
|
||||
return postJSON<void>(`${HOMEWORK}/Grade`, data);
|
||||
}
|
||||
/** 催交未交学生 */
|
||||
remind(serid: number) {
|
||||
return postForm<{ reminded: number }>(`${HOMEWORK}/Remind`, { serid });
|
||||
}
|
||||
|
||||
// ========== v2 学生端 ==========
|
||||
/** 今日/我的作业(当前学生视角,含提交与批改态 + 分桶计数) */
|
||||
myHomeworks() {
|
||||
return get<MyHomeworksVo>(`${HOMEWORK}/MyHomeworks`);
|
||||
}
|
||||
/** 我对某作业的详情(作业信息 + 我的提交/批改) */
|
||||
mySubmission(serid: number) {
|
||||
return get<MySubmissionVo>(`${HOMEWORK}/MySubmission`, { serid });
|
||||
}
|
||||
/** 提交 / 订正重交(JSON body:serid, text, images, attachments) */
|
||||
submit(data: SubmitRequest) {
|
||||
return postJSON<{ subId: number; submitStatus: string }>(`${HOMEWORK}/Submit`, data);
|
||||
}
|
||||
|
||||
// ========== 附件 ==========
|
||||
fileDownUrl = fileDownUrl;
|
||||
|
||||
+1147
-817
File diff suppressed because it is too large
Load Diff
Vendored
-3
@@ -6,7 +6,6 @@
|
||||
// biome-ignore lint: disable
|
||||
export {}
|
||||
declare global {
|
||||
const $$userConfigMap: typeof import('./api/index')['$$userConfigMap']
|
||||
const Button: typeof import('view-ui-plus')['Button']
|
||||
const EffectScope: typeof import('vue')['EffectScope']
|
||||
const Form: typeof import('view-ui-plus')['Form']
|
||||
@@ -16,8 +15,6 @@ declare global {
|
||||
const Modal: typeof import('view-ui-plus')['Modal']
|
||||
const Select: typeof import('view-ui-plus')['Select']
|
||||
const Table: typeof import('view-ui-plus')['Table']
|
||||
const alovaInstance: typeof import('./api/index')['alovaInstance']
|
||||
const api: typeof import('./api/index')['default']
|
||||
const apiDefinitions: typeof import('./api/apiDefinitions')['default']
|
||||
const computed: typeof import('vue')['computed']
|
||||
const createApis: typeof import('./api/createApis')['createApis']
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
<template>
|
||||
<!-- 作业对象选择:全部班级 / 指定班级(学生场景,复用 UserCheckModal 树选弹窗) -->
|
||||
<div class="check-user-wrap">
|
||||
<div class="check-user-box">
|
||||
<RadioGroup v-model="isAllClass" class="radio" @on-change="onScopeChange">
|
||||
<Radio :disabled="editDisabled" :label="0">{{ isEdit ? "现有班级" : "全部班级" }}</Radio>
|
||||
<Radio :label="1">指定班级</Radio>
|
||||
</RadioGroup>
|
||||
<Input type="text" v-model="classStr" readonly :disabled="!isAllClass" placeholder="选择通知的班级" class="input"></Input>
|
||||
<Button icon="md-add" @click="openPicker" :disabled="!isAllClass"></Button>
|
||||
<Button icon="md-trash" @click="reset" :disabled="!isAllClass"></Button>
|
||||
</div>
|
||||
<UserCheckModal ref="picker" :sources="sources" :userids="tempIds" @on-submit="submit" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/*
|
||||
* 班级选择输入(学生场景)。v-model = "all" 或 班级 id 逗号串。
|
||||
* 数据源为「年级 → 班级」树(base/GetClassTree),叶子为班级,弹窗仅收集叶子 id。
|
||||
*/
|
||||
import UserCheckModal from "@/components/UserCheckModal.vue";
|
||||
import { baseApi } from "@/api/module/homework";
|
||||
|
||||
export default {
|
||||
name: "ClassCheckInput",
|
||||
components: { UserCheckModal },
|
||||
props: {
|
||||
modelValue: { type: String, default: "all" },
|
||||
/** 编辑态:全部班级选项禁用为「现有班级」 */
|
||||
isEdit: { type: Boolean, default: false },
|
||||
},
|
||||
emits: ["update:modelValue"],
|
||||
data() {
|
||||
return {
|
||||
isAllClass: 0 as number,
|
||||
tempIds: [] as number[],
|
||||
classStr: "",
|
||||
editDisabled: false,
|
||||
sources: [{ name: "班级", loader: () => baseApi.getClassTree().send() as Promise<any[]> }],
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.syncFromValue(this.modelValue);
|
||||
},
|
||||
methods: {
|
||||
idsFromVal(val: string): number[] {
|
||||
return String(val || "")
|
||||
.split(",")
|
||||
.map((x) => parseInt(x))
|
||||
.filter((x) => !isNaN(x));
|
||||
},
|
||||
syncFromValue(val: string) {
|
||||
if (val === "all") {
|
||||
this.isAllClass = 0;
|
||||
this.classStr = this.isEdit ? "现有班级" : "全部班级";
|
||||
} else if (val === "") {
|
||||
this.isAllClass = 1;
|
||||
this.classStr = "";
|
||||
this.tempIds = [];
|
||||
} else {
|
||||
this.isAllClass = 1;
|
||||
this.tempIds = this.idsFromVal(val);
|
||||
this.classStr = "";
|
||||
}
|
||||
},
|
||||
onScopeChange(type: number) {
|
||||
const tempIds = this.idsFromVal(String(this.modelValue || ""));
|
||||
if (type === 0) {
|
||||
if (this.isEdit) {
|
||||
this.tempIds = tempIds;
|
||||
this.classStr = "现有班级";
|
||||
this.$emit("update:modelValue", String(tempIds));
|
||||
} else {
|
||||
this.tempIds = [];
|
||||
this.classStr = "全部班级";
|
||||
this.$emit("update:modelValue", "all");
|
||||
}
|
||||
} else {
|
||||
if (this.isEdit) this.editDisabled = true;
|
||||
this.tempIds = tempIds;
|
||||
this.classStr = "";
|
||||
this.openPicker();
|
||||
}
|
||||
},
|
||||
openPicker() {
|
||||
(this.$refs.picker as any).show();
|
||||
},
|
||||
reset() {
|
||||
this.tempIds = [];
|
||||
this.classStr = "";
|
||||
this.$emit("update:modelValue", "");
|
||||
},
|
||||
submit(arr: any[]) {
|
||||
this.classStr = arr.map((x) => x.name).join("、");
|
||||
const ids = arr.map((x) => x.id).join(",");
|
||||
this.$emit("update:modelValue", ids || "all");
|
||||
if (!arr.length) {
|
||||
this.isAllClass = 0;
|
||||
this.classStr = "全部班级";
|
||||
this.$emit("update:modelValue", "all");
|
||||
}
|
||||
},
|
||||
},
|
||||
watch: {
|
||||
modelValue(val: string) {
|
||||
this.syncFromValue(val);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.check-user-wrap {
|
||||
width: 100%;
|
||||
.check-user-box {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
.radio {
|
||||
width: 180px;
|
||||
flex: none;
|
||||
font-size: 12px;
|
||||
vertical-align: middle;
|
||||
line-height: 32px;
|
||||
}
|
||||
.input {
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,116 +0,0 @@
|
||||
<template>
|
||||
<div class="homework-upload">
|
||||
<!-- 自定义上传附件(自旧前端 oldfront/src/components/uploadFile.vue 适配) -->
|
||||
<div class="upload-row">
|
||||
<Upload
|
||||
:on-success="encloSuccess"
|
||||
:on-remove="encloRemove"
|
||||
:default-file-list="defaultList"
|
||||
:action="uploadFileUrl"
|
||||
:accept="fileType"
|
||||
:multiple="isMultiple"
|
||||
:before-upload="handleUpload"
|
||||
:format="formatArr"
|
||||
:max-size="maxSize"
|
||||
:on-format-error="handleFormatError"
|
||||
:on-exceeded-size="handleExceeded"
|
||||
>
|
||||
<Button><Icon type="ios-cloud-upload-outline"></Icon>选择文件</Button>
|
||||
</Upload>
|
||||
<span class="upload-tip">提示:附件大小不超过{{ maxFileSize }}</span>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/*
|
||||
* 作业附件上传(自旧前端 oldfront/src/components/uploadFile.vue 适配 Vue3)。
|
||||
* v-model 为已上传附件 fileid 数组;编辑时经 defaultList 回显已有附件。
|
||||
*/
|
||||
import { Message, Homework } from "view-ui-plus";
|
||||
import config from "@/assets/config/host.config";
|
||||
|
||||
export default {
|
||||
name: "HomeworkUpload",
|
||||
props: {
|
||||
defaultList: { type: Array as () => any[], default: () => [] },
|
||||
fileids: { type: Array as () => number[], default: () => [] },
|
||||
fileType: { type: String, default: "" },
|
||||
multiple: { type: Boolean, default: false },
|
||||
},
|
||||
emits: ["update:fileids"],
|
||||
data() {
|
||||
return {
|
||||
isMultiple: !this.multiple || false,
|
||||
uploadFileUrl: (config.isMock ? "" : config.serviceHost) + "/api/base/FileUpload",
|
||||
formatArr: ["jpg", "gif", "png", "bmp", "xls", "doc", "txt", "docx", "xlsx", "zip", "rar", "pdf", "ppt", "pptx", "wps"],
|
||||
maxFileSize: "200MB",
|
||||
maxSize: 204800,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
encloSuccess(resp: any, file: any) {
|
||||
if (resp.code !== 0) {
|
||||
Message.error(resp.msg || "上传失败");
|
||||
return;
|
||||
}
|
||||
this.fileids.push(resp.data.fileid);
|
||||
this.$emit("update:fileids", this.fileids);
|
||||
},
|
||||
encloRemove(file: any) {
|
||||
//删除文件:默认列表项带 fileid,刚上传的取 response
|
||||
const list = file.fileid ? file : file.response;
|
||||
let fileid = list?.fileid || list?.data?.fileid;
|
||||
const arry = this.fileids.filter((element: number) => element != fileid);
|
||||
this.$emit("update:fileids", arry);
|
||||
},
|
||||
handleUpload() {
|
||||
if (!this.isMultiple && this.fileids.length > 0) {
|
||||
Message.info("仅允许上传一个附件!");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
handleFormatError() {
|
||||
Homework.info({
|
||||
title: "不支持的上传类型!",
|
||||
desc: "请上传指定的文件类型",
|
||||
});
|
||||
},
|
||||
handleExceeded() {
|
||||
Homework.warning({
|
||||
title: "超出大小限制",
|
||||
desc: "最大文件大小为" + this.maxFileSize + "!",
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.homework-upload {
|
||||
display: block;
|
||||
.upload-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
:deep(.ivu-upload) {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
}
|
||||
/* 文件列表整体另起一行,每项独占一行,不再与按钮挤在一起 */
|
||||
:deep(.ivu-upload-list) {
|
||||
display: block;
|
||||
margin-top: 8px;
|
||||
}
|
||||
:deep(.ivu-upload-list-file) {
|
||||
padding: 4px 0;
|
||||
}
|
||||
.upload-tip {
|
||||
margin-left: 10px;
|
||||
color: #f90;
|
||||
font-size: 12px;
|
||||
line-height: 1;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,8 +2,8 @@
|
||||
<!-- V2 批阅弹窗:ReviewWorkbench 的弹窗形态(学生矩阵行内批阅用)。
|
||||
批改中心(Grade.vue)直接内嵌 ReviewWorkbench,不经过本组件。 -->
|
||||
<Modal
|
||||
:value="open"
|
||||
@input="$emit('update:open', $event)"
|
||||
:model-value="open"
|
||||
@update:model-value="$emit('update:open', $event)"
|
||||
:title="`批阅 · ${student?.studentName || ''}`"
|
||||
width="640px"
|
||||
:mask-closable="false"
|
||||
|
||||
@@ -91,6 +91,10 @@ import { ref, reactive, computed, watch } from "vue";
|
||||
import { Message } from "view-ui-plus";
|
||||
import { teacherApi } from "@/api/module/teacherHomework";
|
||||
import type { AttachmentItem, SubmissionVersionVo, StudentMatrixVo } from "@/types/homeworkV2";
|
||||
import config from "@/assets/config/host.config";
|
||||
|
||||
/** 附件地址前缀:本地 dev/mock 走同源代理(空),线上为基础平台域名(含后端 contextPath) */
|
||||
const serviceBase = config.isMock ? "" : config.serviceHost;
|
||||
|
||||
const props = defineProps<{
|
||||
homeworkId: number;
|
||||
@@ -152,13 +156,14 @@ async function load() {
|
||||
const imageAtts = computed(() => (cur.value?.attachments || []).filter((a) => (a.fileType || "").toLowerCase() === "image"));
|
||||
const fileAtts = computed(() => (cur.value?.attachments || []).filter((a) => (a.fileType || "").toLowerCase() !== "image"));
|
||||
|
||||
/** 附件展示地址:fileUrl 已是 /api/file/Preview?id= 相对路径;绝对地址原样 */
|
||||
/** 附件展示地址:fileUrl 可能是 /api/file/Preview?id= 相对路径(需拼 serviceHost),绝对地址原样 */
|
||||
function attUrl(a: AttachmentItem): string {
|
||||
if (/^(https?:)?\/\//.test(a.fileUrl) || a.fileUrl.startsWith("data:")) return a.fileUrl;
|
||||
return a.fileUrl;
|
||||
const u = a.fileUrl || "";
|
||||
if (/^(https?:)?\/\//.test(u) || u.startsWith("data:")) return u;
|
||||
return `${serviceBase}${u}`;
|
||||
}
|
||||
function attDownUrl(a: AttachmentItem): string {
|
||||
return a.fileId ? `/api/file/Down?id=${a.fileId}` : a.fileUrl;
|
||||
return a.fileId ? `${serviceBase}/api/file/Down?id=${a.fileId}` : attUrl(a);
|
||||
}
|
||||
|
||||
const imgZoom = reactive({ open: false, url: "" });
|
||||
|
||||
@@ -1,446 +0,0 @@
|
||||
<template>
|
||||
<Modal
|
||||
v-model="modal"
|
||||
title="选择用户"
|
||||
width="720px"
|
||||
:mask-closable="false"
|
||||
:closable="false"
|
||||
>
|
||||
<Tabs
|
||||
v-if="sources.length > 1"
|
||||
:key="tabKey"
|
||||
type="card"
|
||||
:value="String(tabIndex)"
|
||||
@on-click="tabChange"
|
||||
>
|
||||
<TabPane v-for="(item, index) in sources" :key="index" :label="item.name" :name="index + ''"></TabPane>
|
||||
</Tabs>
|
||||
<AutoComplete
|
||||
@on-search="handleSearch"
|
||||
@on-select="handleSelect"
|
||||
placeholder="输入名字搜索"
|
||||
v-model="searchTreeName"
|
||||
:clearable="true"
|
||||
class="auto-box"
|
||||
>
|
||||
<Option v-for="item in searchResult" :key="item.id" :value="item.name">
|
||||
<span>{{ item.name }}</span>
|
||||
<span class="fr info">{{ item.group }}</span>
|
||||
</Option>
|
||||
</AutoComplete>
|
||||
<div class="tree-wrap fix">
|
||||
<div class="tree-panel fl">
|
||||
<div class="tree-box">
|
||||
<div :id="ztreeDomId" class="ztree"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="arrow-box fl">
|
||||
<svg
|
||||
t="1626916477711"
|
||||
class="icon"
|
||||
viewBox="0 0 1024 1024"
|
||||
version="1.1"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
width="36"
|
||||
height="36"
|
||||
>
|
||||
<path
|
||||
d="M138.935 256.078v511.844h63.42V256.078h-63.42z m126.842 0v511.844h127.215V256.078H265.777zM885.064 512L583.254 64.323v191.755H456.414v511.844h126.842v191.755L885.064 512z"
|
||||
fill="#2d8cf0"
|
||||
></path>
|
||||
</svg>
|
||||
</div>
|
||||
<div class="user-panel fl">
|
||||
<div class="title-box fix">
|
||||
<Checkbox @on-change="checkAllUser" v-model="isCheckUserAll">全选</Checkbox>
|
||||
<div class="fr">{{ tempUserList.length }}</div>
|
||||
<a
|
||||
href="javascript:;"
|
||||
@click="delCheckUser"
|
||||
v-if="tempUserList.findIndex((x: any) => x.isCheck) > -1"
|
||||
>删除选中</a
|
||||
>
|
||||
</div>
|
||||
<ul class="user-box">
|
||||
<li
|
||||
v-for="item in tempUserList"
|
||||
:key="item.id"
|
||||
:class="{ active: item.isCheck }"
|
||||
@click="checkUserOne(item)"
|
||||
>
|
||||
{{ item.name }}
|
||||
<span class="info">{{ item.group }}</span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<template #footer>
|
||||
<Button type="primary" @click="submit">提交</Button>
|
||||
<Button @click="modal = false" style="margin-left: 8px">取消</Button>
|
||||
</template>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
/*
|
||||
* 选择用户弹窗(自旧前端 oldfront/src/components/userCheck.vue 适配 Vue3)。
|
||||
* 左侧为带复选框的组织树(部门→人员,叶子=人员),勾选/取消按父子级联;
|
||||
* 右侧为已选人员列表,支持全选/删除选中;提交返回去重后的用户 id 数组与用户对象数组。
|
||||
*/
|
||||
import { Message } from "view-ui-plus";
|
||||
import { requireImg } from "@/utils/hook/useImg";
|
||||
|
||||
interface SelectSource {
|
||||
name: string;
|
||||
loader: () => Promise<any[]>;
|
||||
}
|
||||
|
||||
export default {
|
||||
name: "UserCheckModal",
|
||||
props: {
|
||||
/** 数据源 tab:{ name, loader },loader 返回 ztree 树数据(children 嵌套,叶子=人员) */
|
||||
sources: {
|
||||
type: Array as () => SelectSource[],
|
||||
default: () => [],
|
||||
},
|
||||
/** 已选用户 id(打开时自动勾选) */
|
||||
userids: {
|
||||
type: Array as () => number[],
|
||||
default: () => [],
|
||||
},
|
||||
isDisabled: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
},
|
||||
emits: ["update:userids", "on-submit"],
|
||||
data() {
|
||||
return {
|
||||
ztreeDomId: "user_check_tree_" + Math.floor(Math.random() * 1e8),
|
||||
modal: false,
|
||||
tabIndex: 0,
|
||||
/** 每次打开弹窗自增,强制重建 Tabs,避免上次 tab 高亮残留与数据错位 */
|
||||
tabKey: 0,
|
||||
/** 树加载序号:tab 快速切换时只渲染最后一次请求的结果 */
|
||||
treeSeq: 0,
|
||||
isCheckUserAll: false,
|
||||
cacheMap: new Map(),
|
||||
currentTree: [] as any[],
|
||||
searchTreeName: "",
|
||||
searchResult: [] as any[],
|
||||
tempUserList: [] as any[],
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
/** 当前树扁平化(含父级名称,供搜索展示) */
|
||||
currentTreeFlatten(): any[] {
|
||||
const flatten = (data: any[], pid: number, pname: string): any[] =>
|
||||
data.reduce(
|
||||
(arr: any[], { id, name, children = [], type }: any) =>
|
||||
arr.concat([{ id, name, pid, type, group: pname }], flatten(children, id, name)),
|
||||
[]
|
||||
);
|
||||
return flatten(this.currentTree, 0, "");
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
show() {
|
||||
this.modal = true;
|
||||
// 重置到第一个 tab:显式赋值 + key 重建 Tabs,保证高亮与数据一致
|
||||
this.tabIndex = 0;
|
||||
this.tabKey++;
|
||||
this.changeEmpty();
|
||||
this.initTree();
|
||||
},
|
||||
tabChange(index: string) {
|
||||
const idx = Number(index);
|
||||
// 严格比较:v-model 场景下 iview 会把值写成字符串 name,
|
||||
// 宽松相等("1" == 1)会误判“未切换”导致 tab 永远不生效
|
||||
if (idx !== 0 && this.tabIndex === idx) return;
|
||||
this.tabIndex = idx;
|
||||
this.changeEmpty();
|
||||
this.initTree();
|
||||
},
|
||||
handleSearch(query: string) {
|
||||
let arr: any[] = [];
|
||||
const searchArr = this.currentTreeFlatten.filter(
|
||||
(x: any) => x.type == 2 && x.name.indexOf(query) != -1
|
||||
);
|
||||
for (const item of searchArr) {
|
||||
!arr
|
||||
.map((x) => this.getSplitId(x.id))
|
||||
.includes(this.getSplitId(item.id)) && arr.push(item);
|
||||
}
|
||||
this.searchResult = arr;
|
||||
},
|
||||
handleSelect(query: string) {
|
||||
if (query.indexOf(",") != -1) query = query.split(",")[0];
|
||||
var treeObj = ($.fn as any).zTree.getZTreeObj(this.ztreeDomId);
|
||||
var node = treeObj.getNodeByParam("name", query, null);
|
||||
if (!!node) treeObj.checkNode(node, true, true, true);
|
||||
},
|
||||
/**
|
||||
* ztree 数据预处理:拼接 pid 保证同人多组时 id 可区分;叶子标记 type=2。
|
||||
* 组/用户判定优先用接口 isParent(组=文件夹),缺失时按有无子节点兜底;
|
||||
* 并设置组/用户区分图标。
|
||||
*/
|
||||
formatTree(tree: any[], level = 0, pid: number = 0) {
|
||||
tree.forEach((element: any) => {
|
||||
element.open = level == 0;
|
||||
element.pid = pid;
|
||||
element.id = element.id + "," + pid;
|
||||
element.checked = false;
|
||||
if (typeof element.isParent !== "undefined") {
|
||||
element.type = element.isParent ? 1 : 2;
|
||||
} else {
|
||||
element.type = element.children && element.children.length > 0 ? 1 : 2;
|
||||
}
|
||||
element.icon = requireImg(
|
||||
element.type == 1 ? "tree-icon-group.png" : "tree-icon-item.png",
|
||||
"image"
|
||||
);
|
||||
if (typeof element.children !== "undefined" && element.children.length > 0) {
|
||||
element.children = this.formatTree(element.children, level + 1, this.getSplitId(element.id));
|
||||
}
|
||||
});
|
||||
return tree;
|
||||
},
|
||||
initTree() {
|
||||
const _this = this;
|
||||
// 竞态守卫:慢请求返回时若已切换 tab,丢弃结果
|
||||
const seq = ++this.treeSeq;
|
||||
const cacheKey = this.tabIndex;
|
||||
const source = this.sources[this.tabIndex];
|
||||
if (!source) return;
|
||||
const cached = this.cacheMap.get(cacheKey);
|
||||
if (cached) {
|
||||
this.createTree(cached);
|
||||
return;
|
||||
}
|
||||
source
|
||||
.loader()
|
||||
.then((data: any[]) => {
|
||||
if (seq !== _this.treeSeq) return;
|
||||
_this.cacheMap.set(cacheKey, data || []);
|
||||
_this.createTree(data || []);
|
||||
})
|
||||
.catch((e: any) => {
|
||||
if (seq === _this.treeSeq) Message.error(e?.message || "加载组织数据失败");
|
||||
});
|
||||
},
|
||||
createTree(rawData: any[]) {
|
||||
const _this = this;
|
||||
var jtree = JSON.parse(JSON.stringify(rawData));
|
||||
var ftree = _this.formatTree(jtree);
|
||||
_this.currentTree = ftree;
|
||||
|
||||
let treeSetting: any = {
|
||||
view: {
|
||||
dblClickExpand: false,
|
||||
showIcon: true,
|
||||
},
|
||||
check: {
|
||||
enable: true,
|
||||
chkboxType: { Y: "ps", N: "ps" },
|
||||
},
|
||||
callback: {},
|
||||
};
|
||||
/** 勾选变化后同步右侧已选列表:收集勾选节点子树内的所有叶子 */
|
||||
function formatUser(treeNode: any, checked: boolean) {
|
||||
const recursionCheckIds = (tree: any): any[] => {
|
||||
let arrIds: any[] = [];
|
||||
for (const key in tree) {
|
||||
const element = tree[key];
|
||||
if (element.type == 2 && !element.chkDisabled) {
|
||||
arrIds.push({ id: element.id, tid: element.tId });
|
||||
}
|
||||
if (typeof element.children !== "undefined" && element.children) {
|
||||
arrIds = [...arrIds, ...recursionCheckIds(element.children)];
|
||||
}
|
||||
}
|
||||
return arrIds;
|
||||
};
|
||||
const checkIds = recursionCheckIds([treeNode]);
|
||||
const checkUserList = _this.currentTreeFlatten.filter((x: any) =>
|
||||
checkIds.map((x) => x.id).includes(x.id)
|
||||
);
|
||||
const checkUserArr: any[] = [];
|
||||
for (const element of checkUserList) {
|
||||
var findObj = checkIds.find((x) => x.id == element.id);
|
||||
if (
|
||||
!!findObj &&
|
||||
checkUserArr.findIndex((x) => x.id == element.id) === -1 &&
|
||||
_this.tempUserList.findIndex((x) => x.id == element.id) === -1
|
||||
) {
|
||||
checkUserArr.push({ ...element, isCheck: false, tid: findObj.tid });
|
||||
}
|
||||
}
|
||||
if (checked) {
|
||||
_this.tempUserList = _this.tempUserList.concat(checkUserArr);
|
||||
} else {
|
||||
var ids = checkUserList.map((x) => x.id);
|
||||
_this.tempUserList = _this.tempUserList.filter((x) => !ids.includes(x.id));
|
||||
}
|
||||
}
|
||||
treeSetting.callback.onClick = (event: any, treeId: string, treeNode: any) => {
|
||||
let check = treeNode.checked;
|
||||
let treeObj = ($.fn as any).zTree.getZTreeObj(treeId);
|
||||
treeObj.checkNode(treeNode, !check, true);
|
||||
formatUser(treeNode, treeNode.checked);
|
||||
};
|
||||
treeSetting.callback.onCheck = (event: any, treeId: string, treeNode: any) => {
|
||||
formatUser(treeNode, treeNode.checked);
|
||||
};
|
||||
var treeObj = ($.fn as any).zTree.init($("#" + _this.ztreeDomId), treeSetting, ftree);
|
||||
// 回显:已选用户打勾(callbackFlag=true 会触发 onCheck,同步右侧列表)
|
||||
var nodes = treeObj.getNodesByFilter((x: any) =>
|
||||
_this.userids.includes(_this.getSplitId(x.id))
|
||||
);
|
||||
var arr: any[] = [];
|
||||
nodes.forEach((element: any) => {
|
||||
var splitId = _this.getSplitId(element.id); //重复id只选择第一个
|
||||
if (!arr.includes(splitId)) treeObj.checkNode(element, true, true, true);
|
||||
if (_this.isDisabled) treeObj.setChkDisabled(element, true);
|
||||
arr.push(splitId);
|
||||
});
|
||||
},
|
||||
checkAllUser(check: boolean) {
|
||||
this.tempUserList.forEach((element: any) => {
|
||||
element.isCheck = check;
|
||||
});
|
||||
},
|
||||
checkUserOne(item: any) {
|
||||
item.isCheck = !item.isCheck;
|
||||
const tlist = this.tempUserList;
|
||||
this.isCheckUserAll =
|
||||
tlist.length > 0 && tlist.filter((x) => x.isCheck).length == tlist.length;
|
||||
},
|
||||
delCheckUser() {
|
||||
const _this = this;
|
||||
const tlist = _this.tempUserList;
|
||||
const delArr = tlist.filter((item: any) => item.isCheck);
|
||||
var treeObj = ($.fn as any).zTree.getZTreeObj(_this.ztreeDomId);
|
||||
delArr.forEach((element: any) => {
|
||||
var node = treeObj.getNodeByTId(element.tid);
|
||||
treeObj.checkNode(node, false, true, true);
|
||||
});
|
||||
_this.isCheckUserAll = false;
|
||||
},
|
||||
changeEmpty() {
|
||||
this.tempUserList = [];
|
||||
this.searchTreeName = "";
|
||||
this.searchResult = [];
|
||||
},
|
||||
submit() {
|
||||
const _this = this;
|
||||
let idsArr = this.tempUserList.map((x: any) => _this.getSplitId(x.id));
|
||||
idsArr = Array.from(new Set(idsArr));
|
||||
this.$emit("update:userids", idsArr);
|
||||
function delKey(obj: any, ...args: string[]) {
|
||||
args.forEach((v) => delete obj[v]);
|
||||
return obj;
|
||||
}
|
||||
const objArr: any[] = [];
|
||||
idsArr.forEach((element) => {
|
||||
let findObj = _this.tempUserList.find((x: any) => _this.getSplitId(x.id) == element);
|
||||
findObj = delKey({ ...findObj }, "id", "isCheck", "tid", "pid", "type");
|
||||
objArr.push({ ...findObj, id: element });
|
||||
});
|
||||
this.$emit("on-submit", objArr);
|
||||
this.modal = false;
|
||||
},
|
||||
/** 树节点 id 形如 "1,301"(原id,父id),取真实 id */
|
||||
getSplitId(strId: any) {
|
||||
if (typeof strId === "string" && strId.indexOf(",") != -1) return parseInt(strId.split(",")[0]);
|
||||
return strId;
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.tree-wrap {
|
||||
height: 430px;
|
||||
position: relative;
|
||||
}
|
||||
.tree-panel {
|
||||
border: 1px solid #eee;
|
||||
width: 280px;
|
||||
height: 430px;
|
||||
overflow: hidden;
|
||||
}
|
||||
.tree-box {
|
||||
padding: 4px 0;
|
||||
height: 428px;
|
||||
width: auto;
|
||||
overflow-y: auto;
|
||||
border: none;
|
||||
}
|
||||
.user-panel {
|
||||
border: 1px solid #eee;
|
||||
width: 280px;
|
||||
.title-box {
|
||||
background: #f7f7f7;
|
||||
height: 34px;
|
||||
line-height: 34px;
|
||||
padding: 0 12px;
|
||||
a {
|
||||
text-decoration: none;
|
||||
float: right;
|
||||
margin-right: 20px;
|
||||
outline: none;
|
||||
}
|
||||
}
|
||||
.user-box {
|
||||
height: 396px;
|
||||
overflow-y: auto;
|
||||
li {
|
||||
line-height: 32px;
|
||||
padding-left: 12px;
|
||||
cursor: pointer;
|
||||
.info {
|
||||
float: right;
|
||||
margin-right: 12px;
|
||||
font-size: 12px;
|
||||
color: gray;
|
||||
}
|
||||
}
|
||||
li:hover {
|
||||
background: #f3f3f3;
|
||||
}
|
||||
li.active {
|
||||
background: #e4edf6;
|
||||
}
|
||||
}
|
||||
}
|
||||
.arrow-box {
|
||||
width: 128px;
|
||||
text-align: center;
|
||||
position: relative;
|
||||
top: 50%;
|
||||
margin-top: -17px;
|
||||
}
|
||||
.auto-box {
|
||||
width: 200px;
|
||||
margin-bottom: 10px;
|
||||
:deep(.ivu-select-item .info) {
|
||||
font-size: 12px;
|
||||
color: gray;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
}
|
||||
:deep(.ztree li) {
|
||||
overflow: hidden;
|
||||
}
|
||||
:deep(.ztree li a) {
|
||||
width: 100%;
|
||||
}
|
||||
:deep(.ztree li a:hover) {
|
||||
text-decoration: none;
|
||||
}
|
||||
:deep(.ivu-auto-complete .ivu-select-dropdown-list) {
|
||||
max-height: 310px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
</style>
|
||||
+7
-202
@@ -1,17 +1,11 @@
|
||||
/**
|
||||
* 课程作业前端类型契约(P1-7)
|
||||
* 课程作业 V1 冻结接口类型契约(M5 后待评估退役,见 m5-plan §2.3)。
|
||||
*
|
||||
* 与后端 VO/DTO 一一对齐:
|
||||
* - HomeworkVo → 后端 model/homework/HomeworkVo.java(Jackson 默认驼峰序列化)
|
||||
* - HomeworkDetailVo → 后端 model/homework/HomeworkDetailVo.java(@JsonProperty 保留旧字段名)
|
||||
* - BasePageResult → 后端 model/BasePageResult.java
|
||||
* - HomeworkPageResult extends BasePageResult → 后端 model/homework/HomeworkPageResult.java
|
||||
* - UpFileResultVo → 后端 model/homework/UpFileResultVo.java(@JsonProperty)
|
||||
* - UpFileVo → 后端 model/homework/UpFileVo.java
|
||||
* - InitializeRedVo → 后端 model/homework/InitializeRedVo.java(@JsonProperty)
|
||||
* - HomeworkStatisticsVo → 后端 model/homework/HomeworkStatisticsVo.java
|
||||
* - HomeworkRequest → 后端 model/homework/HomeworkRequest.java
|
||||
* - HomeworkQuery → 后端 model/homework/HomeworkQuery.java + BasePageQuery.java
|
||||
* 仅服务未切换页面:/homeworklist(SendList/Delete)、/homeworklist/detail
|
||||
* (Detail/GetNextPrev/ReadDetail)、/stats(Statis)、/list/new?fid= 转发回显
|
||||
* (GetDetail/ChaoSend)。V2 契约在 types/homeworkV2.ts,两者互不引用。
|
||||
* 与后端 VO/DTO 一一对齐:HomeworkVo/HomeworkDetailVo(@JsonProperty 保留旧字段名)、
|
||||
* BasePageResult、UpFileResultVo/UpFileVo、HomeworkStatisticsVo、HomeworkQuery。
|
||||
*/
|
||||
|
||||
// ============================ 分页外壳 ============================
|
||||
@@ -26,12 +20,6 @@ export interface BasePageResult<T> {
|
||||
hasNext: boolean;
|
||||
}
|
||||
|
||||
/** 作业分页结果(对齐 HomeworkPageResult.java,扩展 unreadCount) */
|
||||
export interface HomeworkPageResult<T> extends BasePageResult<T> {
|
||||
/** 当前用户未读作业总数 */
|
||||
unreadCount: number;
|
||||
}
|
||||
|
||||
// ============================ 作业列表项 ============================
|
||||
|
||||
/** 作业视图对象(对齐 HomeworkVo.java,Jackson 默认驼峰序列化) */
|
||||
@@ -159,13 +147,6 @@ export interface UpFileVo {
|
||||
topicType: string;
|
||||
}
|
||||
|
||||
// ============================ 一键已读 ============================
|
||||
|
||||
/** 一键已读结果(对齐 InitializeRedVo.java,@JsonProperty) */
|
||||
export interface InitializeRedVo {
|
||||
count: number;
|
||||
}
|
||||
|
||||
// ============================ 上一篇/下一篇 ============================
|
||||
|
||||
/** 上一篇/下一篇作业ID */
|
||||
@@ -212,14 +193,11 @@ export interface HomeworkStatisticsVo {
|
||||
scoreDist?: { label: string; key: string; count: number }[];
|
||||
}
|
||||
|
||||
// ============================ 课程作业 v1:提交 / 批改 ============================
|
||||
// ============================ 课程作业 v1 状态与进度 ============================
|
||||
|
||||
/** 作业流程状态 */
|
||||
export type HomeworkStatus = "draft" | "collecting" | "closed" | "done";
|
||||
|
||||
/** 单个提交状态 */
|
||||
export type SubmitStatus = "unsubmitted" | "submitted" | "graded" | "needRedo" | "redone";
|
||||
|
||||
/** 提交/批改进度 */
|
||||
export interface HomeworkProgress {
|
||||
/** 应交人数 */
|
||||
@@ -242,111 +220,8 @@ export interface HomeworkProgress {
|
||||
gradeRate: number;
|
||||
}
|
||||
|
||||
/** 提交名单项(Submissions 接口返回,精简) */
|
||||
export interface SubmissionBrief {
|
||||
subId: number;
|
||||
studentId: number;
|
||||
studentName: string;
|
||||
submitStatus: SubmitStatus;
|
||||
submittedAt: string | null;
|
||||
hasGrade: boolean;
|
||||
score: number | null;
|
||||
level: string | null;
|
||||
isExcellent: boolean;
|
||||
}
|
||||
|
||||
/** 提交名单按班级分组 */
|
||||
export interface SubmissionGroup {
|
||||
className: string;
|
||||
students: SubmissionBrief[];
|
||||
}
|
||||
|
||||
/** 某作业提交情况结果 */
|
||||
export interface SubmissionsResultVo {
|
||||
homeworkId: number;
|
||||
title: string;
|
||||
subject: string;
|
||||
deadline: string | null;
|
||||
hwStatus: HomeworkStatus;
|
||||
hwStatusDesc: string;
|
||||
summary: HomeworkProgress;
|
||||
groups: SubmissionGroup[];
|
||||
}
|
||||
|
||||
/** 批改结果 */
|
||||
export interface GradeResult {
|
||||
score: number | null;
|
||||
level: string | null;
|
||||
comment: string;
|
||||
isExcellent: boolean;
|
||||
markedImages: string[];
|
||||
}
|
||||
|
||||
/** 单份提交详情(批改工作台用) */
|
||||
export interface SubmissionDetailVo {
|
||||
subId: number;
|
||||
homeworkId: number;
|
||||
homeworkTitle: string;
|
||||
subject: string;
|
||||
studentId: number;
|
||||
studentName: string;
|
||||
classId: string;
|
||||
className: string;
|
||||
submitStatus: SubmitStatus;
|
||||
submittedAt: string | null;
|
||||
text: string;
|
||||
images: string[];
|
||||
attachments: string[];
|
||||
grade: GradeResult | null;
|
||||
}
|
||||
|
||||
/** 批改入参 */
|
||||
export interface GradeRequest {
|
||||
subId: number;
|
||||
/** grade 保存批改 / redo 要求订正 / excellent 标为优秀 */
|
||||
action?: "grade" | "redo" | "excellent";
|
||||
score?: number | string;
|
||||
level?: string;
|
||||
comment?: string;
|
||||
isExcellent?: boolean;
|
||||
markedImages?: string[];
|
||||
}
|
||||
|
||||
// ============================ 请求入参 ============================
|
||||
|
||||
/** 作业发布/编辑入参(对齐 HomeworkRequest.java) */
|
||||
export interface HomeworkRequest {
|
||||
title: string;
|
||||
content?: string;
|
||||
/** 学科 */
|
||||
subject?: string;
|
||||
/** 截止时间 yyyy-MM-dd HH:mm:ss */
|
||||
deadline?: string;
|
||||
/** 提交方式:text/image/attach/none */
|
||||
submitType?: string[] | string;
|
||||
type?: number;
|
||||
deptId?: string;
|
||||
/** 是否允许逾期补交 */
|
||||
allowLate?: boolean;
|
||||
/** 截止提醒:如 ["1d","1h"] */
|
||||
remindBefore?: string[];
|
||||
/** 存草稿:true 则不发布 */
|
||||
draft?: boolean;
|
||||
deptName?: string;
|
||||
topmost?: number;
|
||||
/** 接收对象:"all" 或 班级 id 逗号串(receiveType=class) */
|
||||
receiveList?: string;
|
||||
/** 接收对象类型:class=班级 */
|
||||
receiveType?: string;
|
||||
/** 附件文件ID列表(逗号分隔串) */
|
||||
fileIds?: string;
|
||||
timingSendTime?: string;
|
||||
/** 短信发送标记 */
|
||||
smsFlag?: number;
|
||||
/** 转发源作业ID */
|
||||
sourceId?: number;
|
||||
}
|
||||
|
||||
/** 作业列表查询参数(对齐 HomeworkQuery.java + BasePageQuery.java) */
|
||||
export interface HomeworkQuery {
|
||||
pageIndex?: number;
|
||||
@@ -379,73 +254,3 @@ export interface SchoolTreeNode {
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// ============================ 班级 ============================
|
||||
|
||||
/** 年级→班级树节点(叶子=班级,id 为数字班级 id,附学生数) */
|
||||
export interface ClassTreeNode {
|
||||
id: number;
|
||||
name: string;
|
||||
isParent: boolean;
|
||||
studentCount?: number;
|
||||
children?: ClassTreeNode[];
|
||||
[key: string]: any;
|
||||
}
|
||||
|
||||
// ============================ v2 学生端 ============================
|
||||
|
||||
/** 当前视角角色(家长即登录学生账号,不单列) */
|
||||
export type ViewerRole = "teacher" | "student";
|
||||
|
||||
/** 学生对某作业的提交/批改态 */
|
||||
export interface StudentSubmissionInfo {
|
||||
subId: number;
|
||||
submitStatus: SubmitStatus;
|
||||
submittedAt: string | null;
|
||||
text: string;
|
||||
score: number | null;
|
||||
level: string | null;
|
||||
comment: string;
|
||||
isExcellent: boolean;
|
||||
images?: string[];
|
||||
attachments?: string[];
|
||||
grade?: GradeResult | null;
|
||||
}
|
||||
|
||||
/** 学生视角作业项 */
|
||||
export interface StudentHomeworkVo {
|
||||
id: number;
|
||||
title: string;
|
||||
subject: string;
|
||||
publisherName: string;
|
||||
deptName: string;
|
||||
deadline: string | null;
|
||||
createTime: string | null;
|
||||
content: string;
|
||||
submitType: string[];
|
||||
viewOnly: boolean;
|
||||
hwStatus?: HomeworkStatus;
|
||||
allowLate?: boolean;
|
||||
my: StudentSubmissionInfo | null;
|
||||
}
|
||||
|
||||
/** 今日/我的作业列表 */
|
||||
export interface MyHomeworksVo {
|
||||
buckets: { todo: number; submitted: number; graded: number; redo: number; all: number };
|
||||
list: StudentHomeworkVo[];
|
||||
}
|
||||
|
||||
/** 我的某作业详情(作业信息 + 我的提交/批改) */
|
||||
export interface MySubmissionVo {
|
||||
homework: { id: number; title: string; subject: string; content: string; deadline: string | null; submitType: string[]; publisherName: string; deptName: string };
|
||||
my: StudentSubmissionInfo | null;
|
||||
}
|
||||
|
||||
/** 学生提交作业入参 */
|
||||
export interface SubmitRequest {
|
||||
serid: number;
|
||||
text?: string;
|
||||
/** 图片 URL / dataURL 列表(逗号串或数组) */
|
||||
images?: string[] | string;
|
||||
/** 附件 id 列表(逗号串或数组) */
|
||||
attachments?: string[] | string;
|
||||
}
|
||||
|
||||
@@ -240,6 +240,8 @@ export interface StudentHomeworkV2Vo {
|
||||
submitType: string[];
|
||||
hwStatus: HwStatusV2;
|
||||
hwStatusDesc: string;
|
||||
/** 截止后是否允许逾期补交:0 否 / 1 是(CLOSED 时决定是否渲染「补交」入口) */
|
||||
allowLate?: number;
|
||||
my: StudentMySubmission | null;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,12 +23,20 @@ onMounted(load);
|
||||
/* 分数分布条 */
|
||||
const maxDist = computed(() => Math.max(1, ...(stat.value?.scoreDist || []).map((d) => d.count)));
|
||||
const BAR_COLOR: Record<string, string> = { excellent: "#19be6b", good: "#2d8cf0", pass: "#ff9900", fail: "#ed4014" };
|
||||
/** 后端是否提供课程作业口径数据(老部署未升级时避免把「未返回」伪装成 0) */
|
||||
const hasScoreDist = computed(() => (stat.value?.scoreDist?.length ?? 0) > 0);
|
||||
const hasByHomework = computed(() => (stat.value?.byHomework?.length ?? 0) > 0);
|
||||
|
||||
/** 卡片值:字段缺失显示「—」而非 0,避免被误读为「确实没有作业」 */
|
||||
function cardValue(v: number | undefined | null, suffix = ""): string {
|
||||
return v === undefined || v === null ? "—" : `${v}${suffix}`;
|
||||
}
|
||||
|
||||
const cards = computed(() => [
|
||||
{ label: "我布置的作业", value: stat.value?.myAssignCount ?? 0 },
|
||||
{ label: "待批改总量", value: stat.value?.pendingGrade ?? 0 },
|
||||
{ label: "平均提交率", value: (stat.value?.avgSubmitRate ?? 0) + "%" },
|
||||
{ label: "作业总数", value: stat.value?.total ?? 0 },
|
||||
{ label: "我布置的作业", value: cardValue(stat.value?.myAssignCount) },
|
||||
{ label: "待批改总量", value: cardValue(stat.value?.pendingGrade) },
|
||||
{ label: "平均提交率", value: cardValue(stat.value?.avgSubmitRate, "%") },
|
||||
{ label: "作业总数", value: cardValue(stat.value?.total) },
|
||||
]);
|
||||
|
||||
const HW_STATUS_TEXT: Record<string, string> = { draft: "草稿", collecting: "收集中", closed: "已截止", done: "已完成" };
|
||||
@@ -52,7 +60,7 @@ const HW_STATUS_TEXT: Record<string, string> = { draft: "草稿", collecting: "
|
||||
<!-- 分数分布 -->
|
||||
<div class="block">
|
||||
<div class="block-h">成绩分布(已批改提交)</div>
|
||||
<div class="dist">
|
||||
<div class="dist" v-if="hasScoreDist">
|
||||
<div class="dist-row" v-for="d in stat.scoreDist" :key="d.key">
|
||||
<div class="dist-label">{{ d.label }}</div>
|
||||
<div class="dist-track">
|
||||
@@ -61,12 +69,14 @@ const HW_STATUS_TEXT: Record<string, string> = { draft: "草稿", collecting: "
|
||||
<div class="dist-num">{{ d.count }}</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="block-empty" v-else>暂无可统计的批阅分数(后端未返回成绩分布口径)</div>
|
||||
</div>
|
||||
|
||||
<!-- 各作业进度 -->
|
||||
<div class="block">
|
||||
<div class="block-h">我布置的作业 · 提交与批改</div>
|
||||
<Table
|
||||
v-if="hasByHomework"
|
||||
:columns="[
|
||||
{ title: '作业', key: 'title', minWidth: 220, tooltip: true },
|
||||
{ title: '学科', key: 'subject', width: 90, align: 'center' },
|
||||
@@ -85,6 +95,7 @@ const HW_STATUS_TEXT: Record<string, string> = { draft: "草稿", collecting: "
|
||||
:data="stat.byHomework || []"
|
||||
no-data-text="暂无需要收集提交记录的作业"
|
||||
></Table>
|
||||
<div class="block-empty" v-else>暂无需要收集提交记录的作业(后端未返回按作业进度口径)</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else class="main-container"><Spin fix /></div>
|
||||
@@ -124,6 +135,11 @@ const HW_STATUS_TEXT: Record<string, string> = { draft: "草稿", collecting: "
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
}
|
||||
.block-empty {
|
||||
color: #a6aab0;
|
||||
font-size: 13px;
|
||||
padding: 12px 0;
|
||||
}
|
||||
.dist {
|
||||
.dist-row {
|
||||
display: flex;
|
||||
|
||||
@@ -72,7 +72,7 @@ async function loadClasses() {
|
||||
function toggleAll(v: boolean) {
|
||||
if (v) selClasses.value = [...allClassIds.value];
|
||||
}
|
||||
onMounted(loadClasses);
|
||||
/* 班级树由下方统一初始化入口按序加载(fillFromV2 依赖 allClassIds 判定「全部班级」) */
|
||||
|
||||
const ruleValidate = {
|
||||
title: [
|
||||
@@ -147,6 +147,9 @@ function fillFromV2(d: HomeworkV2Vo) {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// 先加载班级树再回显:fillFromV2 用 allClassIds 判定「全部班级」,
|
||||
// 若并行执行则 allClassIds 仍为空,勾选态会被误判为「未全选」
|
||||
await loadClasses();
|
||||
if (!(isEdit.value || fid.value > 0)) return;
|
||||
try {
|
||||
if (isEdit.value) {
|
||||
|
||||
@@ -272,8 +272,8 @@ function zoom(url: string) {
|
||||
<div class="c-actions">
|
||||
<Button v-if="['NOT_SUBMITTED'].includes(myStatus(row)) && canSubmit(row)" type="primary" icon="md-cloud-upload" size="small" @click="openSubmit(row)">
|
||||
{{ row.hwStatus === "CLOSED" ? "补交作业" : "提交作业" }}</Button>
|
||||
<Button v-else-if="myStatus(row) === 'RETURNED'" type="error" icon="md-refresh" size="small" @click="openSubmit(row)">重新提交</Button>
|
||||
<template v-else-if="['SUBMITTED', 'LATE_SUBMITTED'].includes(myStatus(row)) && row.hwStatus === 'PUBLISHED'">
|
||||
<Button v-else-if="myStatus(row) === 'RETURNED' && canSubmit(row)" type="error" icon="md-refresh" size="small" @click="openSubmit(row)">重新提交</Button>
|
||||
<template v-else-if="['SUBMITTED', 'LATE_SUBMITTED'].includes(myStatus(row)) && canSubmit(row) && row.hwStatus === 'PUBLISHED'">
|
||||
<Button ghost icon="md-create" size="small" @click="openSubmit(row)">修改提交</Button>
|
||||
<Button icon="md-undo" size="small" @click="withdraw(row)">撤回</Button>
|
||||
</template>
|
||||
|
||||
@@ -252,11 +252,6 @@ function del(row: HomeworkV2Vo) {
|
||||
});
|
||||
}
|
||||
|
||||
/* 文本按钮 */
|
||||
function btn(text: string, onClick: () => void) {
|
||||
return h("Button", { type: "text", size: "small", onClick }, () => text);
|
||||
}
|
||||
|
||||
/* ============ 已发布列表列 ============ */
|
||||
const pubColumns = computed(() => [
|
||||
{ title: "序号", type: "index", width: 60, align: "center" },
|
||||
@@ -335,44 +330,21 @@ const pubColumns = computed(() => [
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
width: 250,
|
||||
slot: "action",
|
||||
width: 230,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h: any, p: any) => {
|
||||
const row = p.row as HomeworkV2Vo;
|
||||
const nodes: any[] = [];
|
||||
nodes.push(btn("提交情况", () => viewSubmissions(row)));
|
||||
if ((row.progress?.pendingGrade ?? 0) > 0) nodes.push(btn("批阅", () => toGrade(row)));
|
||||
const more: any[] = [];
|
||||
if (row.hwStatus === "PUBLISHED") {
|
||||
if ((row.progress?.unread ?? 0) > 0) more.push(mItem("提醒未读", () => remind(row, "NOT_READ")));
|
||||
if ((row.progress?.unsubmitted ?? 0) > 0) more.push(mItem("催交", () => remind(row, "NOT_SUBMITTED")));
|
||||
more.push(mItem("延长截止", () => openExtend(row)));
|
||||
}
|
||||
more.push(mItem("复制", () => copyRow(row)));
|
||||
if (row.hwStatus === "PUBLISHED" || row.hwStatus === "CLOSED") more.push(mItem("归档", () => archive(row)));
|
||||
more.push(mItem("导出报表", () => doExport(row)));
|
||||
nodes.push(
|
||||
h("Dropdown", { transfer: true, onOnClick: (name: string) => onMore(name) }, () => [
|
||||
h("Button", { type: "text", size: "small" }, () => "更多∨"),
|
||||
h("DropdownMenu", { slot: "list" }, () => more),
|
||||
])
|
||||
);
|
||||
return h("div", {}, nodes);
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
/* 更多菜单回调(闭包 name→action) */
|
||||
const moreActions = new Map<string, () => void>();
|
||||
let moreSeq = 0;
|
||||
function mItem(text: string, action: () => void) {
|
||||
const key = `m${++moreSeq}`;
|
||||
moreActions.set(key, action);
|
||||
return h("DropdownItem", { name: key }, () => text);
|
||||
}
|
||||
function onMore(name: string) {
|
||||
moreActions.get(name)?.();
|
||||
/* 更多菜单分发 */
|
||||
function onPubMore(name: string, row: HomeworkV2Vo) {
|
||||
if (name === "notRead") remind(row, "NOT_READ");
|
||||
else if (name === "notSubmitted") remind(row, "NOT_SUBMITTED");
|
||||
else if (name === "extend") openExtend(row);
|
||||
else if (name === "copy") copyRow(row);
|
||||
else if (name === "archive") archive(row);
|
||||
else if (name === "export") doExport(row);
|
||||
}
|
||||
|
||||
/* ============ 草稿箱列 ============ */
|
||||
@@ -401,18 +373,10 @@ const draftColumns = computed(() => [
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
slot: "draftAction",
|
||||
width: 250,
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
render: (h: any, p: any) => {
|
||||
const row = p.row as HomeworkV2Vo;
|
||||
const nodes: any[] = [];
|
||||
nodes.push(btn("编辑", () => edit(row)));
|
||||
nodes.push(btn("发布", () => publishDraft(row)));
|
||||
if (row.hwStatus === "DRAFT_SCHEDULED") nodes.push(btn("取消定时", () => cancelSchedule(row)));
|
||||
nodes.push(btn("删除", () => del(row)));
|
||||
return nodes;
|
||||
},
|
||||
},
|
||||
]);
|
||||
|
||||
@@ -462,7 +426,33 @@ const tableHeight = computed(() => Utils.useTableHeight({ isSearch: true, isOper
|
||||
:height="tableHeight"
|
||||
:loading="loading"
|
||||
no-data-text="暂无数据"
|
||||
></Table>
|
||||
>
|
||||
<!-- 已发布行操作 -->
|
||||
<template #action="{ row }">
|
||||
<Button type="text" size="small" @click="viewSubmissions(row)">提交情况</Button>
|
||||
<Button v-if="(row.progress?.pendingGrade ?? 0) > 0" type="text" size="small" @click="toGrade(row)">批阅</Button>
|
||||
<Dropdown transfer @on-click="(name: string) => onPubMore(name, row)">
|
||||
<Button type="text" size="small">更多∨</Button>
|
||||
<template #list>
|
||||
<DropdownMenu>
|
||||
<DropdownItem v-if="row.hwStatus === 'PUBLISHED' && (row.progress?.unread ?? 0) > 0" name="notRead">提醒未读</DropdownItem>
|
||||
<DropdownItem v-if="row.hwStatus === 'PUBLISHED' && (row.progress?.unsubmitted ?? 0) > 0" name="notSubmitted">催交</DropdownItem>
|
||||
<DropdownItem v-if="row.hwStatus === 'PUBLISHED'" name="extend">延长截止</DropdownItem>
|
||||
<DropdownItem name="copy">复制</DropdownItem>
|
||||
<DropdownItem v-if="row.hwStatus === 'PUBLISHED' || row.hwStatus === 'CLOSED'" name="archive">归档</DropdownItem>
|
||||
<DropdownItem name="export">导出报表</DropdownItem>
|
||||
</DropdownMenu>
|
||||
</template>
|
||||
</Dropdown>
|
||||
</template>
|
||||
<!-- 草稿箱行操作 -->
|
||||
<template #draftAction="{ row }">
|
||||
<Button type="text" size="small" @click="edit(row)">编辑</Button>
|
||||
<Button type="text" size="small" @click="publishDraft(row)">发布</Button>
|
||||
<Button v-if="row.hwStatus === 'DRAFT_SCHEDULED'" type="text" size="small" @click="cancelSchedule(row)">取消定时</Button>
|
||||
<Button type="text" size="small" @click="del(row)">删除</Button>
|
||||
</template>
|
||||
</Table>
|
||||
<div class="page-panel">
|
||||
<div class="fl ml-15 align-middle"></div>
|
||||
<Page
|
||||
|
||||
Reference in New Issue
Block a user