import { createCrudApi } from './common';
import request from '@/axios';

const baseUrl = '/blade-transport/transport-plan';
const api = createCrudApi(baseUrl);

export const getList = api.getList;
export const getDetail = api.getDetail;
export const submit = api.submit;
export const dispatch = api.dispatch;
export const remove = api.remove;
export const copy = api.copy;
export const cancel = api.cancel;
export const complete = api.complete;

export const importTransportPlan = ({
  file,
  projectId,
  projectName,
  customerName,
  contractId,
  contractName,
}) => {
  const data = new FormData();
  data.append('file', file);
  data.append('projectId', projectId || '');
  data.append('projectName', projectName || '');
  data.append('customerName', customerName || '');
  data.append('contractId', contractId || '');
  data.append('contractName', contractName || '');
  return request({
    url: `${baseUrl}/import-transport-plan`,
    method: 'post',
    data,
    responseType: 'blob',
    timeout: 60000,
  });
};
