/**
 * @desc 提交盘点扫码数据
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios';
import type { AxiosResponse } from 'axios';
export default async function (
  /** 申请单ID */
  applyId: number,

  /** 请求体 */
  requestBody: Array<material.StocktakingScanDetail>,

  success: (data: void) => void = defaultSuccess,
  fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
  return http({
    method: 'post',
    url: `/scan-data/${applyId}`,
    data: requestBody,
  })
    .then((data: AxiosResponse<void, unknown>) => {
      success(data.data);
    })
    .catch((error: { code: string; error?: string }) => fail(error));
}
