Bladeren bron

支持 progress

visuddhinanda 11 maanden geleden
bovenliggende
commit
99dccb6dc4

+ 1 - 0
dashboard-v4/dashboard/src/components/api/Channel.ts

@@ -33,6 +33,7 @@ export interface IApiResponseChannelData {
   lang: string;
   status: number;
   is_system: boolean;
+  progress?: number;
   created_at: string;
   updated_at: string;
   role?: TRole;

+ 27 - 4
dashboard-v4/dashboard/src/components/channel/ChannelTable.tsx

@@ -1,7 +1,7 @@
 import { ActionType, ProTable } from "@ant-design/pro-components";
 import { FormattedMessage, useIntl } from "react-intl";
 import { Link } from "react-router-dom";
-import { Alert, Badge, message, Modal, Typography } from "antd";
+import { Alert, Badge, message, Modal, Progress, Typography } from "antd";
 import { Button, Dropdown, Popover } from "antd";
 import {
   PlusOutlined,
@@ -77,7 +77,7 @@ export const renderBadge = (count: number, active = false) => {
   );
 };
 
-interface IChapter {
+export interface IChapter {
   book: number;
   paragraph: number;
 }
@@ -91,6 +91,7 @@ interface IChannelItem {
   role?: TRole;
   studio?: IStudio;
   publicity: number;
+  progress?: number;
   created_at: string;
 }
 
@@ -243,6 +244,22 @@ const ChannelTableWidget = ({
               );
             },
           },
+          {
+            title: intl.formatMessage({
+              id: "dict.fields.createdAt.label",
+            }),
+            key: "progress",
+            hideInTable: typeof chapter === "undefined",
+            render(dom, entity, index, action, schema) {
+              return (
+                <Progress
+                  size="small"
+                  percent={Math.floor((entity.progress ?? 0) * 100)}
+                  style={{ width: 150 }}
+                />
+              );
+            },
+          },
           {
             title: intl.formatMessage({
               id: "forms.fields.summary.label",
@@ -404,7 +421,7 @@ const ChannelTableWidget = ({
             url += `view=studio&view2=${activeKey}&name=${studioName}`;
           }
           if (chapter) {
-            url += `&chapter=${chapter.book}-${chapter.paragraph}`;
+            url += `&book=${chapter.book}&paragraph=${chapter.paragraph}`;
           }
           const offset =
             ((params.current ? params.current : 1) - 1) *
@@ -414,7 +431,12 @@ const ChannelTableWidget = ({
           url += collaborator ? "&collaborator=" + collaborator : "";
           url += params.keyword ? "&search=" + params.keyword : "";
           url += channelType ? "&type=" + channelType : "";
-          url += getSorterUrl(sorter);
+          if (chapter && activeKey === "community") {
+            url += "&order=progress";
+          } else {
+            url += getSorterUrl(sorter);
+          }
+
           console.log("url", url);
           const res: IApiResponseChannelList = await get(url);
           const items: IChannelItem[] = res.data.rows.map((item, id) => {
@@ -425,6 +447,7 @@ const ChannelTableWidget = ({
               summary: item.summary,
               type: item.type,
               role: item.role,
+              progress: item.progress,
               studio: item.studio,
               publicity: item.status,
               created_at: item.created_at,

+ 5 - 1
dashboard-v4/dashboard/src/components/channel/ChannelTableModal.tsx

@@ -2,7 +2,7 @@ import React, { useEffect, useState } from "react";
 import { Modal } from "antd";
 
 import { ArticleType } from "../article/Article";
-import ChannelTable from "./ChannelTable";
+import ChannelTable, { IChapter } from "./ChannelTable";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { IChannel } from "./Channel";
@@ -17,6 +17,7 @@ interface IWidget {
   multiSelect?: boolean;
   disableChannels?: string[];
   open?: boolean;
+  chapter?: IChapter;
   onClose?: Function;
   onSelect?: Function;
 }
@@ -28,6 +29,7 @@ const ChannelTableModalWidget = ({
   disableChannels,
   channelType,
   open = false,
+  chapter,
   onClose,
   onSelect,
 }: IWidget) => {
@@ -64,6 +66,7 @@ const ChannelTableModalWidget = ({
         title={intl.formatMessage({
           id: "buttons.select.channel",
         })}
+        destroyOnClose
         footer={false}
         open={isModalOpen}
         onOk={handleOk}
@@ -73,6 +76,7 @@ const ChannelTableModalWidget = ({
           <ChannelTable
             studioName={user?.realName}
             type={type}
+            chapter={chapter}
             channelType={channelType}
             disableChannels={disableChannels}
             onSelect={(channel: IChannel) => {