소스 검색

部位台账,查找定位,超计判断调整

MaiXinRong 5 년 전
부모
커밋
ccc2cc737e
2개의 변경된 파일44개의 추가작업 그리고 38개의 파일을 삭제
  1. 13 37
      app/public/js/ledger_search.js
  2. 31 1
      app/public/js/stage_bwtz.js

+ 13 - 37
app/public/js/ledger_search.js

@@ -160,18 +160,10 @@
             const sortData = SpreadJsObj.getSortData(searchSheet);
             for (const node of sortData) {
                 if (node.children && node.children.length > 0) continue;
-                if (node.end_gather_qty) {
-                    if (!node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty))) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
-                } else if (node.end_gather_tp) {
-                    if (!node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp))) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
+                if (setting.checkOver && setting.checkOver(node)) {
+                    const data = JSON.parse(JSON.stringify(node));
+                    data.visible = true;
+                    searchResult.push(data);
                 }
             }
             calculateCompletePercent(searchResult);
@@ -182,18 +174,10 @@
             const sortData = SpreadJsObj.getSortData(searchSheet);
             for (const node of sortData) {
                 if (node.children && node.children.length > 0) continue;
-                if (node.quantity) {
-                    if (!node.end_gather_qty || checkZero(node.end_gather_qty)) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
-                } else if (node.total_price) {
-                    if (!node.end_gather_tp || checkZero(node.end_gather_tp)) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
+                if (setting.checkEmpty && setting.checkEmpty(node)) {
+                    const data = JSON.parse(JSON.stringify(node));
+                    data.visible = true;
+                    searchResult.push(data);
                 }
             }
             calculateCompletePercent(searchResult);
@@ -204,23 +188,15 @@
             const sortData = SpreadJsObj.getSortData(searchSheet);
             for (const node of sortData) {
                 if (node.children && node.children.length > 0) continue;
-                if (node.quantity) {
-                    if (ZhCalc.sub(ZhCalc.add(node.quantity, node.end_qc_qty), node.end_gather_qty) > 0) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
-                } else if (node.total_price) {
-                    if (ZhCalc.sub(ZhCalc.add(node.total_price, node.end_qc_tp), node.end_gather_tp) > 0) {
-                        const data = JSON.parse(JSON.stringify(node));
-                        data.visible = true;
-                        searchResult.push(data);
-                    }
+                if (setting.checkLess && setting.checkLess(node)) {
+                    const data = JSON.parse(JSON.stringify(node));
+                    data.visible = true;
+                    searchResult.push(data);
                 }
             }
             calculateCompletePercent(searchResult);
             SpreadJsObj.loadSheetData(resultSpread.getActiveSheet(), 'data', searchResult);
-        }
+        };
 
         $('input', this.obj).bind('keydown', function (e) {
             if (e.keyCode == 13) searchBills();

+ 31 - 1
app/public/js/stage_bwtz.js

@@ -158,7 +158,37 @@ $(document).ready(() => {
                         },
                         afterLocated: function () {
                             unitTreeObj.loadCurUnitData();
-                        }
+                        },
+                        checkLess: function (node) {
+                            if (node.quantity) {
+                                return ZhCalc.sub(ZhCalc.add(node.quantity, node.end_qc_qty), node.end_gather_qty) > 0;
+                            } else if (node.total_price) {
+                                return ZhCalc.sub(ZhCalc.add(node.total_price, node.end_qc_tp), node.end_gather_tp) > 0;
+                            }
+                        },
+                        checkOver: function (node) {
+                            if (node.unitTree) {
+                                for (const u of node.unitTree.nodes) {
+                                    if (u.end_gather_qty) {
+                                        if (ZhCalc.sub(u.end_contract_qty, u.quantity) > 0) return true;
+                                    } else if (u.end_gather_tp) {
+                                        if (ZhCalc.sub(u.end_contract_tp, u.total_price) > 0) return true;
+                                    }
+                                }
+                                return false;
+                            } else if (node.end_gather_qty) {
+                                return !node.quantity || Math.abs(node.end_gather_qty) > Math.abs(ZhCalc.add(node.quantity, node.end_qc_qty));
+                            } else if (node.end_gather_tp) {
+                                return !node.total_price || Math.abs(node.end_gather_tp) > Math.abs(ZhCalc.add(node.total_price, node.end_qc_tp));
+                            }
+                        },
+                        checkEmpty: function (node) {
+                            if (node.quantity) {
+                                return !node.end_gather_qty || checkZero(node.end_gather_qty);
+                            } else if (node.total_price) {
+                                return !node.end_gather_tp || checkZero(node.end_gather_tp);
+                            }
+                        },
                     });
                 }
                 xmjSearch.spread.refresh();