tableConfig.tsx 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451
  1. import React from "react"
  2. import { Badge, Popover, Space, TableProps, Tag, Typography } from "antd"
  3. import { AD_STATUS_ENUM, DELIVERY_MODE_ENUM, DYNAMIC_CREATIVE_TYPE_ENUM, MARKETING_GOAL_ENUM } from "../const"
  4. import TargetingTooltip from "../../components/TargetingTooltip"
  5. import { QuestionCircleFilled } from "@ant-design/icons"
  6. import AdgroupTooltip from "../../components/AdgroupTooltip"
  7. import DynamicTooltip from "../../components/DynamicTooltip"
  8. import { copy } from "@/utils/utils"
  9. const columns = (geoLocationList: any, modelList: any, callback: (data: any, type: 'log' | 'page' | 'copy' | 'zxLog', allData?: any) => void): TableProps<any>['columns'] => {
  10. return [
  11. {
  12. title: '操作',
  13. dataIndex: 'cz',
  14. key: 'cz',
  15. width: 130,
  16. fixed: 'left',
  17. render: (_, records) => {
  18. return <Space>
  19. <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback(records, 'log', records) }}>日志</a>
  20. <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback(records, 'copy') }}>复制</a>
  21. {records?.submitRule && <>
  22. <a style={{ color: '#1890ff', fontSize: 12 }} onClick={() => { callback(records, 'zxLog') }}>执行记录</a>
  23. </>}
  24. </Space>
  25. }
  26. },
  27. {
  28. title: '任务类型',
  29. dataIndex: 'taskType',
  30. key: 'taskType',
  31. width: 50,
  32. align: 'center',
  33. fixed: 'left',
  34. render(value) {
  35. return value === 'GAME' ? '游戏' : '小说'
  36. },
  37. },
  38. {
  39. title: '任务广告状态',
  40. dataIndex: 'status',
  41. key: 'status',
  42. width: 80,
  43. align: 'center',
  44. fixed: 'left',
  45. render(value) {
  46. let a = {
  47. 0: <Badge status="processing" text={<span style={{ fontSize: 12 }} >执行中</span>} />,
  48. 1: <Badge style={{ fontSize: 12 }} status="error" text={<span style={{ fontSize: 12 }} >全部失败</span>} />,
  49. 2: <Badge style={{ fontSize: 12 }} status="warning" text={<span style={{ fontSize: 12 }} >部分成功</span>} />,
  50. 100: <Badge style={{ fontSize: 12 }} status="success" text={<span style={{ fontSize: 12 }} >全部成功</span>} />,
  51. '-2': <Badge style={{ fontSize: 12 }} status="error" text={<span style={{ fontSize: 12 }} >任务终止</span>} />,
  52. }
  53. return a[value as keyof typeof a]
  54. },
  55. },
  56. {
  57. title: '任务名称',
  58. dataIndex: 'taskName',
  59. key: 'taskName',
  60. width: 120,
  61. ellipsis: true,
  62. fixed: 'left',
  63. render(value) {
  64. return <span style={{ fontSize: 12 }}>{value}</span>
  65. }
  66. },
  67. {
  68. title: '任务提交规则',
  69. dataIndex: 'submitRule',
  70. key: 'submitRule',
  71. width: 80,
  72. align: 'center',
  73. render(value) {
  74. let a = { 0: <Tag color="#108ee9"><span style={{ fontSize: 12 }} >默认</span></Tag>, 1: <Tag color="#f50"><span style={{ fontSize: 12 }} >立即提交</span></Tag>, 2: <Tag color="#2db7f5"><span style={{ fontSize: 12 }} >定时提交</span></Tag>, 3: <Tag color="#87d068"><span style={{ fontSize: 12 }} >分批提交</span></Tag> }
  75. return a[value as keyof typeof a] || '--'
  76. },
  77. },
  78. {
  79. title: 'ID',
  80. dataIndex: 'id',
  81. key: 'id',
  82. align: 'center',
  83. width: 70,
  84. ellipsis: true,
  85. render(value) {
  86. return <span style={{ fontSize: 12 }}>{value}</span>
  87. }
  88. },
  89. {
  90. title: '广告状态',
  91. dataIndex: 'configuredStatus',
  92. key: 'configuredStatus',
  93. align: 'center',
  94. width: 50,
  95. render: (_, b) => {
  96. let configuredStatus = b?.adgroupDTO?.configuredStatus
  97. if (configuredStatus) {
  98. return <span style={{ fontSize: "12px" }}>{AD_STATUS_ENUM[configuredStatus as keyof typeof AD_STATUS_ENUM]}</span>
  99. } else {
  100. return <span>--</span>
  101. }
  102. }
  103. },
  104. {
  105. title: '广告详情',
  106. dataIndex: 'adgroupDTO',
  107. key: 'adgroupDTO',
  108. width: 200,
  109. ellipsis: true,
  110. render(value, records) {
  111. return <div style={{ width: '100%', display: 'flex', alignItems: 'center' }}>
  112. <div style={{ width: 'calc(100% - 20px)' }}><Typography.Text style={{ fontSize: 12 }} ellipsis={{ tooltip: true }}>{value?.adgroupName}</Typography.Text></div>
  113. <Popover
  114. placement="right"
  115. overlayInnerStyle={{ maxWidth: 350, maxHeight: 350, overflow: 'hidden', overflowY: 'auto' }}
  116. mouseEnterDelay={0.5}
  117. content={<AdgroupTooltip
  118. taskType={records?.taskType}
  119. data={value}
  120. />}
  121. >
  122. <QuestionCircleFilled style={{ fontSize: 12 }} />
  123. </Popover>
  124. </div>
  125. }
  126. },
  127. {
  128. title: '定向详情',
  129. dataIndex: 'targetings',
  130. key: 'targetings',
  131. width: 300,
  132. render(value, records) {
  133. return <div style={{ width: '100%', display: 'flex', alignItems: 'center', gap: 10, overflow: 'hidden', overflowX: 'auto' }}>
  134. {value?.map((item: any, index: number) => <Popover
  135. key={index}
  136. placement="right"
  137. overlayInnerStyle={{ maxWidth: 350, maxHeight: 350, overflow: 'hidden', overflowY: 'auto' }}
  138. mouseEnterDelay={1}
  139. content={<TargetingTooltip
  140. data={item}
  141. geoLocationList={geoLocationList}
  142. modelList={modelList}
  143. taskType={records?.taskType}
  144. />}
  145. >
  146. <div style={{ width: 80, cursor: 'help' }}><Typography.Text style={{ fontSize: 12 }} ellipsis>{index + 1}、{item?.targetingName || '--'}</Typography.Text></div>
  147. </Popover>)}
  148. </div>
  149. }
  150. },
  151. {
  152. title: '创意详情',
  153. dataIndex: 'dynamicCreativesDTO',
  154. key: 'dynamicCreativesDTO',
  155. width: 200,
  156. ellipsis: true,
  157. render(value) {
  158. return <div style={{ width: '100%', display: 'flex', alignItems: 'center' }}>
  159. <div style={{ width: 'calc(100% - 20px)' }}><Typography.Text style={{ fontSize: 12 }} ellipsis={{ tooltip: true }}>{value?.dynamicCreativeName}</Typography.Text></div>
  160. <Popover
  161. placement="right"
  162. overlayInnerStyle={{ maxWidth: 350, maxHeight: 350, overflow: 'hidden', overflowY: 'auto' }}
  163. mouseEnterDelay={0.5}
  164. content={<DynamicTooltip
  165. data={value}
  166. />}
  167. >
  168. <QuestionCircleFilled style={{ fontSize: 12 }} />
  169. </Popover>
  170. </div>
  171. }
  172. },
  173. {
  174. title: '创建时间',
  175. dataIndex: 'createTime',
  176. key: 'createTime',
  177. align: 'center',
  178. width: 125,
  179. ellipsis: true,
  180. render: (value) => {
  181. return <span style={{ fontSize: "12px" }}>{value || '--'}</span>
  182. }
  183. },
  184. {
  185. title: <span style={{ marginLeft: 10 }}>任务反馈</span>,
  186. dataIndex: 'total',
  187. key: 'total',
  188. width: 480,
  189. render: (value, records) => {
  190. return <Space style={{ fontSize: "12px", marginLeft: 10 }} size={10}>
  191. <span style={{ fontSize: 12 }}><Badge status="processing" />广告总数:<span style={{ fontWeight: 'bold', color: '#1890ff' }}>{value}</span>条</span>
  192. {<span style={{ fontSize: 12, fontWeight: 'bold' }}><Badge status="success" />广告成功数:<span style={{ fontWeight: 'bold', color: '#52c41a' }}>{records?.successCount || 0}</span>条</span>}
  193. <span style={{ fontSize: 12, fontWeight: 'bold' }}><Badge status="processing" />创意总数:<span style={{ fontWeight: 'bold', color: '#1890ff' }}>{records?.dynamicCreativeCount || 0}</span>条</span>
  194. {<span style={{ fontSize: 12, fontWeight: 'bold' }}><Badge status="success" />创意成功数:<span style={{ fontWeight: 'bold', color: '#52c41a' }}>{records?.dynamicCreativeSuccessCount || 0}</span>条</span>}
  195. </Space>
  196. }
  197. }
  198. ]
  199. }
  200. export default columns
  201. export const columnsLog = (sync: (value: any) => void): TableProps<any>['columns'] => {
  202. return [
  203. {
  204. title: '广告账号',
  205. dataIndex: 'accountId',
  206. key: 'accountId',
  207. width: 100,
  208. ellipsis: true,
  209. align: 'center',
  210. render(value) {
  211. return <span style={{ fontSize: 12 }}>{value}</span>
  212. }
  213. },
  214. {
  215. title: '广告名称',
  216. dataIndex: 'adgroupName',
  217. key: 'adgroupName',
  218. width: 160,
  219. ellipsis: true,
  220. render(value) {
  221. return <span style={{ fontSize: 12 }}>{value}</span>
  222. }
  223. },
  224. {
  225. title: '定向名称',
  226. dataIndex: 'targetingsName',
  227. key: 'targetingsName',
  228. width: 150,
  229. ellipsis: true,
  230. render(value) {
  231. return <span style={{ fontSize: 12 }}>{value}</span>
  232. }
  233. },
  234. {
  235. title: '营销目的',
  236. dataIndex: 'marketingGoal',
  237. key: 'marketingGoal',
  238. width: 100,
  239. ellipsis: true,
  240. align: 'center',
  241. render(value) {
  242. return <span style={{ fontSize: 12 }}>{MARKETING_GOAL_ENUM[value as keyof typeof MARKETING_GOAL_ENUM]}</span>
  243. },
  244. },
  245. {
  246. title: '出价',
  247. dataIndex: 'bidAmount',
  248. key: 'bidAmount',
  249. width: 90,
  250. align: 'center',
  251. render(value) {
  252. return <span style={{ fontSize: 12 }}>{value}</span>
  253. }
  254. },
  255. {
  256. title: '广告创建状态',
  257. dataIndex: 'adgroupStatus',
  258. key: 'adgroupStatus',
  259. width: 90,
  260. align: 'center',
  261. render(value) {
  262. const a = { 0: <Badge status="processing" text={<span style={{ fontSize: 12 }}>执行中</span>} />, 1: <Badge status="error" text={<span style={{ fontSize: 12 }}>失败</span>} />, 101: <Badge status="warning" text={<span style={{ fontSize: 12 }}>同步异常</span>} />, 100: <Badge status="success" text={<span style={{ fontSize: 12 }}>成功</span>} /> }
  263. return a[value as keyof typeof a]
  264. },
  265. },
  266. {
  267. title: <span style={{ marginLeft: 10 }}>任务反馈</span>,
  268. dataIndex: 'dynamicCreativeCount',
  269. key: 'dynamicCreativeCount',
  270. width: 280,
  271. render: (value, records) => {
  272. return <Space style={{ fontSize: "12px", marginLeft: 10 }} size={10}>
  273. <span style={{ fontSize: 12, fontWeight: 'bold' }}><Badge status="processing" />创意总数:<span style={{ fontWeight: 'bold', color: '#1890ff' }}>{records?.dynamicCreativeCount || 0}</span>条</span>
  274. {<span style={{ fontSize: 12, fontWeight: 'bold' }}><Badge status="success" />创意成功数:<span style={{ fontWeight: 'bold', color: '#52c41a' }}>{records?.dynamicCreativeSuccessCount || 0}</span>条</span>}
  275. </Space>
  276. }
  277. },
  278. {
  279. title: '错误信息',
  280. dataIndex: 'failMsg',
  281. key: 'failMsg',
  282. width: 180,
  283. ellipsis: true,
  284. render(value) {
  285. return <span style={{ fontSize: 12 }}>{value}</span>
  286. }
  287. },
  288. {
  289. title: '操作',
  290. dataIndex: 'cz',
  291. key: 'cz',
  292. width: 70,
  293. align: 'center',
  294. render(_, records) {
  295. return records?.adgroupStatus === 101 ? <a style={{ fontSize: 12 }} onClick={() => sync(records)}>同步</a> : '--'
  296. }
  297. }
  298. ]
  299. }
  300. export const columnsDynamicLog = (): TableProps<any>['columns'] => {
  301. return [
  302. {
  303. title: '创意名称',
  304. dataIndex: 'dynamicCreativeName',
  305. key: 'dynamicCreativeName',
  306. width: 150,
  307. ellipsis: true,
  308. render(value) {
  309. return <span style={{ fontSize: 12 }}>{value}</span>
  310. }
  311. },
  312. {
  313. title: '创意ID',
  314. dataIndex: 'dynamicCreativeId',
  315. key: 'dynamicCreativeId',
  316. width: 80,
  317. ellipsis: true,
  318. align: 'center',
  319. render(value) {
  320. return <span style={{ fontSize: 12 }}>{value}</span>
  321. }
  322. },
  323. {
  324. title: '投放模式',
  325. dataIndex: 'deliveryMode',
  326. key: 'deliveryMode',
  327. width: 80,
  328. ellipsis: true,
  329. align: 'center',
  330. render(value) {
  331. return <span style={{ fontSize: 12 }}>{DELIVERY_MODE_ENUM[value as keyof typeof DELIVERY_MODE_ENUM]}</span>
  332. }
  333. },
  334. {
  335. title: '动态创意类型',
  336. dataIndex: 'dynamicCreativeType',
  337. key: 'dynamicCreativeType',
  338. width: 80,
  339. ellipsis: true,
  340. align: 'center',
  341. render(value) {
  342. return <span style={{ fontSize: 12 }}>{DYNAMIC_CREATIVE_TYPE_ENUM[value as keyof typeof DYNAMIC_CREATIVE_TYPE_ENUM]}</span>
  343. }
  344. },
  345. {
  346. title: '任务ID',
  347. dataIndex: 'taskId',
  348. key: 'taskId',
  349. width: 70,
  350. ellipsis: true,
  351. align: 'center',
  352. render(value) {
  353. return <span style={{ fontSize: 12 }}>{value}</span>
  354. }
  355. },
  356. {
  357. title: '广告组ID',
  358. dataIndex: 'adgroupId',
  359. key: 'adgroupId',
  360. width: 80,
  361. ellipsis: true,
  362. align: 'center',
  363. render(value) {
  364. return <span style={{ fontSize: 12 }}>{value}</span>
  365. }
  366. },
  367. {
  368. title: '创意模板ID',
  369. dataIndex: 'creativeTemplateId',
  370. key: 'creativeTemplateId',
  371. width: 75,
  372. ellipsis: true,
  373. align: 'center',
  374. render(value) {
  375. return <span style={{ fontSize: 12 }}>{value}</span>
  376. }
  377. },
  378. {
  379. title: '创意创建状态',
  380. dataIndex: 'creativeStatus',
  381. key: 'creativeStatus',
  382. width: 80,
  383. align: 'center',
  384. render(value) {
  385. const a = { 0: <Badge status="processing" text={<span style={{ fontSize: 12 }}>执行中</span>} />, 1: <Badge status="error" style={{ fontSize: 12 }} text={<span>失败</span>} />, 100: <Badge style={{ fontSize: 12 }} status="success" text={<span>成功</span>} /> }
  386. return a[value as keyof typeof a]
  387. },
  388. },
  389. {
  390. title: '失败信息',
  391. dataIndex: 'failMsg',
  392. key: 'failMsg',
  393. width: 280,
  394. render: (value) => {
  395. return value ? <span style={{ fontSize: 12 }} onClick={() => copy(value)}>{value}</span> : '--'
  396. }
  397. }
  398. ]
  399. }
  400. export const columnsExecuteLog = (): TableProps<any>['columns'] => {
  401. return [
  402. {
  403. title: '执行时间',
  404. dataIndex: 'nextTime',
  405. key: 'nextTime',
  406. width: 145,
  407. ellipsis: true,
  408. align: 'center',
  409. render(value) {
  410. return <span style={{ fontSize: 12 }}>{value}</span>
  411. }
  412. },
  413. {
  414. title: '提交广告数量',
  415. dataIndex: 'submitAdCount',
  416. key: 'submitAdCount',
  417. width: 110,
  418. align: 'center',
  419. render(value) {
  420. return <span style={{ fontSize: 12 }}>{value}</span>
  421. }
  422. },
  423. {
  424. title: '提交创意总数',
  425. dataIndex: 'submitCreativeCount',
  426. key: 'submitCreativeCount',
  427. width: 110,
  428. align: 'center',
  429. render(value) {
  430. return <span style={{ fontSize: 12 }}>{value}</span>
  431. }
  432. },
  433. {
  434. title: '提交状态',
  435. dataIndex: 'submitStatus',
  436. key: 'submitStatus',
  437. render(value) {
  438. const a = { 2: <Badge status="processing" text={<span style={{ fontSize: 12 }}>执行中</span>} />, 0: <Badge status="error" text={<span style={{ fontSize: 12 }}>已终止</span>} />, 1: <Badge status="default" text={<span style={{ fontSize: 12 }}>待执行</span>} />, 3: <Badge status="success" text={<span style={{ fontSize: 12 }}>完成</span>} /> }
  439. return a[value as keyof typeof a]
  440. },
  441. }
  442. ]
  443. }