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

/**
 * 工具类自动生成的API，请勿做任何修改，请勿做任何修改，请勿做任何修改（重要的事情说3遍）
 * 工具作者: 杨志杰
 * 采购电子元器件申购审批表 
 */
export default {

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据入库单Id查询明细 
	 */
	copyElectronicComponentOrder: function(recordId){
		var requestUrl = "PurchaseRequestResource/copyElectronicComponentOrder";
		var paramCount = 0;
		if(recordId != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('recordId=' + recordId);
			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);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 查询所有申购明细(元器件追踪) 
	 */
	getPurchaseRequestLineDtos: function(queryParamDto){
		var requestUrl = "PurchaseRequestResource/getPurchaseRequestLineDtos";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据申购单id查询所有操作过程(元器件追踪) 
	 */
	listTraceLineByPurchaseRequestId: function(id){
		var requestUrl = "PurchaseRequestResource/listTraceLineByPurchaseRequestId";
		var paramCount = 0;
		if(id != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('id=' + id);
			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);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据条件查询已经审批通过的单据 
	 */
	queryAllElectronicComponentOrderDto: function(queryParamDto){
		var requestUrl = "PurchaseRequestResource/queryAllElectronicComponentOrderDto";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据ID查询采购电子元器件申购审批表(供工作流调用) 
	 */
	queryByIdForActiviti: function(recordId){
		var requestUrl = "PurchaseRequestResource/queryByIdForActiviti";
		var paramCount = 0;
		if(recordId != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('recordId=' + recordId);
			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);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 根据申购单id查询申购明细 
	 */
	queryPurchaseRequestLineDto: function(purchaseRequestLineId){
		var requestUrl = "PurchaseRequestResource/queryPurchaseRequestLineDto";
		var paramCount = 0;
		if(purchaseRequestLineId != null){
			requestUrl += (paramCount > 0) ? '&' : '?';
			requestUrl += ('purchaseRequestLineId=' + purchaseRequestLineId);
			paramCount ++;
		}


		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);
				}
			});
		});
	},

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 保存备注 
	 */
	saveElectronicComponentOrder: function(purchaseRequestDto){
		var requestUrl = "PurchaseRequestResource/saveElectronicComponentOrder";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 导入数据 
	 */
	saveImportModelData: function(documentModelData){
		var requestUrl = "PurchaseRequestResource/saveImportModelData";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 给抄送人发送消息 
	 */
	sendCopyUserMessage: function(groupName, recordId, windonNo, tabIndex, userId){
		var requestUrl = "PurchaseRequestResource/sendCopyUserMessage";

		var formData = {};
		if(groupName != null){
			formData.groupName = groupName;
		}
		if(recordId != null){
			formData.recordId = recordId;
		}
		if(windonNo != null){
			formData.windonNo = windonNo;
		}
		if(tabIndex != null){
			formData.tabIndex = tabIndex;
		}
		if(userId != null){
			formData.userId = userId;
		}

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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 办结 
	 */
	transferred: function(purchaseRequestDto){
		var requestUrl = "PurchaseRequestResource/transferred";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 撤销办结 
	 */
	undoPending: function(purchaseRequestDto){
		var requestUrl = "PurchaseRequestResource/undoPending";


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

	/**
	 * 工具类自动生成的方法
	 * 工具作者: 杨志杰
	 * 修改采购方式 
	 */
	updateProcurementMethod: function(procurementMethod, recordId){
		var requestUrl = "PurchaseRequestResource/updateProcurementMethod";

		var formData = {};
		if(procurementMethod != null){
			formData.procurementMethod = procurementMethod;
		}
		if(recordId != null){
			formData.recordId = recordId;
		}

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