소스 검색

Merge branch 'develop' of http://git.zanxiangnet.com/wjx/ad-manage

wjx 4 달 전
부모
커밋
59423065bc
1개의 변경된 파일23개의 추가작업 그리고 3개의 파일을 삭제
  1. 23 3
      src/pages/launchSystemV3/tencentAdPutIn/create/MaterialText/index.tsx

+ 23 - 3
src/pages/launchSystemV3/tencentAdPutIn/create/MaterialText/index.tsx

@@ -1,9 +1,10 @@
 import React, { useContext, useEffect, useState } from "react"
 import style from '../index.less'
-import { Button, Typography } from "antd"
+import { Button, message, Tooltip, Typography } from "antd"
 import { DispatchAddelivery } from "..";
-import { PlusCircleOutlined, RedoOutlined } from "@ant-design/icons";
+import { PlusCircleOutlined, RedoOutlined, SyncOutlined } from "@ant-design/icons";
 import NewText from "./newText";
+import { shuffleArray } from "@/utils/utils";
 const { Title, Text } = Typography;
 
 
@@ -32,9 +33,28 @@ const MaterialText: React.FC<{ adDataGroup?: { [x: number]: any[] } }> = ({ adDa
         }
     }, [textData])
 
+    const handleDisruption = () => {
+        const textDto: { description: string[] }[] = dynamicCreativesTextDTOS.dynamicCreativesTextDetailDTOList
+        if (textDto?.[0]?.description) {
+            const textDtoArr = shuffleArray(textDto.reduce((acc: string[], val) => acc.concat(val.description), []))
+            setAddelivery({
+                ...addelivery,
+                dynamicCreativesTextDTOS: { ...dynamicCreativesTextDTOS, dynamicCreativesTextDetailDTOList: textDto.map(item => ({ description: textDtoArr.splice(0, item.description.length) })) }
+            })
+        } else {
+            message.error('打乱文案出错,请联系管理员')
+        }
+    }
+
     return <div className={`${style.settingsBody_content_row} ${style.row5}`}>
         <div className={style.title}>
-            <span>创意文案 <span className={style.selected}>已选 {dynamicCreativesTextDTOS?.dynamicCreativesTextDetailDTOList?.length || 0}</span></span>
+            <span>
+                创意文案
+                <span className={style.selected}>已选 {dynamicCreativesTextDTOS?.dynamicCreativesTextDetailDTOList?.length || 0}</span>
+                {dynamicCreativesTextDTOS?.dynamicCreativesTextDetailDTOList?.length > 1 && <Tooltip title="随机打乱文案">
+                    <a style={{ marginLeft: 8, fontSize: 12 }} onClick={handleDisruption}><SyncOutlined /></a>
+                </Tooltip>}
+            </span>
             {(dynamicCreativesTextDTOS && Object.keys(dynamicCreativesTextDTOS).length > 0) ? <Button type="link" size="small" style={{ fontSize: 11, padding: 0 }} onClick={() => setAddelivery({ ...addelivery, dynamicCreativesTextDTOS: {} })}><RedoOutlined />清空</Button> : null}
         </div>
         <div className={style.detail}>