Commit 0ee2afca9952e1eb9d3c38b5e13713f3210c51c8
1 parent
771655e0
出入库新增明细添加物料根据code、name模糊匹配
Showing
3 changed files
with
153 additions
and
95 deletions
src/main/java/com/huaheng/pc/config/material/controller/MaterialController.java
... | ... | @@ -35,7 +35,9 @@ import org.springframework.web.multipart.MultipartFile; |
35 | 35 | |
36 | 36 | import javax.annotation.Resource; |
37 | 37 | import java.util.ArrayList; |
38 | +import java.util.HashMap; | |
38 | 39 | import java.util.List; |
40 | +import java.util.Map; | |
39 | 41 | |
40 | 42 | @Api(tags={"物料控制类"}) |
41 | 43 | @Controller |
... | ... | @@ -201,4 +203,28 @@ public class MaterialController extends BaseController { |
201 | 203 | } |
202 | 204 | return prefix + "/print"; |
203 | 205 | } |
206 | + | |
207 | + @PostMapping("/getData") | |
208 | + @ResponseBody | |
209 | + public Map<String, Object> getData(String materialName, String materialCode) { | |
210 | + LambdaQueryWrapper<Material> queryWrapper = Wrappers.lambdaQuery(); | |
211 | + queryWrapper.like(StringUtils.isNotEmpty(materialName), Material::getCode, materialName) | |
212 | + .or() | |
213 | + .like(StringUtils.isNotEmpty(materialName), Material::getName, materialName); | |
214 | + List<Material> materialList = materialService.list(queryWrapper); | |
215 | + | |
216 | + List<Map<String, Object>> list = new ArrayList<>(); | |
217 | + for (Material material : materialList) { | |
218 | + Map<String, Object> resultMap = new HashMap<>(); | |
219 | + if (StringUtils.isNotEmpty(materialCode) && material.getCode().equals(materialCode)) { | |
220 | + resultMap.put("selected", true); | |
221 | + } | |
222 | + resultMap.put("id", material.getCode()); | |
223 | + resultMap.put("text", material.getName()); | |
224 | + list.add(resultMap); | |
225 | + } | |
226 | + Map<String, Object> map = new HashMap<>(); | |
227 | + map.put("results", list); | |
228 | + return map; | |
229 | + } | |
204 | 230 | } |
... | ... |
src/main/resources/templates/receipt/receiptDetail/add.html
... | ... | @@ -24,7 +24,8 @@ |
24 | 24 | <div class="form-group"> |
25 | 25 | <label class="col-sm-3 control-label">物料编码:</label> |
26 | 26 | <div class="col-sm-8"> |
27 | - <input id="materialCode" name="materialCode" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
27 | + <select id="materialCode" name="materialCode" class="form-control"></select> | |
28 | +<!-- <input id="materialCode" name="materialCode" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')">--> | |
28 | 29 | </div> |
29 | 30 | </div> |
30 | 31 | <div class="form-group"> |
... | ... | @@ -175,7 +176,7 @@ |
175 | 176 | "companyCode": $("input[name='companyCode']").val(), |
176 | 177 | "sourceLine": $("input[name='sourceLine']").val(), |
177 | 178 | // "materialId": $("input[name='materialId']").val(), |
178 | - "materialCode": $("input[name='materialCode']").val(), | |
179 | + "materialCode": $("#materialCode").val(), | |
179 | 180 | "batch": $("input[name='batch']").val(), |
180 | 181 | "lot": $("input[name='lot']").val(), |
181 | 182 | "projectNo": $("input[name='projectNo']").val(), |
... | ... | @@ -217,6 +218,19 @@ |
217 | 218 | laydate.render({ elem: '#manufactureDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' }); |
218 | 219 | laydate.render({ elem: '#expirationDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' }); |
219 | 220 | }); |
221 | + $('#materialCode').select2({ | |
222 | + ajax: { | |
223 | + url: ctx+'config/material/getData', | |
224 | + dataType: 'json', | |
225 | + type: 'post', | |
226 | + data: function (params) { | |
227 | + let query = { | |
228 | + materialName: params.term, | |
229 | + } | |
230 | + return query; | |
231 | + } | |
232 | + } | |
233 | + }); | |
220 | 234 | }); |
221 | 235 | |
222 | 236 | </script> |
... | ... |
src/main/resources/templates/shipment/shipmentDetail/add.html
1 | 1 | <!DOCTYPE HTML> |
2 | 2 | <html lang="zh" xmlns:th="http://www.thymeleaf.org"> |
3 | 3 | <meta charset="utf-8"> |
4 | -<head th:include="include :: header"></head> | |
4 | +<head> | |
5 | + <th:block th:include="include :: header" /> | |
6 | + <th:block th:include="include :: select2-css" /> | |
7 | +</head> | |
5 | 8 | <body class="white-bg"> |
6 | 9 | <div class="wrapper wrapper-content animated fadeInRight ibox-content"> |
7 | - <form class="form-horizontal m" id="form-shipmentDetail-add"> | |
8 | - <div class="form-group"> | |
9 | - <label class="col-sm-3 control-label">出库单id:</label> | |
10 | - <div class="col-sm-8"> | |
11 | - <input id="shipmentId" name="shipmentId" class="form-control" type="text" th:value="${shipmentId}" readonly="readonly"> | |
12 | - <input id="companyId" name="companyId" type="hidden" th:value="${companyId}" > | |
13 | - <input id="companyCode" name="companyCode" type="hidden" th:value="${companyCode}" > | |
14 | - </div> | |
10 | + <form class="form-horizontal m" id="form-receiptDetail-add"> | |
11 | + | |
12 | + <div class="form-group"> | |
13 | + <label class="col-sm-3 control-label">出库单id:</label> | |
14 | + <div class="col-sm-8"> | |
15 | + <input id="shipmentId" name="shipmentId" class="form-control" type="text" th:value="${shipmentId}" readonly="readonly"> | |
16 | + <input id="companyId" name="companyId" type="hidden" th:value="${companyId}" > | |
17 | + <input id="companyCode" name="companyCode" type="hidden" th:value="${companyCode}" > | |
15 | 18 | </div> |
16 | - <div class="form-group"> | |
17 | - <label class="col-sm-3 control-label">出库单编码:</label> | |
18 | - <div class="col-sm-8"> | |
19 | - <input id="shipmentCode" name="shipmentCode" class="form-control" type="text" th:value="${shipmentCode}" readonly="readonly"> | |
20 | - </div> | |
19 | + </div> | |
20 | + <div class="form-group"> | |
21 | + <label class="col-sm-3 control-label">出库单编码:</label> | |
22 | + <div class="col-sm-8"> | |
23 | + | |
24 | + <input id="shipmentCode" name="shipmentCode" class="form-control" type="text" th:value="${shipmentCode}" readonly="readonly"> | |
21 | 25 | </div> |
22 | - <div class="form-group"> | |
23 | - <label class="col-sm-3 control-label">物料编码:</label> | |
24 | - <div class="col-sm-8"> | |
25 | - <input id="materialCode" name="materialCode" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
26 | - </div> | |
26 | + </div> | |
27 | + <div class="form-group"> | |
28 | + <label class="col-sm-3 control-label">物料编码:</label> | |
29 | + <div class="col-sm-8"> | |
30 | + <select id="materialCode" name="materialCode" class="form-control"></select> | |
31 | + <!-- <input id="materialCode" name="materialCode" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')">--> | |
27 | 32 | </div> |
28 | - <div class="form-group"> | |
29 | - <label class="col-sm-3 control-label">库存状态:</label> | |
30 | - <div class="col-sm-8"> | |
31 | - <select id="inventoryStatus" class="form-control" th:with="inventoryStatus=${@dict.getType('inventorySts')}"> | |
32 | - <option th:each="dict : ${inventoryStatus}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option> | |
33 | - </select> | |
34 | - </div> | |
33 | + </div> | |
34 | + <div class="form-group"> | |
35 | + <label class="col-sm-3 control-label">库存状态:</label> | |
36 | + <div class="col-sm-8"> | |
37 | + <select id="inventoryStatus" class="form-control" th:with="inventoryStatus=${@dict.getType('inventorySts')}"> | |
38 | + <option th:each="dict : ${inventoryStatus}" th:text="${dict['dictLabel']}" th:value="${dict['dictValue']}"></option> | |
39 | + </select> | |
35 | 40 | </div> |
36 | - <div class="form-group"> | |
37 | - <label class="col-sm-3 control-label">发货数量:</label> | |
38 | - <div class="col-sm-8"> | |
39 | - <input id="shipQty" name="shipQty" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
40 | - </div> | |
41 | + </div> | |
42 | + <div class="form-group"> | |
43 | + <label class="col-sm-3 control-label">发货数量:</label> | |
44 | + <div class="col-sm-8"> | |
45 | + <input id="shipQty" name="shipQty" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
41 | 46 | </div> |
42 | - <div class="form-group"> | |
43 | - <label class="col-sm-3 control-label">批次:</label> | |
44 | - <div class="col-sm-8"> | |
45 | - <input id="batch" name="batch" class="form-control" type="text"> | |
46 | - </div> | |
47 | + </div> | |
48 | + <div class="form-group"> | |
49 | + <label class="col-sm-3 control-label">批次:</label> | |
50 | + <div class="col-sm-8"> | |
51 | + <input id="batch" name="batch" class="form-control" type="text"> | |
47 | 52 | </div> |
48 | - <div class="form-group"> | |
49 | - <label class="col-sm-3 control-label">批号:</label> | |
50 | - <div class="col-sm-8"> | |
51 | - <input id="lot" name="lot" class="form-control" type="text"> | |
52 | - </div> | |
53 | + </div> | |
54 | + <div class="form-group"> | |
55 | + <label class="col-sm-3 control-label">批号:</label> | |
56 | + <div class="col-sm-8"> | |
57 | + <input id="lot" name="lot" class="form-control" type="text"> | |
53 | 58 | </div> |
54 | - <div class="form-group"> | |
55 | - <label class="col-sm-3 control-label">项目号:</label> | |
56 | - <div class="col-sm-8"> | |
57 | - <input id="projectNo" name="project" class="form-control" type="text"> | |
58 | - </div> | |
59 | + </div> | |
60 | + <div class="form-group"> | |
61 | + <label class="col-sm-3 control-label">项目号:</label> | |
62 | + <div class="col-sm-8"> | |
63 | + <input id="projectNo" name="project" class="form-control" type="text"> | |
59 | 64 | </div> |
60 | - <div class="form-group"> | |
61 | - <label class="col-sm-3 control-label">上游系统行号:</label> | |
62 | - <div class="col-sm-8"> | |
63 | - <input id="referLineNum" name="referLineNum" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
64 | - </div> | |
65 | + </div> | |
66 | + <div class="form-group"> | |
67 | + <label class="col-sm-3 control-label">上游系统行号:</label> | |
68 | + <div class="col-sm-8"> | |
69 | + <input id="referLineNum" name="referLineNum" class="form-control" type="text" onkeyup=" this.value=this.value.replace(/^\s+|\s+$/g,'')"> | |
65 | 70 | </div> |
66 | - <div class="form-group"> | |
67 | - <label class="col-sm-3 control-label">分配规则:</label> | |
68 | - <div class="col-sm-8"> | |
69 | - <select id="allocationRule" class="form-control" th:with="allocationRule=${@FilterConfigDetailService.queryFilterConfigDetail('allocationRule')}"> | |
70 | - <option value=" " checked></option> | |
71 | - <option th:each="allocationRules:${allocationRule}" th:text="${allocationRules['description']}" th:value="${allocationRules['code']}"></option> | |
72 | - </select> | |
73 | - </div> | |
71 | + </div> | |
72 | + <div class="form-group"> | |
73 | + <label class="col-sm-3 control-label">分配规则:</label> | |
74 | + <div class="col-sm-8"> | |
75 | + <select id="allocationRule" class="form-control" th:with="allocationRule=${@FilterConfigDetailService.queryFilterConfigDetail('allocationRule')}"> | |
76 | + <option value=" " checked></option> | |
77 | + <option th:each="allocationRules:${allocationRule}" th:text="${allocationRules['description']}" th:value="${allocationRules['code']}"></option> | |
78 | + </select> | |
74 | 79 | </div> |
75 | - <!--<div class="form-group">--> | |
76 | - <!--<label class="col-sm-3 control-label">分配规则:</label>--> | |
77 | - <!--<div class="col-sm-8">--> | |
78 | - <!--<input id="allocationRule" name="allocationRule" class="form-control" type="text">--> | |
79 | - <!--</div>--> | |
80 | - <!--</div>--> | |
81 | - <div class="form-group"> | |
82 | - <label class="col-sm-3 control-label">补货规则:</label> | |
83 | - <div class="col-sm-8"> | |
84 | - <input id="replenishmentRule" name="replenishmentRule" class="form-control" type="text"> | |
85 | - </div> | |
80 | + </div> | |
81 | + <!--<div class="form-group">--> | |
82 | + <!--<label class="col-sm-3 control-label">分配规则:</label>--> | |
83 | + <!--<div class="col-sm-8">--> | |
84 | + <!--<input id="allocationRule" name="allocationRule" class="form-control" type="text">--> | |
85 | + <!--</div>--> | |
86 | + <!--</div>--> | |
87 | + <div class="form-group"> | |
88 | + <label class="col-sm-3 control-label">补货规则:</label> | |
89 | + <div class="col-sm-8"> | |
90 | + <input id="replenishmentRule" name="replenishmentRule" class="form-control" type="text"> | |
86 | 91 | </div> |
87 | - <div class="form-group"> | |
88 | - <label class="col-sm-3 control-label">拣货规则:</label> | |
89 | - <div class="col-sm-8"> | |
90 | - <select id="pickingRule" class="form-control" th:with="pickingRule=${@FilterConfigDetailService.queryFilterConfigDetail('shipmentPickingRule')}"> | |
91 | - <option value=" " checked></option> | |
92 | - <option th:each="pickingRules:${pickingRule}" th:text="${pickingRules['description']}" th:value="${pickingRules['code']}"></option> | |
93 | - </select> | |
94 | - </div> | |
92 | + </div> | |
93 | + <div class="form-group"> | |
94 | + <label class="col-sm-3 control-label">拣货规则:</label> | |
95 | + <div class="col-sm-8"> | |
96 | + <select id="pickingRule" class="form-control" th:with="pickingRule=${@FilterConfigDetailService.queryFilterConfigDetail('shipmentPickingRule')}"> | |
97 | + <option value=" " checked></option> | |
98 | + <option th:each="pickingRules:${pickingRule}" th:text="${pickingRules['description']}" th:value="${pickingRules['code']}"></option> | |
99 | + </select> | |
95 | 100 | </div> |
96 | - <div class="form-group"> | |
97 | - <div class="form-group"> | |
98 | - <label class="col-sm-3 control-label">生产日期:</label> | |
99 | - <div class="col-sm-8"> | |
100 | - <input id="manufactureDate" name="manufactureDate" class="form-control" type="text"> | |
101 | - </div> | |
101 | + </div> | |
102 | + <div class="form-group"> | |
103 | + <label class="col-sm-3 control-label">生产日期:</label> | |
104 | + <div class="col-sm-8"> | |
105 | + <input id="manufactureDate" name="manufactureDate" class="form-control" type="text"> | |
102 | 106 | </div> |
103 | - <div class="form-group"> | |
104 | - <label class="col-sm-3 control-label">失效日期:</label> | |
105 | - <div class="col-sm-8"> | |
106 | - <input id="expirationDate" name="expirationDate" class="form-control" type="text"> | |
107 | - </div> | |
107 | + </div> | |
108 | + <div class="form-group"> | |
109 | + <label class="col-sm-3 control-label">失效日期:</label> | |
110 | + <div class="col-sm-8"> | |
111 | + <input id="expirationDate" name="expirationDate" class="form-control" type="text"> | |
108 | 112 | </div> |
109 | - <div class="form-group"> | |
113 | + </div> | |
114 | + <div class="form-group"> | |
110 | 115 | <div class="form-control-static col-sm-offset-9"> |
111 | 116 | <button type="submit" class="btn btn-primary">提交</button> |
112 | 117 | <button onclick="$.modal.close()" class="btn btn-danger" type="button">关闭</button> |
113 | 118 | </div> |
114 | 119 | </div> |
115 | 120 | </form> |
116 | - </div> | |
117 | - <div th:include="include::footer"></div> | |
121 | + <th:block th:include="include :: footer" /> | |
122 | + <th:block th:include="include :: select2-js" /> | |
118 | 123 | <script type="text/javascript"> |
119 | 124 | var prefix = ctx + "shipment/shipmentDetail" |
120 | 125 | $("#form-shipmentDetail-add").validate({ |
... | ... | @@ -154,7 +159,7 @@ |
154 | 159 | "shipmentCode": $("input[name='shipmentCode']").val(), |
155 | 160 | "companyCode": $("input[name='companyCode']").val(), |
156 | 161 | "referLineNum": $("input[name='referLineNum']").val(), |
157 | - "materialCode": $("input[name='materialCode']").val(), | |
162 | + "materialCode": $("#materialCode").val(), | |
158 | 163 | "batch": $("input[name='batch']").val(), |
159 | 164 | "lot": $("input[name='lot']").val(), |
160 | 165 | "projectNo": $("input[name='project']").val(), |
... | ... | @@ -196,6 +201,19 @@ |
196 | 201 | laydate.render({ elem: '#expirationDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' }); |
197 | 202 | laydate.render({ elem: '#agingDate', theme: 'molv', format: 'yyyy-MM-dd HH:mm:ss' }); |
198 | 203 | }); |
204 | + $('#materialCode').select2({ | |
205 | + ajax: { | |
206 | + url: ctx+'config/material/getData', | |
207 | + dataType: 'json', | |
208 | + type: 'post', | |
209 | + data: function (params) { | |
210 | + let query = { | |
211 | + materialName: params.term, | |
212 | + } | |
213 | + return query; | |
214 | + } | |
215 | + } | |
216 | + }); | |
199 | 217 | }) |
200 | 218 | </script> |
201 | 219 | </body> |
... | ... |