From feb85c60c0d59c4a364570bb03fbb37fcba2c5e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AD=A3=E5=9C=A3=E5=8D=8E?= <752718920@qq.com> Date: Sun, 13 Dec 2020 00:16:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=95=86=E5=93=81=E7=9A=84?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- erp_web/pages/materials/material.html | 63 +++++++++++++------ .../pages/template/init_depot_show_list.html | 11 ++++ .../jsh/erp/controller/DepotController.java | 3 + .../jsh/erp/datasource/entities/DepotEx.java | 2 + .../erp/service/material/MaterialService.java | 24 ++++++- 5 files changed, 81 insertions(+), 22 deletions(-) create mode 100644 erp_web/pages/template/init_depot_show_list.html diff --git a/erp_web/pages/materials/material.html b/erp_web/pages/materials/material.html index c4f288da..21c2839a 100644 --- a/erp_web/pages/materials/material.html +++ b/erp_web/pages/materials/material.html @@ -66,9 +66,16 @@
-
-
+
+
+
+
+
+
+
+
' + rec.stock + ''; + str += '' + rec.stock + ''; return str; } }, @@ -518,7 +525,7 @@ //初始化表格数据 function initMaterialDetailData(mId) { $('#materialTableData').datagrid({ - height: 435, + height: heightInfo, nowrap: false, rownumbers: false, //动画效果 @@ -641,8 +648,9 @@ } function findStockList(mId) { - $('#materialDetailListDlg').dialog('open').dialog('setTitle', ' 查看出入库明细'); + $('#materialDetailListDlg').dialog('open').dialog('setTitle', ' 查看库存及明细'); $(".window-mask").css({width: webW, height: webH}); + initDepotList(mId, "show"); //加载仓库及库存数量 initMaterialDetailData(mId); getMaterialInOutList(mId, 1, initPageSize); ininMaterialDetailPager(mId); @@ -988,7 +996,7 @@ oldManyUnit = ""; materialID = 0; url = '/material/add'; - initDepotList(materialID); //加载仓库列表页面 + initDepotList(materialID, "edit"); //加载仓库列表页面 } //商品价格扩展 @@ -1288,10 +1296,10 @@ //选中基本资料tab $("#materialFM #tt .tabs li").first().click(); url = '/material/update?id=' + rowsdata.id; - initDepotList(rowsdata.id); //加载仓库列表页面 + initDepotList(rowsdata.id, "edit"); //加载仓库列表页面 } - function initDepotList(mId) { + function initDepotList(mId, type) { $.ajax({ type: "get", url: "/depot/getAllListWithStock?mId=" + mId, @@ -1301,18 +1309,33 @@ if (res && res.code == 200) { var json = {}; json.depotList = res.data; - $.ajax({ - type: "get", - url: "../../../pages/template/init_depot_list.html?2121", - async: false, - success: function (tem) { - if (tem) { - var template = Handlebars.compile(tem); - var htmlValue = template(json); - $("#initDepot").html(htmlValue); + if(type == "edit"){ + $.ajax({ + type: "get", + url: "../../../pages/template/init_depot_list.html?2121", + async: false, + success: function (tem) { + if (tem) { + var template = Handlebars.compile(tem); + var htmlValue = template(json); + $("#initDepot").html(htmlValue); + } } - } - }); + }); + } else if(type == "show"){ + $.ajax({ + type: "get", + url: "../../../pages/template/init_depot_show_list.html?888", + async: false, + success: function (tem) { + if (tem) { + var template = Handlebars.compile(tem); + var htmlValue = template(json); + $("#initDepotShow").html(htmlValue); + } + } + }); + } } } }); @@ -1585,7 +1608,7 @@ if(!unit) { //此时为多单位 if (meList.length<2){ - $.messager.alert('提示',"多单位商品的条码数量应该大于2!",'warning'); + $.messager.alert('提示',"多单位的商品条码行数至少要有两行,请再新增一行条码信息!",'warning'); return; } } diff --git a/erp_web/pages/template/init_depot_show_list.html b/erp_web/pages/template/init_depot_show_list.html new file mode 100644 index 00000000..debea9f1 --- /dev/null +++ b/erp_web/pages/template/init_depot_show_list.html @@ -0,0 +1,11 @@ + + {{#depotList}} + + + + + + {{/depotList}} +
+

{{name}}

+
初始库存:{{stock}}总计库存:{{allStock}}
\ No newline at end of file diff --git a/src/main/java/com/jsh/erp/controller/DepotController.java b/src/main/java/com/jsh/erp/controller/DepotController.java index 07c239ea..b461b957 100644 --- a/src/main/java/com/jsh/erp/controller/DepotController.java +++ b/src/main/java/com/jsh/erp/controller/DepotController.java @@ -199,9 +199,12 @@ public class DepotController { DepotEx de = new DepotEx(); if(mId!=0) { BigDecimal stock = materialService.getInitStock(mId, depot.getId()); + BigDecimal currentStock = materialService.getCurrentStock(mId, depot.getId()); de.setStock(stock); + de.setAllStock(stock.add(currentStock)); } else { de.setStock(BigDecimal.ZERO); + de.setAllStock(BigDecimal.ZERO); } de.setId(depot.getId()); de.setName(depot.getName()); diff --git a/src/main/java/com/jsh/erp/datasource/entities/DepotEx.java b/src/main/java/com/jsh/erp/datasource/entities/DepotEx.java index 1105c496..2ede10ec 100644 --- a/src/main/java/com/jsh/erp/datasource/entities/DepotEx.java +++ b/src/main/java/com/jsh/erp/datasource/entities/DepotEx.java @@ -17,4 +17,6 @@ public class DepotEx extends Depot{ private BigDecimal stock; + private BigDecimal allStock; + } diff --git a/src/main/java/com/jsh/erp/service/material/MaterialService.java b/src/main/java/com/jsh/erp/service/material/MaterialService.java index 6767e207..7f51c84b 100644 --- a/src/main/java/com/jsh/erp/service/material/MaterialService.java +++ b/src/main/java/com/jsh/erp/service/material/MaterialService.java @@ -60,6 +60,8 @@ public class MaterialService { @Resource private MaterialInitialStockMapper materialInitialStockMapper; @Resource + private MaterialCurrentStockMapper materialCurrentStockMapper; + @Resource private DepotService depotService; @Resource private MaterialExtendService materialExtendService; @@ -704,7 +706,7 @@ public class MaterialService { } /** - * 根据产品和仓库获取初始库存 + * 根据商品和仓库获取初始库存 * @param materialId * @param depotId * @return @@ -722,7 +724,7 @@ public class MaterialService { } /** - * 根据产品获取初始库存 + * 根据商品获取初始库存 * @param materialId * @return */ @@ -747,6 +749,24 @@ public class MaterialService { return stock; } + /** + * 根据商品和仓库获取当前库存 + * @param materialId + * @param depotId + * @return + */ + public BigDecimal getCurrentStock(Long materialId, Long depotId) { + BigDecimal stock = BigDecimal.ZERO; + MaterialCurrentStockExample example = new MaterialCurrentStockExample(); + example.createCriteria().andMaterialIdEqualTo(materialId).andDepotIdEqualTo(depotId) + .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED); + List list = materialCurrentStockMapper.selectByExample(example); + if(list!=null && list.size()>0) { + stock = list.get(0).getCurrentNumber(); + } + return stock; + } + public List getMaterialByMeId(Long meId) { List result = new ArrayList(); try{