From 2281e3ac9929818587d658c78741a8f5351cded6 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 09 七月 2020 17:02:06 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/pdaCe/index.html |   95 +++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 82 insertions(+), 13 deletions(-)

diff --git a/src/main/webapp/views/pdaCe/index.html b/src/main/webapp/views/pdaCe/index.html
index 3c56849..fce94cf 100644
--- a/src/main/webapp/views/pdaCe/index.html
+++ b/src/main/webapp/views/pdaCe/index.html
@@ -134,7 +134,7 @@
 
 <div id="btn-con">
     <button style="margin-right: 20px" onclick="reset()">閲嶇疆</button>
-    <button >缁勬墭</button>
+    <button onclick="comb()">缁勬墭</button>
     <span id="tips"></span>
 </div>
 
@@ -177,7 +177,6 @@
     var str1 = document.getElementById("str1");
     var count = document.getElementById("count");
 
-    alert(1);
     matDetail.style.display = 'none';
     var initMatCount = 1;
 
@@ -208,7 +207,68 @@
             } else {
                 alert(res.msg);
             }
+        })
+    }
 
+    // 缁勬墭
+    function comb() {
+        var barcode = code.value;
+        if (isEmpty(barcode)) {
+            tips("鎵樼洏鏉$爜涓虹┖", true);
+            // document.getElementById("code").focus();
+            return;
+        }
+        if (matData.length === 0) {
+            tips("璇锋彁鍙栫墿鏂�", true);
+            return;
+        }
+        httpRequest({
+            httpUrl: baseUrl+"/mobile/comb/auth",
+            type: 'post',
+            data: JSON.stringify({
+                barcode: barcode,
+                combMats: matData
+            }),
+        }, function (res) {
+            if (res.code === 200) {
+                if (res.data != null) {
+                    // 鏍峰紡
+                    matMsg.style.display = 'none';
+                    btnCon.style.display = 'none';
+                    matDetail.style.display = 'block';
+                    // 濉厖鏁版嵁
+                    matName.value = res.data.matName;
+                    str1.value = res.data.str1;
+                    count.value = initMatCount;
+                } else {
+                    matMsg.style.display = 'block';
+                    btnCon.style.display = 'block';
+                    matDetail.style.display = 'none';
+                }
+            } else {
+                alert(res.msg);
+            }
+        })
+        $.ajax({
+            url: baseUrl+"/mobile/comb/auth",
+            headers: {'token': localStorage.getItem('token')},
+            data: JSON.stringify({
+                barcode: barcode,
+                combMats: matData
+            }),
+            contentType:'application/json;charset=UTF-8',
+            method: 'POST',
+            async: false,
+            success: function (res) {
+                if (res.code === 200) {
+                    reset();
+                    tips("缁勬墭鎴愬姛")
+                } else if (res.code === 403) {
+                    top.location.href = baseUrl + "/pda";
+                } else {
+                    tips(res.msg, true)
+                }
+            }
         })
     }
 
@@ -225,7 +285,6 @@
         } else {
             line = row;
         }
-
         var html = "";
         for (var i = 0; i < line; i ++){
             html += " <div>\n" +
@@ -244,30 +303,38 @@
             tips("鎻愬彇澶辫触");
             return;
         }
-        let toPush = true;
+        var toPush = true;
         for (var j=0;j<matData.length;j++){
-            if (matnr.value === matData[j].matnr) {
+            if (data.matnr === matData[j].matnr) {
                 matData[j].count = Number(matData[j].count) + Number(data.count);
                 toPush  = false;
             }
         }
         if (toPush) {
             matData.push(data);
-            var html = " <div>\n" +
-                    "       <span>" + data.matnr + "</span>\n" +
-                    "       <span>" + data.matName + "</span>\n" +
-                    "       <span>" + data.str1 + "</span>\n" +
-                    "       <span>" + data.count + "</span>\n" +
-                    "     </div>\n";
-            ttbody.innerHTML = html;
         }
-        tips("鎻愬彇鎴愬姛");
+        var html = "";
+        for (var i=0;i<matData.length;i++) {
+            html += " <div class='table-data'>\n" +
+                "       <span>" + matData[i].matnr + "</span>\n" +
+                "       <span>" + matData[i].matName + "</span>\n" +
+                "       <span>" + matData[i].str1 + "</span>\n" +
+                "       <span>" + matData[i].count + "</span>\n" +
+                "     </div>\n";
+        }
+
+        ttbody.innerHTML = html;
     }
 
     // 閲嶇疆
     function reset() {
         code.value = "";
         matnr.value = "";
+        cancel();
+        while(ttbody.hasChildNodes()) {
+            ttbody.removeChild(ttbody.firstChild);
+
+        }
     }
 
     /**
@@ -296,6 +363,7 @@
             count: count.value
         })
         cancel();
+        tips("鎻愬彇鎴愬姛");
     }
     // 鍙栨秷
     function cancel() {
@@ -306,6 +374,7 @@
         matMsg.style.display = 'block';
         btnCon.style.display = 'block';
         matDetail.style.display = 'none';
+        tips("");
     }
 
     function add() {

--
Gitblit v1.9.1