wzy
2021-04-01 d388e2788b7ef088d7cd40f901b0acdcec460bc3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
<!DOCTYPE HTML>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <META HTTP-EQUIV="Pragma" CONTENT="no-cache">
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <!-- 本框架基本脚本和样式 -->
    <script type="text/javascript"
            th:src="@{/js/plugin/jquery-2.1.4.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/systools/MBase.js}"></script>
</head>
<body>
<div class="ibox-content">
    <form class="form-horizontal" id="dataform"
          onsubmit="javascripr:return false;">
 
            <input autocomplete="off"   th:if="${obj ne null }"  type="hidden" name="id" th:value="${obj?.id }">
 
        <div class="form-group">
            <label class="col-offset-1 col-sm-2 control-label">调拨类型</label>
            <div class="col-sm-3">
                <p class="form-control-static" th:text="${obj?.allottedType}"></p>
            </div>
 
            <label class="col-sm-2 control-label">调拨日期</label>
            <div class="col-sm-3">
                <p class="form-control-static" th:text="${#dates.format(obj.allottedDate, 'yyyy-MM-dd')}">
 
                </p>
            </div>
        </div>
 
        <div class="form-group">
            <label class="col-sm-2 control-label">制单人</label>
            <div class="col-sm-3">
                    <p   class="form-control-static"  th:text="${obj?.makingManName}"></p>
                <div class="Validform_checktip"></div>
            </div>
 
            <label class="col-sm-2 control-label">审核人</label>
            <div class="col-sm-3">
                <p class="form-control-static" th:text="${obj?.appManName}"></p>
            </div>
        </div>
 
        <div class="form-group">
            <label class="col-sm-2 control-label">调入仓库</label>
            <!-- 调入仓库是本店   TODO============= -->
            <div class="col-sm-3">
                <p class="form-control-static" th:text="${obj?.allottedInstoreName}" ></p>
            </div>
            <label class="col-sm-2 control-label">调出仓库</label>
            <div class="col-sm-3">
                <p class="form-control-static" th:text="${obj?.allottedOutstoreName }"></p>
                <input autocomplete="off"   type="hidden" class="form-control autoFull"
                       name="allottedOutstoreId" th:value="${obj.allottedOutstoreId}">
            </div>
        </div>
 
        <div class="form-group">
            <label class="col-sm-2 control-label">备注</label>
            <span class="col-sm-3 form-control-static" th:text="${obj?.allottedRemark}"></span>
 
        </div>
        <div class="form-group">
 
            <label class="col-sm-2 control-label">调拨金额</label>
            <div class="col-sm-3">
                <input autocomplete="off"   type="text" readonly="readonly" th:value="${obj.amountPrice}"
                       class="form-control" id="amountPrice" name="amountPrice"></input>
            </div>
            <div th:if="${obj.checkStatus eq '待收货' or obj.checkStatus eq '已完成'  }">
                <label class="col-sm-2 control-label">收货金额</label>
                <div class="col-sm-3">
                    <input autocomplete="off"   type="text" readonly="readonly" th:value="${obj.receivedPrice}"
                           class="form-control" id="receivedPrice" name="receivedPrice"></input>
                </div>
            </div>
        </div>
 
        <div class="form-group">
            <div class="col-sm-3 col-md-offset-1">
                <span style="font-size: 14px; font-weight: bold;">调拨明细 </span>
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-8 col-md-offset-2">
                <table class="table table-striped table-hover table-bordered"
                       id="mgrid">
                    <thead>
                    <tr>
                        <th>序号</th>
                        <th>产品编号</th>
                        <th>产品名称</th>
                        <th>产品类型</th>
                        <th>单位</th>
                        <th width="120">申请调拨数量</th>
                        <th width="120">实际调拨数量</th>
                        <th width="120">调拨单价</th>
                        <th width="120">调拨金额</th>
                        <th  th:if="${obj.checkStatus eq '待收货' or obj.checkStatus eq '已完成'  }" width="120">实际收货数量</th>
                        <th th:if="${obj.checkStatus eq '待收货' or obj.checkStatus eq '已完成'  }"  width="120">收货金额</th>
                        <th width="120">库存量</th>
                    </tr>
                    </thead>
                    <tbody id="cpId">
 
                    </tbody>
 
                </table>
            </div>
        </div>
        <div class="form-group ">
            <div class="col-sm-12 text-center">
                <div th:if="${(obj.checkStatus eq '待审核')  && (obj.appManId eq session.userInfo.suId) }">
                    <a   href="javascript:;" onclick="myForm.submit()"
                       class="btn btn-info radius">确认审核</a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <a href="javascript:;" onclick="noCheck('addcheckremark')"
                       class="btn btn-success radius">不予审核</a>
                </div>
                    <a th:if="${(obj.checkStatus eq '审核通过')  && (obj.appManId eq session.userInfo.suId) }" href="javascript:;" onclick="toDo('sendGoods')"
                       class="btn btn-success radius">发货</a>
                    <a  th:if="${(obj.checkStatus eq '待收货')}" href="javascript:;" onclick="reject()"
                       class="btn btn-success radius">确认收货</a>
                <button onclick="MTools.closeForm()" class="btn btn-danger radius">取消</button>
            </div>
        </div>
    </form>
