action
package gts.erp.action.ajax;
import gts.erp.action.base.ERPProxyAction;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.oletech.triangle.component.DataBean;
import com.oletech.triangle.component.FormBean;
import com.oletech.triangle.component.RowBean;
import com.oletech.triangle.component.TableBean;
import com.oletech.triangle.utils.TriangleDefinition;
/**
* 根据交易账户组Id读取交易帐号
*
*/
public class GetTradingAccountByGroupIdAction extends ERPProxyAction {
@Override
protected ActionForward doExecute(FormBean parameterFB, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
DataBean returnData = this.getERPServiceDelegation().getTradingService().getTradingAccountByGroupId(parameterFB);
TableBean accountTableBean = returnData.getTableBean("TN_GENERIC_ACCOUNT");
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < accountTableBean.size(); i++) {
RowBean rowBean = accountTableBean.get(i);
String primaryId = rowBean.getCellBeanValue(TriangleDefinition.COLUMN_NAME_CN_ID);
String name = rowBean.getCellBeanValue(TriangleDefinition.COLUMN_NAME_CN_NAME);
JSONObject jsonObject = new JSONObject();
jsonObject.put("primaryId", primaryId);
jsonObject.put("name", name);
jsonArray.add(jsonObject);
}
PrintWriter pw = response.getWriter();
pw.print(jsonArray.toString());
pw.flush();
return null;
}
}
js
$(function(){
$("#accountGroupId").change(function(){
$.ajax({
type : "post",
url : contentPath + "/ajax/getTradingAccountByGroupId.do",
data : {
accountGroupId : $(this).val()
},
success : function(data) {
$("#accountId").empty();
for ( var p in data ){
$("#accountId").append("<option value='"+data[p].primaryId+"'>"+data[p].name+"</option>");
}
},
dataType : "json"
});
});
action
package gts.erp.action.ajax;
import gts.erp.action.base.ERPProxyAction;
import java.io.PrintWriter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.oletech.triangle.component.CellBean;
import com.oletech.triangle.component.FormBean;
import com.oletech.triangle.utils.TriangleUIHelper;
/**
*
* 通过工段ID获取部门列表
* @author ole
*
*/
public class GetDepartmentListBySectionIdAction extends ERPProxyAction {
@Override
protected ActionForward doExecute(FormBean parameterFB, ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
FormBean formBean = this.getERPServiceDelegation().getMasterProductionScheduleService().getDepartmentBySection(parameterFB);
JSONArray jsonArray = new JSONArray();
for (int i = 0; i < formBean.size(); i++) {
CellBean cellBean = formBean.get(i);
JSONObject jsonObject = new JSONObject();
jsonObject.put("departmentId", cellBean.getKey());
jsonObject.put("departmentName", TriangleUIHelper.getMessageResources(request, cellBean.getValue()));
jsonArray.add(jsonObject);
}
PrintWriter pw = response.getWriter();
pw.print(jsonArray);
pw.flush();
return null;
}
}
js
/**通过工段ID获取部门列表*/
function getDepartmentListBySectionIdFun(){
var sectionId=$("#sectionId").val();
var defvalue = $("#departmentId").attr("defvalue");
$("#departmentId").empty();
$.ajax({
type : "post",
url : contentPath + "/ajax/getDepartmentListBySectionId.do",
data : {
sectionId : sectionId
},
async : false,
dataType : "json",
success : function(data) {
if (data) {
var arr=eval(data);
for(var i = 0; i < arr.length; i++) {
$("#departmentId").append("<option value = '"+arr[i].departmentId+"'>"+arr[i].departmentName+"</option>");
}
if(defvalue){
$("#departmentId").find("option[value = '"+defvalue+"']").attr("selected","selected");
}
}
}
});
showIePHAndIePersons();
}