From aa963091956e9d3f9a4a0f1a19809f56344ba988 Mon Sep 17 00:00:00 2001
From: jiazx0107@163.com <jiazx0107@163.com>
Date: 星期三, 31 五月 2023 22:37:26 +0800
Subject: [PATCH] 出入库优化-称重实现粮食产地

---
 igds-web/src/main/resources/static/admin/inout/in-weight.js |  392 +++++++++++--------------------------------------------
 1 files changed, 83 insertions(+), 309 deletions(-)

diff --git a/igds-web/src/main/resources/static/admin/inout/in-weight.js b/igds-web/src/main/resources/static/admin/inout/in-weight.js
index e5e5e36..86e82ee 100644
--- a/igds-web/src/main/resources/static/admin/inout/in-weight.js
+++ b/igds-web/src/main/resources/static/admin/inout/in-weight.js
@@ -5,7 +5,8 @@
 var recordData = null;// 涓氬姟鏁版嵁淇℃伅
 var snapData;//绯荤粺鎶撴媿瀵硅薄淇℃伅
 var timerWeight;
-var textParam;//璁惧璇嗗埆缁撴灉
+var paramIntelCard;//璁惧璇嗗埆缁撴灉
+var paramIdCard;//璁惧璇嗗埆缁撴灉
 
 $(function () {
     layui.use(['layer', 'laydate', 'form', 'table', 'util'], function () {
@@ -49,8 +50,7 @@
 
     // 鐩戝惉閲嶉噺鍙樺寲
     $(".weight").blur(function () {
-        var name = this.name;
-        deAutoByIn(name);
+        deAutoByIn(this.name);
     });
 
     // 鍒濆鍖朩ebSocket
@@ -78,7 +78,6 @@
             updateWeight();
         });
     });
-
 };
 
 // socket淇℃伅杩斿洖铏曠悊
@@ -86,108 +85,38 @@
     //鏆傛棤
 }
 
-// 鏍规嵁褰撳墠鎿嶄綔鐨勬寜閽甀D鏇存柊鍏朵粬鎸夐挳鐘舵��
-function flushBtn(btnId) {
-    if ("btn-weight" == btnId) {// 绉伴噸鍚庡彲浠ョ偣鍑诲畬鎴愮О閲�
-        $("#btn-submit").removeClass("layui-btn-disabled");
-        $("#btn-submit").attr("disabled", false);
-    }
-
-    if ("btn-submit" == btnId) {
-        $("#btn-submit").addClass("layui-btn-disabled");
-        $("#btn-submit").attr("disabled", true);
-        if (InoutProgress.WEIGHT_FULL == recordData.progress) {// 濡傛灉鏄弧杞︾О閲嶏紝鍒欑洿鎺ュ綋鍓嶈妭鐐瑰畬鎴�
-            resetForm();
-        } else {
-            // 瀹屾垚绉伴噸鍚庢帶鍒舵寜閽�
-            $("#btn-weight").addClass("layui-btn-disabled");
-            $("#btn-weight").attr("disabled", true);
-
-            $("#btn-printBill").removeClass("layui-btn-disabled");
-            $("#btn-printBill").attr("disabled", false);
-
-            addDisabled();
-        }
-    }
-    if ("btn-printBill" == btnId) {// 鎵撳嵃杩囩鍗曪紝璇存槑涓氬姟瀹屾垚
-        $("#btn-weight").removeClass("layui-btn-disabled");
-        $("#btn-weight").attr("disabled", false);
-
-        $("#btn-submit").addClass("layui-btn-disabled");
-        $("#btn-submit").attr("disabled", true);
-
-        $("#btn-printBill").addClass("layui-btn-disabled");
-        $("#btn-printBill").attr("disabled", true);
-
-        delDisabled();
-        resetForm();
-    }
-}
-
-//鏇存敼鎵i噸淇℃伅妗嗕笉鍙紪杈�
-function addDisabled() {
-    //鏉傝川
-    $("#impurity").attr("disabled", true);
-    $("#deImpurity").attr("disabled", true);
-    //姘村垎
-    $("#wet").attr("disabled", true);
-    $("#deWet").attr("disabled", true);
-    //鍊间粨
-    $("#deHandle").attr("disabled", true);
-    //鍏朵粬
-    $("#deOther").attr("disabled", true);
-}
-
-//鎭㈠鎵i噸淇℃伅妗嗙紪杈戠姸鎬�
-function delDisabled() {
-    //鏉傝川
-    $("#impurity").attr("disabled", false);
-    $("#deImpurity").attr("disabled", false);
-    //姘村垎
-    $("#wet").attr("disabled", false);
-    $("#deWet").attr("disabled", false);
-    //鍊间粨
-    $("#deHandle").attr("disabled", false);
-    //鍏朵粬
-    $("#deOther").attr("disabled", false);
-}
-
-// 鐐瑰嚮绉伴噸
+//鐐瑰嚮绉伴噸
 function weight() {
     // 娌℃湁涓氬姟鏁版嵁涓嶅彲鎵ц
     if (!recordData) {
-        layer.alert("娌℃湁鏌ヨ鍒颁笟鍔℃暟鎹紝鎵ц琚嫆缁濓紒锛�");
+        alertError("娌℃湁鏌ヨ鍒颁笟鍔℃暟鎹紝鎵ц琚嫆缁濓紒");
         return;
     }
-
     // 濡傛灉鏄┖杞︾О閲�
     if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
         form.val("form-data", {
             emptyWeight: weightDto.weight
         });
+        form.render();
     }
