dst.defineClass("com.dst.slms.supplierreview.reviewtemplate.reviewTemplateEdit", dst.framework.Edit, {
	initalizeDOM:function(){
		com.dst.slms.supplierreview.reviewtemplate.reviewTemplateEdit.superClass.initalizeDOM.call(this);
	},
	editChangeOrg:function(datag,target,index,field,newValue, oldValue){
		if(field=='org'){
			var nodes  = $('#unitWeight-entity').datagrid('getRows');
			var flag = true;
			if(nodes){
				for (var i = 0; i < nodes.length; i++) {
					if(nodes[i].org.id==newValue.id){
						flag = false
					}
				}
			}
			if(flag){
				$('#unitWeight-entity').datagrid('insertRow',{
					index: 0,
					row: {
						org:newValue
					}
				});
			}
		}
	},
	/**
	 * 可编辑表格删除行
	 */
	removeRow:function(event,gridname){
		var node  = $('#'+gridname).datagrid('getSelected');
		if(!node){
			dst.tip({
				message: "请选择删除行!"
			});
		}
		dst.showConfirm('确定删除选中的行？', function(){
			var  idx = $('#'+gridname).datagrid('getRowIndex',node);
			$('#'+gridname).datagrid('deleteRow',idx);
			var nodes  = $('#'+gridname).datagrid('getRows');
			var flag = 0;
			if(nodes&&node){
				for (var i = 0; i < nodes.length; i++) {
					if(nodes[i].org&&node.org){
						if(nodes[i].org.id==node.org.id){
							flag ++;
						}
					}
				}
			}
			if(flag==0){
				var nodes  = $('#unitWeight-entity').datagrid('getRows');
				if(nodes){
					for (var i = 0; i < nodes.length; i++) {
						if(nodes[i].org.id==node.org.id){
							$('#unitWeight-entity').datagrid('deleteRow',i);
						}
					}
				}
			}
		})
	}
});