Kaynağa Gözat

投手指派临时开放全部用户

shenwu 2 yıl önce
ebeveyn
işleme
5fac6d08cd
1 değiştirilmiş dosya ile 37 ekleme ve 14 silme
  1. 37 14
      src/pages/launchSystemNew/adq/ad/index.tsx

+ 37 - 14
src/pages/launchSystemNew/adq/ad/index.tsx

@@ -102,13 +102,13 @@ const Ad: React.FC<Props> = (props) => {
             message.error('请先勾选要同步的广点通账号!')
             return
         }
-        let arr = [...new Set(selectedRows?.map(item=>item.accountId))]
-        syncAjax.run({ accountIdList:arr }).then(res => {
+        let arr = [...new Set(selectedRows?.map(item => item.accountId))]
+        syncAjax.run({ accountIdList: arr }).then(res => {
             res && listAjax.refresh()
             res ? message.success('同步成功!') : message.error('同步失败!')
 
         })
-    }, [listAjax,selectedRows])
+    }, [listAjax, selectedRows])
 
     /** 删除 */
     const deleteHandle = (type: 0 | 1, adgroupId?: number) => {
@@ -188,7 +188,6 @@ const Ad: React.FC<Props> = (props) => {
         setDetailData(data)
         setDetailShow(true)
     }
-
     return <div>
         {/* 修改广告 */}
         {update.visible && <UpdateAd
@@ -412,8 +411,32 @@ const Ad: React.FC<Props> = (props) => {
                             record?.deepConversionSpec?.deepConversionWorthSpec?.goal === 'GOAL_1DAY_PURCHASE_ROAS'
                         )
                 }),
-                onChange: (selectedRowKeys: any, selectedRows: any) => {
-                    setSelectedRows(selectedRows)
+                onChange: (selectedRowKeys: any, selectedRowss: any) => {
+                    let newArr: any = [...selectedRows]
+                    let type = selectedRowss.length === 0 ? 'delAll' : selectedRowss.length === listAjax?.data.data.records.length ? 'add' : 'del'
+                    switch (type) {
+                        case 'add':
+                            console.log('新增')
+                            newArr = [...newArr, ...selectedRowss]
+                            break;
+                        case 'del':
+                            console.log('删除')
+                            newArr.forEach((item: { adgroupId: any }) => {
+                                if (selectedRowss.every((i: { adgroupId: any }) => i.adgroupId != item.adgroupId)) {
+                                    newArr = newArr.filter((i: { adgroupId: any }) => i.adgroupId != item.adgroupId)
+                                }
+                            })
+                            break;
+                        case 'delAll':
+                            console.log('删除全部')
+                            newArr.forEach((item: { adgroupId: any }) => {
+                                if (listAjax?.data.data.records.some((i: { adgroupId: any }) => i.adgroupId == item.adgroupId)) {
+                                    newArr = newArr.filter((i: { adgroupId: any }) => i.adgroupId != item.adgroupId)
+                                }
+                            })
+                            break;
+                    }
+                    setSelectedRows(newArr)
                 }
             }}
             onChange={(props: any) => {
@@ -425,14 +448,14 @@ const Ad: React.FC<Props> = (props) => {
         />
         {detailShow && <PlanDetail visible={detailShow} onClose={() => { setDetailShow(false) }} data={detailData} />}
         {czjlShow && <Modal
-                visible={czjlShow}
-                onCancel={()=>{setCzjlShow(false)}}
-                onOk={()=>{setCzjlShow(false)}}
-                width={1200}
-                footer={null}
-                title={"广告操作记录"}
-            >
-                <Log {...props} />
+            visible={czjlShow}
+            onCancel={() => { setCzjlShow(false) }}
+            onOk={() => { setCzjlShow(false) }}
+            width={1200}
+            footer={null}
+            title={"广告操作记录"}
+        >
+            <Log {...props} />
         </Modal>}
     </div>
 }