tableConfig.tsx 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. import { message, Progress, Statistic } from 'antd'
  2. import { ColumnsType } from 'antd/lib/table'
  3. import { SortOrder } from 'antd/lib/table/interface'
  4. import React from 'react'
  5. import { getAccApi } from '@/services/dataStatistics/dataCenter'
  6. /**日期table配置 */
  7. function fcolumns(dispatch?: any, pitcherId?: number, userId?: number): any {
  8. return function columns(props?: { sortOrder?: { columnKey: string, order: SortOrder | undefined } }) {
  9. const setChannel = (channel: string) => {
  10. if (dispatch) {
  11. getAccApi({user_id: userId, name: channel, pitcher_id: pitcherId}).then(res => {
  12. if(res && res?.data && res?.data?.length > 0) {
  13. if (res?.data?.findIndex((item: { nick_name: string }) => item?.nick_name === channel) === -1) {
  14. message.error('没有这个公众号的权限')
  15. return
  16. }
  17. } else {
  18. message.error('没有这个公众号的权限')
  19. return
  20. }
  21. dispatch({ type: 'channels', params: { channels: [decodeURI(channel)] } })
  22. window.location.href = '#/dataStatistics/weChat/payTrend'
  23. })
  24. // dispatch({ type: 'channel', params: { channel: decodeURI(channel) } })
  25. }
  26. }
  27. const newArr: ColumnsType<any> = [
  28. {
  29. title: '日期',
  30. dataIndex: 'date',
  31. key: 'date',
  32. align: 'center',
  33. width: 140
  34. },
  35. {
  36. title: '投手',
  37. dataIndex: 'pitcher',
  38. key: 'pitcher',
  39. align: 'center',
  40. width: 50
  41. },
  42. {
  43. title: '公众号名称',
  44. dataIndex: 'channel',
  45. key: 'channel',
  46. align: 'center',
  47. width: 70,
  48. render: (a: string) => {
  49. let newchannel: string = ''
  50. if (a?.length > 1) {
  51. let b = a.split('')
  52. b[1] = '*'
  53. b[2] = '*'
  54. newchannel = b.join('')
  55. }
  56. return <a onClick={() => { setChannel(a) }}>{newchannel || a}</a>
  57. },
  58. },
  59. {
  60. title: '投放位置',
  61. dataIndex: 'type',
  62. key: 'type',
  63. align: 'center',
  64. width: 40,
  65. },
  66. {
  67. title: '期数',
  68. dataIndex: 'stage',
  69. key: 'stage',
  70. align: 'center',
  71. width: 90
  72. },
  73. {
  74. title: '小说',
  75. dataIndex: 'book',
  76. key: 'book',
  77. align: 'center',
  78. ellipsis: true,
  79. width: 70,
  80. render: (str) => {
  81. return <a href={`#/dataStatistics/weChat/todayRanking?bookName=${str}`}>{str}</a>
  82. }
  83. },
  84. {
  85. title: '消耗',
  86. dataIndex: 'cost',
  87. key: 'cost',
  88. align: 'center',
  89. sorter: true,
  90. // sortOrder: (props?.sortOrder?.columnKey === 'cost' && props?.sortOrder?.order) || undefined,
  91. width: 80,
  92. render: (a: number) => {
  93. return <div style={{ height: 25, position: 'relative' }}>
  94. <Progress
  95. strokeColor={{
  96. from: '#108ee9',
  97. to: '#87d068',
  98. }}
  99. status="active"
  100. showInfo={false}
  101. percent={a ? a / 60000 * 100 : 0}
  102. />
  103. {/* style={a >= 10000 ? { background: '#FFDEAD', display: 'block' } : {}} */}
  104. <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>
  105. </div>
  106. },
  107. },
  108. {
  109. title: '曝光量',
  110. dataIndex: 'view_count',
  111. key: 'view_count',
  112. align: 'center',
  113. sorter: true,
  114. // sortOrder: (props?.sortOrder?.columnKey === 'view_count' && props?.sortOrder?.order) || undefined,
  115. width: 70,
  116. render: (a: number) => {
  117. return <Statistic value={a || 0} />
  118. },
  119. },
  120. {
  121. title: '点击量',
  122. dataIndex: 'click_count',
  123. key: 'click_count',
  124. align: 'center',
  125. sorter: true,
  126. // sortOrder: (props?.sortOrder?.columnKey === 'click_count' && props?.sortOrder?.order) || undefined,
  127. width: 70,
  128. render: (a: number) => {
  129. return <Statistic value={a || 0} />
  130. },
  131. },
  132. {
  133. title: '点击率',
  134. dataIndex: 'click_rate',
  135. key: 'click_rate',
  136. align: 'center',
  137. sorter: true,
  138. // sortOrder: (props?.sortOrder?.columnKey === 'click_rate' && props?.sortOrder?.order) || undefined,
  139. width: 70,
  140. render: (a: number) => {
  141. a = a ? parseFloat((a * 100).toFixed(2)) : 0
  142. return <span style={a <= 8 ? { color: '#0f990f', fontWeight: 600 } : a >= 100 ? { color: 'red', fontWeight: 600 } : {}}> {a + '%'}</span >
  143. },
  144. },
  145. {
  146. title: '千次曝光成本',
  147. dataIndex: 'thousand_view_cost',
  148. key: 'thousand_view_cost',
  149. align: 'center',
  150. sorter: true,
  151. // sortOrder: (props?.sortOrder?.columnKey === 'thousand_view_cost' && props?.sortOrder?.order) || undefined,
  152. width: 70,
  153. render: (a: number) => {
  154. return <Statistic value={a || 0} />
  155. },
  156. },
  157. {
  158. title: '新增付费人数',
  159. dataIndex: 'reg_user',
  160. key: 'reg_user',
  161. align: 'center',
  162. sorter: true,
  163. // sortOrder: (props?.sortOrder?.columnKey === 'reg_user' && props?.sortOrder?.order) || undefined,
  164. width: 70,
  165. render: (a: number) => {
  166. return <Statistic value={a || 0} />
  167. },
  168. },
  169. {
  170. title: '新用户充值次数',
  171. dataIndex: 'reg_count',
  172. key: 'reg_count',
  173. align: 'center',
  174. sorter: true,
  175. // sortOrder: (props?.sortOrder?.columnKey === 'reg_count' && props?.sortOrder?.order) || undefined,
  176. width: 90,
  177. render: (a: number) => {
  178. return <Statistic value={a || 0} />
  179. },
  180. },
  181. {
  182. title: '新用户首日充值',
  183. dataIndex: 'first_amount',
  184. key: 'first_amount',
  185. align: 'center',
  186. sorter: true,
  187. // sortOrder: (props?.sortOrder?.columnKey === 'first_amount' && props?.sortOrder?.order) || undefined,
  188. width: 90,
  189. render: (a: number) => {
  190. return <Statistic value={a || 0} />
  191. },
  192. },
  193. {
  194. title: '新用户累计充值',
  195. dataIndex: 'reg_amount',
  196. key: 'reg_amount',
  197. align: 'center',
  198. sorter: true,
  199. // sortOrder: (props?.sortOrder?.columnKey === 'reg_amount' && props?.sortOrder?.order) || undefined,
  200. width: 90,
  201. render: (a: number) => {
  202. return <Statistic value={a || 0} />
  203. },
  204. },
  205. {
  206. title: '首日roi',
  207. dataIndex: 'first_roi',
  208. key: 'first_roi',
  209. align: 'center',
  210. sorter: true,
  211. // sortOrder: (props?.sortOrder?.columnKey === 'first_roi' && props?.sortOrder?.order) || undefined,
  212. width: 60,
  213. render: (a: number) => {
  214. a = a ? parseFloat((a * 100).toFixed(2)) : 0
  215. return <span style={a <= 8 ? { color: '#0f990f', fontWeight: 600 } : a >= 100 ? { color: 'red', fontWeight: 600 } : {}}> {a + '%'}</span >
  216. },
  217. },
  218. {
  219. title: '总回本率',
  220. dataIndex: 'roi',
  221. key: 'roi',
  222. align: 'center',
  223. sorter: true,
  224. // sortOrder: (props?.sortOrder?.columnKey === 'roi' && props?.sortOrder?.order) || undefined,
  225. width: 60,
  226. render: (a: number) => {
  227. a = a ? parseFloat((a * 100).toFixed(2)) : 0
  228. return <span style={a <= 8 ? { color: '#0f990f', fontWeight: 600 } : a >= 100 ? { color: 'red', fontWeight: 600 } : {}}> {a + '%'}</span >
  229. },
  230. },
  231. ]
  232. return newArr
  233. }
  234. }
  235. export default fcolumns