index.tsx 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. import { useAjax } from "@/Hook/useAjax"
  2. import { PromotionDataDay, getPromotionDataDatListApi, getPromotionDataDatTotalApi } from "@/services/gameData/adlist"
  3. import React, { useEffect, useState } from "react"
  4. import columns12 from "./tableConfig"
  5. import QueryForm from "@/components/QueryForm"
  6. import TableData from "../../components/TableData"
  7. import moment from "moment"
  8. import { getPresets } from "@/components/QueryForm/const"
  9. const Monitor = () => {
  10. /***************************************/
  11. const [queryForm, setQueryForm] = useState<PromotionDataDay>({ pageNum: 1, pageSize: 20, sourceSystem: 'ZX_ONE', costBeginDate: moment().format('YYYY-MM-DD'), costEndDate: moment().format('YYYY-MM-DD') })
  12. const [totalData, setTotalData] = useState<any[]>([])
  13. const getPromotionDataDatList = useAjax((params) => getPromotionDataDatListApi(params))
  14. const getPromotionDataDatTotal = useAjax((params) => getPromotionDataDatTotalApi(params))
  15. /***************************************/
  16. useEffect(() => {
  17. getPromotionDataDatList.run(queryForm)
  18. getPromotionDataDatTotal.run(queryForm).then(res => {
  19. res.id = 1
  20. res.agentName = '总计'
  21. setTotalData([res])
  22. })
  23. }, [queryForm])
  24. return <div>
  25. <TableData
  26. leftChild={<QueryForm
  27. initialValues={{ sourceSystem: 'ZX_ONE', consumeDay: [moment(), moment()] }}
  28. onChange={(data: any) => {
  29. const { type, gameClassify, costBeginDay, costEndDay, pitcherId, sysUserName, ...params } = data
  30. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  31. newQueryForm.pageNum = 1
  32. newQueryForm.zxPitcherId = pitcherId
  33. newQueryForm.pitcherName = sysUserName
  34. newQueryForm.accountType = type
  35. newQueryForm.classify = gameClassify
  36. if (costBeginDay && costEndDay) {
  37. newQueryForm.costBeginDate = costBeginDay
  38. newQueryForm.costEndDate = costEndDay
  39. } else {
  40. delete newQueryForm.costBeginDate
  41. delete newQueryForm.costEndDate
  42. }
  43. setQueryForm({ ...newQueryForm, ...params })
  44. }}
  45. isSource
  46. isAccountId
  47. isAccount
  48. isType
  49. isAgentId
  50. isBGGameClassify
  51. isConsumeDay={{ ranges: getPresets() }}
  52. isCpName
  53. isGameId
  54. isSysUserId
  55. isProjectId
  56. isProjectName
  57. isPromotionId
  58. isPromotionName
  59. isAdStatus
  60. />}
  61. isZj
  62. totalData={totalData}
  63. scroll={{ x: 1000, y: 600 }}
  64. ajax={getPromotionDataDatList}
  65. fixed={{ left: 3, right: 0 }}
  66. dataSource={getPromotionDataDatList?.data?.records?.map((item: any, index: number) => ({ ...item, id: item?.orderId?.replace(/\D/g, '') || index }))}
  67. total={getPromotionDataDatList?.data?.total}
  68. page={queryForm.pageNum}
  69. pageSize={queryForm.pageSize}
  70. title='广告监控'
  71. onChange={(props: any) => {
  72. let { pagination, sortData } = props
  73. let { current, pageSize } = pagination
  74. let newQueryForm = JSON.parse(JSON.stringify(queryForm))
  75. if (sortData && sortData?.order) {
  76. newQueryForm['sortType'] = sortData?.order === 'ascend' ? 'asc' : 'desc'
  77. newQueryForm['sortFiled'] = sortData?.field
  78. } else {
  79. delete newQueryForm['sortType']
  80. delete newQueryForm['sortFiled']
  81. }
  82. newQueryForm.pageNum = current
  83. newQueryForm.pageSize = pageSize
  84. setQueryForm({ ...newQueryForm })
  85. }}
  86. config={columns12()}
  87. configName={'广告监控'}
  88. />
  89. </div>
  90. }
  91. export default Monitor