Parcourir la source

清单汇总,超计判断,还原

MaiXinRong il y a 7 mois
Parent
commit
31cf550209
2 fichiers modifiés avec 64 ajouts et 44 suppressions
  1. 26 43
      app/public/js/stage_gather.js
  2. 38 1
      app/view/stage/gather.ejs

+ 26 - 43
app/public/js/stage_gather.js

@@ -45,13 +45,13 @@ function generateChapterHtml(data) {
 
 $(document).ready(function () {
     const preUrl = window.location.pathname.split('/').slice(0, 6).join('/');
-    // let per = _.toNumber(getLocalCache('StageGatherOverPercent'));
-    // if (per && !_.isNaN(per)) {
-    //     $('#over-percent').val(per >= 50 ? (per <= 100 ? per : 100) : 50);
-    // }
-    //
-    // let overType = $('#' + getLocalCache('StageGatherOverType'))[0];
-    // if (overType) overType.checked = true;
+    let per = _.toNumber(getLocalCache('StageGatherOverPercent'));
+    if (per && !_.isNaN(per)) {
+        $('#over-percent').val(per >= 50 ? (per <= 100 ? per : 100) : 50);
+    }
+
+    let overType = $('#' + getLocalCache('StageGatherOverType'))[0];
+    if (overType) overType.checked = true;
     autoFlashHeight();
     // 初始化工程量清单
     const gclSpread = SpreadJsObj.createNewSpread($('#gcl-spread')[0]);
@@ -68,18 +68,10 @@ $(document).ready(function () {
     // 初始化所属项目节
     const leafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-spread')[0]);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(leafXmjSpreadSetting);
-    leafXmjSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
-        if (!data) return defaultColor;
-        return data.overRange && hintOver ? spreadColor.stage.over : defaultColor;
-    };
     SpreadJsObj.initSheet(leafXmjSpread.getActiveSheet(), leafXmjSpreadSetting);
 
     const gatherLeafXmjSpread = SpreadJsObj.createNewSpread($('#leaf-xmj-gather-spread')[0]);
     if (thousandth) sjsSettingObj.setTpThousandthFormat(gatherLeafXmjSpreadSetting);
-    gatherLeafXmjSpreadSetting.getColor = function (sheet, data, row, col, defaultColor) {
-        if (!data) return defaultColor;
-        return data.overRange && hintOver ? spreadColor.stage.over : defaultColor;
-    };
     const gatherLeafXmjSheet = gatherLeafXmjSpread.getActiveSheet();
     SpreadJsObj.initSheet(gatherLeafXmjSheet, gatherLeafXmjSpreadSetting);
 
@@ -173,33 +165,14 @@ $(document).ready(function () {
                     : data.end_contract_tp < ZhCalc.mul(data[tpField], per) || data.end_contract_tp > 0;
             }
         };
-        const nPercent = checkOverInfo.coe;
+        const bQty = $('#customRadio1')[0].checked, bDealQty = $('#customRadio2')[0].checked;
+        const nPercent = Math.min(Math.max(ZhCalc.div(parseFloat($('#over-percent').val()), 100), 0.5), 1);
         for (const node of data) {
             if (node) {
-                const bOverRangeTz = checkOverInfo.checkTz ? billsGatherOver(node, 'final_1_qty', 'final_1_tp', nPercent) : false;
-                const bOverRangeDeal = checkOverInfo.checkDeal ? billsGatherOver(node, 'deal_final_1_qty', 'deal_final_1_tp', nPercent) : false;
-                node.overRange = bOverRangeTz || bOverRangeDeal;
-            }
-        }
-    }
-    function checkXmjOverRange(data, checkXmjList) {
-        const xmjGatherOver = function (data, qtyField, per) {
-            if (data.end_contract_qty) {
-                if (!data[qtyField]) return true;
-                return data[qtyField] > 0
-                    ? data.end_contract_qty > ZhCalc.mul(data[qtyField], per)
-                    : data.end_contract_qty < ZhCalc.mul(data[qtyField], per) || data.end_contract_qty > 0;
-            } else {
-                return false;
-            }
-        };
-        const nPercent = checkOverInfo.coe;
-        for (const node of data) {
-            if (!node || !node[checkXmjList] || node[checkXmjList].length === 0) continue;
-            for (const xmj of node[checkXmjList]) {
-                const bOverRangeTz = checkOverInfo.checkTz ? xmjGatherOver(xmj, 'final_1_qty', nPercent) : false;
-                const bOverRangeDeal = false; // checkOverInfo.checkDeal ? xmjGatherOver(xmj, 'deal_final_1_qty', nPercent) : false;
-                xmj.overRange = bOverRangeDeal || bOverRangeTz;
+                if (node.b_code === '103-4')console.log(node);
+                const bOverRangeTz = billsGatherOver(node, 'final_1_qty', 'final_1_tp', nPercent);
+                const bOverRangeDeal = billsGatherOver(node, 'deal_final_1_qty', 'deal_final_1_tp', nPercent);
+                node.overRange = bQty ? bOverRangeTz : (bDealQty ? bOverRangeDeal : bOverRangeTz || bOverRangeDeal);
             }
         }
     }
@@ -208,6 +181,19 @@ $(document).ready(function () {
         const iOldRow = info.oldSelections[0].row, iNewRow = info.newSelections[0].row;
         if (iNewRow !== iOldRow) loadRelaData(iNewRow);
     });
+    $('.custom-radio').click(() => {
+        setLocalCache('StageGatherOverType', $('input[name=customRadio]:checked').attr('id'));
+        checkOverRange(gclGatherData);
+        SpreadJsObj.reLoadSheetData(gclSpread.getActiveSheet());
+        // 收起菜单
+        $('.dropdown-menu').click();
+    });
+    $('#over-percent').change(function () {
+        this.value = this.value >= 50 ? (this.value <= 100 ? ZhCalc.round(this.value, 2) : 100) : 50;
+        setLocalCache('StageGatherOverPercent', this.value);
+        checkOverRange(gclGatherData);
+        SpreadJsObj.reLoadSheetData(gclSpread.getActiveSheet());
+    });
 
     postData(preUrl + '/load', { filter: 'ledger;pos;dealBills;spec;change;stageChange;preStageChange' }, function (result) {
         // 解析清单汇总数据
@@ -221,8 +207,6 @@ $(document).ready(function () {
         gclGatherModel.checkDiffer(gclGatherData);
         gclGatherModel.reGatherLeafXmj();
         checkOverRange(gclGatherData);
-        checkXmjOverRange(gclGatherData, 'leafXmjs');
-        checkXmjOverRange(gclGatherData, 'gatherLeafXmjs');
         // 加载清单数据
         SpreadJsObj.loadSheetData(gclSpread.getActiveSheet(), SpreadJsObj.DataType.Data, gclGatherData);
         loadRelaData(0);
@@ -307,7 +291,6 @@ $(document).ready(function () {
             col.visible = col.type === 'Number' || fields.indexOf(col.field) >= 0;
         }
         gclGatherModel.reGatherLeafXmj(fields);
-        checkXmjOverRange(gclGatherData, 'gatherLeafXmjs');
         SpreadJsObj.refreshColumnVisible(gatherLeafXmjSheet);
         loadGatherLeafXmjData();
     });

+ 38 - 1
app/view/stage/gather.ejs

@@ -5,6 +5,44 @@
             <% include ./stage_sub_mini_menu.ejs %>
             <div>
                 <div class="d-inline-block">
+                    <div class="dropdown">
+                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
+                            超计显示
+                        </button>
+                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" style="width:290px">
+                            <span class="dropdown-item-text text-danger">截止本期合同计量 大于</span>
+                            <form class="px-4 py-3">
+                                <div class="form-group">
+                                    <div class="custom-control custom-radio">
+                                        <input type="radio" id="customRadio1" name="customRadio" class="custom-control-input" checked="">
+                                        <label class="custom-control-label" for="customRadio1">台账数量</label>
+                                    </div>
+                                </div>
+                                <div class="form-group">
+                                    <div class="custom-control custom-radio">
+                                        <input type="radio" id="customRadio2" name="customRadio" class="custom-control-input">
+                                        <label class="custom-control-label" for="customRadio2">签约清单数量</label>
+                                    </div>
+                                </div>
+                                <div class="form-group mb-0">
+                                    <div class="custom-control custom-radio">
+                                        <input type="radio" id="customRadio3" name="customRadio" class="custom-control-input">
+                                        <label class="custom-control-label" for="customRadio3">台账数量 或 签约清单数量</label>
+                                    </div>
+                                </div>
+                            </form>
+                            <span class="dropdown-item-text text-danger">
+                            <div class="input-group input-group-sm">
+                                <input type="number" step="5" class="form-control form-control-sm m-0" placeholder="100" max="100" min="50" id="over-percent" value="100">
+                                <div class="input-group-append">
+                                    <span class="input-group-text" id="basic-addon2">%</span>
+                                </div>
+                            </div>
+                        </span>
+                        </div>
+                    </div>
+                </div>
+                <div class="d-inline-block">
                     <button href="#zjhj" class="btn btn-sm btn-light text-primary" data-toggle="modal" data-target="#zjhj">章节合计</button>
                 </div>
                 <% if (ctx.app.config.is_debug) { %>
@@ -102,6 +140,5 @@
     const chapter = JSON.parse('<%- JSON.stringify(ctx.tender.info.chapter) %>');
     const thousandth = <%- ctx.tender.info.display.thousandth %>;
     const hintOver = <%- hintOver %>;
-    const checkOverInfo = JSON.parse('<%- JSON.stringify(ctx.tender.info.checkOverInfo) %>');
     const tenderDecimal = JSON.parse(unescape('<%- escape(JSON.stringify(ctx.tender.info.decimal)) %>'));
 </script>