/**
 * @desc 查询所有物料列表
 */
import { defaultSuccess, defaultError, http } from '@/plugins/axios'
import type { AxiosResponse } from 'axios'
export interface Params {
	/** 类型 */
	type?: string
	/** 是否赋码 */
	assignRule?: boolean
}

export default async function (
	params: Params,
	success: (data: Array<material.Material>) => void = defaultSuccess,
	fail: (error: { code: string; error?: string }) => void = defaultError,
): Promise<void> {
	return http({
		method: 'post',
		url: `/material/list`,

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