import { Modal, message } from '@/common/one-ui'
import FlowService from '@/webflow/flow-service'
export default function({ button }) {
  const duration = 1
  return new Promise((resolve) => {
    Modal.confirm({
      content: `确定是否${button.buttonName}？`,
      onOk: () => {
        const key = 'key'
        message.loading({ content: '处理中...', key, duration })
        this.FlowData.inputs = this.getFormData()
        FlowService.subTaskReturn(this.FlowData)
          .then(() => {
            // @ts-ignore
            message.loading({ content: '处理完成', key, duration }).then(() => {
              resolve()
              this.close(true)
            })
          })
          .catch(() => {
            message.error({ content: '处理失败', key, duration })
            resolve()
          })
      },
      onCancel: () => resolve(),
    })
  })
}
