Browse Source

奖罚金、其他,右侧新增合计数据,设计同甲供材料

MaiXinRong 4 years ago
parent
commit
3ed07b0f60

+ 23 - 0
app/public/js/se_bonus.js

@@ -270,12 +270,31 @@ $(document).ready(() => {
             });
             return cur.indexOf(bonusData) === cur.length - 1;
         }
+        sum () {
+            const result = {
+                tp: 0,
+            };
+            for (const d of this.data) {
+                result.tp = ZhCalc.add(result.tp, d.tp);
+            }
+            return result;
+        }
     }
     const bonusObj = new Bonus();
+    const refreshSum = function () {
+        const sum = bonusObj.sum();
+        const html = [];
+        const getTrHtml = function (name, value) {
+            return '<tr><td>' + name + '</td><td class="text-right">' + (!checkZero(value) ? value : '') + ' </td></tr>';
+        };
+        html.push(getTrHtml('金额', sum.tp));
+        $('#sum').html(html.join(' '));
+    };
 
     postData(window.location.pathname + '/load', null, function (result) {
         bonusObj.loadDatas(result);
         SpreadJsObj.loadSheetData(bonusSheet, SpreadJsObj.DataType.Data, bonusObj.data);
+        refreshSum();
     });
 
     if (!readOnly) {
@@ -322,6 +341,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', {update: datas}, function (result) {
                         bonusObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(bonusSheet);
+                        refreshSum();
                     }, function () {
                         SpreadJsObj.reLoadSheetData(bonusSheet);
                     });
@@ -357,6 +377,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', {del: datas}, function (result) {
                         bonusObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(sheet);
+                        refreshSum();
                     }, function () {
                         SpreadJsObj.reLoadSheetData(sheet);
                     });
@@ -394,6 +415,7 @@ $(document).ready(() => {
                 postData(window.location.pathname + '/update', data, function (result) {
                     bonusObj.loadUpdateData(result);
                     SpreadJsObj.reLoadSheetData(info.sheet);
+                    refreshSum();
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 });
@@ -457,6 +479,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', updateData, function (result) {
                         bonusObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(info.sheet);
+                        refreshSum();
                     });
                 } else {
                     SpreadJsObj.reLoadSheetData(info.sheet);

+ 29 - 0
app/public/js/se_other.js

@@ -162,12 +162,37 @@ $(document).ready(() => {
             this.calculateAll();
             this.resortData();
         }
+        sum () {
+            const result = {
+                total_price: 0,
+                tp: 0,
+                end_tp: 0,
+            };
+            for (const d of this.data) {
+                result.total_price = ZhCalc.add(result.total_price, d.total_price);
+                result.tp = ZhCalc.add(result.tp, d.tp);
+                result.end_tp = ZhCalc.add(result.end_tp, d.end_tp);
+            }
+            return result;
+        }
     }
     const seOtherObj = new SeOther();
+    const refreshSum = function () {
+        const sum = seOtherObj.sum();
+        const html = [];
+        const getTrHtml = function (name, value) {
+            return '<tr><td>' + name + '</td><td class="text-right">' + (!checkZero(value) ? value : '') + ' </td></tr>';
+        };
+        html.push(getTrHtml('金额', sum.total_price));
+        html.push(getTrHtml('本期金额', sum.tp));
+        html.push(getTrHtml('截止本期金额', sum.end_tp));
+        $('#sum').html(html.join(' '));
+    };
 
     postData(window.location.pathname + '/load', null, function (result) {
         seOtherObj.loadDatas(result);
         SpreadJsObj.loadSheetData(otherSheet, SpreadJsObj.DataType.Data, seOtherObj.data);
+        refreshSum();
     });
 
     if (!readOnly) {
@@ -211,6 +236,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', {update: datas}, function (result) {
                         seOtherObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(otherSheet);
+                        refreshSum();
                     }, function () {
                         SpreadJsObj.reLoadSheetData(otherSheet);
                     });
@@ -245,6 +271,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', {del: datas}, function (result) {
                         seOtherObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(otherSheet);
+                        refreshSum();
                     }, function () {
                         SpreadJsObj.reLoadSheetData(otherSheet);
                     });
@@ -282,6 +309,7 @@ $(document).ready(() => {
                 postData(window.location.pathname + '/update', data, function (result) {
                     seOtherObj.loadUpdateData(result);
                     SpreadJsObj.reLoadSheetData(info.sheet);
+                    refreshSum();
                 }, function () {
                     SpreadJsObj.reLoadRowData(info.sheet, info.row);
                 });
@@ -362,6 +390,7 @@ $(document).ready(() => {
                     postData(window.location.pathname + '/update', updateData, function (result) {
                         seOtherObj.loadUpdateData(result);
                         SpreadJsObj.reLoadSheetData(info.sheet);
+                        refreshSum();
                     });
                 } else {
                     SpreadJsObj.reLoadSheetData(info.sheet);

+ 13 - 4
app/view/stage_extra/bonus.ejs

@@ -16,11 +16,20 @@
     </div>
     <div class="content-wrap">
         <div class="c-header p-0"></div>
-        <div class="c-body">
-            <div class="sjs-height-0" id="bonus-spread">
+        <div class="w-100 sub-content row">
+            <div class="c-body col-9">
+                <div class="sjs-height-0" id="bonus-spread">
+                </div>
+                <div z-index="0" style="display: none;">
+                    <input class="datepicker-here form-control form-control-sm" data-date-format="yyyy-MM-DD" data-language="zh" type="text" autocomplete="off" id="dp-input">
+                </div>
             </div>
-            <div z-index="0" style="display: none;">
-                <input class="datepicker-here form-control form-control-sm" data-date-format="yyyy-MM-DD" data-language="zh" type="text" autocomplete="off" id="dp-input">
+            <div class="c-body col-3">
+                <table class="table table-bordered" style="width: 99%">
+                    <tr><th class="text-center" width="66.6%">名称</th><th class="text-center">金额</th></tr>
+                    <tbody id="sum">
+                    </tbody>
+                </table>
             </div>
         </div>
     </div>

+ 13 - 4
app/view/stage_extra/other.ejs

@@ -16,11 +16,20 @@
     </div>
     <div class="content-wrap">
         <div class="c-header p-0"></div>
-        <div class="c-body">
-            <div class="sjs-height-1" id="other-spread" z-index="1">
+        <div class="w-100 sub-content row">
+            <div class="c-body col-9">
+                <div class="sjs-height-1" id="other-spread" z-index="1">
+                </div>
+                <div z-index="0" style="display: none;">
+                    <input class="datepicker-here form-control form-control-sm" data-date-format="yyyy-MM-DD" data-language="zh" type="text" autocomplete="off" id="dp-input">
+                </div>
             </div>
-            <div z-index="0" style="display: none;">
-                <input class="datepicker-here form-control form-control-sm" data-date-format="yyyy-MM-DD" data-language="zh" type="text" autocomplete="off" id="dp-input">
+            <div class="c-body col-3">
+                <table class="table table-bordered" style="width: 99%">
+                    <tr><th class="text-center" width="66.6%">名称</th><th class="text-center">金额</th></tr>
+                    <tbody id="sum">
+                    </tbody>
+                </table>
             </div>
         </div>
     </div>