tableConfig.tsx 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. import React from "react"
  2. import { Badge, Space } from "antd"
  3. import { AdStatus, PromotedObjectType, SpeedMode } from "@/services/launchAdq/enum"
  4. import TargetingPopover from "../../components/targetingPopover"
  5. import AdPopover from "../../components/adPopover"
  6. function tableConfig(callback: (data: any, type: 'log' | 'page' | 'copy', allData?: any) => void): any {
  7. return [
  8. {
  9. title: '操作',
  10. dataIndex: 'taskName',
  11. key: 'taskName',
  12. width: 80,
  13. align: 'center',
  14. render: (a: any, b: any) => {
  15. return <Space>
  16. <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback({ taskId: b.id, campaignName: b.campaignName }, 'log', b) }}>日志</a>
  17. <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback({ taskId: b.id, campaignName: b.campaignName }, 'copy') }}>复制</a>
  18. </Space>
  19. }
  20. },
  21. {
  22. title: 'ID',
  23. dataIndex: 'id',
  24. key: 'id',
  25. align: 'center',
  26. width: 50,
  27. },
  28. {
  29. title: '计划名称',
  30. dataIndex: 'campaignName',
  31. key: 'campaignName',
  32. align: 'left',
  33. width: 180,
  34. ellipsis: true,
  35. render: (a: any, b: any) => {
  36. return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
  37. }
  38. },
  39. {
  40. title: '计划类型',
  41. dataIndex: 'campaignType',
  42. key: 'campaignType',
  43. align: 'center',
  44. width: 120,
  45. render: (a: any, b: any) => {
  46. if (a) {
  47. return <span style={{ fontSize: "12px" }}>{a === 'CAMPAIGN_TYPE_NORMAL' ? '普通展示广告' : '微信朋友圈广告'}</span>
  48. } else {
  49. return <span>--</span>
  50. }
  51. }
  52. },
  53. {
  54. title: '广告状态',
  55. dataIndex: 'configuredStatus',
  56. key: 'configuredStatus',
  57. align: 'center',
  58. width: 80,
  59. render: (a: any, b: any) => {
  60. if (a) {
  61. return <span style={{ fontSize: "12px" }}>{AdStatus[a]}</span>
  62. } else {
  63. return <span>--</span>
  64. }
  65. }
  66. },
  67. {
  68. title: '推广目标',
  69. dataIndex: 'promotedObjectType',
  70. key: 'promotedObjectType',
  71. align: 'center',
  72. width: 100,
  73. render: (a: any, b: any) => {
  74. if (a) {
  75. return <span style={{ fontSize: "12px" }}>{PromotedObjectType[a]}</span>
  76. } else {
  77. return <span>--</span>
  78. }
  79. }
  80. },
  81. {
  82. title: '投放速度模式',
  83. dataIndex: 'speedMode',
  84. key: 'speedMode',
  85. align: 'center',
  86. width: 90,
  87. render: (a: any, b: any) => {
  88. if (a) {
  89. return <span style={{ fontSize: "12px" }}>{SpeedMode[a]}</span>
  90. } else {
  91. return <span>--</span>
  92. }
  93. }
  94. },
  95. {
  96. title: '广告',
  97. dataIndex: 'sysAdgroupId',
  98. key: 'sysAdgroupId',
  99. align: 'center',
  100. width: 90,
  101. ellipsis: true,
  102. render: (a: any, b: any) => {
  103. if (a) {
  104. return <AdPopover name={b?.sysAdgroup?.adgroupName} id={a} />
  105. } else {
  106. return <span>--</span>
  107. }
  108. }
  109. },
  110. {
  111. title: '定向ID',
  112. dataIndex: 'sysTargetingId',
  113. key: 'sysTargetingId',
  114. align: 'center',
  115. width: 80,
  116. render: (a: any, b: any) => {
  117. if (a) {
  118. return <Space><span style={{ fontSize: "12px" }}>{a}</span><TargetingPopover id={b.sysTargetingId} /></Space>
  119. } else {
  120. return <span>--</span>
  121. }
  122. }
  123. },
  124. {
  125. title: '创建时间',
  126. dataIndex: 'createTime',
  127. key: 'createTime',
  128. align: 'center',
  129. width: 140,
  130. render: (a: any, b: any) => {
  131. return <span style={{ fontSize: "12px" }}>{a || '--'}</span>
  132. }
  133. },
  134. {
  135. title: <span style={{ marginLeft: 10 }}>任务反馈</span>,
  136. dataIndex: 'total',
  137. key: 'total',
  138. render: (a: any, b: any) => {
  139. let errCount = a - (b?.successCount || 0)
  140. return <Space style={{ fontSize: "12px", marginLeft: 10 }} size={20}>
  141. <span><Badge status="processing" />总条数:{a}条</span>
  142. {<span><Badge status="success" />成功数:{b?.successCount || 0}条</span> }
  143. {/* {errCount ? <span><Badge status="error" />创建中:{errCount}条</span> : null} */}
  144. </Space>
  145. }
  146. }
  147. ]
  148. }
  149. export default tableConfig