</div>
</body>
 
 
<script type="text/javascript" th:src="@{/js/systools/MJsBase.js}"></script>
<script  th:inline="javascript">
    var totalGoods = [];
    readInitData();
    writeDate();
    /*<![CDATA[*/
    var checkStatus =/*[[${obj.checkStatus}]]*/;
    /*]]>*/
 
    if (checkStatus == '待收货') {
        var url = basePath+"/admin/allotted/rejectGoods";
    } else {
        var url = basePath+"/admin/allotted/check";
    }
    var myForm = MForm.initForm({
        invokeUrl : url,
        afterSubmit : function() {
            parent.myGrid.serchData();
        },
    });
    var length;
    function reject() {
        var t = true;
        for (var i = 0; i < length; i++) {
            if ($("#receiveTotal" + i).val() < totalGoods[i].realTotal) {
                layer.confirm('实际收货数少于发货数量,是否继续操作?', {
                    btn : [ '确定', '取消' ], //按钮
                    shade : false
                    //不显示遮罩
                }, function() {
                    myForm.submit();
                });
                return;
            }
        }
        myForm.submit();
 
    }
 
 
    //初始化产品列表
    function readInitData(){
 
        /*<![CDATA[*/
        var projItemsL=/*[[${obj?.sysAllotDetails}]]*/;
 
        var allottedOutstoreId=/*[[${obj?.allottedOutstoreId}]]*/;
        /*]]>*/
 
        if(projItemsL){
 
            for(var i =0; i<projItemsL.length; i++) {
 
                var obj = new Object();
                //库存sku信息
                var goods = {};
                var projItems=projItemsL[i];
                goods.id = projItems.goods.id;
                goods.name = projItems.goods.name;
               goods.unit = projItems.goods.unit;
               goods.goodsSortName = projItems.goods.goodsSortName;
               goods.goodsNo = projItems.goods.goodsNo;
                //调拨单本身的信息
                obj.detailId = projItems.id;
                //调拨单价
                obj.wholesale = projItems.wholesale;
                //调拨申请数量
                obj.appTotal = projItems.appTotal;
                //出库仓id
                obj.storeId = allottedOutstoreId;
                //库存量
                obj.storeTotal = projItems.storeInfo.storeTotal;
                //实际库存量
                obj.realTotal = projItems.realTotal;
                obj.batch = projItems.storeInfo.batch;
                obj.goods = goods;
                console.log(obj);
                totalGoods[i] = obj;
            }
        }
 
 
    }
 
 
    //填写数据到html
    function writeDate() {
 
        /*<![CDATA[*/
        var status=/*[[${obj.checkStatus}]]*/
        /*]]>*/
 
 
        var html = "";
        length = totalGoods.length;
        for (var i = 0; i < totalGoods.length; i++) {
            if (!totalGoods[i].realTotal) {
                totalGoods[i].realTotal = "";
            }
            if (status == "待收货") {
                html += '<tr>' + '<td>' + (i + 1) + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].id" value="'+totalGoods[i].detailId+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsNo+ '</td>'
                    + '<td>' + totalGoods[i].goods.name + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].skuId" value="'+totalGoods[i].goods.id+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsSortName+ '</td>'
                    + '<td>'+ totalGoods[i].goods.unit+ '</td>'
                    + '<td>'+ totalGoods[i].appTotal + '</td>'
                    + '<td>' + totalGoods[i].realTotal + '</td>'
                    + '<td>' + totalGoods[i].wholesale + '</td>'
                    + '<td >'+ (totalGoods[i].wholesale * totalGoods[i].appTotal).toFixed(2) + '</td>'
                    + '<td><input autocomplete="off"   id="receiveTotal'+i+'" name="sysAllotDetails['+i+'].receiveTotal" value="'+totalGoods[i].realTotal+'"  onchange="changePriceSh(this)"  data-max="'+totalGoods[i].realTotal+'" type="text" dataType="n" nullmsg="请填写数字" errormsg="请填写数字" class="form-control"><div class="Validform_checktip"></div></td>'
                    + '<td class="total">'+ (totalGoods[i].wholesale * totalGoods[i].realTotal).toFixed(2) + '</td>'
                    + '<td>' + totalGoods[i].storeTotal + '</td>'
 
                    + '</tr>';
 
            } else if (status == '待审核') {
                html += '<tr>' + '<td>'
                    + (i + 1)
                    + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].id" value="'+totalGoods[i].detailId+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsNo + '</td>'
                    + '<td>'+ totalGoods[i].goods.name  + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].skuId" value="'+totalGoods[i].goods.id+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsSortName + '</td>'
                    + '<td>'+ totalGoods[i].goods.unit + '</td>'
                    + '<td>'
                    + totalGoods[i].appTotal
                    + '</td>'
                    + '<td><input autocomplete="off"   name="sysAllotDetails['
                    + i
                    + '].realTotal" value="'
                    + totalGoods[i].appTotal
                    + '"  onchange="changePrice(this)"  data-max="'+totalGoods[i].appTotal+'"    type="text" dataType="n" nullmsg="请填写数字" errormsg="请填写数字" class="form-control"><div class="Validform_checktip"></div></td>'
                    + '<td>'
                    + totalGoods[i].wholesale
                    + '</td>'
                    + '<td class="total">'
                    + (totalGoods[i].wholesale * totalGoods[i].appTotal)
                        .toFixed(2) + '</td>' + '<td>'
                    + totalGoods[i].storeTotal + '</td>' + '</tr>';
 
            } else if (status == "审核通过") {
                html += '<tr>'
                    + '<td>'
                    + (i + 1)
                    + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].id" value="'+totalGoods[i].detailId+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsNo + '</td>'
                    + '<td>'+ totalGoods[i].goods.name  + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].skuId" value="'+totalGoods[i].goods.id+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsSortName + '</td>'
                    + '<td>'+ totalGoods[i].goods.unit + '</td>'
                    + '<td>' + totalGoods[i].appTotal + '</td>' + '<td>'
                    + totalGoods[i].realTotal + '</td>'
                    + '<td>'
                    + totalGoods[i].wholesale
                    + '</td>'
                    + '<td class="total">'+ (totalGoods[i].wholesale * totalGoods[i].appTotal).toFixed(2) + '</td>'
                    + '<td>'+ totalGoods[i].storeTotal + '</td>'
                    + '</tr>';
            } else {
                html += '<tr>' + '<td>'
                    + (i + 1)
                    + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].id" value="'+totalGoods[i].detailId+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsNo + '</td>'
                    + '<td>'+ totalGoods[i].goods.name  + '<input autocomplete="off"   type="hidden" name="sysAllotDetails['+i+'].skuId" value="'+totalGoods[i].goods.id+'"></td>'
                    + '<td>'+ totalGoods[i].goods.goodsSortName + '</td>'
                    + '<td>'+ totalGoods[i].goods.unit + '</td>'
                    + '<td>' + totalGoods[i].appTotal + '</td>'
                    + '<td>'+ totalGoods[i].realTotal + '</td>'
                    + '<td>' + totalGoods[i].wholesale + '</td>'
                    + '<td >'+ (totalGoods[i].wholesale * totalGoods[i].realTotal).toFixed(2) + '</td>'
                    + '<td>'+ totalGoods[i].receiveTotal + '</td>'
                    + '<td class="total">'+ (totalGoods[i].wholesale * totalGoods[i].receiveTotal).toFixed(2) + '</td>'
                    + '<td>' + totalGoods[i].storeTotal + '</td>' + '</tr>';
            }
 
 
 
        }
        $("#cpId").html(html);
 
 
 
        //初始化收货金额
        if (status == "待收货") {
            //计算总金额
            var sum = 0;
            $(".total").each(function() {
                sum += parseFloat(this.innerHTML);
            });
            $("#receivedPrice").val(sum.toFixed(2));
        }
 
 
 
    }
 
 
 
    //收货计算价格
    function changePriceSh(node) {
        console.log("changePriceSh");
        var $node=$(node);
        var maxValue=$(node).data("max");
        var $tr = $node.closest("tr");
        var tds = $tr.find("td");
        var price = tds.eq(6).html();
        var total = tds.eq(8).find("input").val();
 
        total=total>maxValue?maxValue:total;
        $node.val(parseInt(total));
 
        tds.eq(9).html((price * total).toFixed(2));
        //计算总金额
        var sum = 0;
        $(".total").each(function() {
            sum += parseFloat(this.innerHTML);
        });
        $("#receivedPrice").val(sum.toFixed(2));
    }
 
    function changePrice(node) {
        console.log("changePrice");
        var $node=$(node);
        var maxValue=$(node).data("max");
 
        var $tr = $(node).closest("tr");
        var tds = $tr.find("td");
        var price = tds.eq(6).html();
        var total = tds.eq(5).find("input").val();
 
        total=total>maxValue?maxValue:total;
        $node.val(parseInt(total));
 
        tds.eq(7).html((price * total).toFixed(2));
        //计算总金额
        var sum = 0;
        $(".total").each(function() {
            sum += parseFloat(this.innerHTML);
        });
        $("#amountPrice").val(sum.toFixed(2));
 
    }
 
    function toDo(url) {
        var id=[[${obj.id}]]
        $.AjaxProxy({
            a : false,
            c : false,
            p : {
                id : id
            }
        }).invoke(basePath+'/admin/allotted/' + url, function(loj) {
            if (layer.alert) {
                // 执行成功弹出提示层
                layer.alert(loj.getValue("info"), {
                    icon : 1
                }, function(inindex) {
                    layer.closeAll();
                    parent.myGrid.serchData();
                    MTools.closeForm();
                });
                return;
            }
        });
    }
 
    function noCheck(url) {
        var id = $
        {
            obj.id
        }
        ;
        layer.prompt({
            formType : 2,
            title : '审核意见'
        }, function(value, index, elem) {
            $.AjaxProxy({
                a : false,
                c : false,
                p : {
                    id : id,
                    appRemark : value,
                    appStatus : 3
                }
            }).invoke(basePath+'/admin/allotted/' + url, function(loj) {
                if (loj.attr("result").status == '200') {
                    layer.msg('备注成功', {
                        icon : 1
                    }, function() {
                        parent.myGrid.serchData();
                        MTools.closeForm();
                    });
 
                }
            });
 
        });
 
    }
</script>
</body>
</html>