dst.defineClass("com.dst.slms.contractmange.econtermsadjust.econTermsAdjustEdit", dst.framework.coreBillBaseEdit, {
	initalizeDOM:function(){
		com.dst.slms.contractmange.econtermsadjust.econTermsAdjustEdit.superClass.initalizeDOM.call(this);
	},
	
	contract_change:function(newValue,oldValue){
		var contractid = $('#contract').textbox('getBizValue').id;
		dst.remoteCall({
			method : "getContractInfo",
			async:true,  
			url: this.uipk,
			param : {contractid:contractid},
			success : function(data, textStatus) {
				debugger;
				var grid = $('#econTermsAdjustE1-entity');
				grid.datagrid('loadData', []);
				if(!jQuery.isEmptyObject(data)){
					$("#project").textbox("setBizValue",data.project);
					$("#org").textbox("setBizValue",data.orgunit);
					$("#supplier").textbox("setBizValue",data.supplier);
					$("#conAmount").numberspinner("setValue",data.taxConAmt);
					var entrys = data.entry;
					for(var i=0;i<entrys.length;i++){
						var rowData=entrys[i];
						grid.datagrid('addRow',{
							adjustDate:rowData.bizDate,//日期
							payType:rowData.payType,//付款类型
							conditions:rowData.pay,//付款条件
							rate:rowData.payScale,//比例
							amount:rowData.amount,//衣服金额
							payAmount:rowData.payAmt //付款金额
						})
					}
				}else{
					$("#project").textbox("setBizValue","");
					$("#org").textbox("setBizValue","");
					$("#supplier").textbox("setBizValue","");
					$("#conAmount").numberspinner("setValue","");
				}
			}
		});
	},
	
	//可编辑表格值改变事件，可对表格进行值代入、带出操作
	entry_change:function(datagridTarget,target,index,field,newValue,oldValue){
		//获取编辑行数据
		var conAmount = $('#conAmount').numberspinner('getValue');//合同金额
		var row = datagridTarget.datagrid('getRows')[index];
		row[field]=newValue;
		
		var v = {};
		if(field=='rate'){
			//计算金额
			var rate =row["rate"]==undefined?0:row["rate"];
			
			rate = Number(rate)/ Number(100);
			
			var payAmount = Number(conAmount) * Number(rate);
			
			v["payAmount"] = payAmount;
		}
		//更新行数据
		datagridTarget.datagrid("updateRow",{index:index,row:v});
	},
	
});