index.tsx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 { PromoteTotalProps, getPromoteTotalListApi } from "@/services/gameData/extensionData"
  6. import QueryForm from "@/components/QueryForm"
  7. import moment from "moment"
  8. import { getGameChoiceParentListType1Api } from "@/services/gameData"
  9. const Total: React.FC = () => {
  10. /************************************/
  11. const [queryForm, setQueryForm] = useState<PromoteTotalProps>({
  12. pageNum: 1,
  13. pageSize: 20,
  14. costBeginDay: moment().subtract(30, 'd').format('YYYY-MM-DD'),
  15. costEndDay: moment().format('YYYY-MM-DD'),
  16. rechargeBeginDay: moment().subtract(30, 'd').format('YYYY-MM-DD'),
  17. rechargeEndDay: moment().format('YYYY-MM-DD'),
  18. })
  19. const [gameType, setGameType] = useState<any>({})
  20. const getPromoteTotalList = useAjax((params) => getPromoteTotalListApi(params))
  21. const getGameChoiceParentListType1 = useAjax(() => getGameChoiceParentListType1Api())
  22. /************************************/
  23. useEffect(() => {
  24. getPromoteTotalList.run(queryForm)
  25. }, [queryForm])
  26. useEffect(() => {
  27. getGameChoiceParentListType1.run().then(res => {
  28. let newType: any = {}
  29. res.forEach((item: { id: number, name: string }) => {
  30. newType[item.id] = item.name
  31. })
  32. setGameType(newType)
  33. })
  34. }, [])
  35. return <div>
  36. <TableData
  37. leftChild={<QueryForm
  38. initialValues={{ consumeDay: [moment().subtract(30, 'd'), moment()], rechargeDay: [moment().subtract(30, 'd'), moment()] }}
  39. onChange={(data: any) => {
  40. const { pitcherId, rechargeDay, ...params } = data
  41. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  42. newQueryForm.pageNum = 1
  43. if (rechargeDay && rechargeDay?.length === 2) {
  44. newQueryForm['rechargeBeginDay'] = moment(rechargeDay[0]).format('YYYY-MM-DD')
  45. newQueryForm['rechargeEndDay'] = moment(rechargeDay[1]).format('YYYY-MM-DD')
  46. } else {
  47. delete newQueryForm['rechargeBeginDay']
  48. delete newQueryForm['rechargeEndDay']
  49. }
  50. newQueryForm.sysUserId = pitcherId
  51. setQueryForm({ ...newQueryForm, ...params })
  52. }}
  53. isSource
  54. isAccountId
  55. isAgentId
  56. isConsumeDay
  57. isCpName
  58. isGameName
  59. isGameType
  60. rechargeDay={{}}
  61. isSysUserId
  62. />}
  63. scroll={{ x: 1000, y: 600 }}
  64. ajax={getPromoteTotalList}
  65. dataSource={getPromoteTotalList?.data?.records}
  66. total={getPromoteTotalList?.data?.total}
  67. page={queryForm.pageNum}
  68. pageSize={queryForm.pageSize}
  69. fixed={{ left: 5, right: 0 }}
  70. title='推广总数据'
  71. onChange={(props: any) => {
  72. console.log('props--->', props)
  73. let { pagination, sortData } = props
  74. let { current, pageSize } = pagination
  75. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  76. if (sortData && sortData?.order) {
  77. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  78. newQueryForm['sortFiled'] = sortData?.field
  79. } else {
  80. delete newQueryForm['sortType']
  81. delete newQueryForm['sortFiled']
  82. }
  83. newQueryForm.pageNum = current
  84. newQueryForm.pageSize = pageSize
  85. setQueryForm({ ...newQueryForm })
  86. }}
  87. config={columns12(gameType)}
  88. configName={'推广总数据'}
  89. />
  90. </div>
  91. }
  92. export default Total