import { request } from '@/service/request';

/**
 * 统一上传文件
 * @param data
 * @returns
 */
export function fetchUpload(data: File, config?: any) {
  return request({
    url: '/admin/file/upload/img',
    method: 'post',
    data: {
      file: data
    },
    headers: {
      'Content-Type': 'multipart/form-data'
    },
    ...config
  });
}

/**
 * 企业ID查询运费模板
 * @param channelId
 * @returns
 */
export function fetchGetTransport(channelId: number) {
  return request<Api.delivery.Transport2>({
    url: `/platform/transport2/queryTransport2ByChannelId/${channelId}`,
    method: 'get'
  });
}

/**
 *新增或更新运费模板
 * @param data
 * @returns
 */
export function fetchGetAddOrEditTransport(data: any) {
  return request({
    url: '/platform/transport2/addOrEdit',
    method: 'post',
    data
  });
}

/**
 * 后管端-企业运费列表
 * @returns
 */

export function fetchChannelList() {
  return request<{ records: Api.delivery.Transport2[] }>({
    url: '/platform/transport2/transport2List',
    method: 'get'
  });
}
