今天学习了修改前端代码,修复了很多东西,比如说修复了修改的回显以及弹出多选选择框修改成单选选择框,修改好修改没有回显的办法,然后我认为,修改sql语句的方法,
修改后的代码
package com.more.mes.wms.outmaterielinfo.func;import javax.servlet.http.HttpServletRequest;import com.more.fw.core.base.core.action.ModelAction;
import com.more.fw.core.common.exception.BussException;
import com.more.fw.core.common.method.CommMethod;
import com.more.fw.core.common.method.ConstantsMc;
import com.more.fw.core.common.method.StringUtils;
import com.more.fw.core.dbo.model.service.ModelService;
import com.more.fw.core.dbo.model.service.impl.base.FuncService;
import com.more.mes.base.item.BussItem;
import com.more.mes.wms.outmaterielinfo.BussOutMateriel;
import com.more.mes.wms.outstock.BussOutStock;
import com.more.mes.wms.outstock.model.OutStockDoc;
import com.more.mes.wms.outstock.model.OutStockItem;
import com.more.util.log.BussLogger;/*** @Title 生产领料-修改* @Description 生产领料-修改* @ClassName EditOutMaterielInfo* @Author wzy* @ChangeLog: 2019-4-5 wzy 创建类 2020-6-23 wzy 新增重复提交表单校验 修改了throw new 方法,将报错提示返回*/
public class EditOutMaterielInfo implements FuncService {@Overridepublic String exeFunc(ModelAction modelAction, ModelService modelService) {// TODO Auto-generated method stubHttpServletRequest request = modelAction.getRequest();String dataAuth = String.valueOf(modelAction.getRequest().getSession().getAttribute("mcDataAuth"));String formId = request.getParameter("formId");if (StringUtils.isBlank(formId)) {formId = request.getParameter("formIds");}String iframeId = request.getParameter("iframeId");try {if (!CommMethod.isRepeatSubmit(request)) {CommMethod.rmSessionMap(modelAction.getSession(), ConstantsMc.FORM_TOKEN);} else {return modelAction.alertParentInfo(modelAction.getText("请不要重复提交表单!"));}// 生产领料String dispatchSn = request.getParameter("paraMapObj.DISPATCH_SN");// 收发类型String planOutstockDate = request.getParameter("paraMapObj.PLAN_OUTSTOCK_DATE");// 计划出库日期String areaSn = request.getParameter("paraMapObj.AREA_SN");// 生产车间String pickDocType = request.getParameter("paraMapObj.PICK_DOC_TYPE");// 备料类型String pickDocAttr = request.getParameter("paraMapObj.PICK_DOC_ATTR");// 领料单属性String isUrgent = request.getParameter("paraMapObj.IS_URGENT");// 是否加急String isRelease = request.getParameter("paraMapObj.IS_RELEASE");// 是否放行String memo = request.getParameter("paraMapObj.MEMO");// 备注String docStatus = request.getParameter("paraMapObj.DOC_STATUS");// 单据状态String custCode = request.getParameter("paraMapObj.CUST_CODE");// 客户编码String id = modelAction.getDataId();String docNo = request.getParameter("docNo");// 单号if (StringUtils.isBlank(isUrgent)) {isUrgent = "N";}if (StringUtils.isBlank(isRelease)) {isRelease = "N";}// 生产领料明细String delItemId = request.getParameter("delItemId");// 删除String[] itemSeq = request.getParameterValues("ITEM_SEQ");// 项次String[] itemCode = request.getParameterValues("ITEM_CODE");// 物料料号String[] connectDoc = request.getParameterValues("CONNECT_DOC");// 制令单String[] subType = request.getParameterValues("SUB_TYPE");// 属性管控类型String[] controlValue = request.getParameterValues("CONTROL_VALUE");// 属性管控值String[] memos = request.getParameterValues("MEMO");// 备注String[] status = request.getParameterValues("STATUS");// 备注String[] type = request.getParameterValues("TYPE");// 备注String[] itemCodeId = request.getParameterValues("ITEMCODE_ID");// 获取原有的物料String[] importType = request.getParameterValues("importType");// 判断物料类型 1.存在的料号,2.导入的料号String[] units = request.getParameterValues("SUB_UNIT");// 计量单位组if (StringUtils.isNotBlank(delItemId)) {String[] itemId = delItemId.split(",");for (int i = 0; i < itemId.length; i++) {BussOutMateriel.delOtherDetailInfo(itemId[i], dataAuth, modelAction);}}OutStockDoc doc = new OutStockDoc();doc.setId(id);doc.setDocNo(docNo);doc.setDispatchSn(dispatchSn);doc.setPickDocType(pickDocType);doc.setDocType("DJ11");doc.setUserId(modelAction.getUser().getId());doc.setUserName(modelAction.getUser().getName());BussOutMateriel.editOtherOutStockInfo(doc);OutStockItem item = new OutStockItem();for (int i = 0; i < itemSeq.length; i++) {if (importType[i].equals("2")) {int count = BussItem.getItemCode(itemCode[i], dataAuth);if (count <= 0) {CommMethod.setFormTokenToSession(request);return modelAction.alertParentInfo(modelAction.getText("物料料号不存在"));}}item.setItemSeq(StringUtils.toInteger(itemSeq[i]));item.setItemCode(itemCode[i]);item.setConnectDoc(connectDoc[i]);item.setSingleQty(StringUtils.toDouble(singleQty[i]));item.setRequestQty(StringUtils.toDouble(planNum[i]));item.setPlanQty(StringUtils.toDouble(planNum[i]));item.setWhCode(whCode[i]);item.setControlType(subType[i]);item.setUgDetaiId(units[i]);item.setUserId(modelAction.getUser().getId());item.setUserName(modelAction.getUser().getName());if (type[i].endsWith("1")) {item.setId(itemCodeId[i]);BussOutMateriel.editOtherOutStockItem(item);} else {item.setId(StringUtils.getUUID());BussOutStock.saveOtherOutStockItem(item);}}} catch (Exception e) {// TODO: handle exceptionCommMethod.setFormTokenToSession(request);BussLogger.productError(this.getClass(), e);throw new BussException(modelAction.getText("修改失败"), e);}return modelAction.reloadIframeByIds(iframeId, modelAction.getText("修改成功"), "0");}}
了解到Java代码上的bussOutMateriel的类,里面有很多关于赋值的代码,他们能够很好很方便的帮助开发人员制作代码,修改页面应该要去关注他的id以及代码的制作方式以及理解方式
然后是制作回调函数和sql语句的 书写,回调函数就是将修改后的代码回显到主视图上代码如下:
function setTestInfo(MKEY,val,obj){if(null!=obj){ console.log(MKEY);console.log(val);console.log(obj);console.log(obj.eq(4).text());$("#paraMapObj_ITEM_NAME").val(obj.eq(4).text());$("#paraMapObj_ITEM_CODE").val(obj.eq(3).text());$("#paraMapObj_ITEM_CODE_SHOW").val(obj.eq(2).text());$("#paraMapObj_ITEM_SPEC").val(obj.eq(5).text());$("#paraMapObj_MEMO").val(obj.eq(6).text());//$("#paraMapObj_DOC_NO").val(MKEY);}
}
然后就是sql语句的书写
select ITEM_CODE MKEY,ITEM_CODE VAL,ITEM_NAME,ITEM_SPEC,MEMO from t_co_item
最后就是前端代码的书写
<%-- 平台公用头文件 --%>
<%@page language="java" errorPage="/plf/error.jsp" pageEncoding="UTF-8" contentType="text/html;charset=UTF-8"%>
<%@ include file="/plf/common/pub_tag.jsp"%>
<%@page import="com.more.fw.core.staticresource.PlfStaticRes"%>
<%-- 扩展修改页面开头位置,页面加载前 --%>
<jsp:include page="/plf/page/mesdemo/commCode/commCode.jsp"><jsp:param name="modelName" value="VIEW_TYPE_11" /><jsp:param name="location" value="beforePageLoad" />
</jsp:include>
<head><%-- 平台公用meta --%><%@ include file="/plf/common/pub_meta.jsp"%><title><dict:lang value="修改" /></title><%-- 平台公用head,包括公用IMG、CSS、JS资源文件 --%><jsp:include page="/plf/common/fp/pub_head_fp.jsp"><jsp:param name="popDivWinFp" value="1" /><jsp:param name="datePicker" value="1" /><jsp:param name="chosen" value="1" /></jsp:include><%-- 公用新增JS页面 --%><%@ include file="/plf/page/common/buss/addCommJs.jsp"%><%-- 公用列表JS页面 --%><%@ include file="/plf/page/common/buss/bussCommJs.jsp"%><%-- 动态加载js文件方法 --%><script type = "text/javascript" src = "${path}plf/js/ui/include.js?_mc_res_version=<%=PlfStaticRes.PlfJsUi_Include_js %>"></script><%-- 在head里面要插入平台的代码 --%><jsp:include page="/plf/page/mesdemo/commCode/commCode.jsp"><jsp:param name="modelName" value="VIEW_TYPE_11" /><jsp:param name="location" value="inHead" /></jsp:include><%-- 产品静态资源 --%><%@ include file="/buss/reso/product/commcode/page/comm-page.jsp"%></head>
<body style="overflow:auto;"><div class="edit"><form id="editForm" name="editForm" action="${path}buss/bussModel_editAjaxComm.ms" method="post" target="submitFrame"<bu:formet exeid="%{exeid}" />><div class="hd"><div style="margin-left:40px;"><s:if test="${isDataAuth == '1'}"><span class="dot">*</span><dict:lang value="组织机构" /><s:if test="${fn:length(deptLs)==1}"><s:select list="deptLs" listKey="id" listValue="name" name="paraMapObj._DATA_AUTH" id="deptLs_data_auth" cssStyle="width: 200px;" cssClass="_VAL_NULL dept_select"/> </s:if><s:else><s:select list="deptLs" headerKey="" headerValue='--%{getText("请选择")}--'listKey="id" listValue="name" name="paraMapObj._DATA_AUTH"id="deptLs_data_auth" cssStyle="width: 200px;" cssClass="_VAL_NULL dept_select"/> </s:else></s:if> </div><div class="optn"><button type="button" onclick="editCal();"><i class="ico ico-save"></i><dict:lang value="保存" /></button><button type="button" onclick="closeWindow();" ><i class="ico ico-cancel"></i><dict:lang value="取消" /></button><button type="button" onclick="resetForm();" ><i class="ico ico-gk"></i><dict:lang value="重置" /></button></div></div><div class="bd"><%-- 视图修改页面平台默认数据区域,如视图ID、表单ID、token --%><jsp:include page="/plf/page/mesdemo/commCode/commCode.jsp"><jsp:param name="modelName" value="VIEW_TYPE_11" /><jsp:param name="location" value="editForm" /></jsp:include><bu:set name="paraMapObj" value="${dataId}" formId="80e7dbef360c407d8c7c81dbf6cbed37" type="edit" /><table class="basic-table" ><input type="hidden" name="formIds" value="80e7dbef360c407d8c7c81dbf6cbed37" /><input type="hidden" id="prefixInd" name="80e7dbef360c407d8c7c81dbf6cbed37" value="paraMap1@" /><input type="hidden" name="paraMap1@__LEVEL__" value="1" /><input type="hidden" name="paraMap1@__DATA_COUNT__" value="1" /><s:set name="_$viewId" value="'0898a7b11fc144829e27068d70d0512f'" /><s:set name="_$formId_1" value="'80e7dbef360c407d8c7c81dbf6cbed37'" /><s:set name="_$type" value="'edit'"/><tr><td class="name-six" /><bu:uitn colNo="DOC_NO" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="DOC_NO" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="DOC_NO" formId="80e7dbef360c407d8c7c81dbf6cbed37" dataId="${dataId}" formIndex="1" /></bu:td><td class="name-six" /><bu:uitn colNo="ITEM_NAME" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="ITEM_NAME" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="ITEM_NAME" formId="80e7dbef360c407d8c7c81dbf6cbed37" dataId="${dataId}" formIndex="1" /></bu:td><td class="name-six" /><bu:uitn colNo="ITEM_CODE" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="ITEM_NAME" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="ITEM_CODE" formId="80e7dbef360c407d8c7c81dbf6cbed37" dataId="${dataId}" formIndex="1" /></bu:td></tr><tr><!-- bug: 17344 新增字段--> <td class="name-six" /><bu:uitn colNo="ITEM_SPEC" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="ITEM_SPEC" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="ITEM_SPEC" formId="87edd1849aec473399dc39d523513233" dataId="${dataId}" formIndex="1" /></bu:td><td class="name-six" /><bu:uitn colNo="PLAN_QTY" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="PLAN_QTY" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="PLAN_QTY" formId="87edd1849aec473399dc39d523513233" dataId="${dataId}" formIndex="1" /></bu:td><td class="name-six" /><bu:uitn colNo="MEMO" formId="80e7dbef360c407d8c7c81dbf6cbed37" /></td><bu:td cssClass="dec-self" colNo="MEMO" formId="80e7dbef360c407d8c7c81dbf6cbed37" ><bu:ui colNo="MEMO" formId="80e7dbef360c407d8c7c81dbf6cbed37" dataId="${dataId}" formIndex="1" /></bu:td></tr></table><!--<div id="retract" class="retract" name="retract">--></div> <bu:jsVal formId="80e7dbef360c407d8c7c81dbf6cbed37" formIndex="1" /></div></form> </div><div style="display: none;"><iframe id="submitFrame" name="submitFrame" src="" width="0" height="0"></iframe></div><%-- 平台预留在JS加载前执行的代码片段 --%><jsp:include page="/plf/page/mesdemo/commCode/commCode.jsp"><jsp:param name="modelName" value="VIEW_TYPE_11" /><jsp:param name="location" value="jsLoading" /></jsp:include><%-- 表单结束区域 --%><jsp:include page="/plf/common/fp/pub_dom_fp.jsp"><jsp:param name="popConfirm" value="1" /><jsp:param name="needValidate" value="1" /></jsp:include><script type="text/javascript">var wmsOption;var whList;var controlList;var controlTypeOption;var rawMaterial;var rawMaterialList;/*** 初始化属性管控类型和仓库下拉数据* @method getSelectOption* @param itemAttrName 物料类型* @author zf* @changelog 修改人:ZF 物料类型参数来显示产品与原料的的属性类型*/
//function getSelectOption(itemAttr){function getSelectOption(){var getWmsSelUrl="${path}buss/bussModel_exeFunc.ms?funcMId=545e928cea0542a6a93dea66a0fc608b";//VM-其它出库管理-新增 操作功能 加载仓库信息$.ajax({type: "POST",dataType: "json",url: getWmsSelUrl,//关闭异步//async: false,data: {"badFlag":"",//"itemAttr": itemAttr},success: function(data){if(null == data){return ;}if(null != data.ajaxMap.whList){wmsOption = "<option value=''>--请选择--</option>";whList = eval(data.ajaxMap.whList);for(var i = 0;i < whList.length; i++){wmsOption = wmsOption + "<option value='"+whList[i].AREA_SN+"'>"+whList[i].AREA_NAME+"</option>";}}if(null != data.ajaxMap.controlList){controlTypeOption="<option value=''>--请选择--</option>";controlList = eval(data.ajaxMap.controlList);for(var i = 0;i < controlList.length; i++){controlTypeOption = controlTypeOption + "<option value='"+controlList[i].CODE+"'>"+controlList[i].VALUE+"</option>";}}if(null != data.ajaxMap.rawMaterial){rawMaterialList="<option value=''>--请选择--</option>";rawMaterial= eval(data.ajaxMap.rawMaterial);for(var i = 0;i < rawMaterial.length; i++){rawMaterialList = rawMaterialList + "<option value='"+rawMaterial[i].CODE+"'>"+rawMaterial[i].VALUE+"</option>";}}/*if(null != data.ajaxMap.unitGroupList){unitgroupOption = "<option value=''>--请选择--</option>";var rccList = eval(data.ajaxMap.unitGroupList);for(var i = 0;i < rccList.length; i++){unitgroupOption = unitgroupOption + "<option value='"+rccList[i].ID+"'>"+rccList[i].UNIT_GROUP+"</option>";}}*/},error: function(msg){util.closeLoading();_TOOL_PRO.showAjaxErrorMsg(msg);}});}//删除行
var delItemId="";
function editCal(){if(!val.valNullData()){return ;}if(!valData()){return ;}if(!val.valOjbsData()){return ;}if(!val.valDataBaseSetData()){return ;}if($("#isCloseWin") && $("#addForm").find("#isCloseWin").length == 0){$("#addForm").append($("#isCloseWin").clone());$("#addForm").find("#isCloseWin").wrap("<div id=\"isCloseWinDiv\" style=\"display:none;\"></div>");}emptyValToHide('N');$("#datagrid-btable-ajax4f273d714d9544149f34e2d6d7ff1234").find("input").removeAttr("disabled");$("#datagrid-btable-ajax4f273d714d9544149f34e2d6d7ff1234").find("select").removeAttr("disabled");$(".basic-table").find("input").removeAttr("disabled");$(".basic-table").find("select").removeAttr("disabled");$(".basic-table").find("input:checkbox").removeAttr("disabled");$("#saveBtn").prop("disabled","disabled");var docNo = $("#paraMapObj_DOC_NO").val();document.forms.editForm.action = "${path}buss/bussModel_exeFunc.ms?funcMId=ae17bf913f35495db34f3ae1dd2c2e19&docNo="+docNo;document.forms.editForm.submit();isQuery = true;}//初始化时间$(function(){// $("#paraMapObj_PLAN_QTY").find("input").removeAttr("disabled");$("#paraMapObj_PLAN_QTY").prop("disabled", false);$("#paraMapObj_ITEM_SPEC").prop("disabled", false);})</script> <script>(function($){$(window).on('load',function(){setPopScroll('.scroll1','.head1');setPopScroll('.scroll3');})
})(jQuery)</script>
</body>
<%-- 平台公用的底部代码区域 --%>
<%@ include file="/plf/common/pub_end.jsp"%>
<%-- 页面结束 --%>
<jsp:include page="/plf/page/mesdemo/commCode/commCode.jsp"><jsp:param name="modelName" value="VIEW_TYPE_11" /><jsp:param name="location" value="pageOver" />
</jsp:include>