import request from '@/utils/request'


/***************************************************** 食材分类管理 ****************************************************/
// 食材分类列表
export function getProductTypeList(params : Record<string, any>) {
	return request.get(`erp/product/type`, params)
}

// 食材分类选择列表
export function getProductTypeSelect() {
	return request.get(`erp/product/type/select`)
}

/**
 * 获取商品分类详情
 * @param id 商品分类id
 * @returns
 */
export function getProductTypeInfo(id : number) {
	return request.get(`erp/product/type/${id}`);
}

/**
 * 添加商品分类
 * @param params
 * @returns
 */
export function addProductType(params : Record<string, any>) {
	return request.post("erp/product/type", params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 编辑商品分类
 * @param id
 * @param params
 * @returns
 */
export function editProductType(params : Record<string, any>) {
	return request.put(`erp/product/type/${params.id}`, params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

// 删除食材分类
export function deleteProductType(id : number) {
	return request.delete(`erp/product/type/${id}`, { showErrorMessage: true });
}


/**
 * 获取商品单位列表
 * @param params
 * @returns
 */
export function getProductUnitList(params : Record<string, any>) {
	return request.get(`erp/product/unit`, params);
}

export function getProductUnitSelect(params : Record<string, any>) {
	return request.get(`erp/product/unit/select`, params);
}

/**
 * 获取商品单位详情
 * @param id 商品单位id
 * @returns
 */
export function getProductUnitInfo(id : number) {
	return request.get(`erp/product/unit/${id}`);
}

/**
 * 添加商品单位
 * @param params
 * @returns
 */
export function addProductUnit(params : Record<string, any>) {
	return request.post("erp/product/unit", params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 编辑商品单位
 * @param id
 * @param params
 * @returns
 */
export function editProductUnit(params : Record<string, any>) {
	return request.put(`erp/product/unit/${params.id}`, params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 删除商品单位
 * @param id
 * @returns
 */
export function deleteProductUnit(id : number) {
	return request.delete(`erp/product/unit/${id}`, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}


/**
 * 获取食材信息列表
 * @param params
 * @returns
 */
export function getProductList(params : Record<string, any>) {
	return request.get(`erp/product/product`, params);
}

/**
 * 获取食材信息列表
 * @param params
 * @returns
 */
export function getProductListByWarehouse(params : Record<string, any>) {
	return request.get(`erp/product/product/getListsByWarehouse`, params);
}
/**
 * 获取食材信息列表-new
 * @param params
 * @returns
 */
export function getProductListByWarehouseNew(params : Record<string, any>) {
	return request.get(`erp/product/product/getListsByWarehousea`, params);
}


/**
 * 获取食材信息详情
 * @param id 食材信息id
 * @returns
 */
export function getProductInfo(id : number) {
	return request.get(`erp/product/product/${id}`);
}

/**
 * 添加食材信息
 * @param params
 * @returns
 */
export function addProduct(params : Record<string, any>) {
	return request.post("erp/product/product", params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 编辑食材信息
 * @param id
 * @param params
 * @returns
 */
export function editProduct(params : Record<string, any>) {
	return request.put(`erp/product/product/${params.id}`, params, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}

/**
 * 删除食材信息
 * @param id
 * @returns
 */
export function deleteProduct(id : number) {
	return request.delete(`erp/product/product/${id}`, {
		showErrorMessage: true,
		showSuccessMessage: true,
	});
}