Selaa lähdekoodia

1. 清单、部位明细,缓存本期是否使用
2. 合同支付,缓存上期是否使用

MaiXinRong 5 vuotta sitten
vanhempi
commit
3efcfb046a

+ 16 - 0
app/public/js/stage.js

@@ -1181,6 +1181,22 @@ $(document).ready(() => {
                 }
             }
         })
+    } else {
+        $.contextMenu({
+            selector: '#stage-pos',
+            build: function ($trigger, e) {
+                const target = SpreadJsObj.safeRightClickSelection($trigger, e, spSpread);
+                return target.hitTestType === spreadNS.SheetArea.viewport || target.hitTestType === spreadNS.SheetArea.rowHeader;
+            },
+            items: {
+                'debug': {
+                    name: 'debug',
+                    callback: function (key, opt) {
+                        console.log(SpreadJsObj.getSelectObject(spSpread.getActiveSheet()));
+                    }
+                }
+            }
+        })
     }
     $.subMenu({
         menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',

+ 14 - 8
app/service/stage_bills_final.js

@@ -89,23 +89,29 @@ module.exports = app => {
                     const p = this.ctx.helper._.find(pre, function (x) {
                         return x.lid === c.lid;
                     });
-                    if (!p) continue;
-                    c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
-                    c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
-                    c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
-                    c.qc_tp = this.ctx.helper.add(c.qc_tp, p.qc_tp);
-                    pre.splice(pre.indexOf(p), 1);
+                    if (p) {
+                        c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
+                        c.contract_tp = this.ctx.helper.add(c.contract_tp, p.contract_tp);
+                        c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
+                        c.qc_tp = this.ctx.helper.add(c.qc_tp, p.qc_tp);
+                        c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                        pre.splice(pre.indexOf(p), 1);
+                    } else {
+                        c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                    }
                 }
 
                 //await transaction.insert(this.tableName, cur);
                 for (const p of pre) {
                     p.sid = stage.id;
                     p.sorder = stage.order;
+                    p.used = p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty);
                 }
                 await transaction.insert(this.tableName, cur.concat(pre));
             } else {
-                const sql = 'Insert Into ??(tid, sid, lid, sorder, contract_qty, contract_tp, qc_qty, qc_tp)' +
-                    '  SELECT b.tid, b.sid, b.lid, ? As `sorder`, b.contract_qty, b.contract_tp, b.qc_qty, b.qc_tp' +
+                const sql = 'Insert Into ??(tid, sid, lid, sorder, contract_qty, contract_tp, qc_qty, qc_tp, used)' +
+                    '  SELECT b.tid, b.sid, b.lid, ? As `sorder`, b.contract_qty, b.contract_tp, b.qc_qty, b.qc_tp,' +
+                    '    IFNULL((b.contract_qty <> 0 or b.contract_tp <> 0 or b.qc_qty <> 0 or b.qc_tp <> 0), 0) As used' +
                     '  FROM ' + this.ctx.service.stageBills.tableName + ' AS b' +
                     '  INNER JOIN(' +
                     '    SELECT Max(`times` * ' + timesLen + ' + `order`) As `flow`, `lid` FROM ' + this.ctx.service.stageBills.tableName +

+ 1 - 0
app/service/stage_pay.js

@@ -104,6 +104,7 @@ module.exports = app => {
                     sp.expr = pp.expr;
                     sp.pre_tp= pp.end_tp;
                     sp.pause = pp.pause;
+                    sp.pre_used = pp.pre_used || !this.ctx.helper.checkZero(pp.tp);
                 }
             }
             let result;

+ 1 - 1
app/service/stage_pos.js

@@ -94,7 +94,7 @@ module.exports = app => {
                 const key = 'sp-' + sp.pid;
                 const spi = stagePosIndex[key];
                 if (spi) {
-                    if ((spi.times * timesLen + spi.order) < (sp.times * timesLen + spi.order)) stagePosIndex[key] = sp;
+                    if ((spi.times * timesLen + spi.order) < (sp.times * timesLen + sp.order)) stagePosIndex[key] = sp;
                 } else {
                     stagePosIndex[key] = sp;
                 }

+ 12 - 6
app/service/stage_pos_final.js

@@ -73,20 +73,26 @@ module.exports = app => {
                     const p = this.ctx.helper._.find(pre, function (x) {
                         return x.pid === c.pid;
                     });
-                    if (!p) continue;
-                    c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
-                    c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
-                    pre.splice(pre.indexOf(p), 1);
+                    if (p) {
+                        c.contract_qty = this.ctx.helper.add(c.contract_qty, p.contract_qty);
+                        c.qc_qty = this.ctx.helper.add(c.qc_qty, p.qc_qty);
+                        c.used = p.used || !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                        pre.splice(pre.indexOf(p), 1);
+                    } else {
+                        c.used = !this.ctx.helper.checkZero(c.contract_qty) || !this.ctx.helper.checkZero(c.qc_qty);
+                    }
                 }
                 //await transaction.insert(this.tableName, cur);
                 for (const p of pre) {
                     p.sid = stage.id;
                     p.sorder = stage.order;
+                    p.used = p.used || !this.ctx.helper.checkZero(p.contract_qty) || !this.ctx.helper.checkZero(p.qc_qty);
                 }
                 await transaction.insert(this.tableName, cur.concat(pre));
             } else {
-                const sql = 'Insert Into ??(tid, sid, lid, pid, sorder, contract_qty, qc_qty)' +
-                            '  SELECT p.tid, p.sid, p.lid, p.pid, ? As `sorder`, p.contract_qty, p.qc_qty' +
+                const sql = 'Insert Into ??(tid, sid, lid, pid, sorder, contract_qty, qc_qty, used)' +
+                            '  SELECT p.tid, p.sid, p.lid, p.pid, ? As `sorder`, p.contract_qty, p.qc_qty,' +
+                            '    IFNULL((p.contract_qty <> 0 or p.qc_qty <> 0), 0) As used' +
                             '  FROM ' + this.ctx.service.stagePos.tableName + ' AS p' +
                             '  INNER JOIN(' +
                             '    SELECT Max(`times` * ' + timesLen +' + `order`) As `flow`, `pid` FROM ' + this.ctx.service.stagePos.tableName +