MaiXinRong 2 rokov pred
rodič
commit
4ccdbfbe8c

+ 1 - 1
Dockerfile

@@ -4,7 +4,7 @@ COPY . /app/calc
 
 WORKDIR /app/calc
 
-RUN npm install --registery=https://registery.npm.taobao.org
+RUN npm install --registery=https://registry.npmmirror.com
 
 EXPOSE 7005
 

+ 58 - 9
app/public/js/se_bonus.js

@@ -217,20 +217,32 @@ $(document).ready(() => {
     class Bonus {
         constructor () {
             this.data = [];
+            this.displayData = [];
+            this._curOnlyKey = 'se_bonus_' + window.location.pathname.split('/')[2];
+            const cache = getLocalCache(this._curOnlyKey);
+            this._curOnly = cache && cache === 'true' ? true : false;
         }
         resortData() {
             this.data.sort(function (a, b) {
                 return a.sorder !== b.sorder ? a.sorder - b.sorder : a.order - b.order;
             });
         }
+        refreshDisplay() {
+            this.displayData.length = 0;
+            for (const d of this.data) {
+                if (!this._curOnly || d.sid === stageId) this.displayData.push(d);
+            }
+        }
         loadDatas(datas) {
             this.data = datas;
             this.resortData();
+            this.refreshDisplay();
         }
         loadUpdateData(updateData) {
             if (updateData.add) {
                 for (const a of updateData.add) {
                     this.data.push(a);
+                    this.displayData.push(a);
                 }
             }
             if (updateData.update) {
@@ -242,6 +254,7 @@ $(document).ready(() => {
                         _.assign(d, u);
                     } else {
                         this.data.push(d);
+                        this.displayData.push(d);
                     }
                 }
             }
@@ -249,6 +262,9 @@ $(document).ready(() => {
                 _.remove(this.data, function (d) {
                     return updateData.del.indexOf(d.id) >= 0;
                 });
+                _.remove(this.displayData, function (d) {
+                    return updateData.del.indexOf(d.id) >= 0;
+                });
             }
             this.resortData();
         }
@@ -271,30 +287,58 @@ $(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);
+            const result = [];
+            const sum = { name: '合计', positive_tp: 0, negative_tp: 0 };
+            for (const d of this.displayData) {
+                if (d.b_type) {
+                    let type = result.find(x => { return d.b_type === x.name; });
+                    if (!type) {
+                        type = { name: d.b_type, positive_tp: 0, negative_tp: 0 };
+                        result.push(type);
+                    }
+                    if (d.tp >= 0) {
+                        type.positive_tp = ZhCalc.add(type.positive_tp, d.tp);
+                    } else {
+                        type.negative_tp = ZhCalc.add(type.negative_tp, d.tp);
+                    }
+                }
+                if (d.tp >= 0) {
+                    sum.positive_tp = ZhCalc.add(sum.positive_tp, d.tp);
+                } else {
+                    sum.negative_tp = ZhCalc.add(sum.negative_tp, d.tp);
+                }
             }
+            result.push(sum);
+            result.forEach(x => { x.tp = ZhCalc.add(x.positive_tp, x.negative_tp); });
             return result;
         }
+        set curOnly(b) {
+            this._curOnly = b;
+            setLocalCache(this._curOnlyKey, this._curOnly);
+            this.refreshDisplay();
+        }
+        get curOnly() {
+            return this._curOnly;
+        }
     }
     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>';
+        const getTrHtml = function (s) {
+            return `<tr><td>${s.name}</td><td class="text-right">${s.positive_tp || ''}</td><td class="text-right">${s.negative_tp || ''}</td><td class="text-right">${s.tp || ''}</td></tr>`;
         };
-        html.push(getTrHtml('金额', sum.tp));
+        for (const s of sum) {
+            html.push(getTrHtml(s));
+        }
         $('#sum').html(html.join(' '));
     };
 
     postData(window.location.pathname + '/load', null, function (result) {
         bonusObj.loadDatas(result);
-        SpreadJsObj.loadSheetData(bonusSheet, SpreadJsObj.DataType.Data, bonusObj.data);
+        SpreadJsObj.loadSheetData(bonusSheet, SpreadJsObj.DataType.Data, bonusObj.displayData);
         refreshSum();
+        $('#cur-only')[0].checked = bonusObj.curOnly;
     });
 
     if (!readOnly) {
@@ -590,4 +634,9 @@ $(document).ready(() => {
     });
     $('#upload-file').change(fileObj.uploadFile);
     $('body').on('click', '.delete-att', fileObj.deleteFile);
+    $('#cur-only').change(function (){
+        bonusObj.curOnly = this.checked;
+        SpreadJsObj.reLoadSheetData(bonusSheet);
+        refreshSum();
+    })
 });

+ 7 - 2
app/view/stage_extra/bonus.ejs

@@ -4,7 +4,12 @@
         <div class="title-main d-flex">
             <% include ./sub_mini_menu.ejs %>
             <div>
-                奖罚金
+                <a class="btn btn-sm btn-light">
+                    <div class="custom-control custom-checkbox">
+                        <input type="checkbox" class="custom-control-input" id="cur-only">
+                        <label class="custom-control-label text-primary" for="cur-only">只显示本期</label>
+                    </div>
+                </a>
             </div>
             <% if (ctx.app.config.is_debug) { %>
             <div class="d-inline-block ml-3">
@@ -26,7 +31,7 @@
             </div>
             <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>
+                    <tr><th class="text-center" width="50%">类型</th><th class="text-center">奖金</th><th class="text-center">罚金</th><th class="text-center">合计</th></tr>
                     <tbody id="sum">
                     </tbody>
                 </table>

+ 6 - 0
sql/update.2022115.sql

@@ -0,0 +1,6 @@
+ALTER TABLE `zh_s2b_spec_msg`
+ADD COLUMN `push_count`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行推送数量' AFTER `status`;
+-- 以上于2022/11/2更新uat、prod,下次更新时,不可执行
+
+ALTER TABLE `zh_cooperation_confirm`
+ADD COLUMN `locked`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否锁定' AFTER `create_time`;

+ 0 - 6
sql/update.sql

@@ -1,8 +1 @@
-ALTER TABLE `zh_s2b_spec_msg`
-ADD COLUMN `push_count`  int(11) UNSIGNED NOT NULL DEFAULT 0 COMMENT '执行推送数量' AFTER `status`;
-
-ALTER TABLE `zh_cooperation_confirm`
-ADD COLUMN `locked`  tinyint(4) UNSIGNED NOT NULL DEFAULT 0 COMMENT '是否锁定' AFTER `create_time`;
-
 ALTER TABLE `zh_project_account` CHANGE `stamp_path` `stamp_path` VARCHAR(5000) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '用户签章oss地址';