import {
  BaseListResult,
  BaseResult,
  GetTraceBackListParams,
  GetTraceBackSNListData,
  GetTraceBackSNListParams,
  TraceBackListData,
} from '@models';
import {request, uploadRequest} from './request';

const BASE_URL = '/traceBack';

/** 获取交货单列表 */
export function getTraceBackList(
  data: GetTraceBackListParams,
  signal?: AbortSignal,
): BaseListResult<TraceBackListData> {
  return request({
    url: `${BASE_URL}/getTraceBack`,
    data,
    method: 'GET',
    signal,
  });
}

/** 导入 */
export function importTraceBack(data: FormData): BaseResult {
  return uploadRequest(`${BASE_URL}/import`, data);
}

/** 追溯单据导出 */
export function exportTraceBack(data: GetTraceBackListParams): any {
  return request({
    url: `${BASE_URL}/export`,
    method: 'GET',
    data,
  });
}

/** 删除追溯单 */
export function delTraceBack(id: string): BaseResult {
  return request({
    url: `${BASE_URL}/delTraceBack`,
    method: 'DELETE',
    data: {id},
  });
}

/** 查询具体的sn码列表 */
export function getTraceBackSNList(
  data: GetTraceBackSNListParams,
  signal?: AbortSignal,
): BaseListResult<GetTraceBackSNListData> {
  return request({
    url: `${BASE_URL}/getTraceBackSn`,
    method: 'GET',
    data,
    signal,
  });
}

/**具体sn码列表导出 */
export function exportTraceBackSN(data: GetTraceBackSNListParams): any {
  return request({
    url: `${BASE_URL}/TraceBackSnExport`,
    method: 'GET',
    data,
  });
}
