1234567891011121314151617181920212223242526272829303132333435363738 |
- import { useAjax } from "@/Hook/useAjax"
- import { modifyStatusBatchApi } from "@/services/gameData"
- import { message, notification, Switch } from "antd"
- import React from "react"
- /**
- * 修改启停
- */
- interface Props {
- configuredStatus: string,
- accountId: number
- adgroupId: number
- isDeleted?: boolean,
- onChange?: () => void
- }
- const SwitchStatus: React.FC<Props> = (prosp) => {
- const { configuredStatus, isDeleted, adgroupId, accountId, onChange } = prosp
- const modifyStatusBatch = useAjax((params) => modifyStatusBatchApi(params))
-
- const switchHandle = (accountAdgroupMaps: string[], type: boolean) => {
- modifyStatusBatch.run({ accountAdgroupMaps, suspend: !type }).then(res => {
- if (res?.data?.failIdList?.length === 0) {
- message.success(`${type ? '启动' : '暂停'}成功,结果有延迟请手动刷新`)
- // onChange?.()
- } else {
- message.success(`${type ? '启动' : '暂停'}失败,${JSON.stringify(res?.data?.failIdList)}`)
- }
- })
- }
- return <Switch size="small" checked={configuredStatus === 'AD_STATUS_NORMAL'} loading={modifyStatusBatch.loading} disabled={isDeleted} onChange={(checked) => switchHandle([accountId + ',' + adgroupId] ,checked)}/>
- }
- export default React.memo(SwitchStatus)
|