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

---
 src/main/webapp/views/pdaCe/index.html |   94 ++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 84 insertions(+), 10 deletions(-)

diff --git a/src/main/webapp/views/pdaCe/index.html b/src/main/webapp/views/pdaCe/index.html
index a67fe5a..d60fe6b 100644
--- a/src/main/webapp/views/pdaCe/index.html
+++ b/src/main/webapp/views/pdaCe/index.html
@@ -139,18 +139,18 @@
 </div>
 
 <!-- 璇︽儏 -->
-<div class="form-box">
+<div class="form-box" id="mat-detail">
     <div class="form-item">
         <span>鍚嶇О</span>
-        <input id="matName" type="text" disabled="disabled" style="background-color: #ececec">
+        <input id="matName" type="text" disabled="disabled" style="background-color: #ececec;color: #000">
     </div>
     <div class="form-item">
         <span>鍗曚綅</span>
-        <input id="str1" type="text" disabled="disabled" style="background-color: #ececec">
+        <input id="str1" type="text" disabled="disabled" style="background-color: #ececec;color: #000; text-align: center;">
     </div>
     <div class="form-item form-count">
         <span style="margin-right: 10px">鏁伴噺</span>
-        <button onclick="reduce()">-</button><input id="count" type="number"><button onclick="add()">+</button>
+        <button onclick="reduce()">-</button><input id="count" type="number" style="text-align: center"><button onclick="add()">+</button>
     </div>
     <div class="form-item form-btn-con">
         <button id="confirm" onclick="confirm()">鎻愬彇</button>
@@ -161,8 +161,8 @@
 
 </body>
 <script>
-    // initCrnMsgTable()
     var matMsgTableBlankRows = 0;   // 绌虹櫧琛屾暟
+    var matData = []; // 琛ㄦ牸鏁版嵁
     var code = document.getElementById("code")
     var matnr = document.getElementById("matnr")
     var matMsg = document.getElementById("mat-msg-id");
@@ -172,9 +172,13 @@
     var btnCon = document.getElementById("btn-con");
     var tipDom = document.getElementById("tips");
 
-    // todo
-    matMsg.style.display = 'none';
-    btnCon.style.display = 'none';
+    var matDetail = document.getElementById("mat-detail");
+    var matName = document.getElementById("matName");
+    var str1 = document.getElementById("str1");
+    var count = document.getElementById("count");
+
+    matDetail.style.display = 'none';
+    var initMatCount = 1;
 
     // 鏌ヨ鐗╂祦
     function find(el) {
@@ -187,11 +191,18 @@
         }, 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);
@@ -201,7 +212,6 @@
     }
 
     initCrnMsgTable();
-    // 鍫嗗灈鏈烘暟鎹〃鑾峰彇  ----- 琛ㄤ簩
     function initCrnMsgTable(row) {
         var line;
         if (row === undefined){
@@ -214,7 +224,6 @@
         } else {
             line = row;
         }
-
         var html = "";
         for (var i = 0; i < line; i ++){
             html += " <div>\n" +
@@ -225,6 +234,35 @@
                 "     </div>\n";
         }
         ttbody.innerHTML = html;
+    }
+
+    // 娣诲姞琛ㄦ牸鏁版嵁
+    function addTableData(data) {
+        if (isEmpty(data.matName)){
+            tips("鎻愬彇澶辫触");
+            return;
+        }
+        var toPush = true;
+        for (var j=0;j<matData.length;j++){
+            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 = "";
+            for (var i=0;i<matData.length;i++) {
+                html += " <div>\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;
+        }
     }
 
     // 閲嶇疆
@@ -247,6 +285,42 @@
         }
     }
 
+    /**
+     * 璇︽儏
+     */
+    // 鎻愬彇
+    function confirm() {
+        addTableData({
+            matnr: matnr.value,
+            matName: matName.value,
+            str1: str1.value,
+            count: count.value
+        })
+        cancel();
+        tips("鎻愬彇鎴愬姛");
+    }
+    // 鍙栨秷
+    function cancel() {
+        matnr.value = "";
+        matName.value = "";
+        str1.value = "";
+        count.value = initMatCount;
+        matMsg.style.display = 'block';
+        btnCon.style.display = 'block';
+        matDetail.style.display = 'none';
+        tips("");
+    }
+
+    function add() {
+        count.value = Number(count.value) + 1;
+    }
+    function reduce() {
+        if (count.value <= initMatCount) {
+            return;
+        }
+        count.value = count.value - 1;
+    }
+
     function httpRequest(paramObj,fun,errFun) {
         var xmlhttp = null;
         /*鍒涘缓XMLHttpRequest瀵硅薄锛�

--
Gitblit v1.9.1