import { message } from '@/common/one-ui'
import FlowService from '../flow-service'

const duration = 1
export default function({ button }) {
  const key = 'key'
  message.loading({ content: '处理中...', key, duration })
  return FlowService.copyFlowForm(this.FlowData).then(
    (res) => {
      window.open(`#/sd-webflow/pages/draft/${res.instId}`, '_blank')
    },
    () => {
      message.error({ content: '拷贝新建失败', key, duration })
    }
  )
}
