tableConfig.tsx 1.9 KB

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