/* 点击某条消息跳转到具体的业务模块 */
var jumpModulepermissionsEnameArray = [];
// 把获取到的当前用户权限的ename整合到一个数组中
function jumpModulepermissionsIntergrateEname(permission){
	for( var i=0;i<permission.length;i++ ){
		jumpModulepermissionsEnameArray.push(permission[i].ename);
		if( permission[i].childPermission!=undefined && permission[i].childPermission.length>0 ){
			jumpModulepermissionsIntergrateEname(permission[i].childPermission)
		}
	};
	i = null;
};

// 判断有无(要跳转的模块的)权限
function jumpModulepermissions(ename,notip){
	// 判断当前用户是否是管理员
	var jumpModulepermissionsAdminFlag = false;
	$.ajax({
		url:'/user/do_getLongUser',
		type:'get',
		data:{},
		async:false,
		success:function(data){
			if( data.success ){
				if( data.data.admin ){
					jumpModulepermissionsAdminFlag = true;
				}
			}else{
				new $.zui.Messager('获取当前用户是否是管理员失败:'+data.msg, {
				    type: 'danger'
				}).show();
			}
		},
		error:function(status){
			new $.zui.Messager('获取当前用户是否是管理员时发生错误:'+status, {
			    type: 'danger'
			}).show();
		}
	});
	// 是管理员时, 一定有权限可跳转, 如果不是, 则继续做判断
	if( jumpModulepermissionsAdminFlag ){// 是管理员
		return true;
	}else{// 不是管理员, 获取当前用户的权限且把权限的ename整合到一个数组中
		jumpModulepermissionsEnameArray = [];
		jumpModulepermissionsIntergrateEname(getpermission());
		if( jumpModulepermissionsEnameArray.includes(ename)){
			return true;
		}else{
			if( !notip ){
				new $.zui.Messager('您没有对应模块的权限，请联系管理员开通', {
				    type: 'danger'
				}).show();
			};
			return false;
		}
	}
};

// 判断是否因任务已完成或分配等原因不可再跳转
function jumpModuleOtherReason(id){
	var comFlag = false;
	$.ajax({
		url:'/businessProcessingTask/doDuplicateProcessing',
		type:'get',
		data:{
			'taskId':id
		},
		async:false,
		success:function(data){
			if( data.success ){
				if( data.data ){
					comFlag = true;
				}else{
					new $.zui.Messager('该任务已完成或被分配，您无权限操作', {
					    type: 'danger'
					}).show();
				}
			}else{
				new $.zui.Messager(data.msg, {
				    type: 'danger'
				}).show();
			};
		},
		error:function(status){
			new $.zui.Messager('获取该任务是否完成或被分配时出错:'+status, {
			    type: 'danger'
			}).show();
		}
	});
	return comFlag;
};

//判断是否因任务已完成或分配等原因不可再跳转--'收放款执行(保理融资款)'/'收放款执行(应收账款)'
function jumpModuleOtherReasonPay(businessId,businessType,msgType){
	var comFlag = false;
	$.ajax({
		url:'/businessProcessingTask/doDuplicateProcessingBusiness',
		type:'get',
		data:{
			'businessId':businessId,
			'businessType':businessType,
			'msgType':msgType
		},
		async:false,
		success:function(data){
			if( data.success ){
				if( data.data ){
					comFlag = true;
				}else{
					new $.zui.Messager('该任务已完成或被分配，您无权限操作', {
					    type: 'danger'
					}).show();
				}
			}else{
				new $.zui.Messager(data.msg, {
				    type: 'danger'
				}).show();
			};
		},
		error:function(status){
			new $.zui.Messager('获取该任务是否完成或被分配时出错:'+status, {
			    type: 'danger'
			}).show();
		}
	});
	return comFlag;
};

// 跳转
function jumpModuleFn(ename){
	$(".yk_menuactive").removeClass('yk_menuactive');
	$('#'+ename).addClass('yk_menuactive');
	$('.yk_secondmenu,.yk_thirdmenu').hide();
	if( $('#'+ename).parent().parent().hasClass("yk_thirdmenu") ){
		$('#'+ename).parent().parent().show();
	}
	$('#'+ename).parents('.yk_menuout').find('.yk_secondmenu').show();
	$.ajax({
		url:'/org/findRootOrgTreeNode',
		type:'get',
		async:false,
		data:{},
		success:function(data){
			$("#navTreeSelectOrgId").val(data[0].id);
			orgIdTitle=undefined;
		}
	});
	localStorage.removeItem("localdata");
	$('.datetimepicker.dropdown-menu').remove();

	if( ename == 'creditInsuranceManagement' ){
		$(".yk_rightcontent").load('/inkassonPolicy/list?ename=exportCreditInsuranceCorp',function(){
			backTop('.yk_rightcontent');
		});
	}else{
		$(".yk_rightcontent").load($('#'+ename).attr("url"),function(){
			backTop('.yk_rightcontent');
		});
	}

};

