From e1749547c76a5d8bae94e47d38d4d75b481610c1 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@63.com>
Date: 星期四, 09 九月 2021 10:51:15 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/ioWorks/matQuery.js |  234 +++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 212 insertions(+), 22 deletions(-)

diff --git a/src/main/webapp/static/js/ioWorks/matQuery.js b/src/main/webapp/static/js/ioWorks/matQuery.js
index 3721713..7a2b7f1 100644
--- a/src/main/webapp/static/js/ioWorks/matQuery.js
+++ b/src/main/webapp/static/js/ioWorks/matQuery.js
@@ -1,5 +1,8 @@
 
 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'}
@@ -9,12 +12,19 @@
     cols.push({fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:65})
     return cols;
 }
-
-layui.use(['table','laydate', 'form'], function() {
+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',
@@ -41,26 +51,166 @@
         switch (obj.event) {
             case 'createDoc':
                 if (data.length === 0){
-                    layer.msg('璇锋坊鍔犵墿鏂�');
+                    notice.error({
+                        title: '娑堟伅閫氱煡',
+                        message: '璇锋坊鍔犵墿鏂�'
+                    });
                 } else {
                     var success = true;
                     for (var i=0;i<matData.length;i++) {
                         if (matData[i].count <= 0) {
-                            layer.msg(matData[i].matnr + '鐗╂枡鏁伴噺蹇呴』澶т簬闆讹紒', {icon: 2})
+                            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')},
+                        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) {
-                        layer.open({
+                        admin.open({
                             type: 1,
-                            title: '瀹氫箟閿�鍞崟缂栧彿',
+                            title: '鍗曟嵁濉厖',
                             offset: '100px',
                             area: ['360px'],
-                            shade: 0.1,
+                            shade: 0.3,
                             content: $('#getOrderNo'),
                             success: function(layero, index){
-                                layer.iframeAuto(index)
+                                layer.iframeAuto(index);
+                                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                                layui.form.render('select');
                             },
                             cancel: function () {
                                 $('#orderNo').val('');
@@ -71,6 +221,26 @@
                 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){
@@ -93,14 +263,17 @@
     form.on('submit(confirm)', function (data) {
         var matDetls = [];
         matData.forEach(function(elem) {
-            matDetls.push({matnr: elem.matnr
+            matDetls.push({
+                matnr: elem.matnr
                 , count: elem.count
-
             });
         });
         var req = JSON.stringify({
-            number: data.field.orderNo
-            , customerTypeId: '1'
+            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({
@@ -111,12 +284,18 @@
             method: 'POST',
             success: function (res) {
                 if (res.code === 200){
-                    layer.msg(res.msg, {icon: 1});
+                    notice.success({
+                        title: '娑堟伅閫氱煡',
+                        message: res.msg
+                    });
                     top.layui.layer.close(top.popupRight);
                 } else if (res.code === 403){
                     top.location.href = baseUrl+"/";
                 } else {
-                    layer.msg(res.msg, {icon: 2})
+                    notice.error({
+                        title: '娑堟伅閫氱煡',
+                        message: res.msg
+                    });
                 }
             }
         });
@@ -124,27 +303,35 @@
 
     function updateMatData(locNo, matnr, count) {
         if (isNaN(count)) {
-            layer.msg("璇疯緭鍏ユ暟瀛�");
+            notice.error({
+                title: '娑堟伅閫氱煡',
+                message: '璇疯緭鍏ユ暟瀛�'
+            });
         } else {
             if (count > 0) {
                 for (var i=0;i<matData.length;i++){
                     if (matData[i]["matnr"] === matnr){
-                        // if (count > locDetlData[i]["anfme"]) {
-                        //     layer.msg("涓嶈兘瓒呰繃鍘熸暟閲�");
-                        // } else {
-                            matData[i]["count"] = count;
-                        // }
+                        matData[i]["count"] = count;
                         break;
                     }
                 }
             } else {
-                layer.msg("鏁伴噺蹇呴』澶т簬闆�");
+                notice.error({
+                    title: '娑堟伅閫氱煡',
+                    message: '鏁伴噺蹇呴』澶т簬闆�'
+                });
             }
         }
         tableIns.reload({data: matData,done:function (res) {
             limit();
         }});
     }
+
+    layDate.render({
+        elem: '#orderTime',
+        trigger: 'click',
+        type: 'date'
+    });
 
 })
 
@@ -197,7 +384,10 @@
             } else if (res.code === 403){
                 top.location.href = baseUrl+"/";
             } else {
-                layer.msg(res.msg, {icon: 2})
+                notice.error({
+                    title: '娑堟伅閫氱煡',
+                    message: res.msg
+                });
             }
         }
     });

--
Gitblit v1.9.1