/**
 * 审核
 */

function reviewSubmit(id, type, step){//type 1:审核案件;2:审核融资协议,step 1:问题反馈;2:不通过;3:通过
	var url = contextPath + '/ssrz/ssrzOrder/saveReview';
	var reason = '';
	var oId = 'mod-reviewReq-orderId';
	var reasonId = 'reviewReqFailReason';
	if(type == 2){
		oId = 'mod-reviewPro-orderId';
		reasonId = 'reviewProFailReason';
	}
	if(step < 3){
		reason = $('#' + reasonId).val();
		if(reason.length < 1){
			showMsg('原因不能为空');
			return false;
		}
	}
	var parameters = {"orderId":$('#' + oId).val(),"type":type,"step":step,"reason":reason};
	postData(url, parameters, reviewSubmitCallback, errorCallbackDefault);
}

function reviewSubmitCallback(data){
	if(data.success){
		$('#' + data.modalId).modal('toggle');
		showMsg('保存成功');
		myGrid.trigger("reloadGrid");
		if(isNotBlank(data.modalIdAfter)){
			rzysClear();
			$('#mod-rzys-orderId').val($('#mod-reviewReq-orderId').val());
			$('#' + data.modalIdAfter).modal('toggle');
		}
	}else{
		showMsg(data.message);
	}
}

function reviewPro(id){
	$('#mod-reviewPro-orderId').val(id);
	$('#reviewProFailReason').val('');
	$('#modal-reviewPro-attachs').html('');
	var url = contextPath + '/ssrz/ssrzOrder/getOrderFilesByType';
	var parameters = {'orderId' : id,'type' : 3};
	postData(url, parameters, reviewProCallback, errorCallbackDefault);
}

function reviewProCallback(data){
	if(data.success){
		var attachs = data.attachs;
		var oa = null;
		var html = '';
		for(var j=0;j<attachs.length;j++){
			oa = attachs[j];
			html +=   '<a href="' + logoUrl + '/' + oa.path + '" target="_blank">';
			html +=    '<img class="lazy" src="' + contextPath + '/static/img/loading.gif" data-original="' + logoThum + '/' + oa.path + logoSize + '" height="100" width="100">';
			html +=   '</a>&nbsp;';
		}
		$('#modal-reviewPro-attachs').html(html);
		$('#modal-reviewPro').modal('toggle');
		setTimeout(function () {
			$("img.lazy").lazyload({
				threshold : 200
			});
		}, 200);
	}else{
		showMsg(data.message);
	}
}

function reviewReq(id){
	$('#mod-reviewReq-orderId').val(id);
	$('#reviewReqFailReason').val('');
	$("#modal-reviewReq").modal("toggle");
}