// 列表的操作按钮滑入在上方显示提示文字
$('body').on('mouseenter',".operateIcon.noHover p i",function(e){
	$(this).parents('p').find('span').show();
	$(this).parents('td').css('overflow','visible');
});
$('body').on('mouseleave',".operateIcon.noHover p i",function(e){
	$(this).parents('p').find('span').hide();
});

// 带搜索的(不请求后台)的下拉框
function withSearchDropDownBox(obj){
	// obj.allOptionSelector    所有的选项的选择器(用于克隆)
	// obj.triggerSelector      触发选择(显示下拉框)的表单的选择器(存放选择的name)
	// obj.resultIdSelector     表单元素选择器(存放选择的id)
	// obj.dropdownSelector     下拉框的选择器
	// obj.searchBtn            查询按钮的选择器(有则表示需要点击按钮才会查询)
	// obj.otherfn
	// obj.isCallback           是否需要输入框回调函数
	// obj.callback
	var otherfn = obj.otherfn || '';
	var businessSpecial = obj.businessSpecial || '';//业务管理特殊处理
	var searchBtn = obj.searchBtn || '';
	var isCallback = obj.isCallback || false
	var allOptionsClone = $(obj.allOptionSelector).clone();
	$(obj.triggerSelector).click(function(e){
		$(obj.dropdownSelector).find("ul").empty().append(allOptionsClone);
		$(obj.dropdownSelector).show();
		$(obj.dropdownSelector).find('input').val('').focus();
		// 额度支用处的特殊处理--设置选项的是否选中样式
		$(obj.dropdownSelector).find("ul").find('li').removeClass('multiple-alreadyActive');
		if( $(e.target).hasClass('multiple-resultBox') || $(e.target).hasClass('multiple-chooseSpan') ){
			$(obj.dropdownSelector).parent().find('.multiple-resultBox').find('span').each(function(i,ele){
				$(obj.dropdownSelector).find("ul").find('li').each(function(j,dom){
					if( $(ele).attr('value') == $(dom).attr('value') ){
						$(dom).addClass('multiple-alreadyActive');
					}
				})
			});
		};
		return false;
	});
	$("body").on("click",function(){
		$(obj.dropdownSelector).hide();
	});
	$(obj.dropdownSelector).find('input').click(function(){
		return false;
	});

	$(obj.dropdownSelector).find('input').keyup(function(){
		if( searchBtn!='' ){
			return;
		}
		$(obj.dropdownSelector).find("ul").empty();
		if( $(this).val()=='' ){
			$(obj.dropdownSelector).find("ul").append(allOptionsClone);
		}else{
			for( var i=0;i<$(obj.allOptionSelector).length;i++ ){
				if( $(obj.allOptionSelector).eq(i).text().indexOf($(this).val())>=0 ){
					$(obj.dropdownSelector).find("ul").append($(obj.allOptionSelector).eq(i).clone());
				};
			};
			i = null;
			if( $(obj.dropdownSelector).find("ul").find('li').length<=0 ){
				$(obj.dropdownSelector).find("ul").append('<li class="notcompanyli" style="background-color:#f0f0f3;">未找到相关选项! "'+$(this).val()+'"</li>')
			}
		};
		$(obj.dropdownSelector).find("ul").find('li').removeClass('multiple-alreadyActive');
		if( otherfn != '' ){// 额度支用处的特殊处理--设置选项的是否选中样式
			if( !$(obj.dropdownSelector).parent().find('.multiple-resultBox').hasClass('hide') ){
				$(obj.dropdownSelector).parent().find('.multiple-resultBox').find('span').each(function(i,ele){
					$(obj.dropdownSelector).find("ul").find('li').each(function(j,dom){
						if( $(ele).attr('value') == $(dom).attr('value') ){
							$(dom).addClass('multiple-alreadyActive')
						}
					})
				});
			};
		};
	});
	$(obj.dropdownSelector).on("click","li.notcompanyli",function(){
		return false;
	});


	if( searchBtn!='' ){
		$(searchBtn).click(function(){
			$(obj.dropdownSelector).find("ul").empty();
			if( $(obj.dropdownSelector).find('input').val()=='' ){
				$(obj.dropdownSelector).find("ul").append(allOptionsClone);
			}else{
				for( var i=0;i<$(obj.allOptionSelector).length;i++ ){
					if( $(obj.allOptionSelector).eq(i).text().indexOf($(obj.dropdownSelector).find('input').val())>=0 ){
						$(obj.dropdownSelector).find("ul").append($(obj.allOptionSelector).eq(i).clone());
					};
				};
				i = null;
				if( $(obj.dropdownSelector).find("ul").find('li').length<=0 ){
					$(obj.dropdownSelector).find("ul").append('<li class="notcompanyli" style="background-color:#f0f0f3;">未找到相关选项! "'+$(obj.dropdownSelector).find('input').val()+'"</li>')
				}
			};
			$(obj.dropdownSelector).find("ul").find('li').removeClass('multiple-alreadyActive');
			return false;
		})
	};

	if( otherfn == '' ){
		if(businessSpecial == '') {
			$(obj.dropdownSelector).on("click","li.companyli",function(){
				$(obj.triggerSelector).val($(this).text());
				if(isCallback) {
					obj.callback()
				}
				$(obj.triggerSelector).blur()
				$(obj.resultIdSelector).val($(this).attr('value'));
				$(obj.dropdownSelector).hide();
				if( $(obj.triggerSelector).val()!='' ){
					//移除验证效果
					$(obj.triggerSelector).removeClass('error');
					$(obj.triggerSelector+"-error").remove();
				};
				return false;
			});
		}else {
			$(obj.dropdownSelector).on("click","li.companyli",function(){
				$(obj.triggerSelector).val($(this).text());
				$(obj.resultIdSelector).val($(this).attr('value'));
				if(isCallback) {
					obj.callback()
				}
				$(obj.dropdownSelector).hide();
				if( $(obj.triggerSelector).val()!='' ){
					//移除验证效果
					$(obj.triggerSelector).removeClass('error');
					$(this).parent().parent().parent().find('.error').removeClass('shows').hide()
				};
				return false;
			});
		}

	};
};

