import http from '@/http/http.js'
const request = http.request
// 商品----------------------------------------------------------------------------------------------------
/**
 * 获取商品分页
 * @returns
 */
export function getProductPage(data, urlType = 'product', showLoading) {
	return request({
		url: `${urlType}/admin/product/page`,
		method: "GET",
		data: {
			...data
		},
		showLoading
	})
}

/**
 * 获取商品列表
 * @returns
 */
export function getProductList(data, urlType = 'product', showLoading) {
	return request({
		url: `${urlType}/admin/product/list`,
		method: "GET",
		data: {
			...data
		},
		showLoading
	})
}


/**
 * 获取商品详情
 * @returns
 */
export function getProductDetail(id, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/${id}`,
		method: "GET",

	})
}

/**
 * 添加商品
 * @returns
 */
export function addProduct(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 删除商品
 * @returns
 */
export function delProduct(id, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/${id}`,
		method: "DELETE",
	})
}

/**
 * 商品上下架
 * @returns
 */
export function productOnOff(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/onOff`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 商品售罄
 * @returns
 */
export function productMarkIsSoldOut(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/markIsSoldOut`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 修改商品
 * @returns
 */
export function updateProduct(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product`,
		method: "PUT",
		data: {
			...data
		}
	})
}

/**
 * 绑定耗材
 * @returns
 */
export function productBindCons(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/bind`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 商品报损
 * @returns
 */
export function productReportDamage(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/reportDamage`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 商品商品-修改库存
 * @returns
 */
export function productModifyStock(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/modifyStock`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 商品-库存变动记录
 * @returns
 */
export function productStockFlow(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/stockFlow`,
		method: "GET",
		data: {
			...data
		}
	})
}

// 商品分类----------------------------------------------------------------------------------------------------
/**
 * 获取商品分类列表
 * @returns
 */
export function getCategoryList(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/category/list`,
		method: "GET",
		data: {
			...data
		}
	})
}

// 商品单位----------------------------------------------------------------------------------------------------
/**
 * 获取商品单位列表
 * @returns
 */
export function getProdUnitList(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/unit/list`,
		method: "GET",
		data: {
			...data
		}
	})
}

// 商品规格----------------------------------------------------------------------------------------------------
/**
 * 获取商品规格列表
 * @returns
 */
export function getSpecList(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/spec/list`,
		method: "GET",
		data: {
			...data
		}
	})
}

/**
 * 添加商品规格
 * @returns
 */
export function addSpec(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/spec`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 修改商品规格
 * @returns
 */
export function updateSpec(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/spec`,
		method: "PUT",
		data: {
			...data
		}
	})
}

/**
 * 快捷添加商品规格
 * @returns
 */
export function addSpecQuic(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/spec/quickAdd`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 删除商品规格
 * @returns
 */
export function delSpec(id, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/spec/${id}`,
		method: "DELETE",

	})
}

// 商品分组----------------------------------------------------------------------------------------------------
/**
 * 获取商品分组列表
 * @returns
 */
export function getProdGroupPage(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group/page`,
		method: "GET",
		data: {
			...data
		}
	})
}

/**
 * 获取商品分组详情
 * @returns
 */
export function getProdGroupDetail(id, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group/${id}`,
		method: "GET",
	})
}

/**
 * 商品分组添加
 * @returns
 */
export function addProdGroup(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group`,
		method: "POST",
		data: {
			...data
		}
	})
}

/**
 * 商品分组修改
 * @returns
 */
export function updateProdGroup(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group`,
		method: "PUT",
		data: {
			...data
		}
	})
}

/**
 * 商品分组简单修改
 * @returns
 */
export function editProdGroup(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group/update`,
		method: "PUT",
		data: {
			...data
		}
	})
}

/**
 * 商品分组删除
 * @returns
 */
export function delProdGroup(id, urlType = 'product') {
	return request({
		url: `${urlType}/admin/prod/group/${id}`,
		method: "DELETE",
	})
}

/**
 * 入库单识别
 * @returns
 */
export function stockOcr(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/stock/ocr`,
		method: "post",
		data
	})
}

/**
 * ocr识别结果
 * @returns
 */
export function ocrResult(data, urlType = 'product') {
	return request({
		url: `${urlType}/admin/product/stock/ocrResult`,
		method: "get",
		data
	})
}