tableConfig.tsx 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import { gameClassifyEnum } from "@/components/QueryForm/const"
  2. import WidthEllipsis from "@/components/widthEllipsis"
  3. import { Statistic } from "antd"
  4. import React from "react"
  5. import moment from "moment"
  6. import style from './index.less'
  7. function columns12(): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  8. let defaultStart = 8
  9. const day = Array(90).fill('').map((_item: string, index: number) => {
  10. let field = `daRetention${index + 1}`
  11. let data = {
  12. title: `D${index + 1}`,
  13. dataIndex: field,
  14. label: "D1~Dn",
  15. align: "center",
  16. width: 150,
  17. children: [{
  18. title: `留存率`,
  19. dataIndex: field,
  20. key: 'retained',
  21. align: "center",
  22. width: 125,
  23. render: (a: any, b: any) => {
  24. let date1 = moment()
  25. if (b?.gameName === '总计') {
  26. if (b?.dt) {
  27. date1 = moment(b?.dt)
  28. } else {
  29. date1 = moment()
  30. }
  31. } else {
  32. date1 = moment(b.dt)
  33. }
  34. let dt = moment()
  35. let day = dt.diff(date1, 'day');
  36. if (index <= day) {
  37. let data: any = {}
  38. if (b?.[field]) {
  39. data = b?.[field]
  40. return <div>
  41. <div className={style.dbox}>
  42. <span style={{ color: '#d81b60', fontWeight: 600 }}>
  43. <span>活跃:</span>
  44. <span>{data?.activeRetention}%</span>
  45. </span>
  46. <span style={{ color: '#faad14', fontWeight: 600 }}>
  47. <span>付费:</span>
  48. <span>{data?.paidRetentionRate}%</span>
  49. </span>
  50. <span style={{ color: 'rgb(12,130,16)', fontWeight: 600 }}>
  51. <span>小R:</span>
  52. <span>{data?.smallR}%</span>
  53. </span>
  54. <span style={{ color: '#0f538a', fontWeight: 600 }}>
  55. <span>中R:</span>
  56. <span>{data?.mediumR}%</span>
  57. </span>
  58. <span style={{ color: '#eb2f96', fontWeight: 600 }}>
  59. <span>大R:</span>
  60. <span>{data?.largeR}%</span>
  61. </span>
  62. <span style={{ color: '#2f54eb', fontWeight: 600 }}>
  63. <span>超大R:</span>
  64. <span>{data?.superR}%</span>
  65. </span>
  66. </div>
  67. </div>
  68. }
  69. return <div style={{ height: 126, lineHeight: '126px' }}>--</div>
  70. }
  71. return <div style={{ height: 126, lineHeight: '126px' }}>--</div>
  72. }
  73. }]
  74. }
  75. data['default'] = defaultStart + index
  76. return data
  77. })
  78. return [
  79. {
  80. label: '游戏信息',
  81. data: [
  82. {
  83. title: '游戏名称', dataIndex: 'parentGameName', label: '游戏信息', align: 'center', width: 90, default: 1,
  84. render: (a: string) => (<WidthEllipsis value={a} />)
  85. },
  86. { title: '游戏ID', dataIndex: 'parentGameId', label: '游戏信息', align: 'center', width: 90 },
  87. {
  88. title: '游戏应用类型', dataIndex: 'parentGameClassify', label: '游戏信息', align: 'center', width: 80, default: 2,
  89. render: (a: string) => (<WidthEllipsis value={gameClassifyEnum[a]} />)
  90. },
  91. {
  92. title: '区服名称', dataIndex: 'serverName', label: '游戏信息', align: 'center', width: 90, default: 3,
  93. render: (a: string) => (<WidthEllipsis value={a} />)
  94. },
  95. { title: '区服ID', dataIndex: 'serverId', label: '游戏信息', align: 'center', width: 90 },
  96. {
  97. title: '开服时间', dataIndex: 'dt', label: '游戏信息', align: 'center', width: 90, default: 4, sorter: true,
  98. render: (a: any, b: any) => {
  99. if (b.gameName === '总计') {
  100. return '--'
  101. }
  102. return a
  103. }
  104. },
  105. ]
  106. },
  107. {
  108. label: '数据',
  109. data: [
  110. {
  111. title: '新用户人数', dataIndex: 'totalRegNum', label: '数据', align: 'center', width: 70, sorter: true, default: 5,
  112. render: (a: number) => <Statistic value={a || 0} />
  113. },
  114. {
  115. title: '创角人数', dataIndex: 'totalRoleNum', label: '数据', align: 'center', width: 70, sorter: true, default: 6,
  116. render: (a: number) => <Statistic value={a || 0} />
  117. },
  118. {
  119. title: '付费人数', dataIndex: 'totalAmountNum', label: '数据', align: 'center', width: 70, sorter: true, default: 7,
  120. render: (a: number) => <Statistic value={a || 0} />
  121. }
  122. ]
  123. },
  124. {
  125. label: 'D1~Dn',
  126. data: [
  127. ...day
  128. ]
  129. }
  130. ]
  131. }
  132. export default columns12