公司-->ajax擷取資料

來源:互聯網
上載者:User

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();}


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 {@Overrideprotected 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;}}


impl內容:

/**  * 根據工段查詢部門   * @author zhuyz  * @date 2016年11月19日17:45:16 * @param dataBean * FormBean => key : "parameterFB" *           CellBean key : sectionId * @return FormBean * FormBean Key: errorMsg *  TableBean => key : "TN_DEPARTMENT" *                CellBean key : CN_ID,CN_NAME.......... *              TableBean => key : "TN_DEPARTMENT_IESETUP" *                     CellBean key :  CN_ID,CR_DEPARTMENT_ID......                     */public FormBean getDepartmentBySection(FormBean formBean) {String sectionId = formBean.getCellBeanValue("sectionId");FormBean returnFB = new FormBean();try {if (StringUtils.isNotEmpty(sectionId)) {CondSetBean csb = new CondSetBeanJustAnd();csb.addCondBean(new CondBeanEqual("CR_SECTION_ID", sectionId));TableBean tableBean = this.baseDAO.queryForTableBean(new ClassPOJO("TN_DEPARTMENT_IESETUP"), csb);CondSetBean csbDepartment = new CondSetBeanJustAnd();CondBeanIn cbiDepartment = new CondBeanIn(TriangleDefinition.COLUMN_NAME_CN_ID);for (int i = 0; i < tableBean.size(); i++) {cbiDepartment.addValue(tableBean.get(i).getCellBeanValue("CR_DEPARTMENT_ID"));}if (cbiDepartment.size() > 0) {csbDepartment.addCondBean(cbiDepartment);TableBean departmentTB = this.baseDAO.queryForTableBean(new ClassPOJO("TN_DEPARTMENT"), csbDepartment);for (int i = 0; i < departmentTB.size(); i++) {RowBean rowBean = departmentTB.get(i);returnFB.addCellBean(new CellBean(rowBean.getCellBeanValue(TriangleDefinition.COLUMN_NAME_CN_ID), rowBean.getCellBeanValue(TriangleDefinition.COLUMN_NAME_CN_NAME)));}}}} catch (Exception e) {TriangleBLHelper.printExceptionLog(log, e);e.printStackTrace();throw new RuntimeException("**** Run time Exception。****");}return returnFB;}


相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.