// 暂存时验证'期限'类型的方法
function tempSavingTermFn(t){
	if( t.val()!='' ){
		if( /^[0-9]*$/.test(t.val()) ){
			t.parent().find('span.error').removeClass('shows').hide();
		}else{
			t.parent().find('span.error').addClass('shows').show();
		}
	}else{
		t.parent().find('span.error').removeClass('shows').hide();
	}
};

// 暂存时验证'比例'类型的方法
function tempSavingRateFn(t){
	if( t.val()!='' ){
		if( (/^([1-9]\d?(\.\d{1,2})?|0\.\d{1,2}|99.99)$/.test(t.val())) ){
			if( parseFloat(t.val())==0 ){
				t.parent().find('span.error').addClass('shows').show();
			}else{
				t.parent().find('span.error').removeClass('shows').hide();
			}
		}else{
			t.parent().find('span.error').addClass('shows').show();
		}
	}else{
		t.parent().find('span.error').removeClass('shows').hide();
	}
};

//暂存时验证'比例'类型的方法2--可以等于0和100
function tempSavingRateFn2(t){
	if( t.val()!='' ){
		if( (/^(0|[1-9]\d?(\.\d{1,2})?|0\.\d{1,2}|100)$/.test(t.val())) ){
			t.parent().find('span.error').removeClass('shows').hide();
		}else{
			if( t.val()=='100.0' || t.val()=='100.00' ){
				t.parent().find('span.error').removeClass('shows').hide();
			}else{
				t.parent().find('span.error').addClass('shows').show();
			};
		}
	}else{
		t.parent().find('span.error').removeClass('shows').hide();
	}
}

