tableConfig.tsx 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import WidthEllipsis from "@/components/widthEllipsis"
  2. import { Progress, Statistic } from "antd"
  3. import React from "react"
  4. import { AdUnitType_Enum, PRODUCT_TYPE_ENUM } from "../../../const"
  5. import style from './index.less'
  6. import moment from "moment"
  7. import { ACCOUNTTYPE, APPTYPE } from "@/pages/iaaSystem/manage/const"
  8. function columns12(): { label: string, fieldSHow?: { label: string, saveField: string, defaultValue: any[], data: any[] }, data: any[] }[] {
  9. const defaultIndex = 23
  10. const trend = [1, 2, 3, 4, 5, 6, 7, 14, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 365].map((index, count) => {
  11. const dataIndex = `da${index}`
  12. return {
  13. title: `D${index}`, dataIndex, label: '基本信息', default: defaultIndex + count, width: 300, children: [
  14. {
  15. title: "",
  16. key: "left" + index,
  17. width: 150,
  18. align: 'center',
  19. render: (_: any, b: any) => {
  20. if (moment().subtract(1, 'days') >= moment(b.dt === '总计' ? b.costDayBegin : b.dt).add(index - 1, 'days')) {
  21. const data = b?.[dataIndex]?.split('/')
  22. return <div className={style.newbox} >
  23. <span style={{ color: '#F44336', fontWeight: 600, }}>变现人数:<span><Statistic value={data?.[0] || 0} /></span></span>
  24. <span style={{ color: '#FF9800', fontWeight: 600, }}>变现次数:<span><Statistic value={data?.[1] || 0} /></span></span>
  25. <span style={{ color: '#d81b60', fontWeight: 600, }}>新增收入:<span><Statistic value={data?.[2] || 0} precision={2} /></span></span>
  26. <span style={{ color: '#0f538a', fontWeight: 600, }}>累计收入:<span><Statistic value={data?.[3] || 0} precision={2} /></span></span>
  27. {index < 8 && <span style={{ color: '#ed2a78', fontWeight: 600, }}>价值:<span><Statistic value={data?.[9] || 0} precision={2} /></span></span>}
  28. </div>
  29. }
  30. return <div style={{ height: 102, width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>--</div>
  31. }
  32. },
  33. {
  34. title: "",
  35. key: "right" + index,
  36. width: 150,
  37. align: 'center',
  38. render: (_: any, b: any) => {
  39. if (moment().subtract(1, 'days') >= moment(b.dt === '总计' ? b.costDayBegin : b.dt).add(index - 1, 'days')) {
  40. const data = b?.[dataIndex]?.split('/')
  41. return <div className={style.newbox}>
  42. <span style={{ color: '#9C27B0', fontWeight: 600, }}>ARPU:<span><Statistic value={data?.[7] || 0} precision={2} /></span></span>
  43. <span style={{ color: '#2196F3', fontWeight: 600, }}>ARPPU<span><Statistic value={data?.[8] || 0} precision={2} /></span></span>
  44. <span style={{ color: 'rgb(12,130,16)', fontWeight: 600, }}>增:<span><Statistic value={data?.[4] ? data?.[4] * 100 : 0} precision={2} valueStyle={!data?.[4] ? {} : data?.[4] >= 0.5 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" /></span></span>
  45. <span style={{ color: '#ff5722', fontWeight: 600, }}>回:<span><Statistic value={data?.[5] ? data?.[5] * 100 : 0} precision={2} valueStyle={!data?.[5] ? {} : data?.[5] >= 0.5 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" /></span></span>
  46. <span style={{ color: '#d81b60', fontWeight: 600, }}>倍:<span><Statistic value={data?.[6] || 0} precision={2} /></span></span>
  47. </div>
  48. }
  49. return <div style={{ height: 102, width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center' }}>--</div>
  50. }
  51. },
  52. ]
  53. }
  54. })
  55. return [
  56. {
  57. label: '基本信息',
  58. data: [
  59. {
  60. title: '日期', dataIndex: 'dt', label: '基本信息', align: 'center', width: 80, default: 1,
  61. render: (a: string) => (<WidthEllipsis value={a} />)
  62. },
  63. {
  64. title: '应用', dataIndex: 'appName', label: '基本信息', align: 'center', width: 120, default: 2,
  65. render: (a: string) => (<WidthEllipsis value={a} />)
  66. },
  67. {
  68. title: '应用ID', dataIndex: 'iaaAppId', label: '基本信息', align: 'center', width: 80,
  69. render: (a: string) => (<WidthEllipsis value={a} />)
  70. },
  71. {
  72. title: '小程序名称', dataIndex: 'mpName', label: '基本信息', align: 'center', width: 85, default: 3,
  73. render: (a: string) => (<WidthEllipsis value={a} />)
  74. },
  75. {
  76. title: '小程序ID', dataIndex: 'mpId', label: '基本信息', align: 'center', width: 80,
  77. render: (a: string) => (<WidthEllipsis value={a} />)
  78. },
  79. {
  80. title: '账号归属', dataIndex: 'adUnitType', label: '基本信息', align: 'center', width: 80,
  81. render: (a: string) => (<WidthEllipsis value={AdUnitType_Enum[a as keyof typeof AdUnitType_Enum]} />)
  82. },
  83. {
  84. title: '业务类型', dataIndex: 'productType', label: '基本信息', align: 'center', width: 80, default: 4,
  85. render: (a: string) => (<WidthEllipsis value={PRODUCT_TYPE_ENUM[a as keyof typeof PRODUCT_TYPE_ENUM]} />)
  86. },
  87. {
  88. title: '应用类型', dataIndex: 'appType', label: '基本信息', align: 'center', width: 80, default: 5,
  89. render: (a: string) => (<WidthEllipsis value={APPTYPE[a as keyof typeof APPTYPE]?.text} />)
  90. },
  91. {
  92. title: '消耗', dataIndex: 'cost', label: '基本信息', align: 'right', width: 125, default: 6, sorter: true,
  93. className: 'padding_0',
  94. render: (a: number) => <div style={{ height: 107, position: 'relative' }}>
  95. <Progress
  96. strokeColor={{
  97. from: '#ff5900',
  98. to: '#ffd380',
  99. }}
  100. status="active"
  101. showInfo={false}
  102. percent={a ? a / 20000 * 100 : 0}
  103. />
  104. <span style={{ position: 'absolute', left: '50%', top: '50%', width: '100%', padding: '0 5px', transform: 'translate(-50%, -50%)' }}><Statistic value={a || 0} precision={2} valueStyle={a >= 20000 ? { color: '#000', fontWeight: 'bold' } : { fontWeight: 'bold' }} /></span>
  105. </div>
  106. },
  107. {
  108. title: '广告变现成本', dataIndex: 'adMonetizationCost', label: '基本信息', align: 'right', width: 110, default: 7, sorter: true,
  109. render: (a: number) => <Statistic value={a || 0} precision={2} />
  110. },
  111. {
  112. title: '广告变现人数', dataIndex: 'appAdPayingUsers', label: '基本信息', align: 'center', width: 110, default: 8, sorter: true,
  113. render: (a: number) => <Statistic value={a || 0} />
  114. },
  115. {
  116. title: '广告变现arpu', dataIndex: 'arpu', label: '基本信息', align: 'center', width: 110, default: 9, sorter: true,
  117. render: (a: number) => <Statistic value={a || 0} precision={2} />
  118. },
  119. {
  120. title: '广告变现arppu', dataIndex: 'arppu', label: '基本信息', align: 'center', width: 120, default: 10, sorter: true,
  121. render: (a: number) => <Statistic value={a || 0} precision={2} />
  122. },
  123. {
  124. title: '广告变现金额', dataIndex: 'appAdPayingAmount', label: '基本信息', align: 'center', width: 110, default: 11, sorter: true,
  125. render: (a: number) => <Statistic value={a || 0} precision={2} />
  126. },
  127. {
  128. title: '广告变现roi', dataIndex: 'appAdPayingRoi', label: '基本信息', align: 'center', width: 105, default: 12, sorter: true,
  129. render: (a: number) => <Statistic value={a ? (a * 100).toFixed(2) : 0} precision={2} valueStyle={!a ? {} : a >= 0.5 ? { color: 'red' } : { color: '#0f990f' }} suffix="%" />
  130. },
  131. {
  132. title: '注册人数', dataIndex: 'regDedupPv', label: '基本信息', align: 'center', width: 80, default: 13, sorter: true,
  133. render: (a: number, b: any) => <Statistic value={a || 0} />
  134. },
  135. ...trend
  136. ]
  137. }
  138. ]
  139. }
  140. export default columns12