index.tsx 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 moment from "moment"
  8. import { rangePresets } from "@/components/QueryForm/const"
  9. const Account: React.FC = () => {
  10. /********************************/
  11. const [queryForm, setQueryForm] = useState<AccountProps>({ pageNum: 1, pageSize: 20 })
  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. onChange={(data: any) => {
  21. console.log(data)
  22. const { rechargeDay, ...params } = data
  23. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  24. newQueryForm.pageNum = 1
  25. if (rechargeDay && rechargeDay?.length === 2) {
  26. newQueryForm.beginDay = moment(rechargeDay[0]).format('YYYY-MM-DD')
  27. newQueryForm.endDay = moment(rechargeDay[1]).format('YYYY-MM-DD')
  28. } else {
  29. delete newQueryForm.beginDay
  30. delete newQueryForm.endDay
  31. }
  32. setQueryForm({ ...newQueryForm, ...params })
  33. }}
  34. rechargeDay={{ ranges: rangePresets }}
  35. isSysUserId
  36. isType
  37. isAccountId
  38. isGameId
  39. />}
  40. scroll={{ x: 1000, y: 600 }}
  41. ajax={getAccountRechargeRankingList}
  42. fixed={{ left: 3, right: 3 }}
  43. dataSource={getAccountRechargeRankingList?.data?.records?.map((item: any, index: number) => ({ ...item, id: Number(queryForm.pageNum.toString() + index.toString()) }))}
  44. total={getAccountRechargeRankingList?.data?.total}
  45. page={queryForm.pageNum}
  46. pageSize={queryForm.pageSize}
  47. title='推广账号消耗排行榜'
  48. onChange={(props: any) => {
  49. let { pagination, sortData } = props
  50. let { current, pageSize } = pagination
  51. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  52. if (sortData && sortData?.order) {
  53. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  54. newQueryForm['sortFiled'] = sortData?.field
  55. } else {
  56. delete newQueryForm['sortType']
  57. delete newQueryForm['sortFiled']
  58. }
  59. newQueryForm.pageNum = current
  60. newQueryForm.pageSize = pageSize
  61. setQueryForm({ ...newQueryForm })
  62. }}
  63. config={columns12()}
  64. configName={'推广账号消耗排行榜'}
  65. />
  66. </div>
  67. }
  68. export default Account