dst.defineClass("com.dst.slms.proapproval.projectapprove.projectApproveList", dst.framework.coreBillBaseList, {
	initalizeDOM:function(){
		com.dst.slms.proapproval.projectapprove.projectApproveList.superClass.initalizeDOM.call(this);
	},
	clickTreeAction:function(event, treeId, treeNode){
		var _self = this;
		var filter = _self.getDefaultFilterItems();
		var zTree = $.fn.zTree.getZTreeObj("orgTree");       
		var childNodes = zTree.transformToArray(treeNode); 

        var nodes = new Array(); 

        for(i = 0; i < childNodes.length; i++) { 
        	nodes[i] = childNodes[i].value; 
        } 
        filter['selectTreeId']= nodes.join(",");
        $(_self.gridId).datagrid('reload');
	},
	/**
	 * 新增
	 */
	addNewAction: function(event,width,height,tabOpen) {
		var treeObj = $.fn.zTree.getZTreeObj("orgTree");
		var nodes = treeObj.getSelectedNodes();
		if(nodes!=undefined&&nodes.length>0){
			var parentId = nodes[0].parentId;//取对应对象里面的属性值
			if(nodes[0].isParent){
				dst.tip(
						{
							message: "请选择项目新增",code:200
						}); 
			}else{
				var data = this.uiPutContext('addNewAction');
				var id;
				this.createJson(data,'oprtState','ADDNEW');
				var urlparms ={
						url:this.uipk,
						method:'addPage',
						param:{id:encodeURIComponent(nodes[0].value)},
				};
				dst.openBillWindow(this.title,dst.getContextPath()+'/'+dst.getAjaxUrlForParms(urlparms),width,height,this,tabOpen) 
			}
		}else{
			dst.tip(
					{
						message: "请选择项目新增",code:200
					});
		}

	},
	checkisRevise:function(ids){//修订校验
		var _self=this;
		var state=undefined;
		var islatest=undefined;
		var SOURCE=undefined;
		dst.remoteCall({
			method : "checkisRevise",
			async:false,  
			url: _self.uipk,
			param : {id:ids},//放url的才需要编码，例如新增的时候
			success : function(data) {
				if(data.data.length>0){
					state=data.data[0].FSTATE;
					islatest=data.data[0].FISLATEST;
					SOURCE=data.data[0].SOURCE;
				}
			}
		});
		if(islatest!="Y"){
			dst.tip({message:"请选择最新版数据进行修订",code:200});
			return false;
		}
		if(state!="AUDIT"){
			dst.tip({message:"请选择已审批的数据进行修订",code:200});
			return false;
		}
		if(SOURCE=="1"){
			dst.tip({message:"该单据已有修订版数据",code:200});
			return false;
		}
		return true;
	},
	reviseAction:function(){
		var _self=this;
		var ids = this.getSelectedIds('id');
		if(!this.checkSelected()){
			return;
		}
		if(ids!=undefined &&ids!=null&&ids.indexOf(',')>=0){
			dst.tip({
				message: "只能选择一条数据进行修订!",code:200
			});
			return;
		}
		if(!this.checkisRevise(ids)){
			return;
		}
		var b={url:this.uipk,method:"reviseAction",param:{'billId':encodeURIComponent(ids)}};
		dst.openBillWindow(this.title,dst.getContextPath()+'/'+dst.getAjaxUrlForParms(b),'null','null',this,'true')
	},
	toConAction:function(){
		var _self=this;
		var ids = this.getSelectedIds('id');
		if(!this.checkSelected()){
			return;
		}
		if(ids!=undefined &&ids!=null&&ids.indexOf(',')>=0){
			dst.tip({
				message: "只能选择一条数据进行生成合同!",code:200
			});
			return;
		}
		var state=undefined;
		var islatest=undefined;
		var istoContract=undefined;
		var istoCon=undefined;
		dst.remoteCall({
			method : "toConAction",
			async:false,  
			url: _self.uipk,
			param : {id:ids},//放url的才需要编码，例如新增的时候
			success : function(data) {
				if(data.data.length>0){
					state=data.data[0].FSTATE;
					islatest=data.data[0].FISLATEST;
					istoContract=data.data[0].FIstoContract;
					istoCon=data.data[0].istoCon
				}
			}
		});
		if(islatest!="Y"){
			dst.tip({message:"请选择最新版数据生成合同",code:200});
			return;
		}
		if(state!="AUDIT"){
			dst.tip({message:"请选择已审批的数据生成合同",code:200});
			return;
		}
		if(istoContract=="Y"){
			dst.tip({message:"该立项已生成过合同,不能重复生成",code:200});
			return;
		}
		if(istoCon="Y"){
			dst.tip({message:"生成合同成功",code:200});
			return;
		}
	},
	cancelAction:function(){
		var _self=this;
		var ids = this.getSelectedIds('id');
		if(!this.checkSelected()){
			return;
		}
		if(ids!=undefined &&ids!=null&&ids.indexOf(',')>=0){
			dst.tip({
				message: "只能选择一条数据作废!",code:200
			});
			return;
		}
		var SOURCE=undefined;
		var LAST=undefined;
		var TOCON=undefined;
		var CANCEL=undefined;
		dst.remoteCall({
			method : "cancelAction",
			async:false,  
			url: _self.uipk,
			param : {id:ids},//放url的才需要编码，例如新增的时候
			success : function(data) {
				if(data.data.length>0){
					SOURCE=data.data[0].SOURCE;
					LAST=data.data[0].LAST;
					TOCON=data.data[0].TOCON;
					CANCEL=data.data[0].CANCEL;
				}
			}
		});
		if(SOURCE!="0"){
			dst.tip({message:"该立项已生成新版本的立项，不允许作废",code:200});
			return;
		}
		if(LAST!="0"){
			dst.tip({message:"请选择最新版已审批立项单作废",code:200});
			return;
		}
		if(TOCON!="0"){
			dst.tip({message:"该立项已生成合同，不允许作废",code:200});
			return;
		}
		if(CANCEL="Y"){
			dst.tip({message:"作废成功",code:200});
			return;
		}
	},
});