From 9ff5e64187837a3bbd78370c1cfaadf2329f97f0 Mon Sep 17 00:00:00 2001
From: 18516761980 <4761516tqsxp>
Date: 星期六, 19 三月 2022 12:47:13 +0800
Subject: [PATCH] .

---
 src/main/webapp/static/js/ioWorks/matQuery.js                     |    1 
 src/main/webapp/views/receive/matQuery.html                       |    2 
 src/main/java/zy/cloud/wms/manager/controller/WorkController.java |    5 
 src/main/webapp/static/js/receive/matQuery.js                     |  398 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 403 insertions(+), 3 deletions(-)

diff --git a/src/main/java/zy/cloud/wms/manager/controller/WorkController.java b/src/main/java/zy/cloud/wms/manager/controller/WorkController.java
index d4ae753..3729af4 100644
--- a/src/main/java/zy/cloud/wms/manager/controller/WorkController.java
+++ b/src/main/java/zy/cloud/wms/manager/controller/WorkController.java
@@ -201,8 +201,9 @@
     // 鑾峰彇鎵�鏈夊崟鎹被鍨�
     @RequestMapping("/docType/all/get")
     @ManagerAuth
-    public R getDocTypeData() {
-        List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("status", 1).eq("host_id", getHostId()).orderBy("create_time", false).eq("doc_class",1));
+    public R getDocTypeData(Integer docClass) {
+        List<DocType> docTypes = docTypeService.selectList(new EntityWrapper<DocType>().eq("status", 1).
+                eq("host_id", getHostId()).orderBy("create_time", false).eq("doc_class",docClass));
         return R.ok().add(docTypes);
     }
 
