index.tsx 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. import React, { useEffect, useState } from "react"
  2. import TableData from "../../components/TableData"
  3. import columns12 from "./tableConfig"
  4. import { useAjax } from "@/Hook/useAjax"
  5. import { AccountProps, getAccountRechargeRankingListApi } from "@/services/gameData/rankingList"
  6. import QueryForm from "@/components/QueryForm"
  7. import { getPresetsRanking } from "@/components/QueryForm/const"
  8. import moment from "moment"
  9. const Account: React.FC = () => {
  10. /********************************/
  11. const [queryForm, setQueryForm] = useState<AccountProps>({ pageNum: 1, pageSize: 100, sourceSystem: 'ZX_ONE', beginDay: moment().format('YYYY-MM-DD'), endDay: moment().format('YYYY-MM-DD') })
  12. const getAccountRechargeRankingList = useAjax((params) => getAccountRechargeRankingListApi(params))
  13. /********************************/
  14. useEffect(() => {
  15. getAccountRechargeRankingList.run(queryForm)
  16. }, [queryForm])
  17. return <div>
  18. <TableData
  19. leftChild={<QueryForm
  20. initialValues={{ sourceSystem: 'ZX_ONE', consumeDay: [moment(), moment()] }}
  21. onChange={(data: any) => {
  22. console.log(data)
  23. const { costBeginDay, costEndDay, ...params } = data
  24. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  25. newQueryForm.pageNum = 1
  26. if (costBeginDay && costEndDay) {
  27. newQueryForm.beginDay = costBeginDay
  28. newQueryForm.endDay = costEndDay
  29. } else {
  30. delete newQueryForm.beginDay
  31. delete newQueryForm.endDay
  32. }
  33. setQueryForm({ ...newQueryForm, ...params })
  34. }}
  35. isSource
  36. isConsumeDay={{ ranges: getPresetsRanking() }}
  37. isSysUserId
  38. isType
  39. isAccountId
  40. isGameId
  41. />}
  42. scroll={{ x: 1000, y: 600 }}
  43. ajax={getAccountRechargeRankingList}
  44. fixed={{ left: 3, right: 3 }}
  45. dataSource={getAccountRechargeRankingList?.data?.records?.map((item: any, index: number) => ({ ...item, id: Number(queryForm.pageNum.toString() + index.toString()) }))}
  46. total={getAccountRechargeRankingList?.data?.total}
  47. page={queryForm.pageNum}
  48. pageSize={queryForm.pageSize}
  49. title='推广账号消耗排行榜(T+1)'
  50. onChange={(props: any) => {
  51. let { pagination, sortData } = props
  52. let { current, pageSize } = pagination
  53. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  54. if (sortData && sortData?.order) {
  55. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  56. newQueryForm['sortFiled'] = sortData?.field
  57. } else {
  58. delete newQueryForm['sortType']
  59. delete newQueryForm['sortFiled']
  60. }
  61. newQueryForm.pageNum = current
  62. newQueryForm.pageSize = pageSize
  63. setQueryForm({ ...newQueryForm })
  64. }}
  65. config={columns12()}
  66. configName={'推广账号消耗排行榜'}
  67. />
  68. </div>
  69. }
  70. export default Account