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

export default function({ button }) {
  const duration = 1
  return new Promise((resolve) => {
    Modal.confirm({
      title: '您确定恢复此条数据？',
      content: '恢复这条数据后，数据状态就会恢复暂停前。',
      okText: '恢复',
      okType: 'danger',
      onOk: () => {
        const suppendParams = {
          flowCallbackBeanName: 'formBeanCleanerCallBack',
          processInstanceIds: this.FlowData.instId,
        }
        FlowService.resumeFlowById(suppendParams).then(
          (res) => {
            message.success({ content: '恢复流程成功', duration })
            this.updateFlow()
            resolve()
          },
          () => {
            message.error({ content: '恢复流程失败', duration })
            resolve()
          }
        )
      },
      onCancel: () => resolve(),
    })
  })
}
