/**
 * @desc 分页查询盘点列表
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
import type { IPage } from '@/api/api'
export interface Params {
	/** 页码 */
	page?: number
	/** 页面大小 */
	size?: number
	/** 盘点类型 */
	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: IPage<material.ApplyForm>) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'get',
		url: `/audit-applies`,

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