From 356840f0e99a3a16620b33367af0893eca053b30 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期一, 12 四月 2021 13:21:39 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/ioWorks/matQuery.js |  136 +++++++++++++++++++++++++++++++++++++++------
 1 files changed, 118 insertions(+), 18 deletions(-)

diff --git a/src/main/webapp/static/js/ioWorks/matQuery.js b/src/main/webapp/static/js/ioWorks/matQuery.js
index 3721713..66d4b01 100644
--- a/src/main/webapp/static/js/ioWorks/matQuery.js
+++ b/src/main/webapp/static/js/ioWorks/matQuery.js
@@ -9,12 +9,17 @@
     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',  'notice'], function() {
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
     var form = layui.form;
+    var notice = layui.notice;
+    var layDate = layui.laydate;
 
     tableIns = table.render({
         elem: '#chooseData',
@@ -41,26 +46,96 @@
         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);
+
+                    // 椤圭洰
+                    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);
+
+                    layer.close(index);
                     if (success) {
                         layer.open({
                             type: 1,
-                            title: '瀹氫箟閿�鍞崟缂栧彿',
+                            title: '鍗曟嵁濉厖',
                             offset: '100px',
                             area: ['360px'],
                             shade: 0.1,
                             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('');
@@ -98,9 +173,17 @@
 
             });
         });
+        var number = data.field.orderNo; // 鍗曞彿
+        if (number.substring(0, 3) !== 'PR-') {
+            notice.error({
+                title: '娑堟伅閫氱煡',
+                message: '鍗曞彿涓嶇鍚堣鍒欙紝璇蜂互 PR- 寮�澶�'
+            });
+            return false;
+        }
         var req = JSON.stringify({
-            number: data.field.orderNo
-            , customerTypeId: '1'
+            number: number
+            , customerTypeId: data.field.customerTypeId
             , list: matDetls
         })
         $.ajax({
@@ -111,12 +194,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 +213,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 +294,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