فهرست منبع

1. 合同支付,扣款限额相关
2. 台账分解,右键新增、删除,控制可用

MaiXinRong 5 سال پیش
والد
کامیت
33785908b9
6فایلهای تغییر یافته به همراه54 افزوده شده و 16 حذف شده
  1. 7 3
      app/lib/pay_calc.js
  2. 1 1
      app/middleware/stage_check.js
  3. 40 8
      app/public/js/ledger.js
  4. 3 2
      app/public/js/stage_pay.js
  5. 1 1
      app/service/pos.js
  6. 2 1
      app/service/stage_pay.js

+ 7 - 3
app/lib/pay_calc.js

@@ -165,16 +165,20 @@ class PayCalculate {
                         const value = this.ctx.helper.round(this.calculateTpExpr(p, first, addRela), this.decimal);
                         if (p.rprice) {
                             if (this.checkDeadline(p, addRela)) {
-                                p.tp = this.ctx.helper.sub(p.rprice, p.pre_total_price);
+                                p.tp = this.ctx.helper.sub(p.rprice, p.pre_tp);
                             } else {
-                                p.tp = Math.min(this.ctx.helper.sub(p.rprice, p.pre_total_price), value);
+                                p.tp = Math.min(this.ctx.helper.sub(p.rprice, p.pre_tp), value);
                             }
                         } else {
                             p.tp = value;
                         }
                     } else if (p.tp && !this.ctx.helper.checkZero(p.tp)) {
                         if (p.rprice) {
-                            p.tp = Math.min(this.ctx.helper.sub(p.rprice, p.pre_total_price), this.ctx.helper.round(p.tp, this.decimal));
+                            if (this.checkDeadline(p, addRela)) {
+                                p.tp = this.ctx.helper.sub(p.rprice, p.pre_tp);
+                            } else {
+                                p.tp = Math.min(this.ctx.helper.sub(p.rprice, p.pre_tp), this.ctx.helper.round(p.tp, this.decimal));
+                            }
                         } else {
                             p.tp = this.ctx.helper.round(p.tp, this.decimal);
                         }

+ 1 - 1
app/middleware/stage_check.js

@@ -53,7 +53,7 @@ module.exports = options => {
             const accountId = this.session.sessionUser.accountId, auditorIds = _.map(stage.auditors, 'aid'), shareIds = [];
             if (accountId === stage.user_id) { // 原报
                 if (stage.curAuditor) {
-                    stage.readOnly = stage.status === status.checking && stage.curAuditor.user_id === accountId;
+                    stage.readOnly = stage.curAuditor.aid !== accountId;
                 } else {
                     stage.readOnly = stage.status !== status.uncheck && stage.status !== status.checkNo;
                 }

+ 40 - 8
app/public/js/ledger.js

@@ -667,12 +667,28 @@ $(document).ready(function() {
                     callback: function (key, opt) {
                         treeOperationObj.addNode(ledgerSpread.getActiveSheet());
                     },
-                    visible: function(key, opt){
+                    disabled: function (key, opt) {
                         const sheet = ledgerSpread.getActiveSheet();
                         const selection = sheet.getSelections();
-                        const row = selection[0].row;
-                        const select = ledgerTree.nodes[row];
-                        return select;
+                        const sel = selection ? selection[0] : sheet.getSelections()[0];
+                        const row = sel ? sel.row : -1;
+                        const tree = sheet.zh_tree;
+                        if (!tree) return true;
+                        const first = sheet.zh_tree.nodes[row];
+                        let last = first, sameParent = true;
+                        if (sel.rowCount > 1) {
+                            for (let r = 1; r < sel.rowCount; r++) {
+                                const rNode = tree.nodes[sel.row + r];
+                                if (rNode.level > first.level) continue;
+                                if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
+                                    sameParent = false;
+                                    break;
+                                }
+                                last = rNode;
+                            }
+                        }
+                        const valid = !sheet.zh_setting.readOnly;
+                        return !(valid && first && first.level > 1);
                     }
                 },
                 'delete': {
@@ -681,12 +697,28 @@ $(document).ready(function() {
                     callback: function (key, opt) {
                         treeOperationObj.deleteNode(ledgerSpread.getActiveSheet());
                     },
-                    visible: function (key, opt) {
+                    disabled: function (key, opt) {
                         const sheet = ledgerSpread.getActiveSheet();
                         const selection = sheet.getSelections();
-                        const row = selection[0].row;
-                        const select = ledgerTree.nodes[row];
-                        return select;
+                        const sel = selection ? selection[0] : sheet.getSelections()[0];
+                        const row = sel ? sel.row : -1;
+                        const tree = sheet.zh_tree;
+                        if (!tree) return true;
+                        const first = sheet.zh_tree.nodes[row];
+                        let last = first, sameParent = true;
+                        if (sel.rowCount > 1) {
+                            for (let r = 1; r < sel.rowCount; r++) {
+                                const rNode = tree.nodes[sel.row + r];
+                                if (rNode.level > first.level) continue;
+                                if ((rNode.level < first.level) || (rNode.level === first.level && rNode.pid !== first.pid)) {
+                                    sameParent = false;
+                                    break;
+                                }
+                                last = rNode;
+                            }
+                        }
+                        const valid = !sheet.zh_setting.readOnly;
+                        return !(valid && first && sameParent && first.level > 1 && !first.node_type);
                     }
                 },
                 'copyBlock': {

+ 3 - 2
app/public/js/stage_pay.js

@@ -133,7 +133,7 @@ $(document).ready(() => {
                 return data.ptype !== 1;
             },
             isOld: function (data) {
-                if (data.csorder === 0) {
+                if (data.csorder === 0 && payCol.readOnly.isYB(data)) {
                     return stage.order > 1 || stage.times > 1 || stage.curOrder > 0;
                 } else {
                     return stage.order > data.csorder || stage.times > data.cstimes || stage.curOrder > data.csaorder;
@@ -208,7 +208,8 @@ $(document).ready(() => {
             const sheet = paySpread.getActiveSheet();
             const select = SpreadJsObj.getSelectObject(sheet);
             setObjEnable($('#add'), !readOnly);
-            setObjEnable($('#del'), !readOnly && select);
+            setObjEnable($('#del'), !readOnly && select && (!payCol.readOnly.isOld(select) ||
+                (!payCol.readOnly.isStarted(select) && payCol.readOnly.isYB(select))));
             setObjEnable($('#up-move'), !readOnly && select && select.ptype === 1 && dealPay.indexOf(select) > 3);
             setObjEnable($('#down-move'), !readOnly && select && select.ptype === 1 && dealPay.indexOf(select) < dealPay.length - 1);
         },

+ 1 - 1
app/service/pos.js

@@ -38,7 +38,7 @@ module.exports = app => {
 
         async getPosDataByIds(ids) {
             if (ids instanceof Array && ids.length > 0) {
-                const sql = 'SELECT id, tid, lid, name, quantity, drawing_code, sgfh_qty, sjcl_qty, qtcl_qty' +
+                const sql = 'SELECT id, tid, lid, name, quantity, drawing_code, sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user' +
                     '  FROM ' + this.tableName +
                     '  WHERE id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ')';
                 return await this.db.query(sql, []);

+ 2 - 1
app/service/stage_pay.js

@@ -103,9 +103,10 @@ module.exports = app => {
                     const sp = this._.find(stagePays, {pid: pp.pid});
                     sp.name = pp.name;
                     sp.expr = pp.expr;
-                    sp.pre_tp= pp.end_tp;
+                    sp.pre_tp = pp.end_tp;
                     sp.pause = pp.pause;
                     sp.pre_used = pp.pre_used || !this.ctx.helper.checkZero(pp.tp);
+                    sp.pre_finish = pp.rprice ? pp.end_tp === pp.rprice : false;
                 }
             }
             let result;