import request from '@/utils/request'
import { Message, Loading } from 'element-ui'
// 获取处理列表
export function acceptancePendingList(data) {
  return request({
    url: '/businessProcessingTask/doMyPendingList',
    method: 'post',
    data
  })
}

// 获取全部列表
export function acceptanceAllList(params) {
  return request({
    url: '/businessProcessingTask/doList',
    method: 'get',
    params
  })
}

// 获取详情
export function getReviewDetail(params) {
  return request({
    url: '/acceptance/acceptanceDetail/' + params.id,
    method: 'get'
  })
}

// 法务审核
export function legalReview(data) {
  return request({
    url: '/acceptance/legalReview',
    method: 'post',
    data
  })
}

// 单价审核
export function adjustReview(data) {
  return request({
    url: '/acceptancePriceAdjust/doApproval',
    method: 'post',
    data
  })
}

// 下载
export const download = (data) => (
  request({
    url: '/acceptance/downloadPdfSign',
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
)

// 下载证书
export const downloadBook = (data) => (
  request({
    url: '/acceptance/downloadCertificate',
    method: 'get',
    params: data,
    responseType: 'arraybuffer'
  })
)

// loading
const timeout = 60 * 1000 * 3
export function Loadings(text, time = timeout) {
  const loading = Loading.service({
    lock: true,
    text: text || '正在处理您的操作，请稍候...',
    spinner: 'el-icon-loading',
    color: '#fff',
    background: 'rgba(0, 0, 0, 0.7)'
  })
  setTimeout(() => {
    if (loading.visible) {
      Message.error('请求超时')
      loading.close()
    }
  }, time)
  return loading
}

// 验收单管理 - 法务审核

export const businessReviewSubmit = (data) => (
  request({
    url: '/acceptance/businessReview',
    method: 'post',
    data
  })
)
