1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import { useAjax } from "@/Hook/useAjax"
- import { newEditAdqAdgroupsDataApi, updateBatchDynamicCreativesInfoApi } from "@/services/gameData"
- import { message, notification, Switch } from "antd"
- import React from "react"
- /**
- * 修改启停
- */
- interface Props {
- configuredStatus: string,
- isDeleted?: boolean,
- accountId: number,
- dynamicCreativeId: number,
- onChange?: () => void
- }
- const SwitchStatus: React.FC<Props> = (prosp) => {
- const { configuredStatus, isDeleted, accountId, dynamicCreativeId, onChange } = prosp
- const updateBatchDynamicCreativesInfo = useAjax((params) => updateBatchDynamicCreativesInfoApi(params))
-
- const switchHandle = (status: boolean) => {
- updateBatchDynamicCreativesInfo.run({ accountAdgroupMaps: [accountId + ',' + dynamicCreativeId], suspend: !status }).then(res => {
- message.success(`${configuredStatus === 'AD_STATUS_NORMAL' ? '启动' : '暂停'}成功`)
- if (res?.fail) {
- notification.error({
- message: `${configuredStatus === 'AD_STATUS_NORMAL' ? '启动' : '暂停'}失败`,
- description: `修改失败${res.fail}条,失败的请到任务列表查看`,
- duration: 0
- });
- }
- onChange?.()
- })
- }
- return <Switch size="small" checked={configuredStatus === 'AD_STATUS_NORMAL'} loading={updateBatchDynamicCreativesInfo.loading} disabled={isDeleted} onChange={(checked) => switchHandle(checked)}/>
- }
- export default React.memo(SwitchStatus)
|