-
     // 濡傛灉鏄弧杞︾О閲�
     if (InoutProgress.WEIGHT_FULL == recordData.progress) {
         form.val("form-data", {
             fullWeight: weightDto.weight
         });
+        form.render();
     }
-    form.render();
 
-    // 鐐瑰嚮绉伴噸鏃跺�欒嚜鍔ㄦ姄鎷嶆暟鎹�--澧炲姞閫氱煡淇℃伅
-    layer.msg("绯荤粺鑷姩鎶撴媿淇濈暀璁板綍鈥︹��");
+    // 鐐瑰嚮绉伴噸鑷姩璋冪敤鎶撴媿
     snapData = {
         companyId: companyId,
         deptId: deptId,
         progress: recordData.progress,
         bizType: bizType,
         plateNum: recordData.plateNum,
-
-        id1: (null != snapDto1) ? snapDto1.id : null,
-        id2: (null != snapDto2) ? snapDto2.id : null,
-        id3: (null != snapDto3) ? snapDto3.id : null,
-
+        id1: snapDto1.id,
+        id2: snapDto2.id,
+        id3: snapDto3.id,
         sort: $("#scaleName").val(),
         weight: weightDto.weight
     };
@@ -204,62 +133,57 @@
         success: function (result) {
             layer.close(index);
             if (result.code != "0000") {
-                layer.alert(result.msg);
+                alertError(result.msg);
             } else {
                 snapData = result.data;
             }
         },
         error: function () {
             layer.close(index);
-            layer.msg("鍚庡彴璋冪敤鎴浘澶辫触锛岃閲嶆柊灏濊瘯锛侊紒");
+            alertError("鍚庡彴璋冪敤鎴浘澶辫触锛岃閲嶆柊灏濊瘯");
         }
     });
 
-    //鍏ュ簱绗簩娆$О閲嶆椂璋冪敤璁$畻鏂规硶
+    //濡傛灉鏄浜屾绉伴噸锛岄粯璁ゆ墽琛岃嚜鍔ㄨ绠�
     if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
         deAutoByIn("emptyWeight");
     }
-    flushBtn("btn-weight");
 }
 
-//鏂扮殑璇诲崱鏂瑰紡
+//璇绘櫤鎱у崱
 function flushICCard() {
-	flushICCard1();
+    if (!cardDto.protocol) {
+        flushICCard1();
+    } else {
+        flushICCard2();
+    }
 }
 
 /**
  * 鍗忚璇诲彇鏅烘収鍗�
  */
 function flushICCard2() {
-    var param = JSON.stringify(cardDto);
     var index = layer.load();
+    var param = JSON.stringify(cardDto);
     $.ajax({
         type: "POST",
-        url: "../../inout/api/ic-card-num",
+        url: "../../inout/api/get-icCard",
         dataType: "json",
         contentType: "application/json;charset=UTF-8",
         data: param,
         success: function (result) {
-            if (result.code != "0000") {
-                layer.alert(result.msg, {
-                    offset: ['300px', '300px']
-                });
-            } else {
-                if (result.data.errorMsg) {
-                    layer.alert(result.data.errorMsg, {
-                        offset: ['300px', '300px']
-                    });
-                } else {
-                    $("#intelCard").val(result.data.icCardNo);
-                }
-            }
             layer.close(index);
+            if (result.code != "0000") {
+                alertError(result.msg);
+            } else {
+                paramIntelCard = data;
+                $("#text-param").text("璇嗗埆鍗″彿锛�" + paramIntelCard);
+                flushData(paramIntelCard, null);
+            }
         },
         error: function () {
             layer.close(index);
-            layer.alert("IC鍗¤鍙栧け璐ワ紒", {
-                offset: ['300px', '300px']
-            });
+            alertError("IC鍗¤鍙栧け璐�");
         }
     });
 }
