import fetch from '@/api/fetch';
import downloadUrl from '@/utils/download';

export const fetchApplyList = entity =>
  fetch({
    url: '/repair/manager/userRepair4Page',
    method: 'post',
    data: entity,
  });

export const dealApply = entity =>
  fetch({
    url: '/repair/manager/userRepair4Deal',
    method: 'post',
    data: entity,
  });

export const exportApplyList = entity =>
  fetch({
    url: '/repair/export/manager/userRepair',
    method: 'post',
    data: entity,
    responseType: 'blob',
    timeout: 120000,
  }).then(res => {
    let blob = new Blob([res.data], { type: res.headers });
    let fileName = res.headers['content-disposition'].split('=')[1];
    downloadUrl(blob, fileName);
  });
