/**
 * @desc 导出申请单列表
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export interface Params {
	/** 申请类型(1入库 3出库 4盘点) */
	applyType: number
	/** 物料类型 */
	type?: string
	/** 编码/名称 */
	code?: string
}

export default async function (
	params: Params,
	success: (data: void) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'get',
		url: `/apply/download-excel`,

		params,
	})
		.then((data: AxiosResponse<void, unknown>) => {
			success(data.data)
		})
		.catch((error: { code: string; error?: string }) => fail(error))
}
