shenwu 5 月之前
父节点
当前提交
b5969f8148

+ 34 - 0
src/components/MyProTable/index.tsx

@@ -0,0 +1,34 @@
+import 'antd/lib/table/style';
+import 'antd/lib/typography/style';
+import type { ParamsType } from '@ant-design/pro-provider';
+import Summary from 'rc-table/lib/Footer/Summary';
+import React, { useMemo, useState } from 'react';
+import { ProTable, ProTableProps } from '@ant-design/pro-components';
+
+/**
+ * 
+ *ProTable组件外封装了一层传参和ProTable一样,只是可以自己附加一些操作,全局管理一些参数比如table的尺寸
+ * @param props - Table properties
+ */
+const MyProTable = <DataType extends Record<string, any>, Params extends ParamsType = ParamsType, ValueType = "text">(
+    props: ProTableProps<DataType, Params, ValueType>
+): JSX.Element => {
+    const [size,setSize]=useState<"small" | "large" | "middle">(localStorage.getItem("tableSize") as ("small" | "large" | "middle")  || "small")
+    // 尺寸改变设置到本地,全局变动
+    function sizeChangge(size: any) {
+        localStorage.setItem("tableSize", size)
+        setSize(size)
+    }
+    // 组件主体逻辑可以在此编写
+    console.log(size)
+    return <ProTable
+        size={size}//全局默认尺寸假如外面传入会覆盖
+        {...props}
+        onSizeChange={sizeChangge}
+    />
+};
+
+// 将 Summary 属性添加到 CustomTableContainer 上
+MyProTable.Summary = Summary;
+
+export default MyProTable;

+ 2 - 2
src/pages/book/bookManage/author/index.tsx

@@ -11,12 +11,12 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { Button, message } from 'antd';
 import { useRef, useState } from 'react';
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -75,7 +75,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'作者列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/book/bookManage/bookTags/index.tsx

@@ -13,13 +13,13 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message } from 'antd';
 import { useRef, useState } from 'react';
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -114,7 +114,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'标签列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/book/bookManage/classifyList/index.tsx

@@ -12,13 +12,13 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message } from 'antd';
 import { useRef, useState } from 'react';
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -95,7 +95,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'分类列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/book/bookManage/longbookList/index.tsx

