/**
 * @desc 导出盘点申请单列表
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export interface Params {
	/** 盘点类型 */
	auditType?: 'SCAN' | 'MANUAL'
	/** 盘点人 */
	taker?: string
	/** 创建日期 */
	createDate?: string
	/** 审核状态 */
	reviewResults?: Array<'WAIT_SCAN' | 'WAIT_SUBMIT' | 'WAIT_REVIEW' | 'PASS' | 'REJECT'>
}

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/audit/download-excel`,

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