tableConfig.tsx 8.0 KB

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