$(function(){
	// 只有卖方基本信息, 卖方为授信主体
	if( creditReportQuery.source == 'sell' ){
		$('.buyerBasicLi,.businessBasicBuyerLi').remove();
	};
	// 只有买方基本信息, 买方为交易对手
	if( creditReportQuery.source == 'buy' ){
		$('.sellerBasicLi,.businessBasicSellerLi').remove();
	};
	// 买方基本信息和卖方基本信息都有, 买方为授信主体，卖方为交易对手
	if( creditReportQuery.source == 'all' ){
		
	};
	
	// 切换导航
	$('.projectListTab li.sellerBasicLi').click(function(){// 卖方基本信息
		if( !$(this).hasClass('active') ){
			$(".yk_rightcontent").load("/creditReportingBasicInfo/sellerView");
		};
	});
	$('.projectListTab li.buyerBasicLi').click(function(){// 买方基本信息
		if( !$(this).hasClass('active') ){
			$(".yk_rightcontent").load("/creditReportingBasicInfo/buyerView");
		};
	});
	$('.projectListTab li.businessBasicBuyerLi').click(function(){// 买方业务信息
		if( !$(this).hasClass('active') ){
			$(".yk_rightcontent").load("/creditreporting/businessInfo/buyerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.counterpartyId);
		};
	});
	$('.projectListTab li.businessBasicSellerLi').click(function(){// 卖方业务信息
		if( !$(this).hasClass('active') ){
			$(".yk_rightcontent").load("/creditreporting/businessInfo/sellerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.creditSubjectId);
		};
	});
	
	if( $('.form-horizontal .newTabAddUpdateBox div.row').length <= 0 ){
		$('.form-horizontal .newTabAddUpdateBox').append('<p>无相关信息</p>');
		$('.form-horizontal .newTabAddUpdateBtnBox .save').hide();
	};
	
	// 获取字典项数据
	function getDictCode(paramName){
		var dictOptionsData = {};
		$.ajax({
			url:'/orgbaseInfo/doFindDictCode',
			type:'get',
			data:{
				'paramName':paramName
			},
			async:false,
			success:function(data){
				dictOptionsData = data;
			},
			error:function(status){
				new $.zui.Messager('获取字典项时出错:'+status, {
				    type: 'danger'
				}).show();
			}
		});
		return dictOptionsData;
	};
	
	// 保理产品类型/保理业务状态/担保标志/垫款标志/四级分类/五级分类
	// 垫款种类/币种/还款方式/四级分类/五级分类
	// 欠息类型/币种
	// 借贷业务种类/是否是自然人/证件类型/币种/保证担保形式/合同有效状态
	// 借贷业务种类/是否是自然人/证件类型/币种/抵押物种类/合同有效状态
	// 借贷业务种类/是否是自然人/证件类型/币种/质押物种类/合同有效状态
	// 币种/主要资产处理方式
    $('.factoring-classify5,.cashAdvance-repayType,.cashAdvance-classify5,.guarantyContractDialog-isNaturalPerson,.guarantyContractDialog-certType,.guarantyContractDialog-currency,.mortgageContractDialog-isNaturalPerson,.mortgageContractDialog-certType,.mortgageContractDialog-evaluationCurrency,.mortgageContractDialog-mortgageType,.pledgeContractDialog-isNaturalPerson,.pledgeContractDialog-certType,.pledgeContractDialog-pledgeCurrency,.pledgeContractDialog-pledgeType,.badCreditDialog-disposeType,.mortgageContractDialog-mortgageCurrency,.pledgeContractDialog-pledgeCurrency1').each(function(i,ele){
		var selectTypeOptions = getDictCode($(ele).attr('name'));
		if( selectTypeOptions ){
			for( var i in selectTypeOptions){
				$(ele).append('<option value="'+i+'">'+selectTypeOptions[i]+'</option>')
			};
			$(ele).find('option[value='+$(ele).attr('orival')+']').prop('selected',true);
		};
	});
    
    // 日期的处理
	$('.factoring-occurDate,.factoring-bizDate,.factoring-bizChangeDate,.cashAdvance-occurDate,.cashAdvance-advanceDate,.cashAdvance-advanceChgDate,.debitInterest-occurDate,.debitInterest-changeDate').each(function(i,ele){
		if( $(ele).attr('orival') ){
			$(ele).val($(ele).attr('orival').substring(0,4)+'-'+$(ele).attr('orival').substring(4,6)+'-'+$(ele).attr('orival').substring(6,8));
		}
	});
    
    // 日期
	function initDate(selector,startd,endd){
		var startDate = '1970-01-01',
			endDate = '2999-12-31';
		if( startd!=undefined && startd!='' ){
			startDate = startd;
		};
		if( endd!=undefined && endd!='' ){
			endDate = endd;
		};
		$(selector).datetimepicker(
			{	
				weekStart: 1,
			    autoclose: 1,
			    todayHighlight: 0,
			    startView: 2,
			    minView: 2,
			    forceParse: 0,
			    showMeridian: 1,
			    startDate:startDate,
			    endDate:endDate,
			    format: "yyyy-mm-dd"
			}
		);
		$(selector).datetimepicker('setStartDate',startDate);
		$(selector).datetimepicker('setEndDate',endDate);
	};
	initDate('.factoring-occurDate,.factoring-bizDate,.factoring-bizChangeDate,.cashAdvance-occurDate,.cashAdvance-advanceDate,.cashAdvance-advanceChgDate,.debitInterest-occurDate,.debitInterest-changeDate')
	
	
	//日期输入框可删除
	$('.deleteTime').each(function(i,ele){
		$(ele).parent().find('input').change(function(){
			if( $(this).val()!=='' ){
				var transDate = $(this).val().split('-')[0]+$(this).val().split('-')[1]+$(this).val().split('-')[2];
				$(this).val(transDate)
				$(ele).show();
				//日期有值时去掉验证效果
				$(ele).parent().find('input').removeClass('error');
				$("#"+$(ele).parent().find('input').attr('name')+"-error").hide();
			}else{
				$(ele).hide();
			};
			
			// '保证事件日期'变化,对应的'合同签订日期'要重新设置日期选项, 反之一样
			
			// 保证事件日期 >= 合同签订日期
			// 合同签订日期 >= 投放日期
			
			if( $(this).hasClass('guarantyContractDialog-createDate') ){
				createDialogDate('.guarantyContractDialog-occurDate',$(this).val(),'21181231',$('.guarantyContractDialog-occurDate').val());
			};
			if( $(this).hasClass('mortgageContractDialog-assignDate') ){
				createDialogDate('.mortgageContractDialog-occurDate',$(this).val(),'21181231',$('.mortgageContractDialog-occurDate').val())
			};
			if( $(this).hasClass('pledgeContractDialog-assignDate') ){
				createDialogDate('.pledgeContractDialog-occurDate',$(this).val(),'21181231',$('.pledgeContractDialog-occurDate').val());
			};
			
			if( $(this).hasClass('guarantyContractDialog-occurDate') ){
				createDialogDate('.guarantyContractDialog-createDate',$('.factoring-bizDate').attr('orival'),$(this).val(),$('.guarantyContractDialog-createDate').val());
			};
			if( $(this).hasClass('mortgageContractDialog-occurDate') ){
				createDialogDate('.mortgageContractDialog-assignDate',$('.factoring-bizDate').attr('orival'),$(this).val(),$('.mortgageContractDialog-assignDate').val())
			};
			if( $(this).hasClass('pledgeContractDialog-occurDate') ){
				createDialogDate('.pledgeContractDialog-assignDate',$('.factoring-bizDate').attr('orival'),$(this).val(),$('.pledgeContractDialog-assignDate').val());
			};
			
		});
		$(ele).parent().find('input').change();
	});
	$('.deleteTime').click(function(){
		$(this).parent().find('input').val('');
		$(this).hide();
	});
	
	$('.moneyAmount').each(function(i,ele){
		if( $(ele).text()!='' ){
			$(ele).text(handleListAmountFn($(ele).text(),$(ele).attr('curr')))
		}
	});
	
	// 金额的处理
	$('.factoring-bizAmount,.factoring-bizBalance,.cashAdvance-advanceAmount,.cashAdvance-advanceBalance,.debitInterest-interestBalance').each(function(i,ele){
		$(ele).val(commaDelimiter($(ele).val()));
		$(ele).keyup(function(){
			$(this).val( commaDelimiter($(this).val()));
		});
	});	
	
	// 验证金额输入是否符合规范
	function moneyAmountValid(t,s){
		if( t.val()=='' ){t.parent().find('span.error').removeClass('shows').text('').hide();return true};
		if( t.val() == '0' || t.val() == '0.0' || t.val() == '0.00' ){
			t.parent().find('span.error').addClass('shows').text('必须大于0').show();
			return false;
		};
		// 正数和小数
		if( /^[0-9]+([.]{1}[0-9]+){0,1}$/.test(t.val().split(',').join('')) ){
			if( s==undefined ){t.parent().find('span.error').removeClass('shows').text('').hide();};
		}else{
			if( s==undefined ){t.parent().find('span.error').addClass('shows').text('请输入正确的数字').show();}
			return false;
		};
		// 小数点后最多两位
		if( t.val().indexOf('.')>0 ){
			if( String(t.val()).split('.')[1].length<=2 ){
				if( s==undefined ){t.parent().find('span.error').removeClass('shows').text('').hide();};
			}else{
				if( s==undefined ){t.parent().find('span.error').addClass('shows').text('小数点后最多两位小数').show();};
				return false;
			};
		};
		//只能输入17位数,包括小数点和小数点后两位(即使没有输入小数也要自动补两位小数),不包括负号
		var decimalLengthFlag = false,changevalue = '',value = t.val();
		if( value.indexOf('-') != -1 ){//有负号
			changevalue = value.split(',').join('').substring(1,value.split(',').join('').length);
		}else{//没有负号
			changevalue = value.split(',').join('');
		};
		if( changevalue.length<=14 ){
			decimalLengthFlag = true;
		}else{
			if( changevalue.length > 17 ){
				decimalLengthFlag = false;
			}else{
				decimalLengthFlag = true;
				if( changevalue.substring(0,14).indexOf('.') == -1 ){//第15位之前没有小数点,第15位只能是小数点
					if( changevalue.charAt(14) == '.' ){
						 decimalLengthFlag = true;
					 }else{
						 decimalLengthFlag = false;
					 }
				}
			};
		};
		if( decimalLengthFlag ){
			if( s==undefined ){t.parent().find('span.error').removeClass('shows').text('').hide();};
			return true;
		}else{
			if( s==undefined ){t.parent().find('span.error').addClass('shows').text('超出金额可输入最大位数').show();};
			return false;
		};
	};
	
	// (弹框里)金额的验证
	$('.guarantyContractDialog-guarantorAmount,.mortgageContractDialog-mortgageAmount,.pledgeContractDialog-pledgeValue,.pledgeContractDialog-pledgeAmount,.badCreditDialog-recycledAmount,.badCreditDialog-balance,.mortgageContractDialog-evaluationValue').keyup(function(){
		$(this).val( commaDelimiter($(this).val()));
		moneyAmountValid($(this));
	});
	
	
	// 五级分类(保理业务信息和垫款业务信息的)变化操作
	var originalFactoringClassify5 = $('.factoring-classify5').find('option:selected').attr('value'),
		originalCashAdvanceClassify5 = $('.cashAdvance-classify5').find('option:selected').attr('value');
		originalCashAdvanceRepayType = $('.cashAdvance-repayType').find('option:selected').attr('value');
	function classifyChange(tval,orival,domtr,datedom,corresOccurDate,tdom){
		if( tval != orival ){
			$(domtr).removeClass('hide');
			if( $(datedom).val()!='' ){
				var datedomval = $(datedom).val();
				$(datedom).val(datedomval.substring(0,4)+'-'+datedomval.substring(4,6)+'-'+datedomval.substring(6,8))
				initDate(datedom,corresOccurDate.substring(0,4)+'-'+corresOccurDate.substring(4,6)+'-'+corresOccurDate.substring(6,8),'');
				$(datedom).val(datedomval);
			}else{
				initDate(datedom,corresOccurDate.substring(0,4)+'-'+corresOccurDate.substring(4,6)+'-'+corresOccurDate.substring(6,8),'');
			}
		}else{
			if( tdom == 'cashAdvance-classify5' ){
				if( $('cashAdvance-repayType').val() == originalCashAdvanceRepayType ){
					$(domtr).addClass('hide');
				};
			}else if( tdom == 'cashAdvance-repayType' ){
				if( $('.cashAdvance-classify5').val() == originalCashAdvanceClassify5 ){
					$(domtr).addClass('hide');
				};
			}else{
				$(domtr).addClass('hide');
			};
		};
	};
	
	$('.factoring-classify5').change(function(){
		classifyChange($(this).val(),originalFactoringClassify5,'.classify5OccurDateParentTr','[name=classify5OccurDate]',$('.factoring-occurDate').val());
	});
	$('.cashAdvance-classify5').change(function(){
		classifyChange($(this).val(),originalCashAdvanceClassify5,'.classify5OccurDateParentTr2','[name=classify5OccurDate2]',$('.cashAdvance-occurDate').val(),'.cashAdvance-classify5');
	});
	$('.cashAdvance-repayType').change(function(){
		classifyChange($(this).val(),originalCashAdvanceRepayType,'.classify5OccurDateParentTr2','[name=classify5OccurDate2]',$('.cashAdvance-occurDate').val(),'.cashAdvance-repayType');
	});
	
	
	var guarantyContractListData = [];// 担保信息表-保证合同信息段数据-存在的数据
	var guarantyContractListDeleteData = [];// 担保信息表-保证合同信息段数据-删除的数据
	
	var mortgageContractListData = [];// 担保信息表-抵押合同信息段数据-存在的数据
	var mortgageContractListDeleteData = [];// 担保信息表-抵押合同信息段数据-删除的数据
	
	var pledgeContractListData = [];// 担保信息表-质押合同信息段数据-存在的数据
	var pledgeContractListDeleteData = [];// 担保信息表-质押合同信息段数据-删除的数据
	
	var badCreditAssetListData = [];// 不良信贷资产处置信息表-资产处置信息段数据-存在的数据
	var badCreditAssetListDeleteData = [];// 不良信贷资产处置信息表-资产处置信息段数据-删除的数据
	
	var operateIndex = 0;// 操作的条数
	
	// 担保信息表-保证合同信息段数据-初始处理
	$('.guarantyContractTr').each(function(i,ele){
		guarantyContractListData.push({
			'historicGuarantyNo':$(ele).find('td:first').attr('historicGuarantyNo'),// 原保证合同编号
			'historicLoanNo':$(ele).find('td:first').attr('historicLoanNo'),// 原主合同编号
			'historicIsNaturalPerson':$(ele).find('td:first').attr('historicIsNaturalPerson'),// 原 是否自然人
			'historicCertNo':$(ele).find('td:first').attr('historicCertNo'),// 原 自然人证件号码
			'guarantyNo':$(ele).find('td:first').attr('guarantyNo'),// 保证合同编号
			'creditLineType':$(ele).find('td:first').attr('creditLineType'),// 信贷业务种类
			'creditLineTypeCN':$(ele).find('td:first').attr('creditLineTypeCN'),// 信贷业务种类-中文
			'occurDate':$(ele).find('td:first').attr('occurDate'),// 保证事件日期
			'guarantorName':$(ele).find('td:first').attr('guarantorName'),// 保证人名称
			'guarantyLoanCardNo':$(ele).find('td:first').attr('guarantyLoanCardNo'),// 保证人中征码
			'isNaturalPerson':$(ele).find('td:first').attr('isNaturalPerson'),// 是否是自然人
			'isNaturalPersonCN':$(ele).find('td:first').attr('isNaturalPersonCN'),// 是否是自然人-中文
			'certType':$(ele).find('td:first').attr('certType'),// 证件类型
			'certNo':$(ele).find('td:first').attr('certNo'),// 证件号码
			'currency':$(ele).find('td:first').attr('currency'),// 币种
			'guarantorAmount':$(ele).find('td:first').attr('guarantorAmount'),// 保证金额
			'createDate':$(ele).find('td:first').attr('createDate'),// 合同签订日期
			'guaranteeForm':$(ele).find('td:first').attr('guaranteeForm'),// 保证担保形式
			'guaranteeFormCN':$(ele).find('td:first').attr('guaranteeFormCN'),// 保证担保形式--中文
			'status':$(ele).find('td:first').attr('status'),// 合同有效状态
			'statusCN':$(ele).find('td:first').attr('statusCN'),// 合同有效状态--中文
			'isReporting':$(ele).find('td:first').attr('isReporting')// 是否已授权
		});
		$(ele).find('td').eq(1).before('<td style="background:#fff">'+$(ele).find('td:first').text()+'</td>');
		$(ele).find('td:first').remove();
	});
	
	// 担保信息表-抵押合同信息段数据项-初始处理
	$('.mortgageContractTr').each(function(i,ele){
		mortgageContractListData.push({
			'historicGuarantyNo':$(ele).find('td:first').attr('historicGuarantyNo'),// 原抵押合同编号
			'historicLoanNo':$(ele).find('td:first').attr('historicLoanNo'),// 原主合同编号
			'historicIsNaturalPerson':$(ele).find('td:first').attr('historicIsNaturalPerson'),// 原 是否自然人
			'historicMortgageSeqNo':$(ele).find('td:first').attr('historicMortgageSeqNo'),// 原 抵押合同序号
			'guarantyNo':$(ele).find('td:first').attr('guarantyNo'),// 抵押合同编号
			'creditLineType':$(ele).find('td:first').attr('creditLineType'),// 信贷业务种类
			'creditLineTypeCN':$(ele).find('td:first').attr('creditLineTypeCN'),// 信贷业务种类-中文
			'occurDate':$(ele).find('td:first').attr('occurDate'),// 抵押事件日期
			'mortgageSeqNo':$(ele).find('td:first').attr('mortgageSeqNo'),// 抵押序号
			'mortgageName':$(ele).find('td:first').attr('mortgageName'),// 抵押人名称
			'isNaturalPerson':$(ele).find('td:first').attr('isNaturalPerson'),// 是否是自然人
			'isNaturalPersonCN':$(ele).find('td:first').attr('isNaturalPersonCN'),// 是否是自然人--中文
			'guaranteeLoanCardNo':$(ele).find('td:first').attr('guaranteeLoanCardNo'),// 抵押人中征码
			'certType':$(ele).find('td:first').attr('certType'),// 证件类型
			'certNo':$(ele).find('td:first').attr('certNo'),// 证件号码
			'evaluationCurrency':$(ele).find('td:first').attr('evaluationCurrency'),// 币种
			'evaluationValue':$(ele).find('td:first').attr('evaluationValue'),// 抵押物评估价值
			'evaluationDate':$(ele).find('td:first').attr('evaluationDate'),// 评估日期
			'orgName':$(ele).find('td:first').attr('orgName'),// 评估机构名称
			'orgCode':$(ele).find('td:first').attr('orgCode'),// 评估机构组织机构代码
			'assignDate':$(ele).find('td:first').attr('assignDate'),// 合同签订日期
			'mortgageType':$(ele).find('td:first').attr('mortgageType'),// 抵押物种类
			'mortgageAmount':$(ele).find('td:first').attr('mortgageAmount'),// 抵押金额
			'mortgageCurrency':$(ele).find('td:first').attr('mortgageCurrency'),// 抵押金额币种
			'regOrg':$(ele).find('td:first').attr('regOrg'),// 登记机关
			'regDate':$(ele).find('td:first').attr('regDate'),// 登记日期
			'status':$(ele).find('td:first').attr('status'),// 合同有效状态
			'statusCN':$(ele).find('td:first').attr('statusCN'),// 合同有效状态--中文
			'mortgageDesc':$(ele).find('td:first').attr('mortgageDesc'),// 抵押物说明
			'collateralName':$(ele).find('td:first').attr('collateralName'),// 抵押物名称
			'isReporting':$(ele).find('td:first').attr('isReporting')// 是否已授权
		});
		$(ele).find('td').eq(1).before('<td style="background:#fff">'+$(ele).find('td:first').text()+'</td>');
		$(ele).find('td:first').remove();
	});
	
	// 担保信息表-质押合同信息段数据项-初始处理
	$('.pledgeContractTr').each(function(i,ele){
		pledgeContractListData.push({
			'historicPledgeNo':$(ele).find('td:first').attr('historicPledgeNo'),// 原质押合同编号
			'historicLoanNo':$(ele).find('td:first').attr('historicLoanNo'),// 原主合同编号
			'historicIsNaturalPerson':$(ele).find('td:first').attr('historicIsNaturalPerson'),// 原 是否自然人
			'historicPledgeSeqNo':$(ele).find('td:first').attr('historicPledgeSeqNo'),// 原 质押合同序号
			'pledgeNo':$(ele).find('td:first').attr('pledgeNo'),// 质押合同编号
			'creditLineType':$(ele).find('td:first').attr('creditLineType'),// 信贷业务种类
			'creditLineTypeCN':$(ele).find('td:first').attr('creditLineTypeCN'),// 信贷业务种类-中文
			'occurDate':$(ele).find('td:first').attr('occurDate'),// 质押事件日期
			'pledgeSeqNo':$(ele).find('td:first').attr('pledgeSeqNo'),// 质押序号
			'pledgeName':$(ele).find('td:first').attr('pledgeName'),// 出质人名称
			'isNaturalPerson':$(ele).find('td:first').attr('isNaturalPerson'),// 是否是自然人
			'isNaturalPersonCN':$(ele).find('td:first').attr('isNaturalPersonCN'),// 是否是自然人--中文
			'pledgeLoanCardNo':$(ele).find('td:first').attr('pledgeLoanCardNo'),// 出质人中征码
			'certType':$(ele).find('td:first').attr('certType'),// 证件类型
			'certNo':$(ele).find('td:first').attr('certNo'),// 证件号码
			'pledgeCurrency':$(ele).find('td:first').attr('pledgeCurrency'),// 币种
			'pledgeValue':$(ele).find('td:first').attr('pledgeValue'),// 质押物价值
			'assignDate':$(ele).find('td:first').attr('assignDate'),// 合同签订日期
			'pledgeType':$(ele).find('td:first').attr('pledgeType'),// 质押物种类
			'pledgeTypeCN':$(ele).find('td:first').attr('pledgeTypeCN'),// 质押物种类--中文
			'pledgeAmount':$(ele).find('td:first').attr('pledgeAmount'),// 质押金额
			'pledgeCurrency1':$(ele).find('td:first').attr('pledgeCurrency1'),// 质押金额币种
			'status':$(ele).find('td:first').attr('status'),// 合同有效状态
			'statusCN':$(ele).find('td:first').attr('statusCN'),// 合同有效状态--中文
			'isReporting':$(ele).find('td:first').attr('isReporting')// 是否已授权
		});
		$(ele).find('td').eq(1).before('<td style="background:#fff">'+$(ele).find('td:first').text()+'</td>');
		$(ele).find('td:first').remove();
	});
	
	// 不良信贷资产处置信息表-资产处置信息段数据项-初始处理
	$('.badCreditAssetTr').each(function(i,ele){
		badCreditAssetListData.push({
			'historicOccurDate':$(ele).find('td:first').attr('occurDate'),// 原 业务发生日期
			'bizNo':$(ele).find('td:first').attr('bizNo'),// 处置编号
			'occurDate':$(ele).find('td:first').attr('occurDate'),// 业务发生日期
			'borrowerName':$(ele).find('td:first').attr('borrowerName'),// 借款人名称
			'currency':$(ele).find('td:first').attr('currency'),// 币种
			'currencyCode':$(ele).find('td:first').attr('currencyCode'),// 币种
			'balance':$(ele).find('td:first').attr('balance'),// 处置余额
			'disposeDate':$(ele).find('td:first').attr('disposeDate'),// 处置日期
			'disposeType':$(ele).find('td:first').attr('disposeType'),// 主要资产处置方式
			'disposeTypeCN':$(ele).find('td:first').attr('disposeTypeCN'),// 主要资产处置方式--中文
			'recycledAmount':$(ele).find('td:first').attr('recycledAmount'),// 已回收金额
			'isReporting':$(ele).find('td:first').attr('isReporting')// 是否已授权
		});
		$(ele).find('td').eq(1).before('<td style="background:#fff">'+$(ele).find('td:first').text()+'</td>');
		$(ele).find('td:first').remove();
	});
	
	
	// 删除信息
	$('.listBackBox').on('click','.deleteNewsBtn',function(){
		var $that = $(this);
		bootbox.confirm({
			title : '删除',
			message : '<div style="text-align:left;font-size:0.12rem">确认删除吗？</div>',
			size : 'small',
			buttons : {
				cancel : {
					label : '取消',
					className:'btn-white btn-info'
				},
				confirm : {
					label : '确定',
					className:'btn-white btn-info colorbtn'
				}
			},
			callback:function(result){
				if (result) {
					operateIndex = $that.parents('tbody').find('tr').index($that.parents('tr'));
					// 记录删除的数据 / 更新原数据
					if( $that.parents('tr').hasClass('guarantyContractTr') ){// 保证合同信息
						guarantyContractListDeleteData.push(guarantyContractListData[operateIndex]);
						guarantyContractListData.splice(operateIndex,1);
					};
					if( $that.parents('tr').hasClass('mortgageContractTr') ){// 抵押合同信息
						mortgageContractListDeleteData.push(mortgageContractListData[operateIndex]);
						mortgageContractListData.splice(operateIndex,1);
					};
					if( $that.parents('tr').hasClass('pledgeContractTr') ){// 质押合同信息
						pledgeContractListDeleteData.push(pledgeContractListData[operateIndex]);
						pledgeContractListData.splice(operateIndex,1);
					};
					if( $that.parents('tr').hasClass('badCreditAssetTr') ){// 不良信贷-资产处置信息
						badCreditAssetListDeleteData.push(badCreditAssetListData[operateIndex]);
						badCreditAssetListData.splice(operateIndex,1);
					};
					if( $that.parents('tbody').find('tr').length == 1 ){
						$that.parents('tbody').append('<tr><td style="background:#fff;" colspan="'+$that.parents('tbody').attr('col')+'">无</td></tr>')
					};
					$that.parents('tr').remove();
					setGuaranteeFlag();
				}
			}
		})
	});
	
	// 设置'担保标志'----保证/抵押/质押信息中有任意1条及以上数据'授权'了且合同有效状态为'是',则担保标志为“是”
	//                 其他情况担保标志为'否'
	// 与授权操作和删除操作有关(合同有效状态不可更改)
	function setGuaranteeFlag(){
		var reportAndContractNum = 0;
		$('.needNoReport').each(function(i,ele){
			if( $(ele).parents('tr').find('.contractStatusInTable').attr('statusValue') == '1' ){
				reportAndContractNum++;
			}
		});
		if( reportAndContractNum>0 ){// 至少有一个授权了且合同有效状态为'是'的
			$('.factoring-guaranteeFlag').val('是');
			$('.factoring-guaranteeFlag').attr('tval','1');
		}else{
			$('.factoring-guaranteeFlag').val('否');
			$('.factoring-guaranteeFlag').attr('tval','2');
		};
	};
	
	// 授权
	$('.listBackBox').on('click','.needReport',function(){
		var $that = $(this);
		operateIndex = $that.parents('tbody').find('tr').index($that.parents('tr'));
		if( $that.parents('tr').hasClass('guarantyContractTr') ){// 保证合同信息
			guarantyContractListData[operateIndex].isReporting = 'true';
		};
		if( $that.parents('tr').hasClass('mortgageContractTr') ){// 抵押合同信息
			mortgageContractListData[operateIndex].isReporting = 'true';
		};
		if( $that.parents('tr').hasClass('pledgeContractTr') ){// 质押合同信息
			pledgeContractListData[operateIndex].isReporting = 'true';
		};
		if( $that.parents('tr').hasClass('badCreditAssetTr') ){// 不良信贷-资产处置信息
			badCreditAssetListData[operateIndex].isReporting = 'true';
		};
		$(this).removeClass('needReport').addClass('needNoReport').text('取消授权');
		setGuaranteeFlag();
	});
	
	// 取消授权
	$('.listBackBox').on('click','.needNoReport',function(){
		var $that = $(this);
		operateIndex = $that.parents('tbody').find('tr').index($that.parents('tr'));
		if( $that.parents('tr').hasClass('guarantyContractTr') ){// 保证合同信息
			guarantyContractListData[operateIndex].isReporting = 'false';
		};
		if( $that.parents('tr').hasClass('mortgageContractTr') ){// 抵押合同信息
			mortgageContractListData[operateIndex].isReporting = 'false';
		};
		if( $that.parents('tr').hasClass('pledgeContractTr') ){// 质押合同信息
			pledgeContractListData[operateIndex].isReporting = 'false';
		};
		if( $that.parents('tr').hasClass('badCreditAssetTr') ){// 不良信贷-资产处置信息
			badCreditAssetListData[operateIndex].isReporting = 'false';
		};
		$(this).removeClass('needNoReport').addClass('needReport').text('授权');
		setGuaranteeFlag();
	});
	
	// 保证/抵押/质押信息----是否自然人选择
	// 当是自然人时, 显示证件类型/证件号码, 不显示对应中征码, 不显示的提交时也不提交
	// 不是自然人时, 显示对应中征码, 不显示证件类型/证件号码, 不显示的提交时也不提交
	$('.guarantyContractDialog-isNaturalPerson,.mortgageContractDialog-isNaturalPerson,.pledgeContractDialog-isNaturalPerson').each(function(i,ele){
		$(ele).change(function(){
			if( $(ele).find('option:selected').attr('value') == '1' ){// 是自然人
				$(ele).parent().attr('colspan','3');
				$(ele).parent().next().addClass('hide');
				$(ele).parent().next().next().addClass('hide');
				$(ele).parents('tr').next().removeClass('hide');
			};
			if( $(ele).find('option:selected').attr('value') == '2' ){// 不是自然人
				$(ele).parent().removeAttr('colspan');
				$(ele).parent().next().removeClass('hide');
				$(ele).parent().next().next().removeClass('hide');
				$(ele).parents('tr').next().addClass('hide');
			};
		});
	});
	
	// 保证/抵押/质押 的 '保证事件日期'和'合同签订日期'的设置--因需求修改: 这两个日期可以修改了
	function createDialogDate(dom,startDate,endDate,value){
		// startDate endDate value 都是不带'-'连接符的
		// 保证事件日期 >= 合同签订日期
		// 合同签订日期 >= 投放日期
		
		if( value !='' ){
			$(dom).val(value.substring(0,4)+'-'+value.substring(4,6)+'-'+value.substring(6,8));
		}else{
			$(dom).val('');
		};
		
		$(dom).datetimepicker(
			{	
				weekStart: 1,
			    autoclose: 1,
			    todayHighlight: 0,
			    startView: 2,
			    minView: 2,
			    forceParse: 0,
			    showMeridian: 1,
			    startDate:startDate.substring(0,4)+'-'+startDate.substring(4,6)+'-'+startDate.substring(6,8),
			    endDate:endDate.substring(0,4)+'-'+endDate.substring(4,6)+'-'+endDate.substring(6,8),
			    format: "yyyy-mm-dd"
			}
		);
		$(dom).datetimepicker('setStartDate',startDate.substring(0,4)+'-'+startDate.substring(4,6)+'-'+startDate.substring(6,8));
		$(dom).datetimepicker('setEndDate',endDate.substring(0,4)+'-'+endDate.substring(4,6)+'-'+endDate.substring(6,8));
		
		$(dom).val(value);
	};
	
	// 编辑信息
	$('.listBackBox').on('click','.editNewsBtn',function(){
		var $that = $(this);
		operateIndex = $that.parents('tbody').find('tr').index($that.parents('tr'));
		// 打开编辑弹框
		if( $that.parents('tr').hasClass('guarantyContractTr') ){// 保证合同信息
			$('#myModal-guarantyContractDialog').find('.error.shows').removeClass('shows').hide();
			$('#myModal-guarantyContractDialog').find('input,textarea').val('');
			$('#myModal-guarantyContractDialog').find('select').each(function(i,ele){
				$(ele).find('option:first').prop('selected',true);
			});
			$('#myModal-guarantyContractDialog').modal('show');
			
			$('.guarantyContractDialog-guarantyNo').val(guarantyContractListData[operateIndex].guarantyNo?guarantyContractListData[operateIndex].guarantyNo:'');// 保证合同编号
			
			$('.guarantyContractDialog-creditLineType').removeAttr('tval');
			if( guarantyContractListData[operateIndex].creditLineType!=undefined ){
				$('.guarantyContractDialog-creditLineType').val(guarantyContractListData[operateIndex].creditLineTypeCN?guarantyContractListData[operateIndex].creditLineTypeCN:'');// 信贷业务种类
				$('.guarantyContractDialog-creditLineType').attr('tval',guarantyContractListData[operateIndex].creditLineType);
			};
			
			// 保证事件日期
			createDialogDate('.guarantyContractDialog-occurDate',guarantyContractListData[operateIndex].createDate,'21181231',guarantyContractListData[operateIndex].occurDate);
			// 合同签订日期
			createDialogDate('.guarantyContractDialog-createDate',$('.factoring-bizDate').attr('orival'),guarantyContractListData[operateIndex].occurDate,guarantyContractListData[operateIndex].createDate);
			
			$('.guarantyContractDialog-guarantorName').val(guarantyContractListData[operateIndex].guarantorName?guarantyContractListData[operateIndex].guarantorName:'');// 保证人名称
			$('.guarantyContractDialog-guarantyLoanCardNo').val(guarantyContractListData[operateIndex].guarantyLoanCardNo?guarantyContractListData[operateIndex].guarantyLoanCardNo:'');// 保证人中征码
			if( guarantyContractListData[operateIndex].isNaturalPerson!=undefined ){
				$('.guarantyContractDialog-isNaturalPerson').find('option[value='+guarantyContractListData[operateIndex].isNaturalPerson+']').prop('selected',true);// 是否是自然人
			};
			$('.guarantyContractDialog-isNaturalPerson').change();
			if( guarantyContractListData[operateIndex].certType!=undefined ){
				$('.guarantyContractDialog-certType').find('option[value='+guarantyContractListData[operateIndex].certType+']').prop('selected',true);// 证件类型
			};
			$('.guarantyContractDialog-certNo').val(guarantyContractListData[operateIndex].certNo?guarantyContractListData[operateIndex].certNo:'');// 证件号码
			if( guarantyContractListData[operateIndex].currency!=undefined ){
				$('.guarantyContractDialog-currency').find('option[value='+guarantyContractListData[operateIndex].currency+']').prop('selected',true);// 币种
			};
			$('.guarantyContractDialog-guarantorAmount').val(guarantyContractListData[operateIndex].guarantorAmount!=undefined?commaDelimiter(guarantyContractListData[operateIndex].guarantorAmount.toString()):'');// 保证金额
			
			$('.guarantyContractDialog-guaranteeForm').removeAttr('tval');
			if( guarantyContractListData[operateIndex].guaranteeForm!=undefined ){
				$('.guarantyContractDialog-guaranteeForm').val(guarantyContractListData[operateIndex].guaranteeFormCN?guarantyContractListData[operateIndex].guaranteeFormCN:'');// 保证担保形式
				$('.guarantyContractDialog-guaranteeForm').attr('tval',guarantyContractListData[operateIndex].guaranteeForm);
			};
			
			$('.guarantyContractDialog-status').removeAttr('tval');
			if( guarantyContractListData[operateIndex].status!=undefined ){
				$('.guarantyContractDialog-status').val(guarantyContractListData[operateIndex].statusCN?guarantyContractListData[operateIndex].statusCN:'');// 合同有效状态
				$('.guarantyContractDialog-status').attr('tval',guarantyContractListData[operateIndex].status)
			};
		};
		if( $that.parents('tr').hasClass('mortgageContractTr') ){// 抵押合同信息
			$('#myModal-mortgageContractDialog').find('.error.shows').removeClass('shows').hide();
			$('#myModal-mortgageContractDialog').find('input,textarea').val('');
			$('#myModal-mortgageContractDialog').find('select').each(function(i,ele){
				$(ele).find('option:first').prop('selected',true);
			});
			$('#myModal-mortgageContractDialog').modal('show');
			
			$('.mortgageContractDialog-guarantyNo').val(mortgageContractListData[operateIndex].guarantyNo?mortgageContractListData[operateIndex].guarantyNo:'');// 抵押合同编号
			
			$('.mortgageContractDialog-creditLineType').removeAttr('tval');
			if( mortgageContractListData[operateIndex].creditLineType!=undefined ){
				$('.mortgageContractDialog-creditLineType').val(mortgageContractListData[operateIndex].creditLineTypeCN?mortgageContractListData[operateIndex].creditLineTypeCN:'');// 信贷业务种类
				$('.mortgageContractDialog-creditLineType').attr('tval',mortgageContractListData[operateIndex].creditLineType);
			};
			
			// 抵押事件日期
			createDialogDate('.mortgageContractDialog-occurDate',mortgageContractListData[operateIndex].assignDate,'21181231',mortgageContractListData[operateIndex].occurDate);
			// 合同签订日期
			createDialogDate('.mortgageContractDialog-assignDate',$('.factoring-bizDate').attr('orival'),mortgageContractListData[operateIndex].occurDate,mortgageContractListData[operateIndex].assignDate);
			
			$('.mortgageContractDialog-mortgageSeqNo').val(mortgageContractListData[operateIndex].mortgageSeqNo?mortgageContractListData[operateIndex].mortgageSeqNo:'');// 抵押序号
			$('.mortgageContractDialog-mortgageName').val(mortgageContractListData[operateIndex].mortgageName?mortgageContractListData[operateIndex].mortgageName:'');// 抵押人名称
			if( mortgageContractListData[operateIndex].isNaturalPerson!=undefined ){
				$('.mortgageContractDialog-isNaturalPerson').find('option[value='+mortgageContractListData[operateIndex].isNaturalPerson+']').prop('selected',true);// 是否自然人
			};
			$('.mortgageContractDialog-isNaturalPerson').change();
			$('.mortgageContractDialog-guaranteeLoanCardNo').val(mortgageContractListData[operateIndex].guaranteeLoanCardNo?mortgageContractListData[operateIndex].guaranteeLoanCardNo:'');// 抵押人中征码
			if( mortgageContractListData[operateIndex].certType!=undefined ){
				$('.mortgageContractDialog-certType').find('option[value='+mortgageContractListData[operateIndex].certType+']').prop('selected',true);// 证件类型
			};
			$('.mortgageContractDialog-certNo').val(mortgageContractListData[operateIndex].certNo?mortgageContractListData[operateIndex].certNo:'');// 证件号码
			if( mortgageContractListData[operateIndex].evaluationCurrency!=undefined ){
				$('.mortgageContractDialog-evaluationCurrency').find('option[value='+mortgageContractListData[operateIndex].evaluationCurrency+']').prop('selected',true);// 币种
			};
			$('.mortgageContractDialog-evaluationValue').val(mortgageContractListData[operateIndex].evaluationValue!=undefined?commaDelimiter(mortgageContractListData[operateIndex].evaluationValue.toString()):'');// 抵押物评估价值
			if( mortgageContractListData[operateIndex].evaluationDate ){// 评估日期
				$('.mortgageContractDialog-evaluationDate').val(mortgageContractListData[operateIndex].evaluationDate.substring(0,4)+'-'+mortgageContractListData[operateIndex].evaluationDate.substring(4,6)+'-'+mortgageContractListData[operateIndex].evaluationDate.substring(6,8));
				initDate('.mortgageContractDialog-evaluationDate')
				$('.mortgageContractDialog-evaluationDate').val(mortgageContractListData[operateIndex].evaluationDate)
			}else{
				initDate('.mortgageContractDialog-evaluationDate')
			};
			$('.mortgageContractDialog-orgName').val(mortgageContractListData[operateIndex].orgName?mortgageContractListData[operateIndex].orgName:'');// 评估机构名称
			$('.mortgageContractDialog-orgCode').val(mortgageContractListData[operateIndex].orgCode?mortgageContractListData[operateIndex].orgCode:'');// 评估机构组织机构代码
			
			if( mortgageContractListData[operateIndex].mortgageType!=undefined ){
				$('.mortgageContractDialog-mortgageType').find('option[value='+mortgageContractListData[operateIndex].mortgageType+']').prop('selected',true);// 抵押物种类
			};
			$('.mortgageContractDialog-mortgageAmount').val(mortgageContractListData[operateIndex].mortgageAmount!=undefined?commaDelimiter(mortgageContractListData[operateIndex].mortgageAmount.toString()):'');// 抵押金额
			if( mortgageContractListData[operateIndex].mortgageCurrency!=undefined ){
				$('.mortgageContractDialog-mortgageCurrency').find('option[value='+mortgageContractListData[operateIndex].mortgageCurrency+']').prop('selected',true);// 抵押金额币种
			}
			$('.mortgageContractDialog-regOrg').val(mortgageContractListData[operateIndex].regOrg?mortgageContractListData[operateIndex].regOrg:'');// 登记机关
			if( mortgageContractListData[operateIndex].regDate ){// 登记日期
				$('.mortgageContractDialog-regDate').val(mortgageContractListData[operateIndex].regDate.substring(0,4)+'-'+mortgageContractListData[operateIndex].regDate.substring(4,6)+'-'+mortgageContractListData[operateIndex].regDate.substring(6,8));
				initDate('.mortgageContractDialog-regDate')
				$('.mortgageContractDialog-regDate').val(mortgageContractListData[operateIndex].regDate)
			}else{
				initDate('.mortgageContractDialog-regDate')
			};
			
			$('.mortgageContractDialog-status').removeAttr('tval');
			if( mortgageContractListData[operateIndex].status!=undefined ){
				$('.mortgageContractDialog-status').val(mortgageContractListData[operateIndex].statusCN?mortgageContractListData[operateIndex].statusCN:'');// 合同有效状态
				$('.mortgageContractDialog-status').attr('tval',mortgageContractListData[operateIndex].status);
			};
			$('.mortgageContractDialog-mortgageDesc').val(mortgageContractListData[operateIndex].mortgageDesc?mortgageContractListData[operateIndex].mortgageDesc:'');// 抵押物说明
			$('.mortgageContractDialog-collateralName').val(mortgageContractListData[operateIndex].collateralName?mortgageContractListData[operateIndex].collateralName:'');// 抵押物名称
		};
		if( $that.parents('tr').hasClass('pledgeContractTr') ){// 质押合同信息
			$('#myModal-pledgeContractDialog').find('.error.shows').removeClass('shows').hide();
			$('#myModal-pledgeContractDialog').find('input,textarea').val('');
			$('#myModal-pledgeContractDialog').find('select').each(function(i,ele){
				$(ele).find('option:first').prop('selected',true);
			});
			$('#myModal-pledgeContractDialog').modal('show');
			
			$('.pledgeContractDialog-pledgeNo').val(pledgeContractListData[operateIndex].pledgeNo?pledgeContractListData[operateIndex].pledgeNo:'');// 质押合同编号
			
			$('.pledgeContractDialog-creditLineType').removeAttr('tval');
			if( pledgeContractListData[operateIndex].creditLineType!=undefined ){
				$('.pledgeContractDialog-creditLineType').val(pledgeContractListData[operateIndex].creditLineTypeCN?pledgeContractListData[operateIndex].creditLineTypeCN:'');// 信贷业务种类
				$('.pledgeContractDialog-creditLineType').attr('tval',pledgeContractListData[operateIndex].creditLineType);
			};
			
			// 质押事件日期
			createDialogDate('.pledgeContractDialog-occurDate',pledgeContractListData[operateIndex].assignDate,'21181231',pledgeContractListData[operateIndex].occurDate);
			// 合同签订日期
			createDialogDate('.pledgeContractDialog-assignDate',$('.factoring-bizDate').attr('orival'),pledgeContractListData[operateIndex].occurDate,pledgeContractListData[operateIndex].assignDate);
			
			$('.pledgeContractDialog-pledgeSeqNo').val(pledgeContractListData[operateIndex].pledgeSeqNo?pledgeContractListData[operateIndex].pledgeSeqNo:'');// 质押序号
			$('.pledgeContractDialog-pledgeName').val(pledgeContractListData[operateIndex].pledgeName?pledgeContractListData[operateIndex].pledgeName:'');// 出质人名称
			if( pledgeContractListData[operateIndex].isNaturalPerson!=undefined ){
				$('.pledgeContractDialog-isNaturalPerson').find('option[value='+pledgeContractListData[operateIndex].isNaturalPerson+']').prop('selected',true);// 是否自然人
			};
			$('.pledgeContractDialog-isNaturalPerson').change();
			$('.pledgeContractDialog-pledgeLoanCardNo').val(pledgeContractListData[operateIndex].pledgeLoanCardNo?pledgeContractListData[operateIndex].pledgeLoanCardNo:'');// 出质人中征码
			if( pledgeContractListData[operateIndex].certType!=undefined ){
				$('.pledgeContractDialog-certType').find('option[value='+pledgeContractListData[operateIndex].certType+']').prop('selected',true);// 证件类型
			};
			$('.pledgeContractDialog-certNo').val(pledgeContractListData[operateIndex].certNo?pledgeContractListData[operateIndex].certNo:'');// 证件号码
			if( pledgeContractListData[operateIndex].pledgeCurrency!=undefined ){
				$('.pledgeContractDialog-pledgeCurrency').find('option[value='+pledgeContractListData[operateIndex].pledgeCurrency+']').prop('selected',true);// 币种
			};
			$('.pledgeContractDialog-pledgeValue').val(pledgeContractListData[operateIndex].pledgeValue!=undefined?commaDelimiter(pledgeContractListData[operateIndex].pledgeValue.toString()):'');// 质押物价值
			
			if( pledgeContractListData[operateIndex].pledgeType!=undefined ){
				$('.pledgeContractDialog-pledgeType').find('option[value='+pledgeContractListData[operateIndex].pledgeType+']').prop('selected',true);// 质押物种类
			};
			$('.pledgeContractDialog-pledgeAmount').val(pledgeContractListData[operateIndex].pledgeAmount!=undefined?commaDelimiter(pledgeContractListData[operateIndex].pledgeAmount.toString()):'');// 质押金额
			if( pledgeContractListData[operateIndex].pledgeCurrency1!=undefined ){
				$('.pledgeContractDialog-pledgeCurrency1').find('option[value='+pledgeContractListData[operateIndex].pledgeCurrency1+']').prop('selected',true)// 质押金额币种
			};
			
			$('.pledgeContractDialog-status').removeAttr('tval');
			if( pledgeContractListData[operateIndex].status!=undefined ){
				$('.pledgeContractDialog-status').val(pledgeContractListData[operateIndex].statusCN?pledgeContractListData[operateIndex].statusCN:'');// 合同有效状态
				$('.pledgeContractDialog-status').attr('tval',pledgeContractListData[operateIndex].status);
			};
		};
		if( $that.parents('tr').hasClass('badCreditAssetTr') ){// 不良信贷-资产处置信息
			$('#myModal-badCreditDialog').find('input,textarea').val('');
			$('#myModal-badCreditDialog').find('select').each(function(i,ele){
				$(ele).find('option:first').prop('selected',true);
			});
			$('#myModal-badCreditDialog').modal('show');
			
			$('.badCreditDialog-bizNo').val(badCreditAssetListData[operateIndex].bizNo?badCreditAssetListData[operateIndex].bizNo:'');// 处置编号
			if( badCreditAssetListData[operateIndex].occurDate ){// 业务事件日期
				$('.badCreditDialog-occurDate').val(badCreditAssetListData[operateIndex].occurDate.substring(0,4)+'-'+badCreditAssetListData[operateIndex].occurDate.substring(4,6)+'-'+badCreditAssetListData[operateIndex].occurDate.substring(6,8));
				initDate('.badCreditDialog-occurDate')
				$('.badCreditDialog-occurDate').val(badCreditAssetListData[operateIndex].occurDate)
			}else{
				initDate('.badCreditDialog-occurDate')
			};
			$('.badCreditDialog-borrowerName').val(badCreditAssetListData[operateIndex].borrowerName?badCreditAssetListData[operateIndex].borrowerName:'');// 借款人名称
			if( badCreditAssetListData[operateIndex].currency!=undefined ){
				$('.badCreditDialog-currency').find('option[value='+badCreditAssetListData[operateIndex].currency+']').prop('selected',true);// 币种
			};
			$('.badCreditDialog-balance').val(badCreditAssetListData[operateIndex].balance!=undefined?commaDelimiter(badCreditAssetListData[operateIndex].balance.toString()):'');// 处置余额
			if( badCreditAssetListData[operateIndex].disposeDate ){// 处置日期
				$('.badCreditDialog-disposeDate').val(badCreditAssetListData[operateIndex].disposeDate.substring(0,4)+'-'+badCreditAssetListData[operateIndex].disposeDate.substring(4,6)+'-'+badCreditAssetListData[operateIndex].disposeDate.substring(6,8));
				initDate('.badCreditDialog-disposeDate')
				$('.badCreditDialog-disposeDate').val(badCreditAssetListData[operateIndex].disposeDate)
			}else{
				initDate('.badCreditDialog-disposeDate')
			};
			if( badCreditAssetListData[operateIndex].disposeType!=undefined ){
				$('.badCreditDialog-disposeType').find('option[value='+badCreditAssetListData[operateIndex].disposeType+']').prop('selected',true);// 主要资产处置方式
			};
			$('.badCreditDialog-recycledAmount').val(badCreditAssetListData[operateIndex].recycledAmount!=undefined?commaDelimiter(badCreditAssetListData[operateIndex].recycledAmount.toString()):'');// 已回收金额
		};
	});
	
	// 不良信贷信息编辑确认按钮
	$('#myModal-badCreditDialog .colorbtn').click(function(){
		// 验证'保证金额'的正确性
		moneyAmountValid($('.badCreditDialog-balance'));
		if( $('#myModal-badCreditDialog').find('.error.shows').length>0 ){
			$('#myModal-badCreditDialog').find('.error.shows:first').prev().focus();
			return;
		};
		// 更新编辑行的数据
		badCreditAssetListData[operateIndex].bizNo = $('.badCreditDialog-bizNo').val();// 处置编号
		badCreditAssetListData[operateIndex].occurDate = $('.badCreditDialog-occurDate').val();// 业务发生日期
		badCreditAssetListData[operateIndex].borrowerName = $('.badCreditDialog-borrowerName').val();// 借款人名称
		badCreditAssetListData[operateIndex].currency = $('.badCreditDialog-currency option:selected').attr('value');//币种
		badCreditAssetListData[operateIndex].currencyCode = $('.badCreditDialog-currency option:selected').attr('code');//币种code
		badCreditAssetListData[operateIndex].balance = $('.badCreditDialog-balance').val();// 处置余额
		badCreditAssetListData[operateIndex].disposeDate = $('.badCreditDialog-disposeDate').val();// 处置日期
		badCreditAssetListData[operateIndex].disposeType = $('.badCreditDialog-disposeType option:selected').attr('value');// 主要资产处置方式
		badCreditAssetListData[operateIndex].disposeTypeCN = $('.badCreditDialog-disposeType option:selected').text();// 主要资产处置方式--中文
		badCreditAssetListData[operateIndex].recycledAmount = $('.badCreditDialog-recycledAmount').val();// 已回收余额
		// 重新填充页面表格里的内容
		$('.badCreditAssetTbody').empty();
		for( var i=0;i<badCreditAssetListData.length;i++ ){
			$('.badCreditAssetTbody').append('<tr class="badCreditAssetTr"><td style="background:#fff;">'+(i+1)+'</td>'
					+'<td style="background:#fff;">'+(badCreditAssetListData[i].bizNo!=undefined?badCreditAssetListData[i].bizNo:'')+'</td>'
					+'<td style="background:#fff;">'+(badCreditAssetListData[i].occurDate!=undefined?badCreditAssetListData[i].occurDate:'')+'</td>'
					+'<td style="background:#fff;">'+((badCreditAssetListData[i].balance!=undefined&&badCreditAssetListData[i].balance!='')?(commaDelimiter(badCreditAssetListData[i].balance.toString())+' '+badCreditAssetListData[i].currencyCode):'')+'</td>'
					+'<td style="background:#fff;">'+(badCreditAssetListData[i].disposeDate!=undefined?badCreditAssetListData[i].disposeDate:'')+'</td>'
					+'<td style="background:#fff;">'+(badCreditAssetListData[i].disposeTypeCN!=undefined?badCreditAssetListData[i].disposeTypeCN:'')+'</td>'
					+'<td style="background:#fff;">'+((badCreditAssetListData[i].recycledAmount!=undefined&&badCreditAssetListData[i].recycledAmount!='')?(commaDelimiter(badCreditAssetListData[i].recycledAmount.toString())+' '+badCreditAssetListData[i].currencyCode):'')+'</td>'
					+'<td style="background:#fff;">'
						+'<span class="negativeInformationPlus editNewsBtn">编辑</span>'
						+'<span class="negativeInformationPlus deleteNewsBtn">删除</span>'+
						'<span class="negativeInformationPlus '+(badCreditAssetListData[i].isReporting=='true'?'needNoReport':'needReport')+'">'+(badCreditAssetListData[i].isReporting=='true'?'取消授权':'授权')+'</span>'
					+'</td>'
					+'</tr>')
		};
		i = null;
		$('#myModal-badCreditDialog').modal('hide');
	});
	
	// 质押合同信息编辑确认按钮
	$('#myModal-pledgeContractDialog .colorbtn').click(function(){
		// 验证'保证金额'的正确性
		moneyAmountValid($('.pledgeContractDialog-pledgeAmount'));
		moneyAmountValid($('.pledgeContractDialog-pledgeValue'));
		if( $('#myModal-pledgeContractDialog').find('.error.shows').length>0 ){
			$('#myModal-pledgeContractDialog').find('.error.shows:first').prev().focus();
			return;
		};
		// 更新编辑行的数据
		pledgeContractListData[operateIndex].pledgeNo = $('.pledgeContractDialog-pledgeNo').val();// 质押合同编号
		pledgeContractListData[operateIndex].creditLineType = $('.pledgeContractDialog-creditLineType').attr('tval');// 信贷业务种类
		pledgeContractListData[operateIndex].creditLineTypeCN = $('.pledgeContractDialog-creditLineType').val();// 信贷业务种类-中文
		pledgeContractListData[operateIndex].occurDate = $('.pledgeContractDialog-occurDate').val();// 质押事件日期
		pledgeContractListData[operateIndex].pledgeSeqNo = $('.pledgeContractDialog-pledgeSeqNo').val();// 质押序号
		pledgeContractListData[operateIndex].pledgeName = $('.pledgeContractDialog-pledgeName').val();// 出质人名称
		pledgeContractListData[operateIndex].isNaturalPerson = $('.pledgeContractDialog-isNaturalPerson option:selected').attr('value');// 是否是自然人
		pledgeContractListData[operateIndex].isNaturalPersonCN = $('.pledgeContractDialog-isNaturalPerson option:selected').text();// 是否是自然人--中文
		if( $('.pledgeContractDialog-pledgeLoanCardNo').parent().hasClass('hide') ){
			pledgeContractListData[operateIndex].pledgeLoanCardNo = undefined;// 出质人中征码
			pledgeContractListData[operateIndex].certType = $('.pledgeContractDialog-certType option:selected').attr('value');// 证件类型
			pledgeContractListData[operateIndex].certNo = $('.pledgeContractDialog-certNo').val();// 证件号码
		};
		if( !$('.pledgeContractDialog-pledgeLoanCardNo').parent().hasClass('hide') ){
			pledgeContractListData[operateIndex].pledgeLoanCardNo = $('.pledgeContractDialog-pledgeLoanCardNo').val();// 出质人中征码
			pledgeContractListData[operateIndex].certType = undefined;// 证件类型
			pledgeContractListData[operateIndex].certNo = undefined;// 证件号码
		};
		pledgeContractListData[operateIndex].pledgeCurrency = $('.pledgeContractDialog-pledgeCurrency option:selected').attr('value');// 币种
		pledgeContractListData[operateIndex].pledgeValue = $('.pledgeContractDialog-pledgeValue').val();// 质押物评估价值
		pledgeContractListData[operateIndex].assignDate = $('.pledgeContractDialog-assignDate').val();// 合同签订日期
		pledgeContractListData[operateIndex].pledgeType = $('.pledgeContractDialog-pledgeType option:selected').attr('value');// 质押物种类
		pledgeContractListData[operateIndex].pledgeTypeCN = $('.pledgeContractDialog-pledgeType option:selected').text();// 质押物种类--中文
		pledgeContractListData[operateIndex].pledgeAmount = $('.pledgeContractDialog-pledgeAmount').val();// 质押金额
		pledgeContractListData[operateIndex].pledgeCurrency1 = $('.pledgeContractDialog-pledgeCurrency1 option:selected').attr('value');// 质押金额币种
		pledgeContractListData[operateIndex].status = $('.pledgeContractDialog-status').attr('tval');// 合同有效状态
		pledgeContractListData[operateIndex].statusCN = $('.pledgeContractDialog-status').val();// 合同有效状态--中文
		// 重新填充页面表格里的内容
		$('.pledgeContractTbody').empty();
		for( var i=0;i<pledgeContractListData.length;i++ ){
			$('.pledgeContractTbody').append('<tr class="pledgeContractTr"><td style="background:#fff;">'+(i+1)+'</td>'
					+'<td style="background:#fff;">'+(pledgeContractListData[i].pledgeNo!=undefined?pledgeContractListData[i].pledgeNo:'')+'</td>'
					+'<td style="background:#fff;">'+(pledgeContractListData[i].pledgeName!=undefined?pledgeContractListData[i].pledgeName:'')+'</td>'
					+'<td style="background:#fff;">'+(pledgeContractListData[i].occurDate!=undefined?pledgeContractListData[i].occurDate:'')+'</td>'
					+'<td style="background:#fff;text-align:right;">'+handleListAmountFn(pledgeContractListData[i].pledgeValue,pledgeContractListData[i].pledgeCurrency)+'</td>'
					+'<td style="background:#fff;">'+(pledgeContractListData[i].pledgeTypeCN!=undefined?pledgeContractListData[i].pledgeTypeCN:'')+'</td>'
					+'<td style="background:#fff;text-align:right;">'+handleListAmountFn(pledgeContractListData[i].pledgeAmount,pledgeContractListData[i].pledgeCurrency1)+'</td>'
					+'<td style="background:#fff;" class="contractStatusInTable" statusValue="'+pledgeContractListData[i].status+'">'+(pledgeContractListData[i].statusCN!=undefined?pledgeContractListData[i].statusCN:'')+'</td>'
					+'<td style="background:#fff;">'+(pledgeContractListData[i].isNaturalPersonCN!=undefined?pledgeContractListData[i].isNaturalPersonCN:'')+'</td>'
					+'<td style="background:#fff;">'
						+'<span class="negativeInformationPlus editNewsBtn">编辑</span>'
						+'<span class="negativeInformationPlus deleteNewsBtn">删除</span>'+
						'<span class="negativeInformationPlus '+(pledgeContractListData[i].isReporting=='true'?'needNoReport':'needReport')+'">'+(pledgeContractListData[i].isReporting=='true'?'取消授权':'授权')+'</span>'
					+'</td>'
					+'</tr>')
		};
		i = null;
		$('#myModal-pledgeContractDialog').modal('hide');
	});
	
	// 抵押合同信息编辑确认按钮
	$('#myModal-mortgageContractDialog .colorbtn').click(function(){
		// 验证'保证金额'的正确性
		moneyAmountValid($('.mortgageContractDialog-mortgageAmount'));
		moneyAmountValid($('.mortgageContractDialog-evaluationValue'));
		if( $('#myModal-mortgageContractDialog').find('.error.shows').length>0 ){
			$('#myModal-mortgageContractDialog').find('.error.shows:first').prev().focus();
			return;
		};
		// 更新编辑行的数据
		mortgageContractListData[operateIndex].guarantyNo = $('.mortgageContractDialog-guarantyNo').val();// 抵押合同编号
		mortgageContractListData[operateIndex].creditLineType = $('.mortgageContractDialog-creditLineType').attr('tval');// 信贷业务种类
		mortgageContractListData[operateIndex].creditLineTypeCN = $('.mortgageContractDialog-creditLineType').val();// 信贷业务种类-中文
		mortgageContractListData[operateIndex].occurDate = $('.mortgageContractDialog-occurDate').val();// 抵押事件日期
		mortgageContractListData[operateIndex].mortgageSeqNo = $('.mortgageContractDialog-mortgageSeqNo').val();// 抵押序号
		mortgageContractListData[operateIndex].mortgageName = $('.mortgageContractDialog-mortgageName').val();// 抵押人名称
		mortgageContractListData[operateIndex].isNaturalPerson = $('.mortgageContractDialog-isNaturalPerson option:selected').attr('value');// 是否是自然人
		mortgageContractListData[operateIndex].isNaturalPersonCN = $('.mortgageContractDialog-isNaturalPerson option:selected').text();// 是否是自然人--中文
		if( $('.mortgageContractDialog-guaranteeLoanCardNo').parent().hasClass('hide') ){
			mortgageContractListData[operateIndex].guaranteeLoanCardNo = undefined;// 抵押人中征码
			mortgageContractListData[operateIndex].certType = $('.mortgageContractDialog-certType option:selected').attr('value');// 证件类型
			mortgageContractListData[operateIndex].certNo = $('.mortgageContractDialog-certNo').val();// 证件号码
		};
		if( !$('.mortgageContractDialog-guaranteeLoanCardNo').parent().hasClass('hide') ){
			mortgageContractListData[operateIndex].guaranteeLoanCardNo = $('.mortgageContractDialog-guaranteeLoanCardNo').val();// 抵押人中征码
			mortgageContractListData[operateIndex].certType = undefined;// 证件类型
			mortgageContractListData[operateIndex].certNo = undefined;// 证件号码
		};
		mortgageContractListData[operateIndex].evaluationCurrency = $('.mortgageContractDialog-evaluationCurrency option:selected').attr('value');// 币种
		mortgageContractListData[operateIndex].evaluationValue = $('.mortgageContractDialog-evaluationValue').val();// 抵押物评估价值
		mortgageContractListData[operateIndex].evaluationDate = $('.mortgageContractDialog-evaluationDate').val();// 评估日期
		mortgageContractListData[operateIndex].orgName = $('.mortgageContractDialog-orgName').val();// 评估机构名称
		mortgageContractListData[operateIndex].orgCode = $('.mortgageContractDialog-orgCode').val();// 评估机构组织机构代码
		mortgageContractListData[operateIndex].assignDate = $('.mortgageContractDialog-assignDate').val();// 合同签订日期
		mortgageContractListData[operateIndex].mortgageType = $('.mortgageContractDialog-mortgageType option:selected').attr('value');// 抵押物种类
		mortgageContractListData[operateIndex].mortgageAmount = $('.mortgageContractDialog-mortgageAmount').val();// 抵押金额
		mortgageContractListData[operateIndex].mortgageCurrency = $('.mortgageContractDialog-mortgageCurrency option:selected').attr('value');// 抵押金额币种
		mortgageContractListData[operateIndex].regOrg = $('.mortgageContractDialog-regOrg').val();// 登记机关
		mortgageContractListData[operateIndex].regDate = $('.mortgageContractDialog-regDate').val();// 登记日期
		mortgageContractListData[operateIndex].status = $('.mortgageContractDialog-status').attr('tval');// 合同有效状态
		mortgageContractListData[operateIndex].statusCN = $('.mortgageContractDialog-status').val();// 合同有效状态--中文
		mortgageContractListData[operateIndex].mortgageDesc = $('.mortgageContractDialog-mortgageDesc').val();// 抵押物说明
		mortgageContractListData[operateIndex].collateralName = $('.mortgageContractDialog-collateralName').val();// 抵押物名称
		// 重新填充页面表格里的内容
		$('.mortgageContractTbody').empty();
		for( var i=0;i<mortgageContractListData.length;i++ ){
			$('.mortgageContractTbody').append('<tr class="mortgageContractTr"><td style="background:#fff;">'+(i+1)+'</td>'
					+'<td style="background:#fff;">'+(mortgageContractListData[i].guarantyNo!=undefined?mortgageContractListData[i].guarantyNo:'')+'</td>'
					+'<td style="background:#fff;">'+(mortgageContractListData[i].mortgageName!=undefined?mortgageContractListData[i].mortgageName:'')+'</td>'
					+'<td style="background:#fff;">'+(mortgageContractListData[i].occurDate!=undefined?mortgageContractListData[i].occurDate:'')+'</td>'
					+'<td style="background:#fff;text-align:right;">'+handleListAmountFn(mortgageContractListData[i].evaluationValue,mortgageContractListData[i].evaluationCurrency)+'</td>'
					+'<td style="background:#fff;">'+(mortgageContractListData[i].evaluationDate!=undefined?mortgageContractListData[i].evaluationDate:'')+'</td>'
					+'<td style="background:#fff;text-align:right;">'+handleListAmountFn(mortgageContractListData[i].mortgageAmount,mortgageContractListData[i].mortgageCurrency)+'</td>'
					+'<td style="background:#fff;" class="contractStatusInTable" statusValue="'+mortgageContractListData[i].status+'">'+(mortgageContractListData[i].statusCN!=undefined?mortgageContractListData[i].statusCN:'')+'</td>'
					+'<td style="background:#fff;">'+(mortgageContractListData[i].isNaturalPersonCN!=undefined?mortgageContractListData[i].isNaturalPersonCN:'')+'</td>'
					+'<td style="background:#fff;">'
						+'<span class="negativeInformationPlus editNewsBtn">编辑</span>'
						+'<span class="negativeInformationPlus deleteNewsBtn">删除</span>'+
						'<span class="negativeInformationPlus '+(mortgageContractListData[i].isReporting=='true'?'needNoReport':'needReport')+'">'+(mortgageContractListData[i].isReporting=='true'?'取消授权':'授权')+'</span>'
					+'</td>'
					+'</tr>')
		};
		i = null;
		$('#myModal-mortgageContractDialog').modal('hide');
	});
	
	// 保证合同信息编辑确认按钮
	$('#myModal-guarantyContractDialog .colorbtn').click(function(){
		// 验证'保证金额'的正确性
		moneyAmountValid($('.guarantyContractDialog-guarantorAmount'));
		if( $('#myModal-guarantyContractDialog').find('.error.shows').length>0 ){
			$('#myModal-guarantyContractDialog').find('.error.shows:first').prev().focus();
			return;
		};
		// 更新编辑行的数据
		guarantyContractListData[operateIndex].guarantyNo = $('.guarantyContractDialog-guarantyNo').val();// 保证合同编号
		guarantyContractListData[operateIndex].creditLineType = $('.guarantyContractDialog-creditLineType').attr('tval');// 信贷业务种类
		guarantyContractListData[operateIndex].creditLineTypeCN = $('.guarantyContractDialog-creditLineType').val();// 信贷业务种类
		guarantyContractListData[operateIndex].occurDate = $('.guarantyContractDialog-occurDate').val();// 保证事件日期
		guarantyContractListData[operateIndex].guarantorName = $('.guarantyContractDialog-guarantorName').val();// 保证人名称
		guarantyContractListData[operateIndex].isNaturalPerson = $('.guarantyContractDialog-isNaturalPerson option:selected').attr('value');// 是否是自然人
		guarantyContractListData[operateIndex].isNaturalPersonCN = $('.guarantyContractDialog-isNaturalPerson option:selected').text();// 是否是自然人--中文
		if( $('.guarantyContractDialog-guarantyLoanCardNo').parent().hasClass('hide') ){
			guarantyContractListData[operateIndex].guarantyLoanCardNo = undefined;// 保证人中征码
			guarantyContractListData[operateIndex].certType = $('.guarantyContractDialog-certType option:selected').attr('value');// 证件类型
			guarantyContractListData[operateIndex].certNo = $('.guarantyContractDialog-certNo').val();// 证件号码
		};
		if( !$('.guarantyContractDialog-guarantyLoanCardNo').parent().hasClass('hide') ){
			guarantyContractListData[operateIndex].guarantyLoanCardNo = $('.guarantyContractDialog-guarantyLoanCardNo').val();// 保证人中征码
			guarantyContractListData[operateIndex].certType = undefined;// 证件类型
			guarantyContractListData[operateIndex].certNo = undefined;// 证件号码
		};
		guarantyContractListData[operateIndex].currency = $('.guarantyContractDialog-currency option:selected').attr('value');// 币种
		guarantyContractListData[operateIndex].guarantorAmount = $('.guarantyContractDialog-guarantorAmount').val();// 保证金额
		guarantyContractListData[operateIndex].createDate = $('.guarantyContractDialog-createDate').val();// 合同签订日期
		guarantyContractListData[operateIndex].guaranteeForm = $('.guarantyContractDialog-guaranteeForm').attr('tval');// 保证担保形式
		guarantyContractListData[operateIndex].guaranteeFormCN = $('.guarantyContractDialog-guaranteeForm').val();// 保证担保形式--中文
		guarantyContractListData[operateIndex].status = $('.guarantyContractDialog-status').attr('tval');// 合同有效状态
		guarantyContractListData[operateIndex].statusCN = $('.guarantyContractDialog-status').val();// 合同有效状态--中文
		// 重新填充页面表格里的内容
		$('.guarantyContractTbody').empty();
		for( var i=0;i<guarantyContractListData.length;i++ ){
			$('.guarantyContractTbody').append('<tr class="guarantyContractTr"><td style="background:#fff;">'+(i+1)+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].guarantyNo!=undefined?guarantyContractListData[i].guarantyNo:'')+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].guarantorName!=undefined?guarantyContractListData[i].guarantorName:'')+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].occurDate!=undefined?guarantyContractListData[i].occurDate:'')+'</td>'
					+'<td style="background:#fff;text-align:right;">'+handleListAmountFn(guarantyContractListData[i].guarantorAmount,guarantyContractListData[i].currency)+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].createDate!=undefined?guarantyContractListData[i].createDate:'')+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].guaranteeFormCN!=undefined?guarantyContractListData[i].guaranteeFormCN:'')+'</td>'
					+'<td style="background:#fff;" class="contractStatusInTable" statusValue="'+guarantyContractListData[i].status+'">'+(guarantyContractListData[i].statusCN!=undefined?guarantyContractListData[i].statusCN:'')+'</td>'
					+'<td style="background:#fff;">'+(guarantyContractListData[i].isNaturalPersonCN!=undefined?guarantyContractListData[i].isNaturalPersonCN:'')+'</td>'
					+'<td style="background:#fff;">'
						+'<span class="negativeInformationPlus editNewsBtn">编辑</span>'
						+'<span class="negativeInformationPlus deleteNewsBtn">删除</span>'
						+'<span class="negativeInformationPlus '+(guarantyContractListData[i].isReporting=='true'?'needNoReport':'needReport')+'">'+(guarantyContractListData[i].isReporting=='true'?'取消授权':'授权')+'</span>'
					+'</td>'
					+'</tr>')
		};
		i = null;
		$('#myModal-guarantyContractDialog').modal('hide');
	});
	
	// 质押合同信息编辑确认按钮
	
	// 不良信贷-资产处置信息编辑确认按钮
	
	
	
	
	
	//暂存或保存最后的提交
	function submitFunction(e){
		var postdata = {};
		postdata['creditReportingId'] = creditReportQuery.creditReportingId;
		// 保理业务信息表-保理业务信息段数据项
		if( $('.businessInfo-factoring').length>0 ){
			postdata['factoring.creditReportingId'] = creditReportQuery.creditReportingId;
			postdata['factoring.factorNo'] = $('.factoring-factorNo').val();// 保理合同编号
			postdata['factoring.currency'] = $('.factoring-factorNo').attr('curr');// 币种
			postdata['factoring.factorNoSuffix'] = $('.factoring-factorNoSuffix').val();// 后缀
			//postdata['factoring.bizType'] = $('.factoring-bizType').attr('tval');// 保理产品类型
			postdata['factoring.extensionNo'] = $('.factoring-extensionNo').val();// 评审编号
			postdata['factoring.bizState'] = $('.factoring-bizState').attr('tval');// 保理业务状态
			postdata['factoring.occurdate'] = $('.factoring-occurDate').val();// 保理事件日期
			postdata['factoring.occurDate'] = $('.factoring-occurDate').attr('typeofdate');// 保理事件日期
			postdata['factoring.bizAmount'] = $('.factoring-bizAmount').val().split(',').join('');// 投放本金
			postdata['factoring.bizDate'] = $('.factoring-bizDate').val();// 投放日期
			postdata['factoring.bizBalance'] = $('.factoring-bizBalance').val().split(',').join('');// 未还投放本金
			postdata['factoring.bizChangeDate'] = $('.factoring-bizChangeDate').val();// 未还本金变化日期
			postdata['factoring.guaranteeFlag'] = $('.factoring-guaranteeFlag').attr('tval');// 担保标志
			postdata['factoring.cashAdvanceFlag'] = $('.factoring-cashAdvanceFlag').attr('tval');// 垫款标志
			postdata['factoring.classify4'] = $('.factoring-classify4').attr('tval');// 四级分类
			postdata['factoring.classify5'] = $('.factoring-classify5').find('option:selected').attr('value');// 五级分类
			if( !$('.classify5OccurDateParentTr').hasClass('hide') ){
				postdata['factoring.classify5OccurDate'] = $('[name=classify5OccurDate]').val();// 五级分类变化发生日期
			};
		};
		// 垫款业务信息表
		if( $('.businessInfo-cashAdvance').length>0 ){
			postdata['cashAdvance.creditReportingId'] = creditReportQuery.creditReportingId;
			postdata['cashAdvance.advanceNo'] = $('.cashAdvance-advanceNo').val();// 逾期编号
			postdata['cashAdvance.loanCardNo'] = $('.cashAdvance-loanCardNo').val();// 中征码
			postdata['cashAdvance.custId'] = $('.cashAdvance-custId').val();// 客户号
			postdata['cashAdvance.finOrgCode'] = $('.cashAdvance-finOrgCode').val();// 金融机构代码
			postdata['cashAdvance.originalBizNo'] = $('.cashAdvance-originalBizNo').val();// 原业务号
			postdata['cashAdvance.occurdate'] = $('.cashAdvance-occurDate').val();// 逾期事件日期
			postdata['cashAdvance.occurDate'] = $('.cashAdvance-occurDate').attr('typeofdate');// 逾期事件日期
			postdata['cashAdvance.borrowerName'] = $('.cashAdvance-borrowerName').val();// 借款人名称
			postdata['cashAdvance.advanceType'] = $('.cashAdvance-advanceType').attr('tval');// 垫款种类
			postdata['cashAdvance.currency'] = $('.cashAdvance-currency').attr('tval');// 币种
			postdata['cashAdvance.advanceAmount'] = $('.cashAdvance-advanceAmount').val().split(',').join('');// 逾期金额
			postdata['cashAdvance.advanceDate'] = $('.cashAdvance-advanceDate').val();// 逾期日期
			postdata['cashAdvance.advanceBalance'] = $('.cashAdvance-advanceBalance').val().split(',').join('');// 未还逾期金额
			postdata['cashAdvance.advanceChgDate'] = $('.cashAdvance-advanceChgDate').val();//未还逾期变化日期
			postdata['cashAdvance.repayType'] = $('.cashAdvance-repayType').find('option:selected').attr('value');// 还款方式
			postdata['cashAdvance.classify4'] = $('.cashAdvance-classify4').attr('tval');// 四级分类
			postdata['cashAdvance.classify5'] = $('.cashAdvance-classify5').find('option:selected').attr('value');// 五级分类
			if( !$('.classify5OccurDateParentTr2').hasClass('hide') ){
				postdata['cashAdvance.classify5OccurDate'] = $('[name=classify5OccurDate2]').val();// 还款方式或五级分类变化发生日期
			};
		};
		// 欠息信息表-欠息业务信息段数据项
		if( $('.businessInfo-debitInterest').length>0 ){
			postdata['debitInterest.creditReportingId'] = creditReportQuery.creditReportingId;
			postdata['debitInterest.custId'] = $('.debitInterest-custId').val();// 客户号
			postdata['debitInterest.finOrgCode'] = $('.debitInterest-finOrgCode').val();// 金融机构代码
			postdata['debitInterest.loanCardNo'] = $('.debitInterest-loanCardNo').val();// 中征码
			postdata['debitInterest.borrowerName'] = $('.debitInterest-borrowerName').val();// 借款人名称
			postdata['debitInterest.occurdate'] = $('.debitInterest-occurDate').val();// 欠息事件日期
			postdata['debitInterest.occurDate'] = $('.debitInterest-occurDate').attr('typeofdate');// 欠息事件日期
			postdata['debitInterest.currency'] = $('.debitInterest-currency').attr('tval');// 币种
			postdata['debitInterest.interestBalance'] = $('.debitInterest-interestBalance').val().split(',').join('');// 欠息余额
			postdata['debitInterest.interestType'] = $('.debitInterest-interestType').attr('tval');// 欠息类型
			postdata['debitInterest.changeDate'] = $('.debitInterest-changeDate').val();// 欠息余额变化日期
		};
		// 担保信息表-保证合同信息段数据项
		if( $('.businessInfo-guarantyContractList').length>0 ){
			for( var i=0;i<guarantyContractListData.length;i++ ){
				postdata['guarantyContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['guarantyContractList['+i+'].historicGuarantyNo'] = guarantyContractListData[i].historicGuarantyNo;// 原保证合同编号
				postdata['guarantyContractList['+i+'].historicLoanNo'] = guarantyContractListData[i].historicLoanNo;// 原主合同编号
				postdata['guarantyContractList['+i+'].historicCertNo'] = guarantyContractListData[i].historicCertNo;// 原证件号码
				postdata['guarantyContractList['+i+'].historicIsNaturalPerson'] = guarantyContractListData[i].historicIsNaturalPerson;// 原 是否自然人
				
				postdata['guarantyContractList['+i+'].guarantyNo'] = guarantyContractListData[i].guarantyNo;// 保证合同编号
				if( guarantyContractListData[i].creditLineType ){
					postdata['guarantyContractList['+i+'].creditLineType'] = guarantyContractListData[i].creditLineType;// 信贷业务种类
				};
				postdata['guarantyContractList['+i+'].occurDate'] = guarantyContractListData[i].occurDate;// 保证事件日期
				postdata['guarantyContractList['+i+'].guarantorName'] = guarantyContractListData[i].guarantorName;// 保证人名称
				postdata['guarantyContractList['+i+'].guarantyLoanCardNo'] = guarantyContractListData[i].guarantyLoanCardNo;// 保证人中征码
				postdata['guarantyContractList['+i+'].isNaturalPerson'] = guarantyContractListData[i].isNaturalPerson;// 是否是自然人
				postdata['guarantyContractList['+i+'].certType'] = guarantyContractListData[i].certType;// 证件类型
				postdata['guarantyContractList['+i+'].certNo'] = guarantyContractListData[i].certNo;// 证件号码
//				postdata['guarantyContractList['+i+'].currency'] = guarantyContractListData[i].currency;// 币种
//				postdata['guarantyContractList['+i+'].guarantorAmount'] = guarantyContractListData[i].guarantorAmount!=undefined?guarantyContractListData[i].guarantorAmount.split(',').join(''):'';// 保证金额
				postdata['guarantyContractList['+i+'].createDate'] = guarantyContractListData[i].createDate;// 合同签订日期
				if( guarantyContractListData[i].guaranteeForm ){
					postdata['guarantyContractList['+i+'].guaranteeForm'] = guarantyContractListData[i].guaranteeForm;// 保证担保形式
				};
				if( guarantyContractListData[i].status ){
					postdata['guarantyContractList['+i+'].status'] = guarantyContractListData[i].status;// 合同有效状态
				};
				postdata['guarantyContractList['+i+'].isReporting'] = guarantyContractListData[i].isReporting=='true'?true:false;// 是否已授权
			};
			i = null;
			// 删除的
			for( var i=0;i<guarantyContractListDeleteData.length;i++ ){
				postdata['deleteGuarantyContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['deleteGuarantyContractList['+i+'].historicGuarantyNo'] = guarantyContractListDeleteData[i].historicGuarantyNo;// 原保证合同编号
				postdata['deleteGuarantyContractList['+i+'].historicLoanNo'] = guarantyContractListDeleteData[i].historicLoanNo;// 原主合同编号
				postdata['deleteGuarantyContractList['+i+'].historicCertNo'] = guarantyContractListDeleteData[i].historicCertNo;// 原证件号码
				postdata['deleteGuarantyContractList['+i+'].historicIsNaturalPerson'] = guarantyContractListDeleteData[i].historicIsNaturalPerson;// 原 是否自然人
			};
			i = null;
		};
		// 担保信息表-抵押合同信息段数据项
		if( $('.businessInfo-mortgageContractList').length>0 ){
			for( var i=0;i<mortgageContractListData.length;i++ ){
				postdata['mortgageContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['mortgageContractList['+i+'].historicGuarantyNo'] = mortgageContractListData[i].historicGuarantyNo;// 原抵押合同编号
				postdata['mortgageContractList['+i+'].historicLoanNo'] = mortgageContractListData[i].historicLoanNo;// 原主合同编号
				postdata['mortgageContractList['+i+'].historicIsNaturalPerson'] = mortgageContractListData[i].historicIsNaturalPerson;// 原 是否自然人
				postdata['mortgageContractList['+i+'].historicMortgageSeqNo'] = mortgageContractListData[i].historicMortgageSeqNo;// 原 抵押合同序号
				postdata['mortgageContractList['+i+'].guarantyNo'] = mortgageContractListData[i].guarantyNo;// 抵押合同编号
				if( mortgageContractListData[i].creditLineType ){
					postdata['mortgageContractList['+i+'].creditLineType'] = mortgageContractListData[i].creditLineType;// 信贷业务种类
				};
				postdata['mortgageContractList['+i+'].occurDate'] = mortgageContractListData[i].occurDate;// 抵押事件日期
				postdata['mortgageContractList['+i+'].mortgageSeqNo'] = mortgageContractListData[i].mortgageSeqNo;// 抵押序号
				postdata['mortgageContractList['+i+'].mortgageName'] = mortgageContractListData[i].mortgageName;// 抵押人名称
				postdata['mortgageContractList['+i+'].isNaturalPerson'] = mortgageContractListData[i].isNaturalPerson;// 是否是自然人
				postdata['mortgageContractList['+i+'].guaranteeLoanCardNo'] = mortgageContractListData[i].guaranteeLoanCardNo;// 抵押人中征码
				postdata['mortgageContractList['+i+'].certType'] = mortgageContractListData[i].certType;// 证件类型
				postdata['mortgageContractList['+i+'].certNo'] = mortgageContractListData[i].certNo;// 证件号码
				postdata['mortgageContractList['+i+'].evaluationCurrency'] = mortgageContractListData[i].evaluationCurrency;// 币种
				postdata['mortgageContractList['+i+'].evaluationValue'] = mortgageContractListData[i].evaluationValue!=undefined?mortgageContractListData[i].evaluationValue.split(',').join(''):'';// 抵押物评估价值
				postdata['mortgageContractList['+i+'].evaluationDate'] = mortgageContractListData[i].evaluationDate;// 评估日期
				postdata['mortgageContractList['+i+'].orgName'] = mortgageContractListData[i].orgName;// 评估机构名称
				postdata['mortgageContractList['+i+'].orgCode'] = mortgageContractListData[i].orgCode;// 评估机构组织机构代码
				postdata['mortgageContractList['+i+'].assignDate'] = mortgageContractListData[i].assignDate;// 合同签订日期
				postdata['mortgageContractList['+i+'].mortgageType'] = mortgageContractListData[i].mortgageType;// 抵押物种类
//				postdata['mortgageContractList['+i+'].mortgageAmount'] = mortgageContractListData[i].mortgageAmount!=undefined?mortgageContractListData[i].mortgageAmount.split(',').join(''):'';// 抵押金额
//				postdata['mortgageContractList['+i+'].mortgageCurrency'] = mortgageContractListData[i].mortgageCurrency;// 抵押金额币种
				postdata['mortgageContractList['+i+'].regOrg'] = mortgageContractListData[i].regOrg;// 登记机关
				postdata['mortgageContractList['+i+'].regDate'] = mortgageContractListData[i].regDate;// 登记日期
				if( mortgageContractListData[i].status ){
					postdata['mortgageContractList['+i+'].status'] = mortgageContractListData[i].status;// 合同有效状态
				};
				postdata['mortgageContractList['+i+'].mortgageDesc'] = mortgageContractListData[i].mortgageDesc;// 抵押物说明
				postdata['mortgageContractList['+i+'].collateralName'] = mortgageContractListData[i].collateralName;// 抵押物名称
				postdata['mortgageContractList['+i+'].isReporting'] = mortgageContractListData[i].isReporting=='true'?true:false;// 是否已授权
				
			};
			i = null;
			// 删除的
			for( var i=0;i<mortgageContractListDeleteData.length;i++ ){
				postdata['deleteMortgageContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['deleteMortgageContractList['+i+'].historicGuarantyNo'] = mortgageContractListDeleteData[i].historicGuarantyNo;// 原抵押合同编号
				postdata['deleteMortgageContractList['+i+'].historicLoanNo'] = mortgageContractListDeleteData[i].historicLoanNo;// 原主合同编号
				postdata['deleteMortgageContractList['+i+'].historicIsNaturalPerson'] = mortgageContractListDeleteData[i].historicIsNaturalPerson;// 原 是否自然人
				postdata['deleteMortgageContractList['+i+'].historicMortgageSeqNo'] = mortgageContractListDeleteData[i].historicMortgageSeqNo;// 原 抵押合同序号
			};
			i = null;
		};
		// 担保信息表-质押合同信息段数据项
		if( $('.businessInfo-pledgeContractList').length>0 ){
			for( var i=0;i<pledgeContractListData.length;i++ ){
				postdata['pledgeContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['pledgeContractList['+i+'].historicPledgeNo'] = pledgeContractListData[i].historicPledgeNo;// 原质押合同编号
				postdata['pledgeContractList['+i+'].historicLoanNo'] = pledgeContractListData[i].historicLoanNo;// 原主合同编号
				postdata['pledgeContractList['+i+'].historicIsNaturalPerson'] = pledgeContractListData[i].historicIsNaturalPerson;// 原 是否自然人
				postdata['pledgeContractList['+i+'].historicPledgeSeqNo'] = pledgeContractListData[i].historicPledgeSeqNo;// 原 质押合同序号
				postdata['pledgeContractList['+i+'].pledgeNo'] = pledgeContractListData[i].pledgeNo;// 质押合同编号
				if( pledgeContractListData[i].creditLineType ){
					postdata['pledgeContractList['+i+'].creditLineType'] = pledgeContractListData[i].creditLineType;// 信贷业务种类
				};
				postdata['pledgeContractList['+i+'].occurDate'] = pledgeContractListData[i].occurDate;// 质押事件日期
				postdata['pledgeContractList['+i+'].pledgeSeqNo'] = pledgeContractListData[i].pledgeSeqNo;// 质押序号
				postdata['pledgeContractList['+i+'].pledgeName'] = pledgeContractListData[i].pledgeName;// 出质人名称
				postdata['pledgeContractList['+i+'].isNaturalPerson'] = pledgeContractListData[i].isNaturalPerson;// 是否是自然人
				postdata['pledgeContractList['+i+'].pledgeLoanCardNo'] = pledgeContractListData[i].pledgeLoanCardNo;// 出质人中征码
				postdata['pledgeContractList['+i+'].certType'] = pledgeContractListData[i].certType;// 证件类型
				postdata['pledgeContractList['+i+'].certNo'] = pledgeContractListData[i].certNo;// 证件号码
				postdata['pledgeContractList['+i+'].pledgeCurrency'] = pledgeContractListData[i].pledgeCurrency;// 币种
				postdata['pledgeContractList['+i+'].pledgeValue'] = pledgeContractListData[i].pledgeValue!=undefined?pledgeContractListData[i].pledgeValue.split(',').join(''):'';// 质押物价值
				postdata['pledgeContractList['+i+'].assignDate'] = pledgeContractListData[i].assignDate;// 合同签订日期
				postdata['pledgeContractList['+i+'].pledgeType'] = pledgeContractListData[i].pledgeType;// 质押物种类
//				postdata['pledgeContractList['+i+'].pledgeAmount'] = pledgeContractListData[i].pledgeAmount!=undefined?pledgeContractListData[i].pledgeAmount.split(',').join(''):'';// 质押金额
//				postdata['pledgeContractList['+i+'].pledgeCurrency1'] = pledgeContractListData[i].pledgeCurrency1;// 质押金额币种
				if( pledgeContractListData[i].status ){
					postdata['pledgeContractList['+i+'].status'] = pledgeContractListData[i].status;// 合同有效状态
				};
				postdata['pledgeContractList['+i+'].isReporting'] = pledgeContractListData[i].isReporting=='true'?true:false;// 是否已授权
			};
			i = null;
			// 删除的
			for( var i=0;i<pledgeContractListDeleteData.length;i++ ){
				postdata['deletePledgeContractList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['deletePledgeContractList['+i+'].historicPledgeNo'] = pledgeContractListDeleteData[i].historicPledgeNo;// 原质押合同编号
				postdata['deletePledgeContractList['+i+'].historicLoanNo'] = pledgeContractListDeleteData[i].historicLoanNo;// 原主合同编号
				postdata['deletePledgeContractList['+i+'].historicIsNaturalPerson'] = pledgeContractListDeleteData[i].historicIsNaturalPerson;// 原 是否自然人
				postdata['deletePledgeContractList['+i+'].historicPledgeSeqNo'] = pledgeContractListDeleteData[i].historicPledgeSeqNo;// 原 质押合同序号
			};
			i = null;
		};
		// 不良信贷资产处置信息表-资产处置信息段数据项
		if( $('.businessInfo-badCreditAssetList').length>0 ){
			for( var i=0;i<badCreditAssetListData.length;i++ ){
				postdata['badCreditAssetList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['badCreditAssetList['+i+'].historicOccurDate'] = badCreditAssetListData[i].historicOccurDate;// 原 业务发生日期
				postdata['badCreditAssetList['+i+'].bizNo'] = badCreditAssetListData[i].bizNo;// 处置编号
				postdata['badCreditAssetList['+i+'].occurDate'] = badCreditAssetListData[i].occurDate;// 业务发生日期
				postdata['badCreditAssetList['+i+'].borrowerName'] = badCreditAssetListData[i].borrowerName;// 借款人名称
				postdata['badCreditAssetList['+i+'].currency.id'] = badCreditAssetListData[i].currency;// 币种
				postdata['badCreditAssetList['+i+'].balance'] = badCreditAssetListData[i].balance!=undefined?badCreditAssetListData[i].balance.split(',').join(''):'';// 处置余额
				postdata['badCreditAssetList['+i+'].disposeDate'] = badCreditAssetListData[i].disposeDate;// 处置日期
				postdata['badCreditAssetList['+i+'].disposeType'] = badCreditAssetListData[i].disposeType;// 主要资产处置方式
				postdata['badCreditAssetList['+i+'].recycledAmount'] = badCreditAssetListData[i].recycledAmount!=undefined?badCreditAssetListData[i].recycledAmount.split(',').join(''):'';// 已回收金额
				postdata['badCreditAssetList['+i+'].isReporting'] = badCreditAssetListData[i].isReporting=='true'?true:false;// 是否已授权
			};
			i = null;
			// 删除的
			for( var i=0;i<badCreditAssetListDeleteData.length;i++ ){
				postdata['deleteBadCreditAssetList['+i+'].creditReportingId'] = creditReportQuery.creditReportingId;
				postdata['deleteBadCreditAssetList['+i+'].historicOccurDate'] = badCreditAssetListDeleteData[i].historicOccurDate;// 原 业务发生日期
				postdata['deleteBadCreditAssetList['+i+'].bizNo'] = badCreditAssetListDeleteData[i].bizNo;// 处置编号
			};
			i = null;
		};
		
		$.ajax({
			url:'/creditreporting/businessInfo/doUpdate',
			type:'post',
			data:postdata,
			success:function(data){
				if( data.success ){
					new $.zui.Messager('修改成功', {
					    type: 'success'
					}).show();
					if( $(".yk_addNewMsg .btn-cancel").hasClass('sell') ){
						$(".yk_rightcontent").load("/creditreporting/businessInfo/sellerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.creditSubjectId);
					}else{
						$(".yk_rightcontent").load("/creditreporting/businessInfo/buyerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.counterpartyId);
					};
				}else{
					new $.zui.Messager('修改失败:'+data.msg, {
					    type: 'danger'
					 }).show();	
				}
			},
			error:function(){
				new $.zui.Messager('修改时出错:'+status, {
				    type: 'danger'
				 }).show();	
			}
		});
		
		return false;
	} 

	//表单验证
	function addNewCustomer(e){ 
		$("#businessBasicSellerEditForm").validate({
			 promptPosition : "bottomLeft",
			 submitHandler : function(form) {
				 submitFunction(e);
			 }, 
			rules : {
				"factoring-bizAmount":{// 投放本金
					decimalLengthValid:true,
					decimalNumberValid:true,
					decimalPointValid:true
				},
				"factoring-bizBalance":{// 未还投放本金
					decimalLengthValid:true,
					decimalNumberValid:true,
					decimalPointValid:true
				},
				'cashAdvance-advanceBalance':{// 未还逾期金额
					decimalLengthValid:true,
					decimalNumberValid:true,
					decimalPointValid:true
				},
				'cashAdvance-advanceAmount':{// 逾期金额
					decimalLengthValid:true,
					decimalNumberValid:true,
					decimalPointValid:true
				},
				'debitInterest-interestBalance':{// 欠息余额
					decimalLengthValid:true,
					decimalNumberValid:true,
					decimalPointValid:true
				},
				'classify5OccurDate':{// 五级分类变化日期
					required: true
				},
				'classify5OccurDate2':{// 还款方式或五级分类变化日期
					required: true
				}
			},
			messages : {
				'classify5OccurDate':{// 五级分类变化日期
					required: '请选择五级分类变化日期'
				},
				'classify5OccurDate2':{// 还款方式或五级分类变化日期
					required: '请选择还款方式或五级分类变化日期'
				}
			} 
		}); 
	};
	
	//提交按钮
	$("#businessBasicSellerEditForm button.save").click(addNewCustomer);
	
	
	// 返回上级列表
	$(".newBackBtn").click(function(){
		$(".yk_rightcontent").load("/creditreporting/list");
		return false;
	});
	
	// 卖方-返回查看
	$(".yk_addNewMsg .btn-cancel.sell").click(function(){
		$(".yk_rightcontent").load("/creditreporting/businessInfo/sellerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.creditSubjectId);
		return false;
	});
	
	// 买方-返回查看
	$(".yk_addNewMsg .btn-cancel.buy").click(function(){
		$(".yk_rightcontent").load("/creditreporting/businessInfo/buyerView?creditReportingId="+creditReportQuery.creditReportingId+'&custId='+creditReportQuery.counterpartyId);
		return false;
	});
	
})
