diff --git a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java index 11496fb4..31574052 100644 --- a/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java +++ b/src/main/java/com/dreamchaser/depository_manage/controller/MaterialController.java @@ -310,7 +310,7 @@ public class MaterialController { * @return */ @GetMapping("/findMatrialById") - public RestResponse findMatrialById(@RequestParam(value = "mid", required = false) String mid, @RequestParam(value = "type", required = false) String type, HttpServletRequest request) { + public RestResponse findMaterialById(@RequestParam(value = "mid", required = false) String mid, @RequestParam(value = "type", required = false) String type, HttpServletRequest request) { String token = request.getHeader("user-token"); if (token == null) { token = (String) request.getSession().getAttribute("userToken"); @@ -323,9 +323,9 @@ public class MaterialController { Material materialById = materialService.findMaterialById(ObjectFormatUtil.toInteger(mid)); String mcode = materialById.getCode(); - + Inventory inventoryById = null; if ("out".equals(type)) { - Inventory inventoryById = materialService.findInventoryById(ObjectFormatUtil.toInteger(mid)); + inventoryById = materialService.findInventoryById(ObjectFormatUtil.toInteger(mid)); mcode = inventoryById.getCode(); } List placePList = new ArrayList<>(); @@ -350,7 +350,12 @@ public class MaterialController { } tempDepositoryID = (List) CollectionUtils.union(depositoryIdList, tempDepositoryID); List depositoryByIds = depositoryService.findDepositoryByIds(tempDepositoryID); - InventoryP materialP = inventoryPS.get(0); + InventoryP materialP = null; + if (inventoryById != null) { + materialP = new InventoryP(inventoryById); + } else { + materialP = inventoryPS.get(0); + } materialP.setMaterialAndBarCodeList(materialByBarCodeByCondition); List splitInfoByMid = splitUnitService.findSplitInfoByMid(materialP.getMid()); materialP.setSplitInfoList(splitInfoByMid); diff --git a/src/main/resources/templates/pages/application/application-out.html b/src/main/resources/templates/pages/application/application-out.html index 66492234..eed5d779 100644 --- a/src/main/resources/templates/pages/application/application-out.html +++ b/src/main/resources/templates/pages/application/application-out.html @@ -1181,11 +1181,15 @@ } } if (depositoryDisplay !== "none") { + let inventoryInDepositoryId = material.depositoryId; $("#showDepository" + idNumber).empty(); let depositoryList = material.depositoryList; if (depositoryList !== null) { for (let i = 0; i < depositoryList.length; i++) { - $("#showDepository" + idNumber).append(new Option(depositoryList[i].dname, depositoryList[i].id)); + let depositoryListElement = depositoryList[i]; + let defaultSelect = false; + defaultSelect = inventoryInDepositoryId !== null && depositoryListElement.id === inventoryInDepositoryId; + $("#showDepository" + idNumber).append(new Option(depositoryListElement.dname, depositoryListElement.id,defaultSelect,defaultSelect)); } } } diff --git a/src/main/resources/templates/pages/applicationForStorageCenter/application-out.html b/src/main/resources/templates/pages/applicationForStorageCenter/application-out.html index d41499fb..1e0a6766 100644 --- a/src/main/resources/templates/pages/applicationForStorageCenter/application-out.html +++ b/src/main/resources/templates/pages/applicationForStorageCenter/application-out.html @@ -1296,11 +1296,15 @@ } } if (depositoryDisplay !== "none") { + let inventoryInDepositoryId = material.depositoryId; $("#showDepository" + idNumber).empty(); let depositoryList = material.depositoryList; if (depositoryList !== null) { for (let i = 0; i < depositoryList.length; i++) { - $("#showDepository" + idNumber).append(new Option(depositoryList[i].dname, depositoryList[i].id)); + let depositoryListElement = depositoryList[i]; + let defaultSelect = false; + defaultSelect = inventoryInDepositoryId !== null && depositoryListElement.id === inventoryInDepositoryId; + $("#showDepository" + idNumber).append(new Option(depositoryListElement.dname, depositoryListElement.id,defaultSelect,defaultSelect)); } } } diff --git a/src/main/resources/templates/pages/applicationForStorageCenter/application-out_admin.html b/src/main/resources/templates/pages/applicationForStorageCenter/application-out_admin.html index 9181f7cf..f5ff12c4 100644 --- a/src/main/resources/templates/pages/applicationForStorageCenter/application-out_admin.html +++ b/src/main/resources/templates/pages/applicationForStorageCenter/application-out_admin.html @@ -1204,7 +1204,10 @@ let depositoryList = material.depositoryList; if (depositoryList !== null) { for (let i = 0; i < depositoryList.length; i++) { - $("#showDepository" + idNumber).append(new Option(depositoryList[i].dname, depositoryList[i].id)); + let depositoryListElement = depositoryList[i]; + let defaultSelect = false; + defaultSelect = inventoryInDepositoryId !== null && depositoryListElement.id === inventoryInDepositoryId; + $("#showDepository" + idNumber).append(new Option(depositoryListElement.dname, depositoryListElement.id,defaultSelect,defaultSelect)); } } }