import { useAjax } from "@/Hook/useAjax" import { setMaterialTencentApi } from "@/services/adqV3/cloudNew" import { getAccountAssetsGroupListAllApi } from "@/services/adqV3/global" import { getUserAccountListApi } from "@/services/launchAdq/adAuthorize" import { getGroupListApi } from "@/services/launchAdq/subgroup" import { Button, Col, Form, Input, message, Modal, Row, Select, Space, Table } from "antd" import React, { useEffect, useState } from "react" interface Props { data: any[] visible?: boolean onClose?: () => void onChange?: () => void } /** * 上传素材到腾讯 * @param param0 * @returns */ const MoveToTencent: React.FC = ({ data, visible, onClose, onChange }) => { /***********************************/ const [form] = Form.useForm() const [queryForm, setQueryForm] = useState<{ putInType?: string, accountIdList?: number[], adUnitTypeList?: string[], groupId?: number, remark?: string, sysGroupId?: number, pageNum: number, pageSize: number }>({ pageNum: 1, pageSize: 50 }) const [selectedRows, setSelectedRows] = useState([]) const [loading, setLoading] = useState(false) const getUserAccountList = useAjax((params) => getUserAccountListApi(params)) const getGroupList = useAjax(() => getGroupListApi()) const getAccountAssetsGroupListAll = useAjax((params) => getAccountAssetsGroupListAllApi(params)) /***********************************/ const onFinish = (data: any) => { let oldQueryFrom = JSON.parse(JSON.stringify(queryForm)) let params = { ...oldQueryFrom, ...data, pageNum: 1 } if (params?.accountIdList) { params.accountIdList = params?.accountIdList.split(/[,,\n\s]+/ig).filter((item: any) => item) } else { delete params?.accountIdList } setQueryForm(params) } useEffect(() => { getGroupList.run() }, []) useEffect(() => { const { putInType, ...params } = queryForm getUserAccountList.run({ ...params, adUnitTypeList: putInType === 'NOVEL' ? ['NOVEL', 'NOVEL_IAA', 'SKIT_IAA'] : putInType === 'GAME' ? ['GAME', 'GAME_IAA'] : undefined }) }, [queryForm]) const handleOk = () => { console.log(data) if (selectedRows.length) { const typeDatalist = data.reduce((pre, cur) => { if (cur.materialType === 'image') { pre['image']?.length ? pre['image'].push(cur.id) : pre['image'] = [cur.id] } else if (cur.materialType === 'video') { pre['video']?.length ? pre['video'].push(cur.id) : pre['video'] = [cur.id] } return pre }, {}) setLoading(true) const ajaxs = Object.keys(typeDatalist).map(key => { if (key == 'image') { return setMaterialTencentApi({ type: 'IMAGE', accountId: selectedRows[0].accountId, sysFileId: typeDatalist[key] }) } else { return setMaterialTencentApi({ type: 'VIDEO', accountId: selectedRows[0].accountId, sysFileId: typeDatalist[key] }) } }) Promise.all(ajaxs).then(res => { setLoading(false) console.log('66666666', res) message.success('任务提交成功,结果可以到腾讯查看') }).catch(() => setLoading(false)) console.log(typeDatalist) } else { message.error('请选择账号') } } return 素材上传至腾讯} open={visible} onCancel={onClose} onOk={handleOk} className="modalResetCss" maskClosable={false} confirmLoading={loading} width={1000} >
`总共 ${total} 账户`, total: getUserAccountList?.data?.total, showSizeChanger: true, showLessItems: true, defaultCurrent: 1, defaultPageSize: 50,//默认初始的每页条数 onChange: (page, pageSize) => { setQueryForm({ ...queryForm, pageNum: page, pageSize }) } }} loading={getUserAccountList.loading} columns={[ { title: '账号', dataIndex: 'accountId', key: 'accountId', width: 80, align: 'center', render(value) { return {value} } }, { title: '企业', dataIndex: 'corporationName', key: 'corporationName', width: 180, ellipsis: true, render(value) { return {value} } }, { title: '企业标识', dataIndex: 'corporationLicence', key: 'corporationLicence', width: 150, ellipsis: true, render(value) { return {value} } }, { title: '业务单元ID', dataIndex: 'adUnitAccountId', key: 'adUnitAccountId', width: 90, align: 'center', render(value) { return {value || '--'} } }, { title: '备注', dataIndex: 'remark', key: 'remark', ellipsis: true, render(value) { return {value || '--'} } }, ]} rowSelection={{ selectedRowKeys: selectedRows.map(item => item.accountId), type: 'radio', onChange(_, selectedRows) { setSelectedRows(selectedRows) }, }} /> } export default React.memo(MoveToTencent)