浏览代码

台账分解、台账修订、计量台账,在表达式中删除表达式问题

MaiXinRong 5 年之前
父节点
当前提交
70b20b9196
共有 5 个文件被更改,包括 54 次插入30 次删除
  1. 14 2
      app/public/js/ledger.js
  2. 11 5
      app/public/js/revise.js
  3. 16 12
      app/public/js/stage.js
  4. 4 2
      app/service/pos.js
  5. 9 9
      app/service/stage_pos.js

+ 14 - 2
app/public/js/ledger.js

@@ -997,14 +997,17 @@ $(document).ready(function() {
                 tender_id: select.tender_id,
                 ledger_id: select.ledger_id
             };
+            const exprInfo = getExprInfo(field);
             if (newValue !== '') {
                 const num = _.toNumber(newValue);
                 if (num) {
                     data[field] = num;
+                    if (exprInfo) {
+                        data[exprInfo.expr] = '';
+                    }
                 } else {
                     try {
                         data[field] = math.evaluate(transExpr(newValue));
-                        const exprInfo = getExprInfo(field);
                         if (exprInfo) {
                             data[exprInfo.expr] = newValue;
                         }
@@ -1015,6 +1018,9 @@ $(document).ready(function() {
                 }
             } else {
                 data[field] = null;
+                if (exprInfo) {
+                    data[exprInfo.expr] = '';
+                }
             }
 
             // 更新至服务器
@@ -1842,14 +1848,17 @@ $(document).ready(function() {
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
             const data = {id: select.id};
+            const exprInfo = getExprInfo(field);
             if (newValue !== '') {
                 const num = _.toNumber(newValue);
                 if (num) {
                     data[field] = num;
+                    if (exprInfo) {
+                        data[exprInfo.expr] = '';
+                    }
                 } else {
                     try {
                         data[field] = math.evaluate(transExpr(newValue));
-                        const exprInfo = getExprInfo(field);
                         if (exprInfo) {
                             data[exprInfo.expr] = newValue;
                         }
@@ -1860,6 +1869,9 @@ $(document).ready(function() {
                 }
             } else {
                 data[field] = null;
+                if (exprInfo) {
+                    data[exprInfo.expr] = '';
+                }
             }
 
             // 更新至服务器

+ 11 - 5
app/public/js/revise.js

@@ -847,14 +847,17 @@ $(document).ready(() => {
                 tender_id: select.tender_id,
                 ledger_id: select.ledger_id
             };
+            const exprInfo = getExprInfo(field);
             if (newValue !== '') {
                 const num = _.toNumber(newValue);
                 if (num) {
                     data[field] = num;
+                    if (exprInfo) {
+                        data[exprInfo.expr] = '';
+                    }
                 } else {
                     try {
                         data[field] = math.evaluate(transExpr(newValue));
-                        const exprInfo = getExprInfo(field);
                         if (exprInfo) {
                             data[exprInfo.expr] = newValue;
                         }
@@ -865,6 +868,9 @@ $(document).ready(() => {
                 }
             } else {
                 data[field] = null;
+                if (exprInfo) {
+                    data[exprInfo.expr] = '';
+                }
             }
 
             // 更新至服务器
@@ -1525,17 +1531,16 @@ $(document).ready(() => {
             if (orgValue === newValue || (!orgValue && newValue == '')) return;
 
             const data = {id: select.id};
+            const exprInfo = getExprInfo(field);
             if (newValue !== '') {
                 const num = _.toNumber(newValue);
                 if (num) {
                     data[field] = num;
+                    if (exprInfo) data[exprInfo.expr] = '';
                 } else {
                     try {
                         data[field] = math.evaluate(transExpr(newValue));
-                        const exprInfo = getExprInfo(field);
-                        if (exprInfo) {
-                            data[exprInfo.expr] = newValue;
-                        }
+                        if (exprInfo) data[exprInfo.expr] = newValue;
                     } catch (err) {
                         toastr.error('输入的表达式非法');
                         return;
@@ -1543,6 +1548,7 @@ $(document).ready(() => {
                 }
             } else {
                 data[field] = null;
+                if (exprInfo) data[exprInfo.expr] = '';
             }
 
             // 更新至服务器

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

@@ -1463,20 +1463,24 @@ $(document).ready(() => {
             if (orgValue === newValue || (!orgValue && newValue == '')) { return; }
 
             const data = {pid: select.id, lid: select.lid};
-            const num = _.toNumber(newValue);
-            if (num) {
-                data[field] = num;
-            } else {
-                try {
-                    data[field] = math.evaluate(transExpr(newValue));
-                    const exprInfo = getExprInfo(field);
-                    if (exprInfo) {
-                        data[exprInfo.expr] = newValue;
+            const exprInfo = getExprInfo(field);
+            if (newValue !== '') {
+                const num = _.toNumber(newValue);
+                if (num) {
+                    data[field] = num;
+                    if (exprInfo) data[exprInfo.expr] = '';
+                } else {
+                    try {
+                        data[field] = math.evaluate(transExpr(newValue));
+                        if (exprInfo) data[exprInfo.expr] = newValue;
+                    } catch (err) {
+                        toastr.error('输入的表达式非法');
+                        return;
                     }
-                } catch (err) {
-                    toastr.error('输入的表达式非法');
-                    return;
                 }
+            } else {
+                data[field] = null;
+                if (exprInfo) data[exprInfo.expr] = '';
             }
 
             // 提交数据到服务器

+ 4 - 2
app/service/pos.js

@@ -32,7 +32,9 @@ module.exports = app => {
         }
 
         async getPosDataWithAddStageOrder(condition) {
-            const sql = 'SELECT p.id, p.tid, p.lid, p.name, p.quantity, p.position, p.drawing_code, p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.porder, p.add_stage, p.add_times, p.add_user, s.order As add_stage_order ' +
+            const sql = 'SELECT p.id, p.tid, p.lid, p.name, p.quantity, p.position, p.drawing_code,' +
+                '    p.sgfh_qty, p.sjcl_qty, p.qtcl_qty, p.porder, p.add_stage, p.add_times, p.add_user, s.order As add_stage_order,' +
+                '    p.sgfh_expr, p.sjcl_expr, p.qtcl_expr' +
                 '  FROM ' + this.tableName + ' p ' +
                 '  LEFT JOIN ' + this.ctx.service.stage.tableName + ' s' +
                 '  ON p.add_stage = s.id'
@@ -42,7 +44,7 @@ module.exports = app => {
 
         async getPosDataByIds(ids) {
             if (ids instanceof Array && ids.length > 0) {
-                const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code, sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user' +
+                const sql = 'SELECT id, tid, lid, name, quantity, position, drawing_code, sgfh_qty, sjcl_qty, qtcl_qty, add_stage, add_times, add_user, sgfh_expr, sjcl_expr, qtcl_expr' +
                     '  FROM ' + this.tableName +
                     '  WHERE id in (' + this.ctx.helper.getInArrStrSqlFilter(ids) + ')';
                 return await this.db.query(sql, []);

+ 9 - 9
app/service/stage_pos.js

@@ -171,9 +171,9 @@ module.exports = app => {
                     if (d.sgfh_qty!== undefined) p.sgfh_qty = this.round(d.sgfh_qty, precision.value);
                     if (d.sjcl_qty!== undefined) p.sjcl_qty = this.round(d.sjcl_qty, precision.value);
                     if (d.qtcl_qty!== undefined) p.qtcl_qty = this.round(d.qtcl_qty, precision.value);
-                    if (d.sgfh_expr) p.sgfh_expr = d.sgfh_expr;
-                    if (d.sjcl_expr) p.sjcl_expr = d.sjcl_expr;
-                    if (d.qtcl_expr) p.qtcl_expr = d.qtcl_expr;
+                    if (d.sgfh_expr !== undefined) p.sgfh_expr = d.sgfh_expr;
+                    if (d.sjcl_expr !== undefined) p.sjcl_expr = d.sjcl_expr;
+                    if (d.qtcl_expr !== undefined) p.qtcl_expr = d.qtcl_expr;
                     p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                     if (!updateBills) updateBills = {id: bills.id, sgfh_qty: bills.sgfh_qty, sjcl_qty: bills.sjcl_qty, qtcl_qty: bills.qtcl_qty};
                 }
@@ -191,7 +191,7 @@ module.exports = app => {
                         order: this.ctx.stage.curOrder,
                     };
                     if (d.contract_qty !== undefined) ps.contract_qty = this.round(d.contract_qty, precision.value);
-                    if (d.contract_expr) p.contract_expr = d.contract_expr;
+                    if (d.contract_expr !== undefined) p.contract_expr = d.contract_expr;
                     if (d.qc_qty!== undefined) ps.qc_qty = this.round(d.qc_qty, precision.value);
                     if (d.postil!== undefined) ps.postil = d.postil;
                     insertPosStage.push(ps);
@@ -278,9 +278,9 @@ module.exports = app => {
                         p.sgfh_qty = d.sgfh_qty !== undefined ? d.sgfh_qty : op.sgfh_qty;
                         p.sjcl_qty = d.sjcl_qty !== undefined ? d.sjcl_qty : op.sjcl_qty;
                         p.qtcl_qty = d.qtcl_qty !== undefined ? d.qtcl_qty : op.qtcl_qty;
-                        if (d.sgfh_expr) p.sgfh_expr = d.sgfh_expr;
-                        if (d.sjcl_expr) p.sjcl_expr = d.sjcl_expr;
-                        if (d.qtcl_expr) p.qtcl_expr = d.qtcl_expr;
+                        if (d.sgfh_expr !== undefined) p.sgfh_expr = d.sgfh_expr;
+                        if (d.sjcl_expr !== undefined) p.sjcl_expr = d.sjcl_expr;
+                        if (d.qtcl_expr !== undefined) p.qtcl_expr = d.qtcl_expr;
                         p.quantity = this.ctx.helper.sum([p.sgfh_qty, p.sjcl_qty, p.qtcl_qty]);
                         if (!updateBills) updateBills = {id: bills.id};
                     }
@@ -295,7 +295,7 @@ module.exports = app => {
                         if (d.contract_qty !== undefined) {
                             sp.contract_qty = this.ctx.helper.round(d.contract_qty, precision.value);
                         }
-                        if (d.contract_expr) sp.contract_expr = d.contract_expr;
+                        if (d.contract_expr !== undefined) sp.contract_expr = d.contract_expr;
                         if (d.qc_qty !== undefined) {
                             sp.qc_qty = this.ctx.helper.round(d.qc_qty, precision.value);
                         }
@@ -315,7 +315,7 @@ module.exports = app => {
                                 ? osp.contract_qty
                                 : this.ctx.helper.round(d.contract_qty, precision.value);
                         }
-                        if (d.contract_expr) sp.contract_expr = d.contract_expr;
+                        if (d.contract_expr !== undefined) sp.contract_expr = d.contract_expr;
                         if (d.qc_qty || osp) {
                             sp.qc_qty = d.qc_qty === undefined && osp
                                 ? osp.qc_qty