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

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 过滤查询分配数据 
	 */
	filterQueryAllocation: function(registrationOrderDocumentNo, stockOutPrepareDocumentNo, otherRecipientsOrderDocumentNo){
		var requestUrl = "ElecEquipmentAllocationResource/filterQueryAllocation";
		var paramCount = 0;
		if(registrationOrderDocumentNo != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('registrationOrderDocumentNo=' + registrationOrderDocumentNo);
			paramCount ++;
		}
		if(stockOutPrepareDocumentNo != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('stockOutPrepareDocumentNo=' + stockOutPrepareDocumentNo);
			paramCount ++;
		}
		if(otherRecipientsOrderDocumentNo != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('otherRecipientsOrderDocumentNo=' + otherRecipientsOrderDocumentNo);
			paramCount ++;
		}


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 加载登记表明细 
	 */
	loadRegistrationOrderLine: function(param){
		var requestUrl = "ElecEquipmentAllocationResource/loadRegistrationOrderLine";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 生成制单数据 
	 */
	queryElecEquipmentAllocationDocument: function(){
		var requestUrl = "ElecEquipmentAllocationResource/queryElecEquipmentAllocationDocument";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存分配数据 
	 */
	saveAllocation: function(elecEquipmentAllocationLineDtoList){
		var requestUrl = "ElecEquipmentAllocationResource/saveAllocation";


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