tableConfig.tsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. import { Popconfirm, TableProps, Typography } from "antd";
  2. import React from "react";
  3. import { MARKETING_CARRIER_TYPE_ENUM, MARKETING_GOAL_ENUM, MARKETING_SUB_GOAL_ENUM, MARKETING_TARGET_TYPE_ENUM, MARKETING_TARGET_TYPE_GAME_ENUM, SITE_SET_ENUM } from "../../const";
  4. const { Paragraph } = Typography;
  5. export const Columns = (del: (id: number) => void): TableProps<any>['columns'] => {
  6. const columns: TableProps<any>['columns'] = [
  7. {
  8. title: 'ID',
  9. dataIndex: 'id',
  10. key: 'id',
  11. width: 60,
  12. align: 'center'
  13. },
  14. {
  15. title: '创建人',
  16. dataIndex: 'putUserName',
  17. key: 'putUserName',
  18. width: 60,
  19. align: 'center'
  20. },
  21. {
  22. title: '策略组名称',
  23. dataIndex: 'strategyKey',
  24. key: 'strategyKey',
  25. width: 150
  26. },
  27. {
  28. title: '当前账号ID',
  29. dataIndex: 'accountId',
  30. key: 'accountId',
  31. width: 90,
  32. align: 'center',
  33. render: (_, b) => {
  34. let strategyValue = b.strategyValue
  35. let { adData } = JSON.parse(strategyValue)
  36. let AccountSet = new Set(adData.map((item: { accountId: any; }) => item.accountId))
  37. return <Paragraph style={{ marginBottom: 0, wordBreak: 'break-all' }} ellipsis={{ rows: 3, tooltip: true }}>{[...AccountSet].map(accountId => accountId).join(',')}</Paragraph>
  38. }
  39. },
  40. {
  41. title: '当前广告ID',
  42. dataIndex: 'adgroupId',
  43. key: 'adgroupId',
  44. width: 90,
  45. align: 'center',
  46. render: (_, b) => {
  47. let strategyValue = b.strategyValue
  48. let { adData } = JSON.parse(strategyValue)
  49. return <Paragraph style={{ marginBottom: 0, wordBreak: 'break-all' }} ellipsis={{ rows: 3, tooltip: true }}>{adData.map((item: { adgroupId: any; }) => item.adgroupId).join(',')}</Paragraph>
  50. }
  51. },
  52. {
  53. title: '当前广告名称',
  54. dataIndex: 'adName',
  55. key: 'adName',
  56. width: 150,
  57. render: (_, b) => {
  58. let strategyValue = b.strategyValue
  59. let { adData } = JSON.parse(strategyValue)
  60. return <Paragraph style={{ marginBottom: 0, wordBreak: 'break-all' }} ellipsis={{ rows: 3, tooltip: true }}>{adData.map((item: { adgroupName: any; }) => item.adgroupName).join(',')}</Paragraph>
  61. }
  62. },
  63. {
  64. title: '当前选择广告类型',
  65. dataIndex: 'ad',
  66. key: 'ad',
  67. width: 350,
  68. render: (_, b) => {
  69. let strategyValue = b.strategyValue
  70. let { adData } = JSON.parse(strategyValue)
  71. return <span dangerouslySetInnerHTML={{
  72. __html: `营销目的:<span style="color: #52c41a">${b?.taskType === 'GAME' ? MARKETING_SUB_GOAL_ENUM[adData?.[0]?.marketingSubGoal as keyof typeof MARKETING_SUB_GOAL_ENUM] : MARKETING_GOAL_ENUM[adData?.[0]?.marketingGoal as keyof typeof MARKETING_GOAL_ENUM]}</span>,
  73. 推广产品类型:<span style="color: #52c41a">${b?.taskType === 'GAME' ? MARKETING_TARGET_TYPE_GAME_ENUM[adData?.[0]?.marketingTargetType as keyof typeof MARKETING_TARGET_TYPE_GAME_ENUM] : MARKETING_TARGET_TYPE_ENUM[adData?.[0]?.marketingTargetType as keyof typeof MARKETING_TARGET_TYPE_ENUM]}</span>,
  74. 营销载体类型:<span style="color: #52c41a">${MARKETING_CARRIER_TYPE_ENUM[adData?.[0]?.marketingCarrierType as keyof typeof MARKETING_CARRIER_TYPE_ENUM]}</span>,
  75. 版位选择:<span style="color: #52c41a">${adData?.[0]?.automaticSiteEnabled ? '自动版位' : '选择特定版位'}</span>,
  76. ${!adData?.[0]?.automaticSiteEnabled && `广告版位:<span style="color: #52c41a">${adData?.[0]?.siteSet.map((item: string | number) => SITE_SET_ENUM[item as keyof typeof SITE_SET_ENUM]).toString()}</span>`}
  77. `}} />
  78. }
  79. },
  80. {
  81. title: '创建时间',
  82. dataIndex: 'createTime',
  83. key: 'createTime',
  84. ellipsis: true,
  85. width: 135
  86. },
  87. {
  88. title: '操作',
  89. dataIndex: 'cz',
  90. key: 'cz',
  91. fixed: 'right',
  92. width: 55,
  93. align: 'center',
  94. render: (_, b) => {
  95. return <Popconfirm
  96. title="是否删除?"
  97. onConfirm={() => del(b?.id)}
  98. >
  99. <a style={{ color: 'red' }}>删除</a>
  100. </Popconfirm>
  101. }
  102. }
  103. ];
  104. return columns
  105. }