tableConfig.tsx 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. import { Statistic, Tooltip } from 'antd'
  2. import { ColumnsType } from 'antd/lib/table'
  3. import React from 'react'
  4. import { Link } from 'umi'
  5. function columns() {
  6. let newArr: ColumnsType<any> = [
  7. {
  8. title: '公众号名称',
  9. dataIndex: 'channel',
  10. key: 'channel',
  11. align: 'center',
  12. width: 75,
  13. fixed: 'left',
  14. },
  15. {
  16. title: '投手',
  17. dataIndex: 'pitcher',
  18. key: 'pitcher',
  19. align: 'center',
  20. width: 50,
  21. fixed: 'left',
  22. },
  23. {
  24. title: '期数',
  25. dataIndex: 'stage',
  26. key: 'stage',
  27. align: 'center',
  28. width: 60,
  29. fixed: 'left',
  30. },
  31. {
  32. title: '状态',
  33. dataIndex: 'state',
  34. key: 'state',
  35. align: 'center',
  36. width: 40,
  37. },
  38. {
  39. title: '投放位置',
  40. dataIndex: 'location',
  41. key: 'location',
  42. align: 'center',
  43. width: 40,
  44. },
  45. {
  46. title: '最早消耗日期',
  47. dataIndex: 'start',
  48. key: 'start',
  49. align: 'center',
  50. width: 70,
  51. sorter:true,
  52. },
  53. {
  54. title: '最晚消耗日期',
  55. dataIndex: 'end',
  56. key: 'end',
  57. align: 'center',
  58. width: 70,
  59. sorter:true,
  60. },
  61. {
  62. title: '累计消耗',
  63. dataIndex: 'total_cost',
  64. key: 'total_cost',
  65. align: 'center',
  66. width: 80,
  67. sorter:true,
  68. render: (a: string) => {
  69. return <Statistic value={a || 0} />
  70. }
  71. },
  72. {
  73. title: '累计充值',
  74. dataIndex: 'total_amount',
  75. key: 'total_amount',
  76. align: 'center',
  77. width: 80,
  78. sorter:true,
  79. render: (a: string) => {
  80. return <Statistic value={a || 0} />
  81. }
  82. },
  83. {
  84. title: '总毛利额',
  85. dataIndex: 'profit',
  86. key: 'profit',
  87. align: 'center',
  88. width: 80,
  89. sorter:true,
  90. render: (a: number) => {
  91. return <Statistic value={a || 0} valueStyle={a < 0 ? { color: '#0f990f', fontWeight: 600 } : {}} />
  92. }
  93. },
  94. {
  95. title: '回本率',
  96. dataIndex: 'roi',
  97. key: 'roi',
  98. align: 'center',
  99. width: 70,
  100. sorter:true,
  101. render: (a: number) => {
  102. a = a ? parseFloat((a * 100).toFixed(2)) : 0
  103. return <span style={a <= 8 ? { color: '#0f990f', fontWeight: 600 } : a >= 100 ? { color: 'red', fontWeight: 600 } : {}}> {a + '%'}</span >
  104. },
  105. },
  106. {
  107. title: '总关注人数',
  108. dataIndex: 'follow_user',
  109. key: 'follow_user',
  110. align: 'center',
  111. width: 70,
  112. sorter:true,
  113. render: (a: any) => {
  114. return <Statistic value={a || 0} />
  115. }
  116. },
  117. {
  118. title: '平均关注人数成本',
  119. dataIndex: 'follow_per_cost',
  120. key: 'follow_per_cost',
  121. align: 'center',
  122. width: 90,
  123. sorter:true,
  124. render: (a: string) => {
  125. return <Statistic value={a || 0} />
  126. }
  127. },
  128. {
  129. title: '总充值人数',
  130. dataIndex: 'order_user',
  131. key: 'order_user',
  132. align: 'center',
  133. width: 90,
  134. sorter:true,
  135. render: (a: any) => {
  136. return <Statistic value={a || 0} />
  137. }
  138. },
  139. {
  140. title: '充值转化比率',
  141. dataIndex: 'order_tran_rate',
  142. key: 'order_tran_rate',
  143. align: 'center',
  144. width: 90,
  145. sorter:true,
  146. render: (a: number) => {
  147. return a ? (a * 100)?.toFixed(2) + '%' : '0%'
  148. }
  149. },
  150. {
  151. title: '充值转化成本',
  152. dataIndex: 'order_tran_cost',
  153. key: 'order_tran_cost',
  154. align: 'center',
  155. width:90,
  156. sorter:true,
  157. render: (a: string) => {
  158. return <Statistic value={a || 0} />
  159. }
  160. },
  161. {
  162. title: '今日充值',
  163. dataIndex: 'td_amount',
  164. key: 'td_amount',
  165. align: 'center',
  166. width: 110,
  167. sorter: true,
  168. render: (a: any) => {
  169. return <Statistic value={a || 0} />
  170. }
  171. },
  172. {
  173. title: '昨日充值',
  174. dataIndex: 'yd_amount',
  175. key: 'yd_amount',
  176. align: 'center',
  177. width: 110,
  178. sorter: true,
  179. render: (a: any) => {
  180. return <Statistic value={a || 0} />
  181. }
  182. },
  183. {
  184. title: '前日充值',
  185. dataIndex: 'byd_amount',
  186. key: 'byd_amount',
  187. align: 'center',
  188. width: 110,
  189. sorter: true,
  190. render: (a: any) => {
  191. return <Statistic value={a || 0} />
  192. }
  193. },
  194. {
  195. title: '操作',
  196. dataIndex: 'action',
  197. key: 'action',
  198. align: 'center',
  199. width: 40,
  200. render: (a: any, b: { channel: string }) => {
  201. return <Link to={`/dataStatistics/weChat/advertising?channel=${b.channel}`}>进入</Link>
  202. }
  203. },
  204. ]
  205. return newArr
  206. }
  207. export { columns }