// 暂存时验证'irr'的方法
function tempSavingIrrFn(t){
	if( t.val()!='' ){
		if( (/^(\-|\+)?\d+(\.\d+)?$/.test(t.val().split(',').join(''))) ){
			t.parent().find('span.error').removeClass('shows').hide();
		}else{
			t.parent().find('span.error').addClass('shows').text('请输入正确的数字').show();
			return;
		};
		if( t.val().indexOf('.')>0 ){
			if( String(t.val()).split('.')[1].length>2 ){
				t.parent().find('span.error').addClass('shows').text('小数点后最多两位小数').show();
				return;
			}else{
				t.parent().find('span.error').removeClass('shows').hide();
			}
		}else{
			t.parent().find('span.error').removeClass('shows').hide();
		};
		if( t.val().indexOf('-')>=0 ){
			if( t.val().split('.')[0].length > 5 ){
				t.parent().find('span.error').addClass('shows').text('整数位最多四位数字').show();
				return;
			}else{
				t.parent().find('span.error').removeClass('shows').hide();
			};
		}else{
			if( t.val().split('.')[0].length > 4 ){
				t.parent().find('span.error').addClass('shows').text('整数位最多四位数字').show();
				return;
			}else{
				t.parent().find('span.error').removeClass('shows').hide();
			};
		}
	}else{
		t.parent().find('span.error').removeClass('shows').hide();
	}
};

// 回款异常数据处理(填充到页面上)
function fillAbnormalPaymentSituation(abnormalReturnBasicVoList){
	var returnAbnormalDom = '';
	if( abnormalReturnBasicVoList && abnormalReturnBasicVoList.length>0 ){
		for( var i=0;i<abnormalReturnBasicVoList.length;i++ ){
			var abnormalTbodyStr = '<tbody class="abnormalPaymentSituationTbody">';
			for( var j=0;j<abnormalReturnBasicVoList[i].abnormalReturnList.length;j++ ){
				for( var m=0;m<abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList.length;m++ ){
					abnormalTbodyStr += '<tr rownumber="row_'+j+'"><td width="8%" class="rowspantd">'+(abnormalReturnBasicVoList[i].currency?abnormalReturnBasicVoList[i].currency.code:'')+'</td>'
							+'<td width="12%" style="background:#fff;" class="rowspantd">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].businessNo?abnormalReturnBasicVoList[i].abnormalReturnList[j].businessNo:'')+'</td>'
							+'<td width="12%" style="background:#fff;" class="rowspantd">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].quotaBatches!=undefined?abnormalReturnBasicVoList[i].abnormalReturnList[j].quotaBatches:'')+'</td>'
							+'<td width="12%" style="background:#fff;" class="rowspantd">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].contractNo?abnormalReturnBasicVoList[i].abnormalReturnList[j].contractNo:'')+'</td>'
							+'<td width="12%" style="background:#fff;">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].amountType?abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].amountType.name:'')+'</td>'
							+'<td width="12%" style="background:#fff;">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].planDate?getStandardDate(new Date(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].planDate)):'')+'</td>'
							+'<td width="12%" style="background:#fff;">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].receivableAmount!=undefined?commaDelimiter(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].receivableAmount.toString()):'')+'</td>'
							+'<td width="12%" style="background:#fff;">'+(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].actualReceivedAmount!=undefined?commaDelimiter(abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].actualReceivedAmount.toString()):'')+'</td>'
							+'<td width="8%" style="background:#fff;"><span class="viewAbnormalPaymentSituation" style="color:#59c4fc;cursor:pointer;">查看</span></td>'
							+'</tr>'
				};
				m = null;
			};
			j = null;
			abnormalTbodyStr += '<tr><td width="8%">'+abnormalReturnBasicVoList[i].currency.code+'</td><td colspan="4" style="background:#fff">应收金额总计：'+(abnormalReturnBasicVoList[i].totalReceivableAmount!=undefined?commaDelimiter(abnormalReturnBasicVoList[i].totalReceivableAmount.toString()):'')+'</td><td colspan="4" style="background:#fff">实收金额总计：'+(abnormalReturnBasicVoList[i].totalAmountReceived!=undefined?commaDelimiter(abnormalReturnBasicVoList[i].totalAmountReceived.toString()):'')+'</td></tr></tbody>';

			returnAbnormalDom += abnormalTbodyStr;
		};
		i = null;
	}else{
		returnAbnormalDom = '<tr><td style="background:#fff;">无回款异常情况</td></tr>'
	};
	return returnAbnormalDom;
};

