tableConfig.tsx 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417
  1. import WidthEllipsis from "@/components/widthEllipsis"
  2. import { Statistic } from "antd"
  3. import React from "react"
  4. import { version } from "../../components/TableData"
  5. import moment from "moment"
  6. import style from '../../extensionData/everyday/index.less'
  7. function columns12(): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  8. const roiC = Array(29).fill('').map((_item: string, index: number) => {
  9. let data = {
  10. title: `${index + 2}日ROI`,
  11. dataIndex: `roi${index + 2}`,
  12. label: '付费数据',
  13. align: 'center',
  14. width: 80,
  15. sorter: true,
  16. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  17. }
  18. index++;
  19. return data
  20. })
  21. let defaultValue = [ // 默认展示字段
  22. { label: '充值人数', key: 'rechargeUserCount', type: '付费趋势' },
  23. { label: '充值金额', key: 'rechargeMoney', type: '付费趋势' },
  24. { label: '增', key: 'increase', type: '付费趋势' },
  25. { label: '回', key: 'back', type: '付费趋势' },
  26. { label: '倍', key: 'multiples', type: '付费趋势' },
  27. ]
  28. const getFieldDta = () => {
  29. let mySelectFieldData = localStorage.getItem(`myAdFieldConfig${version}_投手推广每日数据`)
  30. let newSelectFieldData: any = {}
  31. if (mySelectFieldData) {
  32. newSelectFieldData = JSON.parse(mySelectFieldData).date_field
  33. } else {
  34. newSelectFieldData = defaultValue
  35. }
  36. return newSelectFieldData
  37. }
  38. // 总付费趋势
  39. let defaultStart = 16
  40. const zC = Array(90).fill('').map((_item: string, index: number) => {
  41. let field = `amountD${index + 1}Trend`
  42. let data = {
  43. title: `D${index + 1}`,
  44. dataIndex: `D${index + 1}`,
  45. label: "时间区间跨度",
  46. width: 110,
  47. render: (a: any, b: any) => {
  48. let date1 = moment()
  49. if (b?.pitcher === '总计') {
  50. if (b?.beginDay) {
  51. date1 = moment(b.beginDay)
  52. } else {
  53. date1 = moment()
  54. }
  55. } else {
  56. date1 = moment(b.dt)
  57. }
  58. let dt = moment()
  59. let day = dt.diff(date1, 'day');
  60. let fieldData = getFieldDta()
  61. if (fieldData?.length > 0 && index <= day) {
  62. let data: any = {}
  63. let keyS: string[] = fieldData?.map((item: any) => item.key)
  64. switch (fieldData[0].type) {
  65. case '付费趋势':
  66. if (b?.[field]) {
  67. data = b?.[field]
  68. return <div className={style.dbox}>
  69. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  70. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  71. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  72. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  73. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  74. </div>
  75. }
  76. return '--'
  77. }
  78. }
  79. return '--'
  80. },
  81. }
  82. if (index < 30) {
  83. data['default'] = defaultStart + index
  84. }
  85. return data
  86. })
  87. // let mDefaultStart = 109, count = 0
  88. const Mc = [4, 5, 6, 7, 8, 9, 10, 11, 12].map(index => {
  89. let field = `amountM${index}Trend`
  90. let data = {
  91. title: `M${index}`,
  92. dataIndex: `M${index}`,
  93. label: "时间区间跨度",
  94. width: 110,
  95. render: (a: any, b: any) => {
  96. let date1 = moment()
  97. if (b?.pitcher === '总计') {
  98. if (b?.beginDay) {
  99. date1 = moment(b.beginDay)
  100. } else {
  101. date1 = moment()
  102. }
  103. } else {
  104. date1 = moment(b.dt)
  105. }
  106. let dt = moment()
  107. let day = dt.diff(date1, 'day');
  108. let fieldData = getFieldDta()
  109. if (fieldData?.length > 0 && index * 30 <= day) {
  110. let data: any = {}
  111. let keyS: string[] = fieldData?.map((item: any) => item.key)
  112. switch (fieldData[0].type) {
  113. case '付费趋势':
  114. if (b?.[field]) {
  115. data = b?.[field]
  116. return <div className={style.dbox}>
  117. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  118. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  119. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  120. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  121. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  122. </div>
  123. }
  124. return '--'
  125. }
  126. }
  127. return '--'
  128. },
  129. }
  130. // data['default'] = mDefaultStart + count
  131. // count++;
  132. return data
  133. })
  134. Mc.push({
  135. title: "总",
  136. default: 46,
  137. dataIndex: "amountSumTrend",
  138. label: "时间区间跨度",
  139. align: "center",
  140. width: 110,
  141. render: (a: any, b: any) => {
  142. let fieldData = getFieldDta()
  143. if (fieldData?.length > 0) {
  144. let data: any = {}
  145. let keyS: string[] = fieldData?.map((item: any) => item.key)
  146. switch (fieldData[0].type) {
  147. case '付费趋势':
  148. if (a) {
  149. data = a
  150. return <div className={style.dbox}>
  151. {keyS?.includes('rechargeUserCount') && <span style={{ color: '#d81b60', fontWeight: 600 }}>充人:<span>{data?.rechargeUserCount}</span></span>}
  152. {keyS?.includes('rechargeMoney') && <span style={{ color: '#0f538a', fontWeight: 600 }}>充金:<span><Statistic value={data?.rechargeMoney || 0} valueStyle={{ color: '#0f538a', fontWeight: 600 }} /></span></span>}
  153. {keyS?.includes('increase') && <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>增:<span>{(data?.increase * 100)?.toFixed(2)}%</span></span>}
  154. {keyS?.includes('back') && <span style={{ color: '#ff5722', fontWeight: 600 }}>回:<span>{(data?.back * 100)?.toFixed(2)}%</span></span>}
  155. {keyS?.includes('multiples') && <span style={{ color: '#d81b60', fontWeight: 600 }}>倍:<span>{data?.multiples?.toFixed(2)}</span></span>}
  156. </div>
  157. }
  158. return '--'
  159. }
  160. }
  161. return '--'
  162. },
  163. } as any)
  164. return [
  165. {
  166. label: '基本信息',
  167. data: [
  168. {
  169. title: '投手', dataIndex: 'pitcher', label: '基本信息', align: 'center', width: 95, default: 1,
  170. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  171. },
  172. {
  173. title: '推广媒体', dataIndex: 'accountType', label: '基本信息', align: 'center', width: 95, default: 2,
  174. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  175. },
  176. {
  177. title: '时间', dataIndex: 'dt', label: '基本信息', align: 'center', width: 110, default: 3, sorter: true,
  178. render: (a: string, b: any) => (<WidthEllipsis value={a} />)
  179. },
  180. {
  181. title: '消耗', dataIndex: 'cost', label: '基本信息', align: 'center', width: 70, default: 4, sorter: true,
  182. render: (a: string) => <Statistic value={a || 0} />
  183. },
  184. {
  185. title: '推广账号数量', dataIndex: 'accountCount', label: '基本信息', align: 'center', width: 80, sorter: true,
  186. render: (a: string) => <Statistic value={a || 0} />
  187. },
  188. {
  189. title: '推广渠道数量', dataIndex: 'agentCount', label: '基本信息', align: 'center', width: 70, sorter: true,
  190. render: (a: string) => <Statistic value={a || 0} />
  191. },
  192. {
  193. title: '推广计划数量', dataIndex: 'planCount', label: '基本信息', align: 'center', width: 70, sorter: true,
  194. render: (a: string) => <Statistic value={a || 0} />
  195. }
  196. ]
  197. },
  198. {
  199. label: '用户数据',
  200. data: [
  201. {
  202. title: '注册人数', dataIndex: 'registerNum', label: '用户数据', align: 'center', width: 70, sorter: true, default: 5,
  203. render: (a: string) => <Statistic value={a || 0} />
  204. },
  205. {
  206. title: '注册成本', dataIndex: 'registerCost', label: '用户数据', align: 'center', width: 70, sorter: true, default: 6,
  207. render: (a: string) => <Statistic value={a || 0} />
  208. },
  209. {
  210. title: '创角人数', tips: '包含新老用户创角', dataIndex: 'roleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  211. render: (a: string) => <Statistic value={a || 0} />
  212. },
  213. {
  214. title: '首日创角人数', dataIndex: 'firstRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  215. render: (a: string) => <Statistic value={a || 0} />
  216. },
  217. {
  218. title: '新用户累计创角人数', dataIndex: 'newUserTotalRoleNum', label: '用户数据', align: 'center', width: 100, sorter: true,
  219. render: (a: string) => <Statistic value={a || 0} />
  220. },
  221. {
  222. title: '首日创角成本', dataIndex: 'firstRoleCost', label: '用户数据', align: 'center', width: 70, sorter: true,
  223. render: (a: string) => <Statistic value={a || 0} />
  224. },
  225. {
  226. title: '新用户累计创角成本', dataIndex: 'newUserTotalRoleCost', label: '用户数据', align: 'center', width: 70, sorter: true,
  227. render: (a: string) => <Statistic value={a || 0} />
  228. },
  229. // {
  230. // title: '创角量', dataIndex: 'roleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  231. // render: (a: string) => <Statistic value={a || 0} />
  232. // },
  233. // {
  234. // title: '首日创角量', dataIndex: 'firstRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  235. // render: (a: string) => <Statistic value={a || 0} />
  236. // },
  237. // {
  238. // title: '新用户累计创角量', dataIndex: 'newUserTotalRoleNum', label: '用户数据', align: 'center', width: 70, sorter: true,
  239. // render: (a: string) => <Statistic value={a || 0} />
  240. // },
  241. {
  242. title: '首日创角率', dataIndex: 'firstRoleRate', label: '用户数据', align: 'center', width: 70, sorter: true,
  243. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 50 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  244. },
  245. {
  246. title: '新用户创角率', tips: '新用户累计创角人数/注册人数', dataIndex: 'newUserTotalRoleRate', label: '用户数据', align: 'center', width: 70, sorter: true,
  247. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 50 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  248. }
  249. ]
  250. },
  251. {
  252. label: '付费数据',
  253. data: [
  254. {
  255. title: '首日新用户充值次数', dataIndex: 'firstNewUserAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  256. render: (a: string) => <Statistic value={a || 0} />
  257. },
  258. {
  259. title: '首日新用户充值人数', dataIndex: 'firstNewUserAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 7,
  260. render: (a: string) => <Statistic value={a || 0} />
  261. },
  262. {
  263. title: '首日新用户充值金额', dataIndex: 'firstNewUserAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 8,
  264. render: (a: string) => <Statistic value={a || 0} />
  265. },
  266. {
  267. title: '老用户充值次数', dataIndex: 'oldAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  268. render: (a: string) => <Statistic value={a || 0} />
  269. },
  270. {
  271. title: '老用户充值人数', dataIndex: 'oldAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  272. render: (a: string) => <Statistic value={a || 0} />
  273. },
  274. {
  275. title: '老用户充值金额', dataIndex: 'oldAmount', label: '付费数据', align: 'center', width: 70, sorter: true,
  276. render: (a: string) => <Statistic value={a || 0} />
  277. },
  278. {
  279. title: '账面充值次数', dataIndex: 'amountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  280. render: (a: string) => <Statistic value={a || 0} />
  281. },
  282. {
  283. title: '账面充值人数', dataIndex: 'amountNum', label: '付费数据', align: 'center', width: 70, sorter: true,
  284. render: (a: string) => <Statistic value={a || 0} />
  285. },
  286. {
  287. title: '账面充值金额', dataIndex: 'amount', label: '付费数据', align: 'center', width: 70, sorter: true,
  288. render: (a: string) => <Statistic value={a || 0} />
  289. },
  290. {
  291. title: '新用户累计充值次数', dataIndex: 'buyNewUserTotalAmountCount', label: '付费数据', align: 'center', width: 70, sorter: true,
  292. render: (a: string) => <Statistic value={a || 0} />
  293. },
  294. {
  295. title: '新用户累计充值人数', dataIndex: 'buyNewUserTotalAmountNum', label: '付费数据', align: 'center', width: 70, sorter: true, default: 9,
  296. render: (a: string) => <Statistic value={a || 0} />
  297. },
  298. {
  299. title: '新用户累计充值金额', dataIndex: 'buyNewUserTotalAmount', label: '付费数据', align: 'center', width: 70, sorter: true, default: 10,
  300. render: (a: string) => <Statistic value={a || 0} />
  301. },
  302. {
  303. title: '首日ROI', tips: '首日新用户充值金额/实际消耗', dataIndex: 'firstRoi', label: '付费数据', align: 'center', width: 70, sorter: true, default: 11,
  304. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  305. },
  306. {
  307. title: '毛利额', dataIndex: 'grossProfit', label: '付费数据', align: 'center', width: 70, sorter: true,
  308. render: (a: number) => <Statistic value={a} precision={2} valueStyle={a < 0 ? { color: 'red' } : {}} />
  309. },
  310. {
  311. title: '至今回收率', tips: '新用户累计充值金额/实际消耗', dataIndex: 'todayRoi', label: '付费数据', align: 'center', width: 70, sorter: true,
  312. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  313. },
  314. ...roiC,
  315. {
  316. title: '60日ROI', dataIndex: 'roi60', label: '付费数据', align: 'center', width: 80, sorter: true,
  317. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 0.9 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  318. },
  319. {
  320. title: '90日ROI', dataIndex: 'roi90', label: '付费数据', align: 'center', width: 80, sorter: true,
  321. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  322. },
  323. {
  324. title: '180日ROI', dataIndex: 'roi180', label: '付费数据', align: 'center', width: 80, sorter: true,
  325. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  326. },
  327. {
  328. title: '1年ROI', dataIndex: 'roi1yaer', label: '付费数据', align: 'center', width: 80, sorter: true,
  329. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  330. },
  331. {
  332. title: '总ROI', dataIndex: 'todayRoi', label: '付费数据', align: 'center', width: 80, default: 12, sorter: true,
  333. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  334. },
  335. {
  336. title: '首日付费率', tips: '首日新用户充值人数/注册人数', dataIndex: 'firstRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  337. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  338. },
  339. {
  340. title: '至今付费率', tips: '至今付费率(总)=新用户累计充值人数/注册人数', dataIndex: 'todayRate', label: '付费数据', align: 'center', width: 80, sorter: true,
  341. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  342. },
  343. {
  344. title: '新用户付费比', tips: '首日新用户充值人数/账面充值人数', dataIndex: 'newUserAmountRatio', label: '付费数据', align: 'center', width: 70, sorter: true,
  345. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  346. },
  347. {
  348. title: '首日客单价', tips: '首日新用户充值金额/首日新用户充值次数', dataIndex: 'firstAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  349. render: (a: string) => <Statistic value={a || 0} />
  350. },
  351. {
  352. title: '至今客单价', dataIndex: 'buyAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  353. render: (a: string) => <Statistic value={a || 0} />
  354. },
  355. {
  356. title: '账面客单价', tips: '账面充值金额/账面充值次数', dataIndex: 'paperAvg', label: '付费数据', align: 'center', width: 70, sorter: true,
  357. render: (a: string) => <Statistic value={a || 0} />
  358. },
  359. {
  360. title: '首日充值成本', tips: '实际消耗/首日新用户充值人数', dataIndex: 'firstAmountCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 13,
  361. render: (a: string) => <Statistic value={a || 0} />
  362. },
  363. {
  364. title: '至今充值成本', dataIndex: 'todayAmountCost', label: '付费数据', align: 'center', width: 70, sorter: true, default: 14,
  365. render: (a: string) => <Statistic value={a || 0} />
  366. },
  367. {
  368. title: '至今复充率', tips: '新用户复充人数/新用户累计充值人数(新用户复充人数为累计值充值次数n≥2)', dataIndex: 'todayAgainRate', label: '付费数据', align: 'center', width: 70, sorter: true,
  369. render: (a: number) => <Statistic value={a ? a * 100 : 0} precision={2} valueStyle={!a ? {} : a >= 1 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  370. },
  371. {
  372. title: '新增注册ARPPU', tips: '新用户累计充值金额/注册人数', dataIndex: 'newRegArpu', label: '付费数据', align: 'center', width: 70, sorter: true, default: 15,
  373. render: (a: string) => <Statistic value={a || 0} />
  374. },
  375. {
  376. title: '首日付费ARPPU', tips: '首日新用户充值金额/首日新用户充值人数', dataIndex: 'firstArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  377. render: (a: string) => <Statistic value={a || 0} />
  378. },
  379. {
  380. title: '至今付费ARPPU', tips: '新用户累计充值金额/新用户累计充值人数', dataIndex: 'todayArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  381. render: (a: string) => <Statistic value={a || 0} />
  382. },
  383. {
  384. title: '账面ARPPU', dataIndex: 'paperArpu', label: '付费数据', align: 'center', width: 70, sorter: true,
  385. render: (a: string) => <Statistic value={a || 0} />
  386. }
  387. ]
  388. },
  389. {
  390. fieldSHow: {
  391. label: '日期区间字段展示',
  392. saveField: 'date_field',
  393. defaultValue,
  394. data: [
  395. {
  396. label: '付费趋势',
  397. data: defaultValue
  398. },
  399. ]
  400. },
  401. label: '时间区间跨度',
  402. data: [
  403. ...zC,
  404. ...Mc
  405. ]
  406. }
  407. ]
  408. }
  409. export default columns12