index.tsx 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { getPromoteAgainListApi } from "@/services/gameData/extensionData"
  3. import { Col, Drawer, Empty, Progress, Row, Spin, Statistic, Table } from "antd"
  4. import React, { useEffect, useMemo } from "react"
  5. import style from './table.less'
  6. import './index.less'
  7. import moment from "moment"
  8. import { FallOutlined, RiseOutlined } from "@ant-design/icons"
  9. import { useAddTime } from "@/utils/utils"
  10. interface Props {
  11. accountId?: number,
  12. agentId?: number,
  13. beginDate?: string
  14. sourceSystem?: string
  15. visible?: boolean
  16. onClose?: () => void
  17. }
  18. /**
  19. * 推广 复充趋势
  20. * @returns
  21. */
  22. const RechargeTrend: React.FC<Props> = ({ visible, onClose, accountId, agentId, beginDate, sourceSystem }) => {
  23. /************************************* */
  24. const getPromoteAgainList = useAjax((params) => getPromoteAgainListApi(params)) // 推广
  25. /************************************* */
  26. useEffect(() => {
  27. getPromoteAgainList.run({ accountId, agentId, beginDate, sourceSystem })
  28. }, [accountId, visible, agentId, beginDate, sourceSystem])
  29. const TableTrend = useMemo(() => {
  30. if (getPromoteAgainList?.data && JSON.stringify(getPromoteAgainList?.data) !== '{}') {
  31. let col: any[] = []
  32. let data: any[] = [{ count: '1', id: 1 }, { count: '2', id: 2 }, { count: '3', id: 3 }, { count: '4', id: 4 }, { count: '5', id: 5 }, { count: '5-10', id: 6 }, { count: '10-20', id: 7 }, { count: '20次以上', id: 8 }]
  33. let date: string = ''
  34. let width = 110
  35. Object.keys(getPromoteAgainList?.data).forEach((key, index) => {
  36. date = key
  37. col.push({
  38. title: key,
  39. dataIndex: 'd' + (index + 1),
  40. key: 'd' + (index + 1),
  41. align: 'center',
  42. width,
  43. render: (value1: any, value2: any) => {
  44. return <Row gutter={[10, 0]} key={index} className={`${style.mytable_body_div} ${style.show}`} >
  45. <Col style={{ color: '#3f51b5', fontWeight: 600 }} span={24} ><span>原:</span>
  46. <Statistic value={value1?.original || 0} valueStyle={{ color: '#3f51b5', fontSize: 12, fontWeight: 600 }} />
  47. </Col>
  48. <Col style={{ color: '#ff9800', fontWeight: 600 }} span={24} ><span>现:</span>
  49. <Statistic value={value1?.present || 0} valueStyle={{ color: '#ff9800', fontSize: 12, fontWeight: 600 }} />
  50. </Col>
  51. <Col style={{ color: 'red', fontWeight: 600 }} span={24} ><span>增:</span>
  52. <Statistic value={value1?.increase || 0} valueStyle={{ color: 'red', fontSize: 12, fontWeight: 600 }} prefix={<RiseOutlined />} />
  53. </Col>
  54. <Col style={{ color: 'green', fontWeight: 600 }} span={24} ><span>移:</span>
  55. <Statistic value={value1?.decrease || 0} valueStyle={{ color: 'green', fontSize: 12, fontWeight: 600 }} prefix={<FallOutlined />} />
  56. </Col>
  57. <Col style={{ color: '#000', fontWeight: 600 }} span={24} >
  58. <div className={style.bitRate}>
  59. <span>比:</span>
  60. <div className="my_progrss">
  61. <span className='content'>{(value1?.rate * 100)?.toFixed(2) || '0.00'}%</span>
  62. <Progress
  63. strokeColor="#d3adf7"
  64. status="active"
  65. showInfo={false}
  66. style={{ height: 25 }}
  67. percent={(value1?.rate * 100) || 0}
  68. />
  69. </div>
  70. </div>
  71. </Col>
  72. </Row>
  73. }
  74. })
  75. getPromoteAgainList?.data[key]?.forEach((item: any, eq: number) => {
  76. data[eq][`d${index + 1}`] = item
  77. })
  78. })
  79. let nullCol: any[] = []
  80. if (col.length < 30) {
  81. Array(30 - col.length).fill('').forEach((item, index) => {
  82. nullCol.push({
  83. title: useAddTime(index, 'days', 'YYYY-MM-DD', date || moment().format('YYYY-MM-DD')),
  84. dataIndex: 'd' + (index + 1),
  85. key: 'd' + (index + 1),
  86. align: 'center',
  87. width,
  88. className: 'zdred',
  89. render: () => {
  90. return '--'
  91. }
  92. })
  93. })
  94. }
  95. const columns: any = [
  96. {
  97. title: '充值次数',
  98. dataIndex: 'count',
  99. key: 'count',
  100. width: 50,
  101. align: 'center'
  102. },
  103. ...col,
  104. ...nullCol
  105. ]
  106. return <Table columns={columns} scroll={{ x: 1000, y: 700 }} className="sumTable" rowKey={'id'} size="small" dataSource={data} bordered pagination={false} />
  107. } else {
  108. return <Empty />
  109. }
  110. }, [getPromoteAgainList?.data])
  111. return <Drawer title={`${accountId} 推广每日数据复充趋势`} visible={visible} onClose={() => onClose?.()} width={'90%'}>
  112. <Spin spinning={getPromoteAgainList.loading} >{TableTrend}</Spin>
  113. </Drawer>
  114. }
  115. export default React.memo(RechargeTrend)