tableConfig.tsx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { Statistic } from "antd"
  2. import React from "react"
  3. let columns = (timeUnit: string) => [
  4. {
  5. title: '时间',
  6. dataIndex: 'time',
  7. key: 'time',
  8. align: 'center',
  9. render: (a: any, b: any) => {
  10. return <span style={{fontSize: "12px"}}>{timeUnit === 'hour' ? b?.time : b?.day}</span>
  11. }
  12. },
  13. {
  14. title: '曝光次数',
  15. dataIndex: 'viewCount',
  16. key: 'viewCount',
  17. align: 'center',
  18. sorter: true
  19. },
  20. {
  21. title: '点击次数',
  22. dataIndex: 'clickCount',
  23. key: 'clickCount',
  24. align: 'center',
  25. width: 120,
  26. sorter: true,
  27. render: (a: any, b: any) => {
  28. return <span style={{fontSize: "12px"}}>{a}</span>
  29. }
  30. },
  31. {
  32. title: '点击率',
  33. dataIndex: 'clickRate',
  34. key: 'clickRate',
  35. align: 'center',
  36. sorter: true,
  37. render: (a: any, b: any) => {
  38. return <Statistic value={a ? (a * 100).toFixed(2) : 0} precision={2} valueStyle={{ color: '#3f8600' }} suffix="%" />
  39. }
  40. },
  41. {
  42. title: '下单量',
  43. dataIndex: 'orderCount',
  44. key: 'orderCount',
  45. align: 'center',
  46. sorter: true,
  47. render: (a: any, b: any) => {
  48. return <span style={{fontSize: "12px"}}>{a}</span>
  49. }
  50. },
  51. {
  52. title: '下单率',
  53. dataIndex: 'orderRate',
  54. key: 'orderRate',
  55. align: 'center',
  56. sorter: true,
  57. render: (a: any, b: any) => {
  58. return <Statistic value={a ? (a * 100).toFixed(2) : 0} precision={2} valueStyle={{ color: '#3f8600' }} suffix="%" />
  59. }
  60. },
  61. {
  62. title: '消耗',
  63. dataIndex: 'cost',
  64. key: 'cost',
  65. align: 'center',
  66. sorter: true,
  67. render: (a: any, b: any) => {
  68. return <Statistic value={a || 0} />
  69. }
  70. },
  71. ]
  72. export default columns