//流程模块【hklist.回款单列表】下录入页面自定义js页面,初始函数
function initbodys(){



			c.onselectdata['hkunit']=function(d){
			  	form('tmp_hkunit').value = d.name;
		};
	 c.onselectdatabefore=function(fid,zb){
       var tmp_hkunit = form('tmp_hkunit').value;
        if(fid == 'hkdetail0_0') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_1') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_2') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_3') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_4') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_5') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_6') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_7') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_8') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_9') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_10') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_11') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_12') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_13') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_14') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
          if(fid == 'hkdetail0_15') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
           if(fid == 'hkdetail0_16') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
           if(fid == 'hkdetail0_17') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
           if(fid == 'hkdetail0_18') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
           if(fid == 'hkdetail0_19') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
           if(fid == 'hkdetail0_20') {
            if(form('tmp_hkunit').value ==''){
              return '请选择回款单位';
            }
 			  return {'hkunit':tmp_hkunit}
        }
       
    }

		c.onselectdata['hkdetail0_0']=function(d) {
		    form('yhamount0_0').value=d.hkamount;
		    form('khamount0_0').value=d.hkamountcan;
		    form('hks_id0_0').value=d.value;

		    
            bindeventchange()

        };

		c.onselectdata['hkdetail0_1']=function(d) {
		    form('yhamount0_1').value=d.hkamount;
		    form('khamount0_1').value=d.hkamountcan;
		     form('hks_id0_1').value=d.value;
            bindeventchange()



        };
		c.onselectdata['hkdetail0_2']=function(d) {
		     form('yhamount0_2').value=d.hkamount;
		    form('khamount0_2').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_3']=function(d) {
		     form('yhamount0_3').value=d.hkamount;
		    form('khamount0_3').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_4']=function(d) {
		    form('yhamount0_4').value=d.hkamount;
		    form('khamount0_4').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_5']=function(d) {
		    form('yhamount0_5').value=d.hkamount;
		    form('khamount0_5').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_6']=function(d) {
		   form('yhamount0_6').value=d.hkamount;
		    form('khamount0_6').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_7']=function(d) {
		    form('yhamount0_7').value=d.hkamount;
		    form('khamount0_7').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_8']=function(d) {
		    form('yhamount0_8').value=d.hkamount;
		    form('khamount0_8').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_9']=function(d) {
		    form('yhamount0_9').value=d.hkamount;
		    form('khamount0_9').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_10']=function(d) {
		    form('yhamount0_10').value=d.hkamount;
		    form('khamount0_10').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_11']=function(d) {
		    form('yhamount0_11').value=d.hkamount;
		    form('khamount0_11').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_12']=function(d) {
		    form('yhamount0_12').value=d.hkamount;
		    form('khamount0_12').value=d.hkamountcan;
		     bindeventchange()
		};

		c.onselectdata['hkdetail0_13']=function(d) {
			form('yhamount0_13').value=d.hkamount;
			form('khamount0_13').value=d.hkamountcan;
			bindeventchange()
		};
	
		c.onselectdata['hkdetail0_14']=function(d) {
		     form('yhamount0_14').value=d.hkamount;
		    form('khamount0_14').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_15']=function(d) {
		     form('yhamount0_15').value=d.hkamount;
		    form('khamount0_15').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_16']=function(d) {
		     form('yhamount0_16').value=d.hkamount;
		    form('khamount0_16').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_17']=function(d) {
		     form('yhamount0_17').value=d.hkamount;
		    form('khamount0_17').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_18']=function(d) {
		     form('yhamount0_18').value=d.hkamount;
		    form('khamount0_18').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_19']=function(d) {
		     form('yhamount0_19').value=d.hkamount;
		    form('khamount0_19').value=d.hkamountcan;
		     bindeventchange()
		};
		c.onselectdata['hkdetail0_20']=function(d) {
		     form('yhamount0_20').value=d.hkamount;
		    form('khamount0_20').value=d.hkamountcan;
		     bindeventchange()
		};
	
    bindeventchange()
}

function eventdelsubrows(xu){
    bindeventchange()
}

function eventaddsubrows(xu){
		$("table#tablesub0").find("input[name~='yhamount0_']:last").val()=0;
		$("table#tablesub0").find("input[name~='khamount0_']:last").val()=0;
  
    bindeventchange()
}

//动态绑定change事件
function bindeventchange(){

  

    //初始化应回金额
    var yhamounts = 0;
    $("table.tablesub").find("input[name~='yhamount0_']").each(function(){
        if(!isNaN($(this).val())) yhamounts += Number($(this).val());
    })
    form('amount').value = yhamounts;



    var khamounts = 0;
    $("table.tablesub").find("input[name~='khamount0_']").each(function(){
        if(!isNaN($(this).val())) khamounts += Number($(this).val());
    })
    form('amountcan').value = khamounts;



 $("table.tablesub").find("input[name~='hkamountreal0_']").each(function(){
        $(this).change(function(){
            filteramount(this)
        })
    })

   
}


//过滤金额
function filteramount(obj) {
    js.setmsg('');
    //如果不符合规则则提示数值不合法
    var val = obj.value;
    if(val != ''){
        val = parseFloat(obj.value);
        var reg = new RegExp(/^\d+\.?\d*$/);
        var res = reg.test(val);

        if(!res) js.setmsg('金额只能填写数字或小数')
        else obj.value = val.toFixed(2);
    }
}

