index.tsx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. /**公众号总数据 */
  7. function Page() {
  8. const { state: { dataSource }, getChannelStatChannel } = useModel('useData.useTableData')
  9. //加工数据
  10. const data = useMemo(() => {
  11. if (dataSource) {
  12. return dataSource?.map((item: any, index: number) => {
  13. item['id'] = index
  14. return item
  15. })
  16. }
  17. return []
  18. }, [dataSource])
  19. const sortArr = useMemo(() => {
  20. let arr: any[] = []
  21. columns().map((item: any) => {
  22. if (typeof item.title === 'string') {
  23. arr.push({ title: item.title, value: item.dataIndex ,key:item.dataIndex })
  24. }
  25. if(typeof item.title === 'object' && typeof item.title.props.children[0] === 'string' ){
  26. arr.push({ title: item.title, value: item.dataIndex ,key:item.dataIndex })
  27. }
  28. })
  29. return arr
  30. }, [columns])
  31. return <>
  32. <TableData
  33. ajax={getChannelStatChannel}
  34. isTableId
  35. isZj
  36. isAdmin
  37. isUserId
  38. isDownload
  39. isSelctAcc
  40. isTableDateArr
  41. columns={columns}
  42. isGroupTab={false}
  43. sortArr={sortArr}
  44. dataSource={data}
  45. title='公众号总数据'
  46. scroll={{ x: 1000, y: 600 }}
  47. className='ranking'
  48. />
  49. </>
  50. }
  51. export default HocError(Page)