Browse Source

Merge pull request #2080 from visuddhinanda/agile

支持显示全部参课记录
visuddhinanda 1 year ago
parent
commit
f81843e95b

+ 1 - 0
dashboard/src/components/api/Course.ts

@@ -165,6 +165,7 @@ export interface ICourseMemberData {
   id?: string;
   user_id: string;
   course_id: string;
+  course?: ICourseDataResponse;
   channel_id?: string;
   channel?: IChannel;
   role?: TCourseRole;

+ 33 - 10
dashboard/src/components/course/CourseMemberTimeLine.tsx

@@ -1,6 +1,6 @@
 import { useEffect, useRef } from "react";
 import { useIntl } from "react-intl";
-import { Space, Tag } from "antd";
+import { Space, Tag, Typography } from "antd";
 import { ActionType, ProList } from "@ant-design/pro-components";
 
 import { get } from "../../request";
@@ -9,6 +9,11 @@ import User from "../auth/User";
 import TimeShow from "../general/TimeShow";
 import { getStatusColor } from "./RolePower";
 
+const { Text } = Typography;
+
+interface IParams {
+  timeline?: string;
+}
 interface IWidget {
   courseId?: string;
   userId?: string;
@@ -25,25 +30,29 @@ const CourseMemberTimeLineWidget = ({ courseId, userId }: IWidget) => {
 
   return (
     <>
-      <ProList<ICourseMemberData>
+      <ProList<ICourseMemberData, IParams>
         actionRef={ref}
         search={{
           filterType: "light",
         }}
         metas={{
-          title: {
-            dataIndex: "name",
-            search: false,
-            render(dom, entity, index, action, schema) {
-              return entity.user?.nickName;
-            },
-          },
           avatar: {
             render(dom, entity, index, action, schema) {
               return <User {...entity.user} showName={false} />;
             },
             editable: false,
           },
+          title: {
+            dataIndex: "name",
+            search: false,
+            render(dom, entity, index, action, schema) {
+              return entity.course ? (
+                <Text strong>{entity.course.title}</Text>
+              ) : (
+                entity.user?.nickName
+              );
+            },
+          },
           description: {
             dataIndex: "desc",
             search: false,
@@ -85,9 +94,20 @@ const CourseMemberTimeLineWidget = ({ courseId, userId }: IWidget) => {
               ];
             },
           },
+          timeline: {
+            // 自己扩展的字段,主要用于筛选,不在列表中显示
+            title: "筛 选",
+            valueType: "select",
+            valueEnum: {
+              all: { text: intl.formatMessage({ id: "course.timeline.all" }) },
+              current: {
+                text: intl.formatMessage({ id: "course.timeline.current" }),
+              },
+            },
+          },
         }}
         request={async (params = {}, sorter, filter) => {
-          console.log(params, sorter, filter);
+          console.info("filter", params, sorter, filter);
 
           let url = `/v2/course-member?view=timeline&course=${courseId}&userId=${userId}`;
           const offset =
@@ -97,6 +117,9 @@ const CourseMemberTimeLineWidget = ({ courseId, userId }: IWidget) => {
           if (typeof params.keyword !== "undefined") {
             url += "&search=" + (params.keyword ? params.keyword : "");
           }
+          if (params.timeline) {
+            url += `&timeline=${params.timeline}&request_course=1`;
+          }
           console.info("api request", url);
           const res = await get<ICourseMemberListResponse>(url);
           if (res.ok) {

+ 1 - 1
dashboard/src/components/notification/NotificationIcon.tsx

@@ -40,7 +40,7 @@ const NotificationIconWidget = () => {
     }
 
     const url = `/v2/notification?view=to&limit=1`;
-    console.info("notification url", url);
+    console.info("notification api request", url);
     get<INotificationListResponse>(url).then((json) => {
       if (json.ok) {
         console.debug("notification fetch ok ", json.data.unread);

+ 5 - 1
dashboard/src/components/notification/NotificationList.tsx

@@ -51,9 +51,11 @@ const NotificationListWidget = ({ onChange }: IWidget) => {
   }, []);
   const putStatus = (id: string, status: string) => {
     const url = `/v2/notification/${id}`;
+    console.info("api request", url);
     put<INotificationRequest, INotificationPutResponse>(url, {
       status: status,
     }).then((json) => {
+      console.info("api response", json);
       if (json.ok) {
         ref.current?.reload();
         if (typeof onChange !== "undefined") {
@@ -118,7 +120,9 @@ const NotificationListWidget = ({ onChange }: IWidget) => {
           ((params.current ? params.current : 1) - 1) *
           (params.pageSize ? params.pageSize : 5);
         url += `&limit=${params.pageSize}&offset=${offset}`;
+        console.info("api request", url);
         const res = await get<INotificationListResponse>(url);
+        console.info("api response", res);
         let items: INotification[] = [];
         if (res.ok) {
           items = res.data.rows.map((item, id) => {
@@ -204,7 +208,7 @@ const NotificationListWidget = ({ onChange }: IWidget) => {
             return (
               <Space>
                 <TimeShow createdAt={row.created_at} />
-                <Tag color="#87d068">{row.channel.name}</Tag>
+                <Tag color="#87d068">{row.channel?.name}</Tag>
                 <Tag color="blue">{row.res_type}</Tag>
               </Space>
             );

+ 2 - 0
dashboard/src/locales/en-US/course/index.ts

@@ -60,6 +60,8 @@ const items = {
     "课程组织者需要查看您在课程期间的每日学习时长。报名意味着您同意。",
   "course.table.count.member.title": "成员数",
   "course.table.count.progressing.title": "待审核",
+  "course.timeline.all": "全部参课记录",
+  "course.timeline.current": "当前课程",
 };
 
 export default items;

+ 2 - 0
dashboard/src/locales/zh-Hans/course/index.ts

@@ -60,6 +60,8 @@ const items = {
     "课程组织者需要查看您在课程期间的每日学习时长。报名意味着您同意。",
   "course.table.count.member.title": "成员数",
   "course.table.count.progressing.title": "待审核",
+  "course.timeline.all": "全部参课记录",
+  "course.timeline.current": "当前课程",
 };
 
 export default items;

+ 1 - 1
dashboard/src/pages/studio/course/edit.tsx

@@ -56,7 +56,7 @@ const Widget = () => {
                       items={[
                         {
                           key: "timeline",
-                          label: "timeline",
+                          label: "录取记录",
                           children:
                             courseId && selected ? (
                               <CourseMemberTimeLine