@@ -268,6 +192,7 @@
  * 鏈湴璇诲彇鏅烘収鍗�
  */
 function flushICCard1() {
+    var index = layer.load();
     $("#text-param").val(null);
     $("#form-data")[0].reset();
     form.render();
@@ -282,21 +207,23 @@
         jsonpCallback: "jsonpCallback",
         success: function (json) {
             var data = json.no;
+            layer.close(index);
             if (data === "not found") {
-            	alertError("璇烽噸鏂拌鍗★紒");
+                alertError("璇烽噸鏂拌鍗★紒");
             } else {
-                textParam = data;
-                $("#text-param").text("璇嗗埆鍗″彿锛�" + textParam);
-                flushData();
+                paramIntelCard = data;
+                $("#text-param").text("璇嗗埆鍗″彿锛�" + paramIntelCard);
+                flushData(paramIntelCard, null);
             }
         },
         error: function () {
-        	alertError("IC鍗¤鍙栧嚭閿欙紒");
+            layer.close(index);
+            alertError("IC鍗¤鍙栧嚭閿欙紒");
         }
     });
 }
 
-// 浣跨敤鎻掍欢鑾峰彇鐪佷唤璇�
+// 浣跨敤鎻掍欢鑾峰彇韬唤璇�
 function flushIdCard() {
     var index = layer.load();
     $.ajax({
@@ -311,21 +238,22 @@
             layer.close(index);
             var data = json.content;
             if (data === "not found") {
-                layer.alert("娌℃湁璇诲彇鍒拌韩浠借瘉淇℃伅锛岃鎵嬪姩褰曞叆锛�", {
-                    offset: ['300px', '300px']
-                });
+                alertError("娌℃湁璇诲彇鍒拌韩浠借瘉淇℃伅锛�");
                 return;
             }
-            $("#userId").val(data.idNum);
-            flushData();
+            paramIdCard = data;
+            $("#text-param").text("璇嗗埆韬唤璇侊細" + paramIdCard);
+            flushData(null, paramIdCard);
         },
         error: function () {
-            layer.alert("韬唤璇佽鍙栧け璐ワ紝璇锋墜鍔ㄥ綍鍏ワ紒", {
-                offset: ['300px', '300px']
-            });
+            alertError("娌℃湁璇诲彇鍒拌韩浠借瘉淇℃伅锛�");
             layer.close(index);
         }
     });
+}
+
+function flushByHand() {
+    flushData(null, null);
 }
 
 function flushWeight() {
@@ -385,12 +313,9 @@
                 layer.msg("寮�濮嬫覆鏌撴墦鍗板崟鈥︹��");
                 if (companyId && companyId == "5016") {
                     print5016Weight(result.data);
-                    console.log("5016");
                 } else {
                     printWeight(result.data);
                 }
-                // 鍒锋柊鎸夐挳
-                flushBtn("btn-printBill");
             }
         },
         error: function () {
@@ -413,12 +338,6 @@
     //绉伴噸鍙互澶嶇敤
     $("#btn-weight").removeClass("layui-btn-disabled");
     $("#btn-weight").attr("disabled", false);
-
-    //绌鸿溅鍜屾弧杞﹁閲嶇疆
-    updateEditAndProgress();
-
-    //鎵i噸淇℃伅妗嗘仮澶嶄负鍙紪杈�
-    delDisabled();
 }
 
 function flushPage() {
@@ -430,19 +349,18 @@
 }
 
 // --鏌ヨ鏂规硶,鑾峰彇韬唤璇佸彿銆佸崱鍙枫�佽溅鐗屽彿锛岃繘琛屾煡璇�
