tableConfig.tsx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. import { ColumnsType } from 'antd/lib/table'
  2. import React from 'react'
  3. import './index.less'
  4. function columns() {
  5. let newArr: ColumnsType<any> = [
  6. {
  7. title: '公众号',
  8. dataIndex: 'channel',
  9. key: 'channel',
  10. align: 'center',
  11. width: 100,
  12. ellipsis: true
  13. },
  14. {
  15. title: '消耗时间',
  16. dataIndex: 'cost_time',
  17. key: 'cost_time',
  18. align: 'center',
  19. width: 160,
  20. },
  21. {
  22. title: '充值时间',
  23. dataIndex: 'date',
  24. key: 'date',
  25. align: 'center',
  26. width: 90,
  27. },
  28. {
  29. title: '总消耗',
  30. dataIndex: 'cost',
  31. key: 'cost',
  32. align: 'center',
  33. width: 100,
  34. sorter: true,
  35. },
  36. {
  37. title: '总充值',
  38. dataIndex: 'amount',
  39. key: 'amount',
  40. align: 'center',
  41. width: 100,
  42. sorter: true,
  43. },
  44. {
  45. title: '回收率',
  46. dataIndex: `roi`,
  47. key: `roi`,
  48. width: 85,
  49. align: 'center',
  50. sorter: true,
  51. render: (a: any) => {
  52. return a === 999999999 ? <div>--</div> : a ?
  53. <div style={a >= 1 ? { color: 'red' } : { color: '#0f990f' }}>{(a * 100).toFixed(2) + '%'}</div>
  54. : a === 0 ?
  55. <div>0</div>
  56. : <div>--</div>
  57. }
  58. }
  59. ]
  60. return newArr
  61. }
  62. export { columns }