import request from '@/utils/request'

const baseUrl = import.meta.env.VITE_APP_BASE_API
// 查询产品管理列表
export function listProduct(query) {
	return request({
		url: baseUrl + '/business/product/list',
		method: 'get',
		params: query
	})
}

export function getTechnological(query) {
	return request({
		url: baseUrl + '/business/product/getTechnological',
		method: 'get',
		params: query
	})
}

// 查询产品管理详细
export function getProduct(id) {
	return request({
		url: baseUrl + '/business/product/getinfo/' + id,
		method: 'get'
	})
}

// 查询产品管理详细
export function getById(id) {
	return request({
		url: baseUrl + '/business/product/getById/' + id,
		method: 'get'
	})
}


// 保存产品信息
export function saveProduct(data) {
	let _action = ''
	if (data.id && data.id !== '0') {
		_action = 'edit'
		return request({
			url: baseUrl + '/business/product/' + _action,
			method: 'put',
			data: data
		})
	} else {
		_action = 'add'
		return request({
			url: baseUrl + '/business/product/' + _action,
			method: 'post',
			data: data
		})
	}
}

// 删除产品管理
export function delProduct(id) {
	return request({
		url: baseUrl + '/business/product/remove/' + id,
		method: 'delete'
	})
}

export function getProductsForSupplier(query) {
	return request({
		url: baseUrl + '/business/product/getProductsForSupplier',
		method: 'get',
		params: query
	})
}

export function getProductsForOutsource(query) {
	return request({
		url: baseUrl + '/business/product/getProductsForOutsource',
		method: 'get',
		params: query
	})
}
export function getProductTotal(query) {
	return request({
	 url: baseUrl +'/business/product/getTotal',
	  method: 'get',
	  params: query
	})
}