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

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据采购订单号、存货档案名称、存货档案编码、规格型号查询采购订单明细DTO 
	 */
	findAllByDocumentNoNameCodeType: function(documentNo, inventoryName, inventoryCode, inventoryType){
		var requestUrl = "PurchaseOrderLineResource/findAllByDocumentNoNameCodeType";

		var formData = {};
		if(documentNo != null){
			formData.documentNo = documentNo;
		}
		if(inventoryName != null){
			formData.inventoryName = inventoryName;
		}
		if(inventoryCode != null){
			formData.inventoryCode = inventoryCode;
		}
		if(inventoryType != null){
			formData.inventoryType = inventoryType;
		}

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据采购订单号、存货档案名称、存货档案编码、规格型号查询对应的未打印采购订单明细DTO 
	 */
	findNotPrintByDocumentNoNameCodeType: function(documentNo, inventoryName, inventoryCode, inventoryType){
		var requestUrl = "PurchaseOrderLineResource/findNotPrintByDocumentNoNameCodeType";

		var formData = {};
		if(documentNo != null){
			formData.documentNo = documentNo;
		}
		if(inventoryName != null){
			formData.inventoryName = inventoryName;
		}
		if(inventoryCode != null){
			formData.inventoryCode = inventoryCode;
		}
		if(inventoryType != null){
			formData.inventoryType = inventoryType;
		}

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据采购订单号、存货档案名称、存货档案编码、规格型号查询对应的已打印采购订单明细DTO 
	 */
	findPrintedByDocumentNoNameCodeType: function(documentNo, inventoryName, inventoryCode, inventoryType){
		var requestUrl = "PurchaseOrderLineResource/findPrintedByDocumentNoNameCodeType";

		var formData = {};
		if(documentNo != null){
			formData.documentNo = documentNo;
		}
		if(inventoryName != null){
			formData.inventoryName = inventoryName;
		}
		if(inventoryCode != null){
			formData.inventoryCode = inventoryCode;
		}
		if(inventoryType != null){
			formData.inventoryType = inventoryType;
		}

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 *  
	 */
	queryByNoInventory: function(documentNo, inventoryMessage){
		var requestUrl = "PurchaseOrderLineResource/queryByNoInventory";

		var formData = {};
		if(documentNo != null){
			formData.documentNo = documentNo;
		}
		if(inventoryMessage != null){
			formData.inventoryMessage = inventoryMessage;
		}

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 模糊查询采购订单号 
	 */
	queryPurchaseOrderLineDocumentNo: function(documentNo){
		var requestUrl = "PurchaseOrderLineResource/queryPurchaseOrderLineDocumentNo";
		var paramCount = 0;
		if(documentNo != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('documentNo=' + documentNo);
			paramCount ++;
		}


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据采购订单明细id 查询包装信息 
	 */
	queryPurchaseOrderLinePackDto: function(purchaseOrderLineId){
		var requestUrl = "PurchaseOrderLineResource/queryPurchaseOrderLinePackDto";
		var paramCount = 0;
		if(purchaseOrderLineId != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('purchaseOrderLineId=' + purchaseOrderLineId);
			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);
				}
			});
		});
	}
}
