index.tsx 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import HocError from '@/Hoc/HocError'
  2. import React, { useMemo } from 'react'
  3. import { useModel } from 'umi'
  4. import TableData from '../../components/TableData'
  5. import { columns } from './tableConfig'
  6. function Page() {
  7. const { state: { dataSource }, getChannelOrderTrend } = useModel('useData.useTableData')
  8. //加工数据
  9. const data = useMemo(() => {
  10. let arr: any[] = []
  11. if (dataSource) {
  12. dataSource?.forEach((item: any, index: number) => {
  13. item['id'] = index
  14. arr.push(item)
  15. })
  16. }
  17. return arr
  18. }, [dataSource])
  19. //获取排序列表
  20. const sortArr = useMemo(() => {
  21. let arr: any[] = []
  22. columns().map((item: any) => {
  23. if (typeof item.title === 'string') {
  24. arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
  25. }
  26. if (typeof item.title === 'object' && typeof item.title.props.children[0] === 'string') {
  27. arr.push({ title: item.title, value: item.dataIndex, key: item.dataIndex })
  28. }
  29. })
  30. return arr
  31. }, [columns])
  32. return <>
  33. <TableData
  34. isGroupTab={false}
  35. isAdmin
  36. isDownload
  37. isSelctAccTags
  38. isUserId
  39. isDataSelectPitcher
  40. isDataSelectPitcher_isDisabled
  41. isTableDateArr
  42. isZj
  43. sortArr={sortArr}
  44. ajax={getChannelOrderTrend}
  45. columns={columns}
  46. dataSource={data}
  47. title='公众号单号付费趋势'
  48. // tableTotal={tableTotal}
  49. scroll={{ x: 1000, y: 600 }}
  50. />
  51. </>
  52. }
  53. export default HocError(Page)