// 回款异常数据处理(合并行等)
function detailAbnormalPaymentSituation(abnormalReturnBasicVoList,parentSelector){
	if( abnormalReturnBasicVoList && abnormalReturnBasicVoList.length>0 ){
		// 存放查看时的data
		for( var i=0;i<abnormalReturnBasicVoList.length;i++ ){
			for( var j=0;j<abnormalReturnBasicVoList[i].abnormalReturnList.length;j++ ){
				for( var m=0;m<abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList.length;m++ ){
					if( abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].receivedRecordList ){
						parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']').find('.viewAbnormalPaymentSituation').eq(m).data('detaildata',abnormalReturnBasicVoList[i].abnormalReturnList[j].returnRecordList[m].receivedRecordList);
					}else{
						parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']').find('.viewAbnormalPaymentSituation').eq(m).data('detaildata',[]);
					};
				};
				m = null;
			};
			j = null;
		};
		i = null;
		// 合并行处理
		for( var i=0;i<abnormalReturnBasicVoList.length;i++ ){
			var bigRowspanLength = 0;
			for( var j=0;j<abnormalReturnBasicVoList[i].abnormalReturnList.length;j++ ){
				parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']:first').find('.rowspantd').attr('rowspan',parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']').length);
				parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']:not(:first)').find('.rowspantd').remove();
				bigRowspanLength += parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']').length;
				if( j!=0 ){
					parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr[rownumber=row_'+j+']:first td:first').remove();
				}
			};
			j = null;
			parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr:first td:first').attr('rowspan',bigRowspanLength+1);
			parentSelector.find('.abnormalPaymentSituationTbody').eq(i).find('tr:last td:first').remove();
		};
		i = null;

	};
	// 回款异常情况--查看
	$('body').off('click').on('click','.viewAbnormalPaymentSituation',function(){
		$("#myModal-viewAbnormalPaymentSituation table tr:not(:first)").remove();
		$('#myModal-viewAbnormalPaymentSituation').modal('show');
		var viewAbnormalDetaildata = $(this).data('detaildata');
		if( viewAbnormalDetaildata && viewAbnormalDetaildata.length>0 ){
			for( var i=0;i<viewAbnormalDetaildata.length;i++ ){
				$('#myModal-viewAbnormalPaymentSituation table').append('<tr><td>'+(i+1)+'</td>'
						+'<td>'+(viewAbnormalDetaildata[i].actualDate?viewAbnormalDetaildata[i].actualDate:'')+'</td>'
						+'<td>'+(viewAbnormalDetaildata[i].actualAmount!=undefined?commaDelimiter(viewAbnormalDetaildata[i].actualAmount.toString()):'')+'</td>'
						+'</tr>')
			};
			i = null;
		}else{
			$('#myModal-viewAbnormalPaymentSituation table').append('<tr><td colspan="3" style="background:#fff;">无数据</td></tr>')
		}
	});
};

//根据企业id查询回款异常
function searchAbnormalPaymentSituation(entBusinessId,parentSelector){
	$.ajax({
		url:'/entCustomerMarketing/info/do_findAbnormalReturnByApplicant',
		type:'get',
		data:{
			'entBusinessId':entBusinessId // 企业 id
		},
		async:false,
		success:function(data){
			if( data.success ){
				// 填值处理
				$(parentSelector).html(fillAbnormalPaymentSituation(data.data));
				// 合并行等处理
				detailAbnormalPaymentSituation(data.data,parentSelector);
			}else{
				new $.zui.Messager('查询回款异常数据失败:'+data.msg, {
				    type: 'danger'
				}).show();
			}
		},
		error:function(status){
			new $.zui.Messager('查询回款异常数据时出错:'+status, {
			    type: 'danger'
			}).show();
		}
	})
};

// 处理存量客户运行情况
function detailStockCustomerData(){
	if( $('.stockCustomerBasicTbody').length<=0 ){
		$('.stockCustomerBasicTable').append('<tr><td colspan="8" style="background:#fff;">无存量客户运行情况</td></tr>')
	}else{
		// 金额添加分隔符
		$('.stockCustomerMoneyData').each(function(i,ele){
			$(ele).text(commaDelimiter($(ele).text()))
		});
		// 日期格式转换
		$('.stockCustomerDateData').each(function(i,ele){
			$(ele).text(getStandardDate(new Date($(ele).text())))
		});
		// 期限添加单位
		$('.stockCustomerTermData').each(function(i,ele){
			if( $(ele).text()!='' ){
				$(ele).text($(ele).text()+'天')
			};
		});
		// 逾期时,剩余额度标红
		$('.stockCustomerMoneyCreditBalance').each(function(i,ele){
			if( $(ele).attr('ex') == 'true' ){
				$(ele).css('color','red');
			}else{
				$(ele).css('color','#333');
			};
		});
		// 合并行
		$('.stockCustomerBasicTbody').each(function(i,ele){
			$(ele).find('tr:first td:first').attr('rowspan',$(ele).find('tr').length);
			$(ele).find('tr:not(:first) .rowspantd').remove();
		});
	};
};