@@ -16,7 +16,6 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, Drawer, message, Popconfirm, Space } from 'antd';
@@ -24,6 +23,7 @@ import { useEffect, useRef, useState } from 'react';
 import formConfig from './formConfig';
 import Item from './item';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 const wordCountRanges: any = {
   '': { start: null, end: null }, // 全部
   '0-2': { start: 0, end: 2 * 10000 },
@@ -132,7 +132,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer title={false} tabProps={{ type: 'card' }}>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         // 实例
         actionRef={actionRef}
         // 标题

+ 2 - 2
src/pages/distribution/book/longBook/index.tsx

@@ -11,7 +11,6 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message, Popconfirm, Space, Tag } from 'antd';
@@ -19,6 +18,7 @@ import { useEffect, useRef, useState } from 'react';
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
 import { removeBook } from '@/services/distribution/weChatInfo';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -107,7 +107,7 @@ const Page: React.FC<Porps> = (props) => {
       header={wechatAppId ? { title: "", breadcrumb: {} } : {}}
       childrenContentStyle={wechatAppId ? { paddingBlockStart: 0 } : {}}
     >
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={wechatAppId ? "长篇小说列表" : '长篇小说配置信息列表'}
         actionRef={actionRef}
         rowKey={(r) => r.bookId}

+ 2 - 2
src/pages/distribution/book/shortBook/index.tsx

@@ -11,7 +11,6 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message, Popconfirm, Space, Tag } from 'antd';
@@ -19,6 +18,7 @@ import { useEffect, useRef, useState } from 'react';
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
 import { apiWxAppInfoList, removeBook } from '@/services/distribution/weChatInfo';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -109,7 +109,7 @@ const Page: React.FC<Porps> = (props) => {
       header={wechatAppId ? { title: "", breadcrumb: {} } : {}}
       childrenContentStyle={wechatAppId ? { paddingBlockStart: 0 } : {}}
     >
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={wechatAppId ? "短篇小说列表" : '短篇小说配置信息列表'}
         actionRef={actionRef}
         rowKey={(r) => r.bookId}

+ 2 - 2
src/pages/distribution/distributor/info/index.tsx

@@ -11,7 +11,6 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message } from 'antd';
@@ -19,6 +18,7 @@ import { useEffect, useRef, useState } from 'react';
 import { formConfig } from './formConfig';
 import Item from './item';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 type DataItem = {
   name: string;
   state: string;
@@ -86,7 +86,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer title={false} tabProps={{ type: 'card' }}>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         // 实例
         actionRef={actionRef}
         // 标题

+ 2 - 2
src/pages/distribution/miniprogram/mimiModule/index.tsx

@@ -3,7 +3,6 @@ import {
   ActionType,
   BetaSchemaForm,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, message } from 'antd';
@@ -11,6 +10,7 @@ import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 're
 import formConfig from './formConfig';
 import { columns } from './tableConfig';
 import { apiMiniappComponentInfoDel, apiMiniappComponentInfoPageList, apiMiniappComponentInfoSave, apiMiniappComponentInfoUpdate, apiMiniappComponentInfoUpdateEnabled } from '@/services/distribution/miniprogram';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -91,7 +91,7 @@ const Page = forwardRef((props: any, ref?: any) =>{
   console.log("open",open)
   return (
     <div >
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={false}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/distribution/miniprogram/pagesManage/index.tsx

@@ -4,7 +4,6 @@ import {
   ActionType,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { Button, message, Modal, Table } from 'antd';
 import { useRef, useState } from 'react';
@@ -12,6 +11,7 @@ import { childrenColumns, columns } from './tableConfig';
 import { appPageList, configAppPages } from '@/services/distribution/pagesManage';
 import FormComp from './formComp';
 import MimiModule from '../mimiModule'
+import MyProTable from '@/components/MyProTable';
 
 const Page: React.FC = () => {
   const formRef = useRef<ProFormInstance>();
@@ -61,7 +61,7 @@ const Page: React.FC = () => {
   }
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'页面模板列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/distribution/miniprogram/weChatInfo/index.tsx

@@ -15,7 +15,6 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { useModel } from '@umijs/max';
 import { Button, Drawer, message } from 'antd';
@@ -25,6 +24,7 @@ import { columns } from './tableConfig';
 import { appPageList } from '@/services/distribution/pagesManage';
 import LongBook from '@/pages/distribution/book/longBook'
 import ShortBook from '@/pages/distribution/book/shortBook'
+import MyProTable from '@/components/MyProTable';
 type DataItem = {
   name: string;
   state: string;
@@ -125,7 +125,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'小程序列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 3 - 2
src/pages/distribution/miniprogram/weChatInfo/user/bookList/index.tsx

@@ -1,9 +1,10 @@
-import { ActionType, ProTable } from "@ant-design/pro-components"
+import { ActionType } from "@ant-design/pro-components"
 import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
 import {  useRef, useState } from "react"
 import { Button, Drawer, Modal } from "antd"
 import { shelfLisOfPage } from "@/services/distribution/MiniAppUser"
+import MyProTable from "@/components/MyProTable"
 type Props={
     data: {
         appId: number
@@ -28,7 +29,7 @@ const Page: React.FC<Props> = (props) => {
             width={"50%"}
             destroyOnClose
         >
-            <ProTable<any, any>
+            <MyProTable<any, any>
                 actionRef={actionRef}
                 scroll={{ x: true ,y:'50vh'}}
                 headerTitle={false}

+ 3 - 2
src/pages/distribution/miniprogram/weChatInfo/user/index.tsx

@@ -1,10 +1,11 @@
-import { ActionType, ProTable } from "@ant-design/pro-components"
+import { ActionType} from "@ant-design/pro-components"
 import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
 import { useModel } from "@umijs/max"
 import { useCallback, useRef, useState } from "react"
 import { Button, Drawer, message, Modal } from "antd"
 import { miniAppusers, updateEnabled } from "@/services/distribution/MiniAppUser"
+import MyProTable from "@/components/MyProTable"
 type Props={
     data:{
         wechatAppId:string
@@ -43,7 +44,7 @@ const Page: React.FC<Props> = (props) => {
             width={"85%"}
             destroyOnClose
         >
-            <ProTable<any, any>
+            <MyProTable<any, any>
                 actionRef={actionRef}
                 scroll={{ x: true }}
                 headerTitle={"微信小程序用户列表"}

+ 3 - 2
src/pages/distribution/miniprogram/weChatInfo/user/loginList/index.tsx

@@ -1,9 +1,10 @@
-import { ActionType, ProTable } from "@ant-design/pro-components"
+import { ActionType } from "@ant-design/pro-components"
 import { columns } from "./tableConfig"
 import { useAjax } from "@/Hook/useAjax"
 import { useRef, useState } from "react"
 import { Button, Modal } from "antd"
 import { loginListOfPage } from "@/services/distribution/MiniAppUser"
+import MyProTable from "@/components/MyProTable"
 type Props = {
     data: {
         appId: number
@@ -28,7 +29,7 @@ const Page: React.FC<Props> = (props) => {
             width={"50%"}
             destroyOnClose
         >
-            <ProTable<any, any>
+            <MyProTable<any, any>
                  actionRef={actionRef}
                  scroll={{ x: true ,y:'50vh'}}
                  headerTitle={false}

+ 3 - 2
src/pages/distribution/orderLog/short/index.tsx

@@ -1,8 +1,9 @@
 import { useAjax } from '@/Hook/useAjax';
 import { apiShortBookOrderListOfPage } from '@/services/distribution/orderLog';
-import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
+import { ActionType, PageContainer } from '@ant-design/pro-components';
 import { useRef } from 'react';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -16,7 +17,7 @@ const Page: React.FC = () => {
 
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'短篇小说订单记录列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 3 - 2
src/pages/distribution/payLog/long/index.tsx

@@ -1,8 +1,9 @@
 import { useAjax } from '@/Hook/useAjax';
 import { apiLongBookCoinChangeLogOfPage } from '@/services/distribution/payLog';
-import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
+import { ActionType, PageContainer } from '@ant-design/pro-components';
 import { useRef } from 'react';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -16,7 +17,7 @@ const Page: React.FC = () => {
 
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'长篇小说书币变更列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 3 - 2
src/pages/distribution/payLog/short/index.tsx

@@ -1,8 +1,9 @@
 import { useAjax } from '@/Hook/useAjax';
 import { apiShortBookCoinChangeLogOfPage } from '@/services/distribution/payLog';
-import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
+import { ActionType, PageContainer } from '@ant-design/pro-components';
 import { useRef } from 'react';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -16,7 +17,7 @@ const Page: React.FC = () => {
 
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'短篇小说书币变更列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 3 - 2
src/pages/distribution/readLog/short/index.tsx

@@ -1,8 +1,9 @@
 import { useAjax } from '@/Hook/useAjax';
 import { apiShortBookReadLogListOfPage } from '@/services/distribution/readLog';
-import { ActionType, PageContainer, ProTable } from '@ant-design/pro-components';
+import { ActionType, PageContainer } from '@ant-design/pro-components';
 import { useRef } from 'react';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 const Page: React.FC = () => {
   const actionRef = useRef<ActionType>();
@@ -12,7 +13,7 @@ const Page: React.FC = () => {
 
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'短篇小说阅读记录列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}

+ 2 - 2
src/pages/distribution/system/index.tsx

@@ -5,11 +5,11 @@ import {
   BetaSchemaForm,
   PageContainer,
   ProFormInstance,
-  ProTable,
 } from '@ant-design/pro-components';
 import { message } from 'antd';
 import { useRef, useState } from 'react';
 import { columns } from './tableConfig';
+import MyProTable from '@/components/MyProTable';
 
 type DataItem = {
   name: string;
@@ -56,7 +56,7 @@ const Page: React.FC = () => {
   };
   return (
     <PageContainer>
-      <ProTable<any, any>
+      <MyProTable<any, any>
         headerTitle={'作者列表'}
         actionRef={actionRef}
         rowKey={(r) => r.id}