index.tsx 4.0 KB

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