// 存量客户运行情况处理(填充到页面上, 历史信息使用)
function fillHistoryStockCustomerData(stockCustomerBasicList){
	var returnStockCustomerDom = '';
	if( stockCustomerBasicList && stockCustomerBasicList.length>0 ){
		for( var i=0;i<stockCustomerBasicList.length;i++ ){
			var stockCustomerTbodyStr = '<tbody class="stockCustomerBasicHistoryTbody">';
			for( var j=0;j<stockCustomerBasicList[i].stockCustomerList.length;j++ ){
				stockCustomerTbodyStr += '<tr><td class="rowspantd" width="8%">'+(stockCustomerBasicList[i].currency?stockCustomerBasicList[i].currency.code:'')+'</td>'
						+'<td style="background:#fff;" width="14%">'+(stockCustomerBasicList[i].stockCustomerList[j].businessNo?stockCustomerBasicList[i].stockCustomerList[j].businessNo:'')+'</td>'
						+'<td style="background:#fff;" width="13%">'+(stockCustomerBasicList[i].stockCustomerList[j].creditType?stockCustomerBasicList[i].stockCustomerList[j].creditType.name:'')+'</td>'
						+'<td style="background:#fff;" width="13%">'+(stockCustomerBasicList[i].stockCustomerList[j].creditLine!=undefined?commaDelimiter(stockCustomerBasicList[i].stockCustomerList[j].creditLine.toString()):'')+'</td>'
						+'<td style="background:#fff;" width="13%">'+(stockCustomerBasicList[i].stockCustomerList[j].creditStartDate?stockCustomerBasicList[i].stockCustomerList[j].creditStartDate:'')+'</td>'
						+'<td style="background:#fff;" width="13%">'+(stockCustomerBasicList[i].stockCustomerList[j].creditTerm?stockCustomerBasicList[i].stockCustomerList[j].creditTerm+'天':'')+'</td>'
						+'<td style="background:#fff;" width="13%">'+(stockCustomerBasicList[i].stockCustomerList[j].creditEndDate?stockCustomerBasicList[i].stockCustomerList[j].creditEndDate:'')+'</td>'
						+'<td style="background:#fff;" width="13%" style="color:'+(stockCustomerBasicList[i].stockCustomerList[j].expired?'red':'#333')+';">'+(stockCustomerBasicList[i].stockCustomerList[j].creditBalance!=undefined?commaDelimiter(stockCustomerBasicList[i].stockCustomerList[j].creditBalance.toString()):'')+'</td>'
						+'</tr>'
			};
			j = null;
			stockCustomerTbodyStr += '<tr><td class="rowspantd">'+stockCustomerBasicList[i].currency.code+'</td><td colspan="3" style="background:#fff">历史授信金额总计：'+(stockCustomerBasicList[i].hisCreditAmountTotal!=undefined?commaDelimiter(stockCustomerBasicList[i].hisCreditAmountTotal.toString()):'')+'</td><td colspan="4" style="background:#fff">历史剩余额度总计：'+(stockCustomerBasicList[i].hisCreditBalanceTotal!=undefined?commaDelimiter(stockCustomerBasicList[i].hisCreditBalanceTotal.toString()):'')+'</td></tr></tbody>';

			returnStockCustomerDom += stockCustomerTbodyStr;
		};
		i = null;
	}else{
		returnStockCustomerDom = '<tr><td style="background:#fff;">无存量客户运行情况</td></tr>'
	}
	return returnStockCustomerDom;
};

// 处理存量客户运行情况(合并行处理, 历史信息使用)
function detailHistoryStockCustomerData(stockCustomerBasicList,parentSelector){
	parentSelector.find('.stockCustomerBasicHistoryTbody').each(function(i,ele){
		$(ele).find('tr:first td:first').attr('rowspan',$(ele).find('tr').length);
		$(ele).find('tr:not(:first) .rowspantd').remove();
	});
};

// 头部统计按钮
$('.yk_headStaticsBtn').click(function(){
	if( $('.yk_headStaticsBtn #statisticsManage').length<=0 ){
		new $.zui.Messager('无统计模块权限, 请联系管理员开通', {
		    type: 'danger'
		}).show();
	}else{
		$(".yk_menuactive").removeClass('yk_menuactive');
		$('.yk_secondmenu,.yk_thirdmenu').hide();
		$('.yk_rightcontent').load('/statistics/list',function(){
			window.location.href = window.location.origin+'/#/statistics';
		})
	}
})
