Przeglądaj źródła

过滤 channel type

visuddhinanda 2 lat temu
rodzic
commit
9466282e1d

+ 9 - 2
dashboard/src/components/channel/ChannelTable.tsx

@@ -68,12 +68,14 @@ interface IWidget {
   studioName?: string;
   type?: string;
   disableChannels?: string[];
+  channelType?: TChannelType;
   onSelect?: Function;
 }
 
 const ChannelTableWidget = ({
   studioName,
   disableChannels,
+  channelType,
   type,
   onSelect,
 }: IWidget) => {
@@ -410,12 +412,17 @@ const ChannelTableWidget = ({
         }}
         */
         request={async (params = {}, sorter, filter) => {
-          // TODO 分页
           console.log(params, sorter, filter);
           let url = `/v2/channel?view=studio&view2=${activeKey}&name=${studioName}`;
+          const offset =
+            ((params.current ? params.current : 1) - 1) *
+            (params.pageSize ? params.pageSize : 20);
+          url += `&limit=${params.pageSize}&offset=${offset}`;
+
           url += collaborator ? "&collaborator=" + collaborator : "";
           url += params.keyword ? "&search=" + params.keyword : "";
-
+          url += channelType ? "&type=" + channelType : "";
+          //url += getSorterUrl(sorter);
           console.log("url", url);
           const res: IApiResponseChannelList = await get(url);
           const items: IChannelItem[] = res.data.rows.map((item, id) => {

+ 4 - 0
dashboard/src/components/channel/ChannelTableModal.tsx

@@ -6,9 +6,11 @@ import ChannelTable from "./ChannelTable";
 import { useAppSelector } from "../../hooks";
 import { currentUser as _currentUser } from "../../reducers/current-user";
 import { IChannel } from "./Channel";
+import { TChannelType } from "../api/Channel";
 
 interface IWidget {
   trigger?: React.ReactNode;
+  channelType?: TChannelType;
   type?: ArticleType | "editable";
   articleId?: string;
   multiSelect?: boolean;
@@ -23,6 +25,7 @@ const ChannelTableModalWidget = ({
   articleId,
   multiSelect = true,
   disableChannels,
+  channelType,
   open = false,
   onClose,
   onSelect,
@@ -65,6 +68,7 @@ const ChannelTableModalWidget = ({
         <ChannelTable
           studioName={user?.realName}
           type={type}
+          channelType={channelType}
           disableChannels={disableChannels}
           onSelect={(channel: IChannel) => {
             handleCancel();

+ 8 - 1
dashboard/src/components/template/SentEdit/SentAdd.tsx

@@ -4,17 +4,24 @@ import { PlusOutlined } from "@ant-design/icons";
 
 import { IChannel } from "../../channel/Channel";
 import ChannelTableModal from "../../channel/ChannelTableModal";
+import { TChannelType } from "../../api/Channel";
 
 interface IWidget {
   disableChannels?: string[];
+  type?: TChannelType;
   onSelect?: Function;
 }
-const Widget = ({ disableChannels, onSelect }: IWidget) => {
+const Widget = ({
+  disableChannels,
+  type = "translation",
+  onSelect,
+}: IWidget) => {
   const [channelPickerOpen, setChannelPickerOpen] = useState(false);
 
   return (
     <ChannelTableModal
       disableChannels={disableChannels}
+      channelType={type}
       trigger={
         <Button
           type="dashed"

+ 1 - 0
dashboard/src/components/template/SentEdit/SentCanRead.tsx

@@ -103,6 +103,7 @@ const SentCanReadWidget = ({
       </div>
       <SentAdd
         disableChannels={channels}
+        type={type}
         onSelect={(channel: IChannel) => {
           if (typeof user === "undefined") {
             return;