index.tsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. import React, { useEffect, useState } from "react"
  2. import { useAjax } from "@/Hook/useAjax"
  3. import { MediaPromotionTotalProps, getMediaPromotionTotalListApi, getMediaPromotionTotalSumApi } from "@/services/gameData/medium"
  4. import moment from "moment"
  5. import TableData from "../../components/TableData"
  6. import QueryForm from "@/components/QueryForm"
  7. import { getPresets } from "@/components/QueryForm/const"
  8. import columns12 from "./tableConfig"
  9. /**
  10. * 推广媒体总数据
  11. * @returns
  12. */
  13. const PromotionTotal: React.FC = () => {
  14. /*****************************/
  15. const [queryForm, setQueryForm] = useState<MediaPromotionTotalProps>({
  16. pageNum: 1, pageSize: 100,
  17. sourceSystem: 'ZX_ONE',
  18. amountBeginDate: moment().format('YYYY-MM-DD'), //.subtract(30, 'd')
  19. amountEndDate: moment().format('YYYY-MM-DD'),
  20. beginDate: moment().format('YYYY-MM-DD'), //subtract(30, 'd').
  21. endDate: moment().format('YYYY-MM-DD')
  22. })
  23. const [totalData, setTotalData] = useState<any[]>([])
  24. const getMediaPromotionTotalList = useAjax((params) => getMediaPromotionTotalListApi(params))
  25. const getMediaPromotionTotalSum = useAjax((params) => getMediaPromotionTotalSumApi(params))
  26. /*****************************/
  27. useEffect(() => {
  28. getMediaPromotionTotalList.run(queryForm)
  29. getMediaPromotionTotalSum.run(queryForm).then((res: { id: number; pitcher: string }) => {
  30. res.id = 1
  31. res.pitcher = '总计'
  32. setTotalData([res])
  33. })
  34. }, [queryForm])
  35. return <div>
  36. <TableData
  37. leftChild={<QueryForm
  38. initialValues={{ rechargeDay: [moment(), moment()], consumeDay: [moment(), moment()], sourceSystem: 'ZX_ONE' }}
  39. onChange={(data: any) => {
  40. console.log(data)
  41. const { costBeginDay, costEndDay, rechargeDay, type, gameClassify, cpName, ...params } = data
  42. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  43. newQueryForm.pageNum = 1
  44. newQueryForm.accountType = type
  45. newQueryForm.gameType = gameClassify
  46. newQueryForm.gameCp = cpName
  47. if (costBeginDay && costEndDay) {
  48. newQueryForm.beginDate = costBeginDay
  49. newQueryForm.endDate = costEndDay
  50. } else {
  51. delete newQueryForm.beginDate
  52. delete newQueryForm.endDate
  53. }
  54. if (rechargeDay && rechargeDay?.length === 2) {
  55. newQueryForm['amountBeginDate'] = moment(rechargeDay[0]).format('YYYY-MM-DD')
  56. newQueryForm['amountEndDate'] = moment(rechargeDay[1]).format('YYYY-MM-DD')
  57. } else {
  58. delete newQueryForm['amountBeginDate']
  59. delete newQueryForm['amountEndDate']
  60. }
  61. setQueryForm({ ...newQueryForm, ...params })
  62. }}
  63. isSource
  64. isConsumeDay={{ ranges: getPresets() }}
  65. rechargeDay={{ ranges: getPresets() }}
  66. isCpName
  67. isSysUserIds
  68. isGameIds
  69. isGameDimension
  70. isBGGameClassify
  71. isType
  72. />}
  73. isZj
  74. totalData={totalData}
  75. scroll={{ x: 1000, y: 600 }}
  76. ajax={getMediaPromotionTotalList}
  77. fixed={{ left: 2, right: 1 }}
  78. dataSource={getMediaPromotionTotalList?.data?.records?.map((item: any, index: number) => ({ ...item, id: Number(queryForm.pageNum.toString() + index.toString()) }))}
  79. total={getMediaPromotionTotalList?.data?.total}
  80. page={queryForm.pageNum}
  81. pageSize={queryForm.pageSize}
  82. sortData={{
  83. field: queryForm?.sortFiled,
  84. order: queryForm?.sortType === 'asc' ? 'ascend' : 'descend'
  85. }}
  86. title={`推广媒体总数据`}
  87. onChange={(props: any) => {
  88. let { pagination, sortData } = props
  89. let { current, pageSize } = pagination
  90. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  91. if (sortData && sortData?.order) {
  92. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  93. newQueryForm['sortFiled'] = sortData?.field
  94. } else {
  95. delete newQueryForm['sortType']
  96. delete newQueryForm['sortFiled']
  97. }
  98. newQueryForm.pageNum = current
  99. newQueryForm.pageSize = pageSize
  100. setQueryForm({ ...newQueryForm })
  101. }}
  102. config={columns12()}
  103. configName={'推广媒体总数据'}
  104. />
  105. </div>
  106. }
  107. export default PromotionTotal