-function flushData() {
+function flushData(intelCard, userIdCard) {
     var index = layer.load();
-    var userId2 = $("#userId").val();
-    var intelCard = $("#intelCard").val();
+    var userIdCard = userIdCard;
+    var intelCard = intelCard;
     var plateNum = $("#plateNum").val();
     var param = {
         type: type,
         progress: progress,
         intelCard: intelCard,
-        userId: userId2,
+        userId: userIdCard,
         plateNum: plateNum
     };
-
     $.ajax({
         type: "POST",
         url: "../../basic/inout/inout-query",
@@ -450,66 +368,57 @@
         contentType: "application/json;charset=UTF-8",
         data: JSON.stringify(param),
         success: function (result) {
+            layer.close(index);
             if (result.code != "0000") {
-                notify(result.msg, result.data);
+                notifyProgress(result.msg, result.data);
             } else {
                 recordData = result.data;
                 // 杩斿洖鐨勬暟鎹繘琛岃祴鍊�
                 form.val("form-data", recordData);
                 form.render();
+
                 updateEditAndProgress();
             }
-            layer.close(index);
         },
         error: function () {
             layer.close(index);
-            layer.alert("鏌ヨ澶辫触锛岃閲嶆柊灏濊瘯锛侊紒");
+            alertError("鏌ヨ澶辫触锛岃閲嶆柊灏濊瘯");
         }
     });
 }
 
+
 /**
- * 璺熸柊娴佺▼璇存槑鎻愬績淇℃伅
+ * 鏍规嵁涓氬姟鏁版嵁鏇存柊椤甸潰涓殑鐘舵��
  */
 function updateEditAndProgress() {
-    if (recordData) {
-        if (InoutProgress.WEIGHT_EMPTY == recordData.progress) {
-            $("#emptyWeight").removeClass("rkbk-search-input");
-            $("#emptyWeight").attr("disabled", false);
+    if (!recordData) return true;
+    var curProgress = recordData.progress;
 
-            $("#progress-hand").addClass("active");
-            $("#progress-emptyWeight").addClass("active");
+    //绌鸿溅绉伴噸
+    if (InoutProgress.WEIGHT_EMPTY == curProgress) {
+        $("#progress-hand").addClass("active");
+        $("#progress-emptyWeight").addClass("active");
 
-            $("#fullWeight").addClass("rkbk-search-input");
-            $("#fullWeight").attr("disabled", true);
-        }
-        if (InoutProgress.WEIGHT_FULL == recordData.progress) {
-            $("#fullWeight").removeClass("rkbk-search-input");
-            $("#fullWeight").attr("disabled", false);
+        $("#depotIdLabel").removeClass("color-red");
+    }
 
-            $("#progress-hand").removeClass("active");
-            $("#progress-emptyWeight").removeClass("active");
-
-            $("#emptyWeight").addClass("rkbk-search-input");
-            $("#emptyWeight").attr("disabled", true);
-        }
-    } else {
-        $("#fullWeight").addClass("rkbk-search-input");
-        $("#fullWeight").attr("disabled", true);
-
-        $("#emptyWeight").addClass("rkbk-search-input");
-        $("#emptyWeight").attr("disabled", true);
-
+    //婊¤溅绉伴噸
+    if (InoutProgress.WEIGHT_FULL == curProgress) {
         $("#progress-hand").removeClass("active");
         $("#progress-emptyWeight").removeClass("active");
-    }
-    //鏍规嵁閰嶇疆淇℃伅璁剧疆鍦扮鏄惁鍙紪杈�
-    if (weightEditTag && weightEditTag == 'N') {
-        $("#fullWeight").addClass("rkbk-search-input");
-        $("#fullWeight").attr("disabled", true);
 
-        $("#emptyWeight").addClass("rkbk-search-input");
-        $("#emptyWeight").attr("disabled", true);
+        //瑁呭嵏浠撳簱蹇呭~
+        $("#depotIdLabel").addClass("color-red");
+    }
+
+    //璁剧疆鍙紪杈�
+    if (weightEditTag == 'Y') {
+        $("#fullWeight").removeClass("rkbk-search-input");
+        $("#fullWeight").attr("disabled", false);
+
+        $("#emptyWeight").removeClass("rkbk-search-input");
+        $("#emptyWeight").attr("disabled", false);
     }
 }
 
@@ -574,8 +483,6 @@
                 notify(result.msg, result.data);
             } else {
                 notify("鏁版嵁鎻愪氦鎴愬姛", result.data);
-                // 鏇存柊鎸夐挳鏄剧ず
-                flushBtn("btn-submit");
             }
             layer.close(index);
         },
