index.tsx 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import HocError from '@/Hoc/HocError'
  2. import React, { useEffect, useMemo } from 'react'
  3. import { useModel } from 'umi'
  4. import TableData from '../../components/TableData'
  5. import { columns } from './tableConfig'
  6. /**公众号用户充值查询 */
  7. function Page() {
  8. const { state: { dataSource}, getChannelAnalysis, dispatch } = useModel('useData.useTableData')
  9. useEffect(() => {
  10. if (window.location.hash?.indexOf('?') !== -1 && window.location.hash?.indexOf('channel') !== -1) {
  11. let cs = window.location.hash?.split('?')
  12. let channel = cs[1]?.split('=')[1]
  13. dispatch({ type: 'channel', params: { channel: decodeURI(channel) } })
  14. }
  15. }, [])
  16. //加工数据
  17. const data = useMemo(() => {
  18. if (dataSource) {
  19. return dataSource?.map((item: any, index: number) => {
  20. item['id'] = index
  21. return item
  22. })
  23. }
  24. return []
  25. }, [dataSource])
  26. //获取排序列表
  27. const sortArr = useMemo(() => {
  28. let arr: any[] = []
  29. columns().map((item: any) => {
  30. if (typeof item.title === 'string') {
  31. arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
  32. }
  33. if (typeof item.title === 'object' && typeof item.title.props.children[0] === 'string') {
  34. arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
  35. }
  36. })
  37. return arr
  38. }, [columns])
  39. return <>
  40. <TableData
  41. isTableDateArr
  42. isTableDateArrSt
  43. isZj
  44. isGroupTab={false}
  45. isAdmin
  46. isUserId
  47. isSelctAcc
  48. // isSelctAccTags
  49. sortArr={sortArr}
  50. columns={columns}
  51. ajax={getChannelAnalysis}
  52. title='公众号用户充值查询'
  53. dataSource={data}
  54. scroll={{ x: 1000, y: 600 }}
  55. />
  56. </>
  57. }
  58. export default HocError(Page)