import request from '@/axios';

export const getList = (current, size, params) => {
  return request({
    url: '/blade-system/cargo-type/list',
    method: 'get',
    params: {
      ...params,
      current,
      size,
    },
  });
};

export const getDetail = id => {
  return request({
    url: '/blade-system/cargo-type/detail',
    method: 'get',
    params: {
      id,
    },
  });
};

export const remove = ids => {
  return request({
    url: '/blade-system/cargo-type/remove',
    method: 'post',
    params: {
      ids,
    },
  });
};

export const submit = row => {
  return request({
    url: '/blade-system/cargo-type/submit',
    method: 'post',
    data: row,
  });
};

export const importCargoType = file => {
  const formData = new FormData();
  formData.append('file', file);
  return request({
    url: '/blade-system/cargo-type/import-cargo-type',
    method: 'post',
    data: formData,
    responseType: 'blob',
    timeout: 60000,
  });
};

export const getParentOptions = keyword => {
  return request({
    url: '/blade-system/cargo-type/parent-options',
    method: 'get',
    params: {
      keyword,
    },
  });
};

export const getNextCode = parentCargoCode => {
  return request({
    url: '/blade-system/cargo-type/next-code',
    method: 'get',
    params: {
      parentCargoCode,
    },
  });
};