@@ -607,140 +514,7 @@
     });
 }
 
-
-// ---------------------------閫氱煡鍗�-寮�濮� -------------------//
-// 寮瑰嚭寰�鏉ュ崟浣嶄笅鎷夋
-function showNotice() {
-    var index = layer.load();
-    var param = {
-        type: type
-    };
-    // 娓叉煋寰�鏉ュ崟浣嶅垪琛�
-    table.render({
-        elem: '#tableNotice',
-        url: '../../basic/inout/list-notice鈥攊n',
-        page: false,
-        // skin : "nob",
-        // size : 'sm',
-        even: true,
-        method: 'POST',
-        contentType: "application/json;charset=UTF-8",
-        cols: [[{
-            field: 'name',
-            title: '閫氱煡鍗曞悕绉�',
-            width: '15%'
-        }, {
-            field: 'customerName',
-            title: '閫佽揣鍗曚綅'
-        }, {
-            field: 'foodVarietyName',
-            title: '绮鍝佺',
-            width: '10%'
-        }, {
-            field: 'year',
-            title: '骞翠唤',
-            width: '8%'
-        }, {
-            field: 'unitName',
-            title: '鏀惰揣鍗曚綅'
-        }, {
-            field: 'contractName',
-            title: '鎵�灞炲悎鍚�'
-        }]],
-        where: param,
-        parseData: function (res) {
-            if ("0000" == res.code) {
-                return {
-                    "code": "0",
-                    "msg": res.msg,
-                    "data": res.data
-                }
-            } else {
-                return {
-                    "code": "1",
-                    "msg": res.msg
-                }
-            }
-        },
-        done: function (res) {
-            layer.close(index);
-        }
-    });
-
-    //鍙屽嚮鏄剧ず閫変腑鏁版嵁
-    table.on('rowDouble(tableNotice)', function (obj) {
-        var data = obj.data;
-        form.val("form-data", {
-            customerId: data.customerId,
-            customerName: data.customerName,
-            noticeId: data.id
-        });
-        // 鍏抽棴
-        layer.closeAll();
-    });
-
-    // 寮瑰嚭瀵硅瘽妗�
-    layer.open({
-        type: 1,
-        offset: ['100px', '250px'],
-        title: "鍏ュ簱閫氱煡鍗�",
-        area: ['900px', '600px'],
-        shade: 0,
-        content: $('#listNotice'),
-        btn: 0,
-        btn: ['鍙栨秷'],
-        yes: function () {
-            layer.closeAll();
-        },
-        closeBtn: 0
-    });
-}
-
-// ---------------------------閫氱煡鍗� -缁撴潫 -------------------//
-//-------------------------閬撻椄鎿嶄綔--------------------------//
-
-function gateCtrl() {
-    layer.open({
-        type: 1,
-        title: '璁惧鎿嶄綔-' + domSelectDevice.attr("name"),
-        area: ['450px', '210px'],
-        shade: 0,
-        content: $('#control-gate'),
-        btn: 0,
-        closeBtn: 2
-    });
-}
-
-function controlGate(targetStatus) {
-    if (gateDto) {
-        var data = {
-            "companyId": companyId
-            , "deptId": deptId
-            , "bizType": type
-            , "confId": gateDto.id
-            , "targetStatus": targetStatus
-            , "sort": gateDto.sort
-        };
-        $.ajax({
-            type: "POST",
-            url: "../../basic/inout/gate-ctrl",
-            dataType: "json",
-            contentType: "application/json;charset=UTF-8",
-            data: JSON.stringify(data),
-            success: function (result) {
-                if (result.code != "0000") {
-                    layer.msg("鎿嶄綔澶辫触锛�" + result.msg);
-                } else {
-                    layer.msg("鎿嶄綔鎴愬姛");
-                }
-            },
-            error: function () {
-                layer.alert("鎿嶄綔澶辫触锛岃閲嶆柊灏濊瘯锛侊紒");
-            }
-        });
-    } else {
-        layer.msg("娌℃湁鑾峰彇鍒拌澶囷紒");
-    }
-}
-
-//-------------------------閬撻椄鎿嶄綔--------------------------//
\ No newline at end of file
+//鏄剧ず璐ㄦ淇℃伅
+function showCheck() {
+    alertError("璋冩暣");
+}
\ No newline at end of file

--
Gitblit v1.9.3