wjx 1 tahun lalu
induk
melakukan
023d24ce79

+ 21 - 18
src/pages/gameDataStatistics/components/TablePro/index.tsx

@@ -41,7 +41,7 @@ const TablePro: React.FC<PROAPI.TableProProps> = ({
 }) => {
 
     /*********************************************/
-    const [lsDataSource, setLsDataSource] = useLocalStorageState(`myAdMonitorConfig${version}_` + configName);
+    const [lsDataSource, setLsDataSource] = useLocalStorageState<PROAPI.ColumnsTypePro<any>>(`myAdMonitorConfig${version}_` + configName);
     const [lsFixed] = useLocalStorageState<{ left: number, right: number }>(`myAdMonitorConfigFixed${version}_` + configName);
     const [state, setState] = useSetState<PROAPI.State>({
         // 所有配置用key转Object
@@ -69,29 +69,29 @@ const TablePro: React.FC<PROAPI.TableProProps> = ({
      */
     const handleConfig = () => {
         // log(config)
-        let newColumns: any[] = []
-        let newConfigObj: { [key: string]: any; } = {}
+        let newColumns: PROAPI.ColumnsTypePro<any> = []
+        let newConfigObj: { [key: string]: PROAPI.ColumnTypePro<any>; } = {}
         config?.forEach((item: { data: { default: any; dataIndex: string }[] }) => {
             item?.data?.forEach((d: { default: any, dataIndex: string }) => {
-                newConfigObj[d.dataIndex] = d
+                newConfigObj[d.dataIndex] = { ...d }
                 if (d.default) {
                     newColumns[d.default - 1] = d
                 }
             })
         })
-        setState({ defaultColumns: newColumns, configObj: JSON.parse(JSON.stringify(newConfigObj)) })
+        setState({ defaultColumns: newColumns, configObj: newConfigObj })
         handleColumns(newColumns, newConfigObj, lsDataSource, lsFixed)
     }
 
     // 处理columns
-    const handleColumns = (defaultColumns: any[], configObj: { [key: string]: string; }, lsDataSource?: any, lsFixed?: { left: number, right: number }) => {
-        log(defaultColumns, 'defaultColumns')
-        log(configObj, 'configObj')
-        log(lsDataSource, 'lsDataSource')
+    const handleColumns = (defaultColumns: PROAPI.ColumnsTypePro<any>, configObj: { [key: string]: PROAPI.ColumnTypePro<any>; }, lsDataSource?: PROAPI.ColumnsTypePro<any>, lsFixed?: { left: number, right: number }) => {
+        // log(defaultColumns, 'defaultColumns')
+        // log(configObj, 'configObj')
+        // log(lsDataSource, 'lsDataSource')
 
         // 使用默认配置
-        let newColumns = defaultColumns
-        let newFixed = fixed
+        let newColumns: PROAPI.ColumnsTypePro<any> = defaultColumns
+        let newFixed: { left: number, right: number } = fixed
         if (lsFixed) {
             newFixed = lsFixed
         }
@@ -99,12 +99,12 @@ const TablePro: React.FC<PROAPI.TableProProps> = ({
             newColumns = lsDataSource
                 .filter((item: { dataIndex: string | number; }) => !!item && configObj[item.dataIndex])
                 .map((item: { dataIndex: string | number; width: number }) => {
-                    let column = configObj[item.dataIndex]
+                    let column = { ...configObj[item.dataIndex] }
                     column['width'] = item.width
                     return column
                 })
         }
-        log(newFixed, 'newFixed')
+        // log(newFixed, 'newFixed')
         newColumns = newColumns.map(item => {
             if (item?.tips && typeof item.title === 'string') {
                 let column: any = configObj[item.dataIndex]
@@ -126,7 +126,7 @@ const TablePro: React.FC<PROAPI.TableProProps> = ({
                 newColumns[i] = { ...newColumns[i], fixed: 'right' };
             }
         }
-        log(newColumns, 'newColumns')
+        // log(newColumns, 'newColumns')
         setState({ columns: newColumns })
     }
 
@@ -158,16 +158,19 @@ const TablePro: React.FC<PROAPI.TableProProps> = ({
 
     const { run: runResize } = useDebounceFn((columns) => {
         if (configName) {
-            let newSelectData = state.columns?.map((item, index) => {
-                item['width'] = columns[index]['width']
-                return item
+            let newSelectData: PROAPI.ColumnsTypePro<any> = []
+            state.columns?.forEach((item, index) => {
+                newSelectData.push({ ...JSON.parse(JSON.stringify(state.configObj[item.dataIndex])), width: columns[index]['width'] })
             })
             setLsDataSource(newSelectData)
+            if (isZj) { // 有总计需要刷新内容表格
+                handleColumns(state.defaultColumns, state.configObj, newSelectData, lsFixed)
+            }
         }
     }, { wait: 200 });
 
     //拖动宽度设置设置保存
-    const handelResize = useCallback((columns: any) => {
+    const handelResize = useCallback((columns: PROAPI.ColumnTypePro<any>) => {
         runResize(columns)
     }, [configName, state.columns])
 

+ 4 - 2
src/pages/gameDataStatistics/components/TablePro/typings.d.ts

@@ -1,5 +1,7 @@
 declare namespace PROAPI {
-    type TableProProps = TableProps<any> & {
+    type ColumnTypePro<RecordType = unknown> = (ColumnGroupType<RecordType> | ColumnType<RecordType>) & { label: string };
+    type ColumnsTypePro<RecordType = unknown> = ColumnTypePro[];
+    type TableProProps<RecordType = unknown> = TableProps<RecordType> & {
         configName: string;
         config: any;
         fixed?: {
@@ -28,7 +30,7 @@ declare namespace PROAPI {
     };
     type State = {
         columns: any[];
-        configObj: { [key: string]: string; };
+        configObj: { [key: string]: ColumnTypePro<any>; };
         defaultColumns: any[];
     };
     type HeaderContentProps = {

+ 56 - 6
src/pages/gameDataStatistics/gameServer/serverGsData/index.tsx

@@ -6,6 +6,7 @@ import columns12 from "./tableConfig"
 import TableData from "../../components/TableData"
 import QueryForm from "@/components/QueryForm"
 import { getPresets } from "@/components/QueryForm/const"
+import TablePro from "../../components/TablePro"
 
 /**
  * GS区服
@@ -14,7 +15,7 @@ import { getPresets } from "@/components/QueryForm/const"
 const ServerGsData: React.FC = () => {
 
     /********************************/
-    const [queryForm, setQueryForm] = useState<GameServerGsListProps>({ pageNum: 1, pageSize: 50, beginDate: moment().format('YYYY-MM-DD'), endDate: moment().format('YYYY-MM-DD'), sourceSystem: 'ZX_ONE' })
+    const [queryForm, setQueryForm] = useState<GameServerGsListProps>({ pageNum: 1, pageSize: 40, beginDate: moment().format('YYYY-MM-DD'), endDate: moment().format('YYYY-MM-DD'), sourceSystem: 'ZX_ONE' })
     const [totalData, setTotalData] = useState<any[]>([])
 
     const getGameServerGsList = useAjax((params) => getGameServerGsListApi(params))
@@ -32,7 +33,7 @@ const ServerGsData: React.FC = () => {
     }, [queryForm])
 
     return <div>
-        <TableData
+        {/* <TableData
             leftChild={<QueryForm
                 initialValues={{ sourceSystem: 'ZX_ONE', serverDay: [moment(), moment()] }}
                 onChange={(data: any) => {
@@ -67,10 +68,6 @@ const ServerGsData: React.FC = () => {
             total={getGameServerGsList?.data?.total}
             page={queryForm.pageNum}
             pageSize={queryForm.pageSize}
-            sortData={{
-                field: queryForm?.sortFiled,
-                order: queryForm?.sortType === 'asc' ? 'ascend' : 'descend'
-            }}
             title='GS区服数据'
             onChange={(props: any) => {
                 let { pagination, sortData } = props
@@ -89,6 +86,59 @@ const ServerGsData: React.FC = () => {
             }}
             config={columns12()}
             configName={'GS区服数据'}
+        /> */}
+        <TablePro
+            leftChild={<QueryForm
+                initialValues={{ sourceSystem: 'ZX_ONE', serverDay: [moment(), moment()] }}
+                onChange={(data: any) => {
+                    const { serverDay, parentGameIds, serverId, ...params } = data
+                    let newQueryForm = JSON.parse(JSON.stringify(queryForm))
+                    if (serverDay && serverDay?.length === 2) {
+                        newQueryForm['beginDate'] = moment(serverDay[0]).format('YYYY-MM-DD')
+                        newQueryForm['endDate'] = moment(serverDay[1]).format('YYYY-MM-DD')
+                    } else {
+                        delete newQueryForm['beginDate']
+                        delete newQueryForm['endDate']
+                    }
+                    newQueryForm.pageNum = 1
+                    newQueryForm.gameId = parentGameIds
+                    newQueryForm.serverId = serverId ? serverId?.split(/[,,\s\n]+/) : []
+                    setQueryForm({ ...newQueryForm, ...params })
+                }}
+                isSource
+                isServerDay={{ ranges: getPresets() }}
+                isParentIds
+                isServerName
+                isServerId={{placeholder: '区服ID(多个逗号,空格,换行)'}}
+                isGsId
+            />}
+            isZj
+            totalData={totalData}
+            config={columns12()}
+            configName={'GS区服数据'}
+            fixed={{ left: 3, right: 0 }}
+            scroll={{ x: 1000, y: 500 }}
+            title='GS区服数据'
+            loading={getGameServerGsList.loading || getGameServerGsTotal.loading}
+            ajax={getGameServerGsList}
+            page={getGameServerGsList?.data?.current || 1}
+            pageSize={getGameServerGsList?.data?.size || 20}
+            total={getGameServerGsList?.data?.total || 0}
+            dataSource={getGameServerGsList?.data?.records}
+            onChange={(pagination: any, _: any, sortData: any) => {
+                let { current, pageSize } = pagination
+                let newQueryForm = JSON.parse(JSON.stringify(queryForm))
+                if (sortData && sortData?.order) {
+                    newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
+                    newQueryForm['sortFiled'] = sortData?.field
+                } else {
+                    delete newQueryForm['sortType']
+                    delete newQueryForm['sortFiled']
+                }
+                newQueryForm.pageNum = current
+                newQueryForm.pageSize = pageSize
+                setQueryForm({ ...newQueryForm })
+            }}
         />
     </div>
 }

+ 16 - 4
src/pages/gameDataStatistics/gameServer/serverGsData/tableConfig.tsx

@@ -106,10 +106,22 @@ function columns12(): { label: string, fieldSHow?: { label: string, saveField: s
                                         <span>付费:</span>
                                         <span>{data?.totalAmountNum}</span>
                                     </span>
-                                    <span style={{ color: 'rgb(12,130,16)', fontWeight: 600, opacity: 0 }}>--</span>
-                                    <span style={{ color: '#eb2f96', fontWeight: 600, opacity: 0 }}>--</span>
-                                    <span style={{ color: 'rgb(12,130,16)', fontWeight: 600, opacity: 0 }}>--</span>
-                                    <span style={{ color: '#eb2f96', fontWeight: 600, opacity: 0 }}>--</span>
+                                    <span style={{ color: '#faad14', fontWeight: 600 }}>
+                                        <span>小R:</span>
+                                        <span>{data?.smallRNum}</span>
+                                    </span>
+                                    <span style={{ color: '#2f54eb', fontWeight: 600 }}>
+                                        <span>中R:</span>
+                                        <span>{data?.mediumRNum}</span>
+                                    </span>
+                                    <span style={{ color: '#0f538a', fontWeight: 600 }}>
+                                        <span>大R:</span>
+                                        <span>{data?.largeRNum}</span>
+                                    </span>
+                                    <span style={{ color: '#eb2f96', fontWeight: 600 }}>
+                                        <span>超大R:</span>
+                                        <span>{data?.superRNum}</span>
+                                    </span>
                                 </div>
                             </div>
                         }

+ 21 - 5
src/pages/gameDataStatistics/rankingList/gamer/index.tsx

@@ -11,7 +11,7 @@ import TablePro from "../../components/TablePro"
 const Gamer: React.FC = () => {
 
     /************************/
-    const [queryForm, setQueryForm] = useState<UserRechargeListType>({ pageNum: 1, pageSize: 100, sourceSystem: 'ZX_ONE', beginDay: moment().format('YYYY-MM-DD'), endDay: moment().format('YYYY-MM-DD') })
+    const [queryForm, setQueryForm] = useState<UserRechargeListType>({ pageNum: 1, pageSize: 50, sourceSystem: 'ZX_ONE', beginDay: moment().format('YYYY-MM-DD'), endDay: moment().format('YYYY-MM-DD') })
     const getRechargeUserList = useAjax((params) => getRechargeUserListApi(params))
     /************************/
 
@@ -20,7 +20,7 @@ const Gamer: React.FC = () => {
     }, [queryForm])
 
     return <div>
-        <TableData
+        {/* <TableData
             leftChild={<QueryForm
                 initialValues={{ sourceSystem: 'ZX_ONE', rechargeDay: [moment(), moment()] }}
                 onChange={(data: any) => {
@@ -79,9 +79,9 @@ const Gamer: React.FC = () => {
             }}
             config={columns12()}
             configName={'玩家充值排行榜'}
-        />
+        /> */}
 
-        {/* <TablePro
+        <TablePro
             leftChild={<QueryForm
                 initialValues={{ sourceSystem: 'ZX_ONE', rechargeDay: [moment(), moment()] }}
                 onChange={(data: any) => {
@@ -119,12 +119,28 @@ const Gamer: React.FC = () => {
             fixed={{ left: 1, right: 0 }}
             scroll={{ x: 1000, y: 600 }}
             title='玩家充值排行榜'
+            loading={getRechargeUserList.loading}
             ajax={getRechargeUserList}
             page={getRechargeUserList?.data?.current || 1}
             pageSize={getRechargeUserList?.data?.size || 20}
             total={getRechargeUserList?.data?.total || 0}
             dataSource={getRechargeUserList?.data?.records}
-        /> */}
+            onChange={(pagination: any, _: any, sortData: any) => {
+                console.log('props--->', pagination, sortData)
+                let { current, pageSize } = pagination
+                let newQueryForm = JSON.parse(JSON.stringify(queryForm))
+                if (sortData && sortData?.order) {
+                    newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
+                    newQueryForm['sortFiled'] = sortData?.field
+                } else {
+                    delete newQueryForm['sortType']
+                    delete newQueryForm['sortFiled']
+                }
+                newQueryForm.pageNum = current
+                newQueryForm.pageSize = pageSize
+                setQueryForm({ ...newQueryForm })
+            }}
+        />
     </div>
 }