wjx há 1 mês atrás
pai
commit
98dab859bb

+ 4 - 4
src/components/SelectAdAccount/index.tsx

@@ -242,7 +242,7 @@ const SelectAdAccount: React.FC<Props> = ({ value, onChange, isReturnFirstValue,
                                 title: '企业',
                                 dataIndex: 'corporationName',
                                 key: 'corporationName',
-                                width: 180,
+                                width: 160,
                                 ellipsis: true,
                                 render(value) {
                                     return <span style={{ fontSize: 12 }}>{value || '--'}</span>
@@ -262,17 +262,17 @@ const SelectAdAccount: React.FC<Props> = ({ value, onChange, isReturnFirstValue,
                                 title: '业务单元账号',
                                 dataIndex: 'adUnitAccountId',
                                 key: 'adUnitAccountId',
-                                width: 80,
+                                width: 100,
                                 align: 'center',
                                 render(value) {
                                     return <span style={{ fontSize: 12 }}>{value || '--'}</span>
                                 }
                             },
                             {
-                                title: '是否业务单元号',
+                                title: '业务单元号?',
                                 dataIndex: 'adUnitAccount',
                                 key: 'adUnitAccount',
-                                width: 80,
+                                width: 90,
                                 align: 'center',
                                 render(value) {
                                     return <span style={{ fontSize: 12 }}>{value ? '是' : '否'}</span>

+ 4 - 4
src/pages/launchSystemV3/material/cloudNew/selectComponentsUnit.tsx

@@ -123,7 +123,7 @@ const SelectComponentsUnit: React.FC<Props> = ({ num: count, defaultParams, chec
             }
             setComponentSubType(componentSubType)
             // defaultParams
-            let params = { ...searchParams, ...queryParams, adAccountId: unitAccountId, componentSubType }
+            const params = { ...searchParams, ...queryParams, adAccountId: unitAccountId, componentSubType, isDeleted: false }
             getCreativeComponentList.run(params)
         }
     }, [queryParams, defaultParams, searchParams, unitAccountId, isGroup, count])
@@ -189,7 +189,7 @@ const SelectComponentsUnit: React.FC<Props> = ({ num: count, defaultParams, chec
                                     <Checkbox
                                         onChange={(e) => {
                                             let newCheckedFolderList: any[] = JSON.parse(JSON.stringify(checkedFolderList))
-                                            const data: any[] = getCreativeComponentList?.data?.records
+                                            const data: any[] = getCreativeComponentList?.data?.records?.filter((item: { status: string }) => item?.status === '正常')
 
                                             if (e.target.checked) { // 全选
                                                 const selectIds = newCheckedFolderList.map(item => item.id)
@@ -272,7 +272,7 @@ const SelectComponentsUnit: React.FC<Props> = ({ num: count, defaultParams, chec
                                                     const componentSubType = item.componentSubType
                                                     const type = getComponentType(componentSubType)
                                                     const isSelect = checkedFolderList?.filter((_, index) => (active || active === 0) ? index === active : true)?.map(item => item.id).includes(id)
-                                                    const disabled = ((active || active === 0) ? false : (checkedFolderList.length >= num && !isSelect))
+                                                    const disabled = ((active || active === 0) ? false : (checkedFolderList.length >= num && !isSelect)) || item?.status !== '正常'
                                                     const imageListLength = item?.componentValue?.imageList?.value?.list?.length || 0
                                                     return <div key={id} className={style.content_row} style={{ width: rowNum ? (1 / rowNum * 100) + '%' : 220 }}>
                                                         <Card
@@ -326,7 +326,7 @@ const SelectComponentsUnit: React.FC<Props> = ({ num: count, defaultParams, chec
                                                             onClick={() => !disabled && onCheckboxChange(!isSelect, item, type)}
                                                         >
                                                             <div className={style.body}>
-                                                                <Text ellipsis strong style={{ flex: '1 0' }}>{item?.componentCustomName}</Text>
+                                                                <Text ellipsis strong style={{ flex: '1 0', color: item?.status !== '正常' ? 'red' : 'rgba(0, 0, 0, 0.85)' }}>{item?.status !== '正常' ? item?.status : item?.componentCustomName}</Text>
                                                             </div>
                                                             <Divider style={{ margin: '0 0 4px 0' }} />
                                                             <div style={{ padding: '0 10px 6px' }}>

+ 12 - 6
src/pages/launchSystemV3/material/cloudNew/selectComponentsUnitSearch.tsx

@@ -1,8 +1,7 @@
-import { Button, Card, Col, DatePicker, Form, Input, InputNumber, Row, Select, Space } from "antd"
+import { Button, Card, Col, DatePicker, Form, Input, Row, Select, Space } from "antd"
 import React from "react"
 import { SearchOutlined } from "@ant-design/icons";
 import moment from "moment";
-import { SOURCE_TYPE_IMAGE_ENUM, SOURCE_TYPE_VIDEO_ENUM } from "../../tencentAdPutIn/const";
 import { COMMON_POTENTIAL_STATUS_ENUM, COMPONENT_GENERATION_TYPE_ENUM, DEFAULT_COMPONENT_SUB_IMAGE_TYPE, DEFAULT_COMPONENT_SUB_VIDEO_TYPE } from "../../tencenTasset/manageComponent/const";
 import { DefaultOptionType } from "antd/lib/select";
 
@@ -27,7 +26,11 @@ const SelectComponentsUnitSearch: React.FC<Props> = ({ type, onSearch, component
             if (['idList'].includes(key) && value !== undefined && value !== null) {
                 let value1 = value.replace(/[,,\s]/g, ',')
                 params[type === 'image' ? 'imageId' : 'videoId'] = value1.split(',').filter((a: any) => a)
-            } if ('createTime' === key && value?.length === 2) {
+            } else if (['componentIdSting'].includes(key) && value !== undefined && value !== null) {
+                let value1 = value.replace(/[,,\s]/g, ',')
+                params['componentId'] = value1.split(',').filter((a: any) => a)
+            }
+            if ('createTime' === key && value?.length === 2) {
                 params.createTimeMin = moment(value?.[0]).format('YYYY-MM-DD')
                 params.createTimeMax = moment(value?.[1]).format('YYYY-MM-DD')
             } else {
@@ -53,6 +56,9 @@ const SelectComponentsUnitSearch: React.FC<Props> = ({ type, onSearch, component
                 <Col><Form.Item name={'idList'}>
                     <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="素材ID(多个空格or换行隔开)" />
                 </Form.Item></Col>
+                <Col><Form.Item name={'componentIdSting'}>
+                    <Input.TextArea rows={1} style={{ width: 190 }} allowClear placeholder="组件ID(多个空格or换行隔开)" />
+                </Form.Item></Col>
                 <Col><Form.Item name={'componentSubType'}>
                     <Select
                         showSearch
@@ -60,7 +66,7 @@ const SelectComponentsUnitSearch: React.FC<Props> = ({ type, onSearch, component
                         filterOption={(input, option) =>
                             ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
                         }
-                        style={{ minWidth: 160 }}
+                        style={{ minWidth: 120 }}
                         maxTagCount={1}
                         mode="multiple"
                         allowClear
@@ -89,7 +95,7 @@ const SelectComponentsUnitSearch: React.FC<Props> = ({ type, onSearch, component
                         filterOption={(input, option) =>
                             ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
                         }
-                        style={{ minWidth: 120 }}
+                        style={{ minWidth: 100 }}
                         maxTagCount={1}
                         mode="multiple"
                         options={Object.keys(COMMON_POTENTIAL_STATUS_ENUM).map(key => ({ label: COMMON_POTENTIAL_STATUS_ENUM[key as keyof typeof COMMON_POTENTIAL_STATUS_ENUM], value: key }))}
@@ -102,7 +108,7 @@ const SelectComponentsUnitSearch: React.FC<Props> = ({ type, onSearch, component
                         filterOption={(input, option) =>
                             ((option?.label ?? '') as any).toLowerCase().includes(input.toLowerCase())
                         }
-                        style={{ minWidth: 120 }}
+                        style={{ minWidth: 100 }}
                         maxTagCount={1}
                         mode="multiple"
                         options={Object.keys(COMPONENT_GENERATION_TYPE_ENUM).map(key => ({ label: COMPONENT_GENERATION_TYPE_ENUM[key as keyof typeof COMPONENT_GENERATION_TYPE_ENUM], value: key }))}

+ 64 - 4
src/pages/launchSystemV3/tencenTasset/manageComponent/index.tsx

@@ -1,9 +1,9 @@
 import React, { useEffect, useRef, useState } from "react"
 import '../../tencentAdPutIn/index.less'
-import { Button, Card, DatePicker, Input, Pagination, Select, Space, Switch, Table, Tabs } from "antd"
-import { getCreativeComponentListApi, GetCreativeComponentProps, getDefaultSharingApi, updateDefaultSharingApi } from "@/services/adqV3/global"
+import { Button, Card, DatePicker, Input, message, Pagination, Popconfirm, Select, Space, Switch, Table, Tabs } from "antd"
+import { delComponentApi, getCreativeComponentListApi, GetCreativeComponentProps, getDefaultSharingApi, updateDefaultSharingApi } from "@/services/adqV3/global"
 import './index.less'
-import { PlusOutlined, SyncOutlined } from "@ant-design/icons"
+import { DeleteOutlined, PlusOutlined, SyncOutlined } from "@ant-design/icons"
 import { useAjax } from "@/Hook/useAjax"
 import SelectAdAccount from "@/components/SelectAdAccount"
 import { COMMON_POTENTIAL_STATUS_ENUM, COMPONENT_GENERATION_TYPE_ENUM, DEFAULT_COMPONENT_SUB_IMAGE_TYPE, DEFAULT_COMPONENT_SUB_SHOW_IMAGE, DEFAULT_COMPONENT_SUB_SHOW_VIDEO, DEFAULT_COMPONENT_SUB_VIDEO_TYPE } from "./const"
@@ -32,10 +32,12 @@ const ManageComponent: React.FC = () => {
     const [adUnitAccount, setAdUnitAccount] = useState<number>()
     const [shared, setShared] = useState<'DEFAULT_SHARED_NONE' | 'DEFAULT_SHARED_ALL_ORGANIZATION'>()
     const [putInType, setPutInType] = useState<'NOVEL' | 'GAME'>('NOVEL')
+    const [selectedRows, setSelectedRows] = useState<any[]>([])
 
     const getCreativeComponentList = useAjax((params) => getCreativeComponentListApi(params))
     const getDefaultSharing = useAjax((params) => getDefaultSharingApi(params))
     const updateDefaultSharing = useAjax((params) => updateDefaultSharingApi(params))
+    const delComponent = useAjax((params) => delComponentApi(params))
     /*************************************/
 
     useEffect(() => {
@@ -73,6 +75,19 @@ const ManageComponent: React.FC = () => {
         })
     }
 
+    const handleDel = (id: number[]) => {
+        const hide = message.loading('正在删除...', 0)
+        delComponent.run({ componentId: id, adAccountId: queryParams?.adAccountId }).then(res => {
+            hide()
+            if (res?.length === 0) {
+                message.success('删除成功')
+                getCreativeComponentList.refresh()
+            } else {
+                message.error(res?.join('、'))
+            }
+        }).catch(() => hide())
+    }
+
     return <div className="manageComponent">
         <Card
             className="cardResetCss"
@@ -115,6 +130,13 @@ const ManageComponent: React.FC = () => {
                     allowClear={false}
                 />
                 <Button icon={<SyncOutlined />} type="link" onClick={() => { getCreativeComponentList.refresh() }} loading={getCreativeComponentList.loading}></Button>
+                <Popconfirm
+                    title="确定删除?"
+                    onConfirm={() => { handleDel(selectedRows.map(item => item.componentId)) }}
+                    disabled={selectedRows.length === 0}
+                >
+                    <Button icon={<DeleteOutlined />} type="primary" danger size="small" disabled={selectedRows.length === 0} loading={delComponent.loading}>删除</Button>
+                </Popconfirm>
                 {adUnitAccount && <Switch
                     checkedChildren="业务单元默认全部共享"
                     unCheckedChildren="业务单元默认不共享"
@@ -226,7 +248,7 @@ const ManageComponent: React.FC = () => {
             </div>
             <div className="manageComponent-content" ref={ref}>
                 <Table
-                    columns={TableConfig(queryParams?.activeKey as any)}
+                    columns={TableConfig(queryParams?.activeKey as any, handleDel)}
                     dataSource={getCreativeComponentList.data?.records || []}
                     loading={getCreativeComponentList.loading || loading}
                     scroll={{ x: 1000, y: (size?.height || 0) - 36 }}
@@ -234,6 +256,44 @@ const ManageComponent: React.FC = () => {
                     size="small"
                     bordered
                     rowKey="componentId"
+                    rowSelection={{
+                        selectedRowKeys: selectedRows.map(item => item.componentId),
+                        getCheckboxProps: (record: any) => ({
+                            disabled: record?.isDeleted
+                        }),
+                        onSelect: (record: { componentId: number }, selected: boolean) => {
+                            if (selected) {
+                                selectedRows.push({ ...record })
+                                setSelectedRows([...selectedRows])
+                            } else {
+                                let newSelectAccData = selectedRows.filter((item: { componentId: number }) => item.componentId !== record.componentId)
+                                setSelectedRows([...newSelectAccData])
+                            }
+                        },
+                        onSelectAll: (selected: boolean, selectedRowss: { componentId: number }[], changeRows: { componentId: number }[]) => {
+                            if (selected) {
+                                let newSelectAccData = [...selectedRows]
+                                changeRows.forEach((item: { componentId: number }) => {
+                                    let index = newSelectAccData.findIndex((ite: { componentId: number }) => ite.componentId === item.componentId)
+                                    if (index === -1) {
+                                        let data: any = { ...item }
+                                        newSelectAccData.push(data)
+                                    }
+                                })
+                                setSelectedRows([...newSelectAccData])
+                            } else {
+                                let newSelectAccData = selectedRows.filter((item: { componentId: number }) => {
+                                    let index = changeRows.findIndex((ite: { componentId: number }) => ite.componentId === item.componentId)
+                                    if (index !== -1) {
+                                        return false
+                                    } else {
+                                        return true
+                                    }
+                                })
+                                setSelectedRows([...newSelectAccData])
+                            }
+                        }
+                    }}
                 />
             </div>
             <div className="manageComponent-footer">

+ 23 - 9
src/pages/launchSystemV3/tencenTasset/manageComponent/tableConfig.tsx

@@ -1,12 +1,12 @@
 import { ColumnsType } from "antd/es/table";
 import React from "react";
 import { COMPONENT_GENERATION_TYPE_ENUM, COMPONENT_SUB_TYPE, getComponentType } from "./const";
-import { Tag } from "antd";
+import { Popconfirm, Tag } from "antd";
 import moment from "moment";
 import Image1X1 from "../../components/AdsComponent/Image1X1";
 import ImageXXX from "../../components/AdsComponent/ImageXXX";
 
-const TableConfig = (activeKey: 'IMAGE' | 'VIDEO'): ColumnsType<any> => {
+const TableConfig = (activeKey: 'IMAGE' | 'VIDEO', del: (id: number[]) => void): ColumnsType<any> => {
 
     const columns: ColumnsType<any> = [
         {
@@ -14,6 +14,7 @@ const TableConfig = (activeKey: 'IMAGE' | 'VIDEO'): ColumnsType<any> => {
             dataIndex: 'componentSubType',
             key: 'componentSubType',
             width: 380,
+            fixed: 'left',
             render(value, records) {
                 const type = getComponentType(value)
                 if (type === 'IMAGE') {
@@ -21,7 +22,7 @@ const TableConfig = (activeKey: 'IMAGE' | 'VIDEO'): ColumnsType<any> => {
                 } else if (type === 'IMAGE_LIST') {
                     return <ImageXXX imageList={records?.componentValue?.imageList?.value?.list || []} />
                 } else if (type === 'VIDEO') {
-                    return <Image1X1 
+                    return <Image1X1
                         imageUrl={records?.componentValue?.video?.value?.coverUrl || records?.componentValue?.shortVideo?.value?.shortVideo2Url}
                         videoUrl={records?.componentValue?.video?.value?.videoUrl || records?.componentValue?.shortVideo?.value?.shortVideo1Url}
                     />
@@ -127,17 +128,30 @@ const TableConfig = (activeKey: 'IMAGE' | 'VIDEO'): ColumnsType<any> => {
                 return value ? <Tag color="error" style={{ margin: 0 }}>是</Tag> : <Tag color="success" style={{ margin: 0 }}>否</Tag>
             },
         },
+        {
+            title: '组件状态',
+            dataIndex: 'status',
+            key: 'status',
+            width: 90,
+            ellipsis: true,
+            render(value) {
+                return <span style={{ fontSize: 12 }}>{value || '--'}</span>
+            },
+        },
         {
             title: '操作',
             dataIndex: 'cz',
             key: 'cz',
+            width: 130,
             render(_, record) {
-                // return <Popconfirm
-                //     title="确定删除?"
-                //     onConfirm={() => {}}
-                // >
-                //     <a style={{ color: 'red', fontSize: 12 }}>删除</a>
-                // </Popconfirm>
+                if (!record?.isDeleted) {
+                    return <Popconfirm
+                        title="确定删除?"
+                        onConfirm={() => { del([record?.componentId]) }}
+                    >
+                        <a style={{ color: 'red', fontSize: 12 }}>删除</a>
+                    </Popconfirm>
+                }
                 return '--'
             },
         },

+ 13 - 0
src/services/adqV3/global.ts

@@ -1249,4 +1249,17 @@ export async function updateDefaultSharingApi(params: { adAccountId: number, typ
         method: 'POST',
         params
     })
+}
+
+/**
+ * 删除组件
+ * @param params 
+ * @returns 
+ */
+export async function delComponentApi({componentId, ...params}: { adAccountId: number, componentId: number[] }) {
+    return request(api + `/adq/creative/component/deleteBatch`, {
+        method: 'DELETE',
+        params,
+        data: componentId
+    })
 }