tableConfig.tsx 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. import React from 'react'
  2. import { Space, Switch, Image, Popover } from 'antd'
  3. import '../index.less'
  4. import { copy } from '@/utils/utils'
  5. import { DELIVERY_MODE, DYNAMIC_CREATIVE_TYPE, dynamicCreativeStatus } from '../const'
  6. import Box from './box'
  7. function tableConfig(): any {
  8. return [
  9. {
  10. title: '启停',
  11. dataIndex: 'configuredStatus',
  12. key: 'configuredStatus',
  13. align: 'center',
  14. width: 40,
  15. fixed: 'left',
  16. render: (a: string, b: any) => {
  17. return <Switch size="small" checked={a === 'AD_STATUS_NORMAL'} onChange={(checked) => { }} />
  18. }
  19. },
  20. // {
  21. // title: '创意预览',
  22. // dataIndex: 'creativeComponents',
  23. // key: 'creativeComponents',
  24. // width: 130,
  25. // render: (a: any) => {
  26. // return <Box creativeComponents={a} />
  27. // }
  28. // },
  29. {
  30. title: '品牌形象',
  31. dataIndex: 'brand',
  32. key: 'brand',
  33. width: 110,
  34. ellipsis: true,
  35. render: (_: any[], b: any) => {
  36. let brand = b?.creativeComponents?.brand
  37. return brand?.length > 0 ? <Space>
  38. <img src={brand?.[0]?.value?.brandImageUrl} height={18} />
  39. <span>{brand?.[0]?.value?.brandName}</span>
  40. </Space> : '--'
  41. }
  42. },
  43. {
  44. title: '文本标题',
  45. dataIndex: 'title',
  46. key: 'title',
  47. width: 140,
  48. ellipsis: true,
  49. render: (_: any[], b: any) => {
  50. let title = b?.creativeComponents?.title
  51. return title?.length > 0 ? title.map((item: { value: { content: any } }, index: number) => `标题${index + 1}:${item?.value?.content}`)?.toString() : '--'
  52. }
  53. },
  54. {
  55. title: '文本描述',
  56. dataIndex: 'description',
  57. key: 'description',
  58. width: 140,
  59. ellipsis: true,
  60. render: (_: any[], b: any) => {
  61. let description = b?.creativeComponents?.description
  62. return description?.length > 0 ? description.map((item: { value: { content: any } }, index: number) => `描述${index + 1}:${item?.value?.content}`)?.toString() : '--'
  63. }
  64. },
  65. {
  66. title: '单图片',
  67. dataIndex: 'image',
  68. key: 'image',
  69. width: 140,
  70. ellipsis: true,
  71. render: (_: any[], b: any) => {
  72. let image = b?.creativeComponents?.image
  73. return <div style={{ minHeight: 50, display: 'flex', alignItems: 'center' }}>
  74. {image?.length > 0 ? <div className='tableScrollbar' style={{ overflow: 'hidden', overflowX: 'auto' }}>
  75. <Image.PreviewGroup>
  76. {image?.map((item: { componentId: string; value: { imageUrl: string | undefined } }, index: string) => <Image key={item?.componentId + '_' + index} src={item?.value?.imageUrl} height={45} />)}
  77. </Image.PreviewGroup>
  78. </div> : '--'}
  79. </div>
  80. }
  81. },
  82. {
  83. title: '图集',
  84. dataIndex: 'imageList',
  85. key: 'imageList',
  86. width: 140,
  87. ellipsis: true,
  88. render: (_: any[], b: any) => {
  89. let imageList = b?.creativeComponents?.imageList
  90. return imageList?.length > 0 ? <div className='tableScrollbar' style={{ overflow: 'hidden', overflowX: 'auto', display: 'flex', gap: 10 }}>
  91. {imageList?.map((item: { value: { list: any[] } }, index: React.Key | null | undefined) => <Image.PreviewGroup key={index}>
  92. {item?.value?.list?.map((list: any, i: number) => <Image key={i} src={list?.imageUrl} height={45} />)}
  93. </Image.PreviewGroup>)}
  94. </div> : '--'
  95. }
  96. },
  97. {
  98. title: '视频',
  99. dataIndex: 'video',
  100. key: 'video',
  101. width: 140,
  102. ellipsis: true,
  103. render: (_: any[], b: any) => {
  104. let video = b?.creativeComponents?.video
  105. return video?.length > 0 ? < Popover
  106. placement='right'
  107. content={< div >
  108. <Space style={{ maxWidth: 300, display: 'flex', flexFlow: 'row wrap', margin: '10px 0' }}>
  109. {video?.map((item: { value: { videoUrl: string | undefined } }, index: React.Key | null | undefined) => <video key={index} src={item?.value?.videoUrl} style={{ width: 250 }} controls />)}
  110. </Space>
  111. </div >}
  112. destroyTooltipOnHide
  113. mouseEnterDelay={0.5}
  114. >
  115. <Space style={{ width: '100%' }}>
  116. <video src={video?.[0]?.value?.videoUrl} style={{ maxHeight: 40, maxWidth: 60 }} />
  117. </Space>
  118. </Popover> : '--'
  119. }
  120. },
  121. {
  122. title: '轮播',
  123. dataIndex: 'floatingZone',
  124. key: 'floatingZone',
  125. width: 150,
  126. ellipsis: true,
  127. render: (_: any[], b: any) => {
  128. let floatingZone = b?.creativeComponents?.floatingZone
  129. return floatingZone?.length > 0 ? <div className='tableScrollbar' style={{ overflow: 'hidden', overflowX: 'auto' }}>
  130. {floatingZone?.map((item: { value: { floatingZoneImageUrl: string | undefined; floatingZoneName: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal | null | undefined; floatingZoneDesc: boolean | React.ReactChild | React.ReactFragment | React.ReactPortal | null | undefined } }, index: React.Key | null | undefined) => <div key={index} style={{ display: 'flex', alignItems: 'center', gap: 1 }}>
  131. <div style={{ width: 40 }}>
  132. <Image src={item?.value?.floatingZoneImageUrl} width={40} height={40} />
  133. </div>
  134. <div>
  135. <span>{item?.value?.floatingZoneName}</span><br />
  136. <span>{item?.value?.floatingZoneDesc}</span>
  137. </div>
  138. </div>)}
  139. </div> : '--'
  140. }
  141. },
  142. {
  143. title: '所属账号',
  144. dataIndex: 'accountId',
  145. key: 'accountId',
  146. align: 'center',
  147. width: 80,
  148. ellipsis: true,
  149. render: (a: string) => {
  150. return <Space>
  151. <a onClick={() => copy(a)} >{a}</a>
  152. </Space>
  153. }
  154. },
  155. {
  156. title: '广告ID',
  157. dataIndex: 'adgroupId',
  158. key: 'adgroupId',
  159. align: 'center',
  160. width: 100,
  161. ellipsis: true,
  162. render: (a: string, b: any) => {
  163. return <Space>
  164. <a onClick={() => copy(a)} >{a}</a>
  165. </Space>
  166. }
  167. },
  168. {
  169. title: '创意名称',
  170. dataIndex: 'dynamicCreativeName',
  171. key: 'dynamicCreativeName',
  172. align: 'center',
  173. width: 120,
  174. ellipsis: true
  175. },
  176. {
  177. title: '创意ID',
  178. dataIndex: 'dynamicCreativeId',
  179. key: 'dynamicCreativeId',
  180. align: 'center',
  181. width: 100,
  182. ellipsis: true,
  183. render: (a: string, b: any) => {
  184. return <Space>
  185. <a onClick={() => copy(a)} >{a}</a>
  186. </Space>
  187. }
  188. },
  189. {
  190. title: '投放模式',
  191. dataIndex: 'deliveryMode',
  192. key: 'deliveryMode',
  193. align: 'center',
  194. width: 120,
  195. render: (a: string) => {
  196. return DELIVERY_MODE[a]
  197. }
  198. },
  199. {
  200. title: '创意形式匹配方式',
  201. dataIndex: 'dynamicCreativeType',
  202. key: 'dynamicCreativeType',
  203. align: 'center',
  204. width: 120,
  205. render: (a: string) => {
  206. return DYNAMIC_CREATIVE_TYPE[a]
  207. }
  208. },
  209. {
  210. title: '状态',
  211. dataIndex: 'systemStatus',
  212. key: 'systemStatus',
  213. align: 'center',
  214. width: 120,
  215. render: (a: string) => {
  216. return dynamicCreativeStatus[a]
  217. }
  218. },
  219. ]
  220. }
  221. export default tableConfig