import { Common } from 'pc-component-v3';

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * 调拨单resource 
 */
export default {

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 生成调拨单
<ul>
<li>项目：西门子。功能：生成或者更新调拨单或者调拨出库。</li>
<li>调拨数量不能大于可调拨数量，同时也要大于0</li>
</ul> 
	 */
	create: function(projectItemAdjustDto){
		var requestUrl = "ProjectItemAdjustResource/create";


		return new Promise((resolve, reject) => {
			$.ajax({
				url: Common.getApiURL(requestUrl),
				type: "post",
				contentType: "application/json",
				
				dataType: "json",
				data: JSON.stringify(projectItemAdjustDto),
				
				beforeSend: function(request) {
					Common.addTokenToRequest(request);
				},
				success: function(data) {
					resolve(data);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					reject(XMLHttpRequest);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 强制完成当前调拨单据。如果调拨1000件，扫了很久还差10件，这时候就选择强制完成当前调拨单 
	 */
	forcedCompletion: function(projectItemAdjustId){
		var requestUrl = "ProjectItemAdjustResource/forcedCompletion";
		var paramCount = 0;
		if(projectItemAdjustId != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('projectItemAdjustId=' + projectItemAdjustId);
			paramCount ++;
		}


		return new Promise((resolve, reject) => {
			$.ajax({
				url: Common.getApiURL(requestUrl),
				type: "get",
				
				dataType: "json",
				
				
				beforeSend: function(request) {
					Common.addTokenToRequest(request);
				},
				success: function(data) {
					resolve(data);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					reject(XMLHttpRequest);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据条件查询调拨单 
	 */
	list: function(allocateQueryDto){
		var requestUrl = "ProjectItemAdjustResource/list";


		return new Promise((resolve, reject) => {
			$.ajax({
				url: Common.getApiURL(requestUrl),
				type: "post",
				contentType: "application/json",
				
				dataType: "json",
				data: JSON.stringify(allocateQueryDto),
				
				beforeSend: function(request) {
					Common.addTokenToRequest(request);
				},
				success: function(data) {
					resolve(data);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					reject(XMLHttpRequest);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 调拨单扫描epc返回信息 
	 */
	queryByEpc: function(projectItemAdjustDto){
		var requestUrl = "ProjectItemAdjustResource/queryByEpc";


		return new Promise((resolve, reject) => {
			$.ajax({
				url: Common.getApiURL(requestUrl),
				type: "post",
				contentType: "application/json",
				
				dataType: "json",
				data: JSON.stringify(projectItemAdjustDto),
				
				beforeSend: function(request) {
					Common.addTokenToRequest(request);
				},
				success: function(data) {
					resolve(data);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					reject(XMLHttpRequest);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 调拨单扫描调拨出库 
	 */
	transferOut: function(projectItemAdjustDto){
		var requestUrl = "ProjectItemAdjustResource/transferOut";


		return new Promise((resolve, reject) => {
			$.ajax({
				url: Common.getApiURL(requestUrl),
				type: "post",
				contentType: "application/json",
				
				dataType: "json",
				data: JSON.stringify(projectItemAdjustDto),
				
				beforeSend: function(request) {
					Common.addTokenToRequest(request);
				},
				success: function(data) {
					resolve(data);
				},
				error: function(XMLHttpRequest, textStatus, errorThrown) {
					reject(XMLHttpRequest);
				}
			});
		});
	}
}