diff --git a/src/main/webapp/static/js/ioWorks/matQuery.js b/src/main/webapp/static/js/ioWorks/matQuery.js
index f2a2614..adeb494 100644
--- a/src/main/webapp/static/js/ioWorks/matQuery.js
+++ b/src/main/webapp/static/js/ioWorks/matQuery.js
@@ -76,6 +76,7 @@
                     $.ajax({
                         url: baseUrl+"/work/docType/all/get",
                         headers: {'token': localStorage.getItem('token')},
+                        data:{docClass: 2},
                         method: 'POST',
                         async: false,
                         success: function (res) {
diff --git a/src/main/webapp/static/js/receive/matQuery.js b/src/main/webapp/static/js/receive/matQuery.js
new file mode 100644
index 0000000..1b938ef
--- /dev/null
+++ b/src/main/webapp/static/js/receive/matQuery.js
@@ -0,0 +1,398 @@
+
+var matData = [];
+var cstmrVal;
+var itemVal;
+
+function getCol() {
+    var cols = [
+        {field: 'count', align: 'center',title: '鍑哄簱鏁伴噺', edit:'text', width: 130,  style:'color: blue;font-weight: bold'}
+    ];
+    arrRemove(matCols,  'field', 'anfme');
+    cols.push.apply(cols, matCols);
+    cols.push(
+            {field: 'stock', align: 'center',title: '搴撳瓨浣欓噺', style: 'font-weight: bold'},
+            {fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:65}
+        )
+    return cols;
+}
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).extend({
+    notice: 'notice/notice',
+}).use(['table','laydate', 'form', 'admin', 'notice', 'xmSelect'], function() {
+    var table = layui.table;
+    var $ = layui.jquery;
+    var layer = layui.layer;
+    var form = layui.form;
+    var notice = layui.notice;
+    var layDate = layui.laydate;
+    var admin = layui.admin;
+    var xmSelect = layui.xmSelect;
+
+    tableIns = table.render({
+        elem: '#chooseData',
+        headers: {token: localStorage.getItem('token')},
+        data: [],
+        limit: 100,
+        even: true,
+        toolbar: '#toolbar',
+        cellMinWidth: 50,
+        cols: [getCol()],
+        done: function(res, curr, count) {
+            limit();
+        }
+    });
+
+    // 椤甸潰淇敼
+    table.on('edit(chooseData)', function (obj) {
+        updateMatData(obj.data.locNo, obj.data.matnr, Number(obj.value));
+    });
+
+    // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+    table.on('toolbar(chooseData)', function (obj) {
+        var data = matData;
+        switch (obj.event) {
+            case 'createDoc':
+                if (data.length === 0){
+                    notice.error({
+                        title: '娑堟伅閫氱煡',
+                        message: '璇锋坊鍔犵墿鏂�'
+                    });
+                } else {
+                    var success = true;
+                    for (var i=0;i<matData.length;i++) {
+                        if (matData[i].count <= 0) {
+                            notice.error({
+                                title: '娑堟伅閫氱煡',
+                                message: matData[i].matnr + '鐗╂枡鏁伴噺蹇呴』澶т簬闆讹紒'
+                            });
+                            success = false;
+                            return false;
+                        }
+                    }
+                    var index = layer.load(1, {shade: [0.1,'#000']});
+                    // 鍗曟嵁绫诲瀷
+                    var docTypeData;
+                    $.ajax({
+                        url: baseUrl+"/work/docType/all/get",
+                        headers: {'token': localStorage.getItem('token')},
+                        data:{docClass: 1},
+                        method: 'POST',
+                        async: false,
+                        success: function (res) {
+                            if (res.code === 200){
+                                docTypeData = res;
+                            } else {
+                                layer.msg(res.msg, {icon: 2})
+                            }
+                        }
+                    });
+                    var tpl1 = $('#docTypeSelectTpl').html();
+                    var template1 = Handlebars.compile(tpl1);
+                    var html1 = template1(docTypeData);
+                    $("#docType").html(html1);
+
+                    // 瀹㈡埛
+                    var cstmrData;
+                    // $.ajax({
+                    //     url: baseUrl+"/work/cstmr/all/get",
+                    //     headers: {'token': localStorage.getItem('token')},
+                    //     method: 'POST',
+                    //     async: false,
+                    //     success: function (res) {
+                    //         if (res.code === 200){
+                    //             cstmrData = res;
+                    //         } else {
+                    //             layer.msg(res.msg, {icon: 2})
+                    //         }
+                    //     }
+                    // });
+                    // var tpl2 = $('#cstmrSelectTpl').html();
+                    // var template2 = Handlebars.compile(tpl2);
+                    // var html2 = template2(cstmrData);
+                    // $("#cstmr").html(html2);
+                    // 鍗曢��
+                    $.ajax({
+                        url: baseUrl+"/work/cstmr/all/get/kv",
+                        headers: {'token': localStorage.getItem('token')},
+                        method: 'POST',
+                        async: false,
+                        success: function (res) {
+                            if (res.code === 200){
+                                cstmrData = res.data;
+                            } else {
+                                layer.msg(res.msg, {icon: 2})
+                            }
+                        }
+                    });
+                    cstmrVal = xmSelect.render({
+                        el: '#cstmr',
+                        radio: true,
+                        clickClose: true,
+                        filterable: true,
+                        create: function(val, arr){
+                            if(arr.length === 0){
+                                return {
+                                    name:  val,
+                                    value: val
+                                }
+                            }
+                        },
+                        model: {
+                            icon: 'hidden',
+                            label: {
+                                type: 'text',
+                            }
+                        },
+                        data: cstmrData
+                    })
+
+                    // 椤圭洰
+                    var itemData;
+                    // $.ajax({
+                    //     url: baseUrl+"/work/item/all/get",
+                    //     headers: {'token': localStorage.getItem('token')},
+                    //     method: 'POST',
+                    //     async: false,
+                    //     success: function (res) {
+                    //         if (res.code === 200){
+                    //             itemData = res;
+                    //         } else {
+                    //             layer.msg(res.msg, {icon: 2});
+                    //         }
+                    //     }
+                    // });
+                    // var tpl3 = $('#itemSelectTpl').html();
+                    // var template3 = Handlebars.compile(tpl3);
+                    // var html3 = template3(itemData);
+                    // $("#item").html(html3);
+                    $.ajax({
+                        url: baseUrl+"/work/item/all/get/kv",
+                        headers: {'token': localStorage.getItem('token')},
+                        method: 'POST',
+                        async: false,
+                        success: function (res) {
+                            if (res.code === 200){
+                                itemData = res.data;
+                            } else {
+                                layer.msg(res.msg, {icon: 2});
+                            }
+                        }
+                    });
+                    itemVal = xmSelect.render({
+                        el: '#item',
+                        radio: true,
+                        clickClose: true,
+                        filterable: true,
+                        create: function(val, arr){
+                            if(arr.length === 0){
+                                return {
+                                    name:  val,
+                                    value: val
+                                }
+                            }
+                        },
+                        model: {
+                            icon: 'hidden',
+                            label: {
+                                type: 'text',
+                            }
+                        },
+                        data: itemData
+                    })
+
+                    // 寮圭獥
+                    layer.close(index);
+                    if (success) {
+                        admin.open({
+                            type: 1,
+                            title: '鍗曟嵁濉厖',
+                            offset: '100px',
+                            area: ['360px'],
+                            shade: 0.3,
+                            content: $('#getOrderNo'),
+                            success: function(layero, index){
+                                layer.iframeAuto(index);
+                                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                                layui.form.render('select');
+                            },
+                            cancel: function () {
+                                $('#orderNo').val('');
+                            }
+                        });
+                    }
+                }
+                break;
+        }
+    });
+
+
+    // // 澶氶��
+    // var demo1 = xmSelect.render({
+    //     el: '#demo1',
+    //     filterable: true,
+    //     create: function(val, arr){
+    //         if(arr.length === 0){
+    //             return {
+    //                 name:  val,
+    //                 value: val
+    //             }
+    //         }
+    //     },
+    //     data: [
+    //         {name: '寮犱笁', value: 1, selected: true},
+    //         {name: '鏉庡洓', value: 2},
+    //         {name: '鐜嬩簲', value: 3, disabled: true},
+    //     ]
+    // })
+
+    // 鐩戝惉琛屽伐鍏蜂簨浠�
+    table.on('tool(chooseData)', function(obj){
+        var data = obj.data;
+        switch (obj.event) {
+            case 'remove':
+                for (var i = matData.length - 1; i >= 0; i--) {
+                    if (matData[i].matnr === data.matnr) {
+                        matData.splice(i, 1);
+                    }
+                }
+                tableIns.reload({data: matData,done:function (res) {
+                    limit();
+                }});
+                break;
+        }
+    });
+
+    // 寮�濮嬬敓鎴愭嫞璐у崟
+    form.on('submit(confirm)', function (data) {
+        var matDetls = [];
+        matData.forEach(function(elem) {
+            matDetls.push({
+                matnr: elem.matnr
+                , count: elem.count
+            });
+        });
+        var req = JSON.stringify({
+            docType: data.field.docType
+            , orderNo: data.field.orderNo
+            , orderTime: data.field.orderTime
+            , item: itemVal.getValue()[0] ? itemVal.getValue()[0].name : null
+            , cstmr: cstmrVal.getValue()[0] ? cstmrVal.getValue()[0].name : null
+            , list: matDetls
+        })
+        $.ajax({
+            url: baseUrl+"/work/order/init",
+            headers: {'token': localStorage.getItem('token')},
+            data: req,
+            contentType:'application/json;charset=UTF-8',
+            method: 'POST',
+            success: function (res) {
+                if (res.code === 200){
+                    notice.success({
+                        title: '娑堟伅閫氱煡',
+                        message: res.msg
+                    });
+                    top.layui.layer.close(top.popupRight);
+                } else if (res.code === 403){
+                    top.location.href = baseUrl+"/";
+                } else {
+                    notice.error({
+                        title: '娑堟伅閫氱煡',
+                        message: res.msg
+                    });
+                }
+            }
+        });
+    })
+
+    function updateMatData(locNo, matnr, count) {
+        if (isNaN(count)) {
+            notice.error({
+                title: '娑堟伅閫氱煡',
+                message: '璇疯緭鍏ユ暟瀛�'
+            });
+        } else {
+            if (count > 0) {
+                for (var i=0;i<matData.length;i++){
+                    if (matData[i]["matnr"] === matnr){
+                        matData[i]["count"] = count;
+                        break;
+                    }
+                }
+            } else {
+                notice.error({
+                    title: '娑堟伅閫氱煡',
+                    message: '鏁伴噺蹇呴』澶т簬闆�'
+                });
+            }
+        }
+        tableIns.reload({data: matData,done:function (res) {
+            limit();
+        }});
+    }
+
+    layDate.render({
+        elem: '#orderTime',
+        trigger: 'click',
+        type: 'date'
+    });
+
+})
+
+// 鎻愬彇鐗╂枡
+var matDetlLayerIdx;
+function getMatDetl() {
+    matDetlLayerIdx = layer.open({
+        type: 2,
+        title: '鎻愬彇鍑哄簱鐗╂枡',
+        maxmin: true,
+        area: [top.detailWidth, top.detailHeight],
+        shadeClose: true,
+        content: 'matQueryBox.html',
+        success: function(layero, index){
+        }
+    });
+}
+
+// 娣诲姞琛ㄦ牸鏁版嵁
+function addTableData(data) {
+    for (var i=0;i<data.length;i++){
+        let pass = false;
+        for (var j=0;j<matData.length;j++){
+            if (data[i].matnr === matData[j].matnr) {
+                pass = true;
+                break;
+            }
+        }
+        if (pass) {
+            data.splice(i--, 1);
+        } else {
+            data[i]["count"] = 0;
+        }
+
+    }
+    matData.push.apply(matData, data);
+    tableIns.reload({data: matData});
+    layer.close(matDetlLayerIdx);
+}
+
+function initOrderNo() {
+    $.ajax({
+        url: baseUrl+"/work/orderNo/init",
+        headers: {'token': localStorage.getItem('token')},
+        async: false,
+        method: 'GET',
+        success: function (res) {
+            if (res.code === 200){
+                $('#orderNo').val(res.data)
+            } else if (res.code === 403){
+                top.location.href = baseUrl+"/";
+            } else {
+                notice.error({
+                    title: '娑堟伅閫氱煡',
+                    message: res.msg
+                });
+            }
+        }
+    });
+}
\ No newline at end of file
diff --git a/src/main/webapp/views/receive/matQuery.html b/src/main/webapp/views/receive/matQuery.html
index deb9bea..5b9d526 100644
--- a/src/main/webapp/views/receive/matQuery.html
+++ b/src/main/webapp/views/receive/matQuery.html
@@ -147,7 +147,7 @@
 <script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
 <script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
 <script type="text/javascript" src="../../static/js/handlebars/handlebars-v4.5.3.js"></script>
-<script type="text/javascript" src="../../static/js/ioWorks/matQuery.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../static/js/receive/matQuery.js" charset="utf-8"></script>
 
 <div id="getOrderNo" style="display: none">
     <!-- 璁㈠崟缂栧彿銆佸崟鎹棩鏈熴�佸崟鎹被鍨嬨�侀」鐩紪鍙枫�佸鎴风紪鍙枫�� -->

--
Gitblit v1.9.1