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

const duration = 1
export default function({ button }) {
  return new Promise((resolve) => {
    Modal.confirm({
      content: '请确认是否恢复',
      onOk: () => {
        const key = 'key'
        message.loading({ content: '处理中...', key, duration })
        FlowService.workflowResume(this.FlowData).then(
          (res) => {
            // @ts-ignore
            message.success({ content: '恢复成功', key, duration }).then(() => {
              resolve()
              this.close(true)
            })
          },
          () => {
            message.error({ content: '恢复失败', key, duration })
            resolve()
          }
        )
      },
      onCancel: () => resolve(),
    })
  })
}
