Kaynağa Gözat

更改各期统计为sjs

ellisran 2 ay önce
ebeveyn
işleme
290f806c3e
2 değiştirilmiş dosya ile 123 ekleme ve 97 silme
  1. 121 65
      app/public/js/material_exponent.js
  2. 2 32
      app/view/material/exponent.ejs

+ 121 - 65
app/public/js/material_exponent.js

@@ -12,71 +12,6 @@ function getPasteHint (str, row = '') {
     }
     return returnObj;
 }
-let show_node = false;
-function resetExTpTable() {
-    $('#tj_ledger').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
-    $('#tj_ledger').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
-    $('#tj_ledger').children('td').eq(3).text(ZhCalc.add(ex_pre_tp, ZhCalc.round(ex_tp, materialExponentDecimal.tp)));
-    $('#tj_ledger').children('td').eq(4).text(ZhCalc.add(ex_pre_tp_hs, ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp)));
-    $('#total_set').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
-    $('#total_set').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
-    $('#total_set').children('td').eq(3).text(ZhCalc.add(ex_pre_tp, ZhCalc.round(ex_tp, materialExponentDecimal.tp)));
-    $('#total_set').children('td').eq(4).text(ZhCalc.add(ex_pre_tp_hs, ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp)));
-    if (exponent_nodes) {
-        const materialExponentNodeSort = exponent_nodes ? ['-1'].concat(exponent_nodes.split(',')) : [];
-        const map = Object.fromEntries(materialExponentNodeSort.map((v, i) => [v, i]));
-        materialExponentNodeData = materialExponentNodeData.sort((a, b) => map[a.node] - map[b.node]);
-        let html = '';
-        for (const node of materialExponentNodeSort) {
-            const mnList = _.filter(materialExponentNodeData, { node });
-            const one_mn = mnList[0];
-            let total_tp = 0;
-            let total_tax_tp = 0;
-            let total_pre_tp = one_mn.ex_pre_tp || 0;
-            let total_pre_tp_hs = one_mn.ex_tax_pre_tp || 0;
-            // 汇总
-            for (const mn of mnList) {
-                total_tp = ZhCalc.add(total_tp, mn.ex_tp ? mn.ex_tp : 0);
-                total_tax_tp = ZhCalc.add(total_tax_tp, mn.ex_tax_tp ? mn.ex_tax_tp : 0);
-                total_pre_tp = ZhCalc.add(total_pre_tp, mn.ex_tp ? mn.ex_tp : 0);
-                total_pre_tp_hs = ZhCalc.add(total_pre_tp_hs, mn.ex_tax_tp ? mn.ex_tax_tp : 0);
-            }
-            const exprHtml = isStageSelf ? '' : `<a href="javascript:void(0);" data-toggle="tooltip" data-placement="bottom" title="${one_mn.name}(${one_mn.code})价差:${one_mn.ex_expr ? one_mn.ex_expr : ''}"><i class="fa fa-question-circle-o"></i></a>`;
-            html += `<tr id="tj_node_${node}">
-                                                <td class="text-center">${one_mn.name}(${one_mn.code}) ${exprHtml}</td>
-                                                <td class="text-center">${total_tp}</td>
-                                                <td class="text-center">${total_tax_tp}</td>
-                                                <td class="text-center">${total_pre_tp}</td>
-                                                <td class="text-center">${total_pre_tp_hs}</td>
-                                            </tr>`;
-            // if (!show_node) {
-            //     show_node = true;
-            // }
-        }
-        $('#tj_node').html(html);
-        $('[data-toggle="tooltip"]').tooltip();
-    }
-    if (showStageExponent) {
-        $('#total_stage').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
-        $('#total_stage').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
-        for (const ms of materialStageData) {
-            if (!exponent_nodes) {
-                $('.ex_expr_' + ms.order).attr('data-original-title', '第' + ms.order + '期价差:' + (ms.ex_expr ? ms.ex_expr : ''));
-            }
-            $('#tj_stage_' + ms.order).children('td').eq(1).text(ms.ex_tp ? ZhCalc.round(ms.ex_tp, materialExponentDecimal.tp) : '');
-            $('#tj_stage_' + ms.order).children('td').eq(2).text(ms.ex_tax_tp ? ZhCalc.round(ms.ex_tax_tp, materialExponentDecimal.tp) : '');
-        }
-        if (exponent_nodes) {
-            for (const mn of materialExponentNodeData) {
-                $('.ex_expr_node_' + mn.id).attr('data-original-title', mn.name + '价差:' + (mn.ex_expr ? mn.ex_expr : ''));
-                $('#tj_node_' + mn.id).children('td').eq(1).text(mn.ex_tp ? ZhCalc.round(mn.ex_tp, materialExponentDecimal.tp) : '');
-                $('#tj_node_' + mn.id).children('td').eq(2).text(mn.ex_tax_tp ? ZhCalc.round(mn.ex_tax_tp, materialExponentDecimal.tp) : '');
-            }
-        }
-    } else {
-        $('#ex_expr').attr('data-original-title', '本期价差:' + (ex_expr ? ex_expr : ''));
-    }
-}
 $(document).ready(() => {
     autoFlashHeight();
     const materialExponentSpread = SpreadJsObj.createNewSpread($('#material-exponent-spread')[0]);
@@ -142,6 +77,28 @@ $(document).ready(() => {
         },
     };
 
+    const stageTjSpread = SpreadJsObj.createNewSpread($('#stage-tj-spread')[0]);
+    const getTipText = function (data) {
+        if (!data || !data.tip) return '';
+
+        return data.tip;
+    };
+    const stageTjSpreadSetting = {
+        cols: [
+            {title: '计量期数', colSpan: '1', rowSpan: '2', field: 'order', hAlign: 0, width: 250, formatter: '@', cellType: 'delayTip', getTip: getTipText},
+            {title: '本期调差金额', colSpan: '1', rowSpan: '2', field: 'ex_tp', hAlign: 1, width: 200, type: 'Number'},
+            {title: '本期调差金额(建筑税)', colSpan: '1', rowSpan: '2', field: 'ex_tax_tp', hAlign: 1, width: 200, type: 'Number'},
+        ],
+        emptyRows: 0,
+        headRows: 1,
+        headRowHeight: [32],
+        defaultRowHeight: 21,
+        headerFont: '12px 微软雅黑',
+        font: '12px 微软雅黑',
+        readOnly: true,
+    };
+    SpreadJsObj.initSheet(stageTjSpread.getActiveSheet(), stageTjSpreadSetting);
+
     const needUpdateArray = ['weight_num', 'm_price', 'remark'];
 
     const materialExponentSpreadObj = {
@@ -990,6 +947,99 @@ $(document).ready(() => {
         });
     }
 
+    $('a', '[id=material-exponent-tab]').click(function() {
+        setTimeout(refreshRelaSpread, 100);
+    });
+
+    function refreshRelaSpread() {
+        stageTjSpread.refresh();
+    }
+
+    function resetExTpTable() {
+        $('#tj_ledger').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
+        $('#tj_ledger').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
+        $('#tj_ledger').children('td').eq(3).text(ZhCalc.add(ex_pre_tp, ZhCalc.round(ex_tp, materialExponentDecimal.tp)));
+        $('#tj_ledger').children('td').eq(4).text(ZhCalc.add(ex_pre_tp_hs, ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp)));
+        $('#total_set').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
+        $('#total_set').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
+        $('#total_set').children('td').eq(3).text(ZhCalc.add(ex_pre_tp, ZhCalc.round(ex_tp, materialExponentDecimal.tp)));
+        $('#total_set').children('td').eq(4).text(ZhCalc.add(ex_pre_tp_hs, ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp)));
+        if (exponent_nodes) {
+            const materialExponentNodeSort = exponent_nodes ? ['-1'].concat(exponent_nodes.split(',')) : [];
+            const map = Object.fromEntries(materialExponentNodeSort.map((v, i) => [v, i]));
+            materialExponentNodeData = materialExponentNodeData.sort((a, b) => map[a.node] - map[b.node]);
+            let html = '';
+            for (const node of materialExponentNodeSort) {
+                const mnList = _.filter(materialExponentNodeData, { node });
+                const one_mn = mnList[0];
+                let total_tp = 0;
+                let total_tax_tp = 0;
+                let total_pre_tp = one_mn.ex_pre_tp || 0;
+                let total_pre_tp_hs = one_mn.ex_tax_pre_tp || 0;
+                // 汇总
+                for (const mn of mnList) {
+                    total_tp = ZhCalc.add(total_tp, mn.ex_tp ? mn.ex_tp : 0);
+                    total_tax_tp = ZhCalc.add(total_tax_tp, mn.ex_tax_tp ? mn.ex_tax_tp : 0);
+                    total_pre_tp = ZhCalc.add(total_pre_tp, mn.ex_tp ? mn.ex_tp : 0);
+                    total_pre_tp_hs = ZhCalc.add(total_pre_tp_hs, mn.ex_tax_tp ? mn.ex_tax_tp : 0);
+                }
+                const exprHtml = isStageSelf ? '' : `<a href="javascript:void(0);" data-toggle="tooltip" data-placement="bottom" title="${one_mn.name}(${one_mn.code})价差:${one_mn.ex_expr ? one_mn.ex_expr : ''}"><i class="fa fa-question-circle-o"></i></a>`;
+                html += `<tr id="tj_node_${node}">
+                                                <td class="text-center">${one_mn.name}(${one_mn.code}) ${exprHtml}</td>
+                                                <td class="text-center">${total_tp}</td>
+                                                <td class="text-center">${total_tax_tp}</td>
+                                                <td class="text-center">${total_pre_tp}</td>
+                                                <td class="text-center">${total_pre_tp_hs}</td>
+                                            </tr>`;
+            }
+            $('#tj_node').html(html);
+            $('[data-toggle="tooltip"]').tooltip();
+        }
+        if (showStageExponent) {
+            // $('#total_stage').children('td').eq(1).text(ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : '');
+            // $('#total_stage').children('td').eq(2).text(ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : '');
+            const stage_datas = [{
+                order: '合计',
+                ex_tp: ex_tp ? ZhCalc.round(ex_tp, materialExponentDecimal.tp) : 0,
+                ex_tax_tp: ex_tax_tp ? ZhCalc.round(ex_tax_tp, materialExponentDecimal.tp) : 0,
+            }];
+            for (const ms of materialStageData) {
+                if (!exponent_nodes) {
+                    $('.ex_expr_' + ms.order).attr('data-original-title', '第' + ms.order + '期价差:' + (ms.ex_expr ? ms.ex_expr : ''));
+                }
+                // $('#tj_stage_' + ms.order).children('td').eq(1).text(ms.ex_tp ? ZhCalc.round(ms.ex_tp, materialExponentDecimal.tp) : '');
+                // $('#tj_stage_' + ms.order).children('td').eq(2).text(ms.ex_tax_tp ? ZhCalc.round(ms.ex_tax_tp, materialExponentDecimal.tp) : '');
+                stage_datas.push({
+                    order: ' 第' + ms.order + '期',
+                    ex_tp: ms.ex_tp ? ZhCalc.round(ms.ex_tp, materialExponentDecimal.tp) : 0,
+                    ex_tax_tp: ms.ex_tax_tp ? ZhCalc.round(ms.ex_tax_tp, materialExponentDecimal.tp) : 0,
+                    tip: !exponent_nodes ? '第' + ms.order + '期价差:' + (ms.ex_expr ? ms.ex_expr : '') : '',
+                });
+                if (exponent_nodes) {
+                    const mnList = _.filter(materialExponentNodeData, { ms_id: ms.id });
+                    for (const mn of mnList) {
+                        stage_datas.push({
+                            order: '        ' + mn.name + '(' + mn.code + ')',
+                            ex_tp: mn.ex_tp ? ZhCalc.round(mn.ex_tp, materialExponentDecimal.tp) : 0,
+                            ex_tax_tp: mn.ex_tax_tp ? ZhCalc.round(mn.ex_tax_tp, materialExponentDecimal.tp) : 0,
+                            tip: mn.name + '(' + mn.code + ')' + '价差:' + (mn.ex_expr ? mn.ex_expr : ''),
+                        })
+                    }
+                }
+            }
+            // if (exponent_nodes) {
+            //     for (const mn of materialExponentNodeData) {
+            //         $('.ex_expr_node_' + mn.id).attr('data-original-title', mn.name + '价差:' + (mn.ex_expr ? mn.ex_expr : ''));
+            //         $('#tj_node_' + mn.id).children('td').eq(1).text(mn.ex_tp ? ZhCalc.round(mn.ex_tp, materialExponentDecimal.tp) : '');
+            //         $('#tj_node_' + mn.id).children('td').eq(2).text(mn.ex_tax_tp ? ZhCalc.round(mn.ex_tax_tp, materialExponentDecimal.tp) : '');
+            //     }
+            // }
+            SpreadJsObj.loadSheetData(stageTjSpread.getActiveSheet(), SpreadJsObj.DataType.Data, stage_datas);
+        } else {
+            $('#ex_expr').attr('data-original-title', '本期价差:' + (ex_expr ? ex_expr : ''));
+        }
+    }
+
     $.divResizer({
         select: '#right-spr',
         callback: function () {
@@ -1009,6 +1059,7 @@ $(document).ready(() => {
             const cutHeight2 = exponent_nodes ? getObjHeight($('#myTab2')) : 0;
             $('.sjs-height-material').height($('.sjs-height-1').height() - cutHeight - cutHeight2);
             materialExponentSpread.refresh();
+            if (showStageExponent) stageTjSpread.refresh();
             // const height = $('#material-exponent-spread').height();
             setLocalCache('material_exponent2_' + materialID, height);
         }
@@ -1035,6 +1086,7 @@ $(document).ready(() => {
             showSideTools(tab.hasClass('active'));
         }
         materialExponentSpread.refresh();
+        if (showStageExponent) stageTjSpread.refresh();
     });
     // 根据浏览器记录展开收起
     const cutHeight = isStageSelf ? getObjHeight($('#myTab')) : 0;
@@ -1048,6 +1100,7 @@ $(document).ready(() => {
         $('#right-view').width(getLocalCache('material_exponent_' + materialID) + '%');
         showSideTools(tab.hasClass('active'));
         materialExponentSpread.refresh();
+        if (showStageExponent) stageTjSpread.refresh();
     }
     if (getLocalCache('material_exponent2_' + materialID)) {
         // $('#material-exponent-spread').height(getLocalCache('material_exponent2_' + materialID));
@@ -1060,9 +1113,11 @@ $(document).ready(() => {
         // var sjs1 = getObjHeight($('.sjs-height-1'));
         // $(".bcontent-wrap").height($(window).height()-cHeader-sjs1-90+53);
         materialExponentSpread.refresh();
+        if (showStageExponent) stageTjSpread.refresh();
     } else {
         $('.sjs-height-material').height($('.sjs-height-1').height() - cutHeight - cutHeight2);
         materialExponentSpread.refresh();
+        if (showStageExponent) stageTjSpread.refresh();
     }
     function getObjHeight(select) {
         return select.length > 0 ? select.outerHeight(true) : 0;
@@ -1083,6 +1138,7 @@ $(document).ready(() => {
             }
             autoFlashHeight();
             materialExponentSpread.refresh();
+            if (showStageExponent) stageTjSpread.refresh();
         }
     });
 });

+ 2 - 32
app/view/material/exponent.ejs

@@ -82,7 +82,7 @@
                 <div class="bcontent-wrap" id="main-bottom">
                     <div id="main-resize" class="resize-y" r-Type="height" div1=".sjs-height-1" div2=".bcontent-wrap" title="调整大小"><!--调整上下高度条--></div>
                     <div class="bc-bar mb-1">
-                        <ul class="nav nav-tabs">
+                        <ul class="nav nav-tabs" id="material-exponent-tab">
                             <li class="nav-item">
                                 <a class="nav-link active" data-toggle="tab" href="#fysum" role="tab">费用统计</a>
                             </li>
@@ -150,37 +150,7 @@
                         </div>
                         <% if (material.showStageExponent) { %>
                         <div class="tab-pane" id="qidetail">
-                            <div class="sp-wrap" style="max-width: 800px;min-width: 500px;overflow: auto;">
-                                <div class="col-12 p-0">
-                                    <table class="table table-sm table-bordered">
-                                        <tr><th class="text-center">计量期数</th><th class="text-center">本期调差金额</th><th class="text-center">本期调差金额(建筑税)</th></tr>
-                                        <tbody>
-                                        <tr id="total_stage">
-                                            <td>合计</td>
-                                            <td class="text-center"><%= material.ex_tp !== null ? ctx.helper.round(material.ex_tp, material.exponent_decimal.tp) : null %></td>
-                                            <td class="text-center"><%= material.ex_tax_tp !== null ? ctx.helper.round(material.ex_tax_tp, material.exponent_decimal.tp) : null %></td>
-                                        </tr>
-                                        <% for (const ms of materialStageData) { %>
-                                            <tr id="tj_stage_<%- ms.order %>">
-                                                <td>第<%- ms.order %>期 <% if (!material.exponent_node) { %><a href="javascript:void(0);" class="ex_expr_<%- ms.order %>" data-toggle="tooltip" data-placement="bottom" title="第<%- ms.order %>期价差:<%- ms.ex_expr ? ms.ex_expr : '' %>"><i class="fa fa-question-circle-o"></i></a><% } %></td>
-                                                <td class="text-center"><%= ms.ex_tp !== null ? ctx.helper.round(ms.ex_tp, material.exponent_decimal.tp) : null %></td>
-                                                <td class="text-center"><%= ms.ex_tax_tp !== null ? ctx.helper.round(ms.ex_tax_tp, material.exponent_decimal.tp) : null %></td>
-                                            </tr>
-                                            <% if (material.exponent_node) { %>
-                                                <% const mnList = ctx.helper._.filter(materialExponentNodeData, { ms_id: ms.id }); %>
-                                                <% for (const mn of mnList) { %>
-                                                    <tr id="tj_node_<%- mn.id %>">
-                                                        <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<%- mn.name %>(<%- mn.code %>) <a href="javascript:void(0);" class="ex_expr_node_<%- mn.id %>" data-toggle="tooltip" data-placement="bottom" title="<%- mn.name %>(<%- mn.code %>)价差:<%- mn.ex_expr ? mn.ex_expr : '' %>"><i class="fa fa-question-circle-o"></i></a></td>
-                                                        <td class="text-center"><%= mn.ex_tp !== null ? ctx.helper.round(mn.ex_tp, material.exponent_decimal.tp) : null %></td>
-                                                        <td class="text-center"><%= mn.ex_tax_tp !== null ? ctx.helper.round(mn.ex_tax_tp, material.exponent_decimal.tp) : null %></td>
-                                                    </tr>
-                                                <% } %>
-                                            <% } %>
-                                        <% } %>
-                                        </tbody>
-                                    </table>
-                                </div>
-                            </div>
+                            <div class="sp-wrap" id="stage-tj-spread"></div>
                         </div>
                         <% } %>
                     </div>