package com.huigou.uasp.builder.jsbutton;

import java.util.ArrayList;
import java.util.List;

import com.huigou.uasp.builder.ButtonTypeInter;
import com.huigou.uasp.builder.vo.ButtonAttributeVO;
import com.huigou.uasp.util.Utils;
import com.huigou.uasp.util.Constant;

public class DisableButtonRowResult implements ButtonTypeInter {
	
	public List<String> processOutResult(StringBuffer sb,ButtonAttributeVO btnAttr){
		List <String> list=new ArrayList<String>();
		 sb.append("//禁用方法 ").append(Constant.SYSMBOL_LINE);
		 sb.append(" function disableRow").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("() {");
		 sb.append("    var row = UICtrl.checkSelectedRows(").append(Utils.toLowerCaseFirstOne(btnAttr.getEntityName())).append("GridManager);");
		 sb.append("    if(row){ ");
		 sb.append("	   if(row.status==0){");
		 sb.append("		 Public.tip(\"").append(btnAttr.getFormName()).append(Constant.DISABLE_TIP).append("\");");
		 sb.append("		 return false;");
		 sb.append("	   }else{");
	     sb.append("		 changeRowStatus(row.id,0);");
		 sb.append("		 Public.successTip(\"").append(btnAttr.getFormName()).append(Constant.DISABLE_SUCCESS).append("\");");
		 sb.append("           reload").append(Utils.toUpperCaseFirstOne(btnAttr.getEntityName())).append("Grid();");
		 sb.append("	   }");
		 sb.append("	}");
		 sb.append("  }");
		 sb.append(" ");
		sb.append(Constant.SYSMBOL_LINE);
	
		  list.add(sb.toString());
		 // list.add(Integer.toString(fieldAttributes.getCurrCols()));
		return list;
	}
}
