import request from '@/utils/request'

/** 接口 */
const Api = {
	queryInBillSkuInfo: '/api/wms/pda/queryInBillSkuInfo',
	createPalletByBill: '/api/wms/pda/createPalletByBill',
	createPalletBySku: '/api/wms/pda/createPalletBySku',
	createPalletAgv: '/api/restful/createPalletAgv',
	getCanUseInBill: '/api/wms/pda/getCanUseInBill',
	list: '/api/wms/inBill/list',
	returnEmptyRack: '/api/wms/pda/returnEmptyRack',
	callAgvIn: '/api/wms/pda/callAgvIn',
	callEmptyOut: '/api/wms/pda/callEmptyRackOut',
	surplusReturn: '/api/wms/pda/surplusReturn',
	manualCall: '/api/wms/pda/manualCall',
	surplusOut: '/api/wms/pda/surplusOut',
	callEmptyRackIn: '/api/wms/pda/callEmptyRackIn',
}
/** 空容器入库 */
export const callEmptyRackIn = data => {
	return request({
		url: Api.callEmptyRackIn,
		data: data,
		method: 'POST'
	})
}
/** 人工叫料 */
export const manualCall = data => {
	return request({
		url: Api.manualCall,
		data: data,
		method: 'POST'
	})
}
/** 余料出库 */
export const surplusOut = data => {
	return request({
		url: Api.surplusOut,
		data: data,
		method: 'POST'
	})
}
/** 余料回库 */
export const surplusReturn = data => {
	return request({
		url: Api.surplusReturn,
		data: data,
		method: 'POST'
	})
}
/** 呼叫空工装返回 */
export const returnEmptyRack = data => {
	return request({
		url: Api.returnEmptyRack,
		data: data,
		method: 'POST'
	})
}
/** 呼叫Agv入库*/
export const callAgvIn = data => {
	return request({
		url: Api.callAgvIn,
		data: data,
		method: 'POST'
	})
}
/** 呼叫空托盘出库*/
export const callEmptyOut = data => {
	return request({
		url: Api.callEmptyOut,
		data: data,
		method: 'POST'
	})
}
/** 物料组盘 */
export const createPalletBySku = data => {
	return request({
		url: Api.createPalletBySku,
		data: data,
		method: 'POST'
	})
}
/**
 * 入库站台组盘
 */
export const createPalletAgv = data => {
	return request({
		url: Api.createPalletAgv,
		data: data,
		method: 'POST'
	})
}
/** 入库单明细查询 */
export const queryInBillSkuInfo = data => {
	return request({
		url: Api.queryInBillSkuInfo,
		params: data,
		method: 'GET'
	})
}
/** 单据组盘表单提交 */
export const createPalletByBill = data => {
	return request({
		url: Api.createPalletByBill,
		data: data,
		method: 'POST'
	})
}
/** 入库单查询 */
export const list = data => {
	return request({
		url: Api.list,
		params: data,
		method: 'GET'
	})
}

/** 新增执行状态单据下拉选择查询 */
export async function getInvoicesByBusinessType(businessType){	
	var invoiceCode =[];
	let responseData = await request({
		url: Api.getCanUseInBill,
		params: {'businessType': businessType},
		method: 'get'
	}).then(response => {
		invoiceCode = response.data;
		invoiceCode.map((item) => {
			item.text = item.invoiceCode
			item.value = item.invoiceCode
			console.log("获取下拉值数",item.text)
		});
	}).catch((e)=>{
		console.log("获取下拉值数据时出现异常",e)
	});
	console.log("单据号",invoiceCode)
	return invoiceCode	
}
