From 91f7d2212d09639b5b6e2e1af0cce535653463cd Mon Sep 17 00:00:00 2001 From: HoshinoSuzumi Date: Sun, 22 Sep 2024 18:07:10 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=B7=A5=E4=BD=9C=E8=BF=9B=E5=BA=A6?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E9=A1=B5=E9=9D=A2=EF=BC=8C=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=B5=84=E6=96=99=E6=9B=B4=E6=96=B0=EF=BC=8C?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components.d.ts | 6 ++ src/App.vue | 22 ++++- src/api/BussApi.ts | 28 ++++-- src/components/page-wrapper.vue | 10 +-- src/pages.json | 13 ++- src/pages/index/index.vue | 21 +++-- src/pages/lesson/index.vue | 2 +- src/pages/progress/index.vue | 155 ++++++++++++++++++++++++++++++++ src/stores/useUser.ts | 15 +++- src/types/api/lesson.ts | 12 +-- src/types/api/user.ts | 13 +++ src/utils/lesson.ts | 22 ++--- 12 files changed, 274 insertions(+), 45 deletions(-) create mode 100644 src/pages/progress/index.vue diff --git a/components.d.ts b/components.d.ts index 610f047..b7d95e9 100644 --- a/components.d.ts +++ b/components.d.ts @@ -14,15 +14,21 @@ declare module 'vue' { WdCellGroup: typeof import('wot-design-uni/components/wd-cell-group/wd-cell-group.vue')['default'] WdCollapse: typeof import('wot-design-uni/components/wd-collapse/wd-collapse.vue')['default'] WdCollapseItem: typeof import('wot-design-uni/components/wd-collapse-item/wd-collapse-item.vue')['default'] + WdDivider: typeof import('wot-design-uni/components/wd-divider/wd-divider.vue')['default'] WdDropMenu: typeof import('wot-design-uni/components/wd-drop-menu/wd-drop-menu.vue')['default'] WdDropMenuItem: typeof import('wot-design-uni/components/wd-drop-menu-item/wd-drop-menu-item.vue')['default'] WdForm: typeof import('wot-design-uni/components/wd-form/wd-form.vue')['default'] WdIcon: typeof import('wot-design-uni/components/wd-icon/wd-icon.vue')['default'] WdInput: typeof import('wot-design-uni/components/wd-input/wd-input.vue')['default'] + WdMessageBox: typeof import('wot-design-uni/components/wd-message-box/wd-message-box.vue')['default'] + WdPicker: typeof import('wot-design-uni/components/wd-picker/wd-picker.vue')['default'] WdProgress: typeof import('wot-design-uni/components/wd-progress/wd-progress.vue')['default'] + WdRadio: typeof import('wot-design-uni/components/wd-radio/wd-radio.vue')['default'] + WdRadioGroup: typeof import('wot-design-uni/components/wd-radio-group/wd-radio-group.vue')['default'] WdStatusTip: typeof import('wot-design-uni/components/wd-status-tip/wd-status-tip.vue')['default'] WdStep: typeof import('wot-design-uni/components/wd-step/wd-step.vue')['default'] WdSteps: typeof import('wot-design-uni/components/wd-steps/wd-steps.vue')['default'] + WdSwitch: typeof import('wot-design-uni/components/wd-switch/wd-switch.vue')['default'] WdTabbar: typeof import('wot-design-uni/components/wd-tabbar/wd-tabbar.vue')['default'] WdTabbarItem: typeof import('wot-design-uni/components/wd-tabbar-item/wd-tabbar-item.vue')['default'] WdToast: typeof import('wot-design-uni/components/wd-toast/wd-toast.vue')['default'] diff --git a/src/App.vue b/src/App.vue index 3505683..ed7aab5 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,18 +1,34 @@ diff --git a/src/api/BussApi.ts b/src/api/BussApi.ts index fa391e6..160b936 100644 --- a/src/api/BussApi.ts +++ b/src/api/BussApi.ts @@ -29,20 +29,24 @@ export default class BussApi { .then((res) => res.data); } - static lessons( - page: number = 1, - limit: number = 20 - ): Promise> { + static lessons(page: number = 1, limit: number = 20) { const user = useUser(); return http .server() - .get("/lesson/task", { + .get>("/lesson/task", { headers: { Authorization: `Bearer ${user.token}`, }, params: { page, limit }, }) - .then((res) => res.data); + .then((res) => { + if (user.hasJobTag("A")) { + res.data.data = res.data.data.filter( + (lesson) => lesson.user_id === user.userinfo?.id + ); + } + return res.data; + }); } static course(id: number): Promise { @@ -56,4 +60,16 @@ export default class BussApi { }) .then((res) => res.data); } + + static editCourse(id: number, params: Partial): Promise { + const user = useUser(); + return http + .server() + .put(`/lesson/task/${id}`, params, { + headers: { + Authorization: `Bearer ${user.token}`, + }, + }) + .then((res) => res.data); + } } diff --git a/src/components/page-wrapper.vue b/src/components/page-wrapper.vue index de93847..7d9d5e1 100644 --- a/src/components/page-wrapper.vue +++ b/src/components/page-wrapper.vue @@ -1,20 +1,12 @@ diff --git a/src/pages.json b/src/pages.json index b483a98..18da6fe 100644 --- a/src/pages.json +++ b/src/pages.json @@ -7,6 +7,13 @@ "navigationBarTitleText": "进度查看" } }, + { + "name": "progress", + "path": "pages/progress/index", + "style": { + "navigationBarTitleText": "工作进度管理" + } + }, { "name": "my", "path": "pages/my/index", @@ -25,7 +32,7 @@ "name": "lesson", "path": "pages/lesson/index", "style": { - "navigationBarTitleText": "课程进度" + "navigationBarTitleText": "微课进度" } } ], @@ -39,6 +46,10 @@ "pagePath": "pages/index/index", "text": "进度查看" }, + { + "pagePath": "pages/progress/index", + "text": "进度管理" + }, { "pagePath": "pages/my/index", "text": "我的" diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 1999e30..77e17cd 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -1,8 +1,10 @@ + + + + diff --git a/src/stores/useUser.ts b/src/stores/useUser.ts index a4ff2fa..cf5e55f 100644 --- a/src/stores/useUser.ts +++ b/src/stores/useUser.ts @@ -6,14 +6,25 @@ export const useUser = defineStore("user", () => { const token = ref(null); const userinfo = ref(null); + /** + * 判断是否有权限 + * @param tag A: 课程制作教师(3) B: 课程制作方沟通联络人(2) C: 课程购买方项目负责人(1) D: 系统制作方项目负责人(4) + * @returns 是否有权限 + */ + function hasJobTag(tag: "A" | "B" | "C" | "D") { + if (!userinfo.value) return false; + return userinfo.value?.jobs.some((job) => job.description === tag) || false; + } + function logout() { - token.value = null - userinfo.value = null + token.value = null; + userinfo.value = null; } return { token, userinfo, + hasJobTag, logout, }; }); diff --git a/src/types/api/lesson.ts b/src/types/api/lesson.ts index 5adc390..b061088 100644 --- a/src/types/api/lesson.ts +++ b/src/types/api/lesson.ts @@ -2,16 +2,18 @@ export interface Lesson { id: number; course_name: string; m_lesson_name: string; - user_id: number | null; + user_id: number; schedule_status: number; - script_confirm_time: number; - video_confirm_time: number; - finish_time: number; script_upload_time: number; + script_confirm_time: number; video_capture_time: number; - script_file: null; + video_confirm_time: number; + script_file: ScriptFileDestination; + finish_time: number; material_file: null; capture_file: null; advise: null; created_at: string; } + +export type ScriptFileDestination = "qq" | "wechat" | "platform"; diff --git a/src/types/api/user.ts b/src/types/api/user.ts index 54b82ff..d0adebd 100644 --- a/src/types/api/user.ts +++ b/src/types/api/user.ts @@ -77,3 +77,16 @@ export interface RolePivot { user_id: number; role_id: number; } + +export enum Roles { + Teacher = 1, + GeneralAdmin, + Contactor, +} + +export enum Jobs { + BuyerManager = 1, + MakerContactor, + MakerTeacher, + SystemManager, +} diff --git a/src/utils/lesson.ts b/src/utils/lesson.ts index 8982441..a463b3b 100644 --- a/src/utils/lesson.ts +++ b/src/utils/lesson.ts @@ -18,33 +18,33 @@ export const calcLessonProgress = (lesson: Lesson, total: number = 4) => { return Math.floor((progress.step / total) * 100); }; -export const getLessonSteps = (lesson: Lesson) => { +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, + title: progress.script_upload ? "脚本提交" : undefined, description: progress.script_upload - ? `已于 ${dayjs(lesson.script_upload_time * 1000).format(dateFormat)} 完成上传` - : "脚本文件上传", + ? (simplify ? '已完成' : `已于 ${dayjs(lesson.script_upload_time * 1000).format(dateFormat)} 完成上传`) + : "脚本文件提交", }, { - title: progress.script_confirm ? "脚本文件确认" : undefined, + title: progress.script_confirm ? "脚本确认" : undefined, description: progress.script_confirm - ? `已于 ${dayjs(lesson.script_confirm_time * 1000).format(dateFormat)} 确认` + ? (simplify ? '已完成' : `已于 ${dayjs(lesson.script_confirm_time * 1000).format(dateFormat)} 确认`) : "脚本文件确认", }, { - title: progress.video_capture ? "视频拍摄和上传" : undefined, + title: progress.video_capture ? "视频拍摄" : undefined, description: progress.video_capture - ? `已于 ${dayjs(lesson.video_capture_time * 1000).format(dateFormat)} 完成上传` - : "视频拍摄上传", + ? (simplify ? '已完成' : `已于 ${dayjs(lesson.video_capture_time * 1000).format(dateFormat)} 完成上传`) + : "视频拍摄提交", }, { - title: progress.post_production ? "视频后期制作" : undefined, + title: progress.post_production ? "后期制作" : undefined, description: progress.post_production - ? `已于 ${dayjs(lesson.video_confirm_time * 1000).format(dateFormat)} 完成上传` + ? (simplify ? '已完成' : `已于 ${dayjs(lesson.video_confirm_time * 1000).format(dateFormat)} 完成上传`) : "视频后期制作", }, ];