wjx 1 year ago
parent
commit
dc8ba78f94

+ 20 - 32
src/components/Tables/index.tsx

@@ -1,4 +1,4 @@
-import React, { ReactNode ,useEffect, useRef, useState} from 'react'
+import React, { ReactNode, useEffect, useRef, useState } from 'react'
 import { Table, Tag, message } from 'antd';
 import { Excle } from '@/utils/Excle'
 import style from './index.less'
@@ -12,7 +12,7 @@ const ResizableHeader = (props: { [x: string]: any; onResize: any; width: any })
     if (!width) {
         return <th {...restProps} />
     }
-    return <Resizable width={width} height={0} onResize={onResize} draggableOpts={{enableUserSelectHack:false}}>
+    return <Resizable width={width} height={0} onResize={onResize} draggableOpts={{ enableUserSelectHack: false }}>
         <th {...restProps} />
     </Resizable>
 }
@@ -52,14 +52,14 @@ interface Props {
     showHeader?: boolean,
     hideOnSinglePage?: boolean,
     className?: string,
-    handelResize?:(columns:any)=>void//当表头被拖动改变宽度时回调设置对应的本地保存
+    handelResize?: (columns: any) => void//当表头被拖动改变宽度时回调设置对应的本地保存
     sortDirections?: SortOrder[],
     isShowTotal?: boolean,  // 是否展示总计
 }
 
 function Tables(props: Props) {
     // //导出数据
-    let { columns, dataSource, excle, total,handelResize, rowSelection, onRow, isShowTotal = true, hideOnSinglePage, rowClassName, className, expandedRowRender, scroll, summary, showHeader = true, bordered, size = 'small', onChange, sortDirections, pagination, ...prop } = props
+    let { columns, dataSource, excle, total, handelResize, rowSelection, onRow, isShowTotal = true, hideOnSinglePage, rowClassName, className, expandedRowRender, scroll, summary, showHeader = true, bordered, size = 'small', onChange, sortDirections, pagination, ...prop } = props
     let handleExcle = () => {
         if (dataSource.length < 1) {
             message.error('请先搜索再导出');
@@ -76,32 +76,33 @@ function Tables(props: Props) {
     }
     let ww = document.body.clientWidth < 415
     // 拖动宽逻辑
-    const [cols,setCols] = useState<any>(columns)
+    const [cols, setCols] = useState<any>(columns)
     const colsRef = useRef<any[]>([])
-    const components={
-        header:{
-            cell:ResizableHeader
+    const components = {
+        header: {
+            cell: ResizableHeader
         }
     }
-    useEffect(()=>{
+    useEffect(() => {
         setCols(columns)
-    },[columns])
-    const handleResize=(index:any)=>(e:any,{size}:any)=>{
-        const nextColumns=[...cols]
-        nextColumns[index]={
+    }, [columns])
+    const handleResize = (index: any) => (e: any, { size }: any) => {
+        const nextColumns = [...cols]
+        nextColumns[index] = {
             ...nextColumns[index],
-            width:size.width
+            width: size.width
         }
         setCols(nextColumns)
         handelResize && handelResize(nextColumns)
     }
-    colsRef.current = (cols||[]).map((col:any,index:any)=>({
+    colsRef.current = (cols || []).map((col: any, index: any) => ({
         ...col,
-        onHeaderCell:(column:any)=>({
-            width:column.width,
-            onResize:handleResize(index)
+        onHeaderCell: (column: any) => ({
+            width: column.width,
+            onResize: handleResize(index)
         })
     }))
+
     return <div className='components-table-resizable-column'>
         {
             excle && <Tag color='#f50' style={{ margin: '10px 0', float: 'right' }} onClick={handleExcle}><a>导出数据</a></Tag>
@@ -127,16 +128,6 @@ function Tables(props: Props) {
                     onClick: onRow?.onClick && onRow?.onClick.bind('', record) || undefined,
                 }
             }}
-            // rowClassName={(record: any) => {
-            //     if (rowClassName && record[rowClassName as string] === 2) {
-            //         return style.unfollow
-            //     }
-            //     if (rowClassName && !record[rowClassName as string]) {
-            //         return style.unfollow
-            //     }
-            // }
-            // }
-            // rowClassName={rowClassName}
             summary={summary}
             className={className}
             expandable={expandedRowRender ? {
@@ -180,7 +171,4 @@ function Tables(props: Props) {
     </div>
 }
 
-export default Tables
-
-
-
+export default Tables

+ 1 - 1
src/pages/gameDataStatistics/extensionData/everyday/index.tsx

@@ -63,7 +63,7 @@ const Everyday: React.FC = () => {
             totalData={totalData}
             scroll={{ x: 1000, y: 600 }}
             ajax={getPromoteDayList}
-            fixed={{ left: 5, right: 1 }}
+            fixed={{ left: 5, right: 2 }}
             dataSource={getPromoteDayList?.data?.records}
             total={getPromoteDayList?.data?.total}
             page={queryForm.pageNum}

+ 2 - 2
src/pages/gameDataStatistics/rankingList/gamer/tableConfig.tsx

@@ -70,7 +70,7 @@ function columns12() {
                             const remainingSeconds = seconds % 60;
                             return `${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds + "秒" : ''}`
                         }
-                        return diff ? secondsToDhms(diff / 1000) : '--'
+                        return diff ? <WidthEllipsis value={secondsToDhms(diff / 1000)} /> : '--'
                     }
                 },
                 {
@@ -88,7 +88,7 @@ function columns12() {
                             const remainingSeconds = seconds % 60;
                             return `${days ? days + "天" : ''}${hours ? hours + "小时" : ''}${minutes ? minutes + "分" : ''}${remainingSeconds ? remainingSeconds.toFixed(0) + "秒" : ''}`
                         }
-                        return diff ? secondsToDhms(diff / 1000) : '--'
+                        return diff ? <span style={Math.floor((diff / 1000) / (3600 * 24)) > 1 ? { color: 'red' } : {}}><WidthEllipsis value={secondsToDhms(diff / 1000)} /></span> : '--'
                     }
                 },
             ]