- 优化工作进度管理页面的样式,使其更加美观和易读 - 更新了 StatusBlock 组件,使其支持动态传入标题和副标题 - 更新了 Lesson 类型定义,将脚本文件、拍摄文件和素材文件的类型改为字符串 - 添加了 wd-drop-menu 和 wd-drop-menu-item 组件,用于下拉菜单的展示和选择 - 更新了首页列表请求参数,添加了加载指示器 - 在 Lesson 页面增加了单位、角色和权限的展示 - 修复了一些接口请求的问题,提升了用户资料更新的效率
92 lines
2.7 KiB
TypeScript
92 lines
2.7 KiB
TypeScript
import { useDayjs } from "@/composables/useDayjs";
|
|
import type { FileUploadDestination, Lesson } from "@/types/api/lesson";
|
|
|
|
export const extractLessonStage = (lesson: Lesson) => {
|
|
const stages = {
|
|
script_upload: !!lesson?.script_upload_time,
|
|
script_confirm: !!lesson?.script_confirm_time,
|
|
video_capture: !!lesson?.video_capture_time,
|
|
post_production: !!lesson?.video_confirm_time,
|
|
step: 0,
|
|
};
|
|
stages.step = Object.values(stages).filter((v) => v).length;
|
|
return stages;
|
|
};
|
|
|
|
export const calcLessonProgress = (lesson: Lesson, total: number = 4) => {
|
|
const progress = extractLessonStage(lesson);
|
|
return Math.floor((progress.step / total) * 100);
|
|
};
|
|
|
|
export const getLessonSteps = (lesson: Lesson, simplify: boolean = false) => {
|
|
const dayjs = useDayjs();
|
|
const dateFormat = "YYYY-MM-DD HH:mm:ss";
|
|
const progress = extractLessonStage(lesson);
|
|
return [
|
|
{
|
|
title: progress.script_upload ? "脚本提交" : undefined,
|
|
description: progress.script_upload
|
|
? simplify
|
|
? "已完成"
|
|
: `已于 ${dayjs(lesson.script_upload_time * 1000).format(
|
|
dateFormat
|
|
)} 完成上传`
|
|
: "脚本文件提交",
|
|
},
|
|
{
|
|
title: progress.script_confirm ? "脚本确认" : undefined,
|
|
description: progress.script_confirm
|
|
? simplify
|
|
? "已完成"
|
|
: `已于 ${dayjs(lesson.script_confirm_time * 1000).format(
|
|
dateFormat
|
|
)} 确认`
|
|
: "脚本文件确认",
|
|
},
|
|
{
|
|
title: progress.video_capture ? "视频拍摄" : undefined,
|
|
description: progress.video_capture
|
|
? simplify
|
|
? "已完成"
|
|
: `已于 ${dayjs(lesson.video_capture_time * 1000).format(
|
|
dateFormat
|
|
)} 完成上传`
|
|
: "视频拍摄提交",
|
|
},
|
|
{
|
|
title: progress.post_production ? "后期制作" : undefined,
|
|
description: progress.post_production
|
|
? simplify
|
|
? "已完成"
|
|
: `已于 ${dayjs(lesson.video_confirm_time * 1000).format(
|
|
dateFormat
|
|
)} 完成上传`
|
|
: "视频后期制作",
|
|
},
|
|
];
|
|
};
|
|
|
|
export const getScriptFile = (lesson: Lesson) => {
|
|
const scriptFile = lesson.script_file ? lesson.script_file.split("|") : [];
|
|
return {
|
|
way: scriptFile[0] || null,
|
|
reupload: scriptFile[1] || null,
|
|
};
|
|
};
|
|
|
|
export const parseCombinedFileString = (
|
|
lesson: Lesson,
|
|
key: keyof Pick<Lesson, "script_file" | "capture_file" | "material_file">
|
|
): {
|
|
method: FileUploadDestination;
|
|
uploaded: Boolean;
|
|
} => {
|
|
const combined = lesson[key]
|
|
? JSON.parse(lesson[key])
|
|
: {
|
|
method: null,
|
|
uploaded: false,
|
|
};
|
|
return combined;
|
|
};
|