import request from '@/utils/request'

// 查询物料列表
export function listMaterial(query) {
	return request({
		url: '/mm/material/list',
		method: 'get',
		params: query
	})
}

export function advListMaterial(query) {
	return request({
		url: '/mm/material/advList',
		method: 'get',
		params: query
	})
}

export function getSimpleProductList() {
	return request({
		url: '/mm/material/getSimpleProductList',
		methods: 'get'
	})
}

/**
 * 查询物料详细
 * @param {Object} materialId 物料id
 */ 
export function getMaterial(materialId) {
	return request({
		url: '/mm/material/' + materialId,
		method: 'get'
	})
}


export function getMatByCode(code) {
	return request({
		url: '/mm/material/getMatByCode/' + code,
		method: 'get'
	})
}

export function importTemplate() {
	return request({
		url: '/mm/material/importTemplate',
		method: 'get'
	})
}

// 新增物料
export function addMaterial(data) {
	return request({
		url: '/mm/material',
		method: 'post',
		data: data
	})
}

// 修改物料
export function updateMaterial(data) {
	return request({
		url: '/mm/material',
		method: 'put',
		data: data
	})
}

// 删除物料
export function delMaterial(materialId) {
	return request({
		url: '/mm/material/' + materialId,
		method: 'delete'
	})
}

// 刷新产品获取
export function reloadPoMat() {
	return request({
		url: '/mm/material/reloadPoMat',
		method: 'post'
	})
}

// 打印物料标签
export function mergePrintPdfs(data) {
	return request({
		url: '/mm/material/mergePrintPdfs',
		method: 'post',
		data: data
	})
}

//同步U9物料信息
export function getU9Material() {
	return request({
		url: '/mm/material/getU9Material',
		method: 'post',
	})
}
