Преглед изворни кода

1. spreadjs树结构添加min代码版本
2. 修改参数取值接口,允许输入空值

MaiXinRong пре 7 година
родитељ
комит
2113e80437

+ 4 - 4
app/extend/helper.js

@@ -338,19 +338,19 @@ module.exports = {
             } else {
                 const rpnArr = this.parse2Rpn(expr);
                 const result = this.evalRpn(rpnArr);
-                return result === Infinity ? NaN : result;
+                return result === Infinity ? null : result;
             }
         } catch (err) {
-            return NaN;
+            return null;
         }
     },
 
     calcExprStr(expr) {
         try {
             const result = mathjs.eval(expr);
-            return result === Infinity ? NaN : result;
+            return result === Infinity ? null : result;
         } catch (err) {
-            return NaN;
+            return null;
         }
     }
 };

Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
app/public/js/path_tree.min.js


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
app/public/js/spreadjs_rela/extend_celltype.min.js


Разлика између датотеке није приказан због своје велике величине
+ 1 - 0
app/public/js/spreadjs_rela/spreadjs_zh.min.js


+ 26 - 7
app/service/tender_param.js

@@ -22,7 +22,15 @@ module.exports = app => {
             this.tableName = 'tender_param';
         }
 
-
+        /**
+         * 计算指标节点下全部指标
+         * @param transaction - 事务
+         * @param {Object} condition - 计算范围
+         * @param {Array} globalParams - 可用全局参数
+         * @param {Object} newParam - 更新的节点参数
+         * @returns {Promise<void>}
+         * @private
+         */
         async _calculateNodeIndex(transaction, condition, globalParams, newParam) {
             const nodeParams = await this.ctx.service.tenderParam.getAllDataByCondition({where: condition});
             const nodeIndexes = await this.ctx.service.tenderIndex.getAllDataByCondition({where: condition});
@@ -43,17 +51,27 @@ module.exports = app => {
             }
         }
 
+        /**
+         * 计算标段内全部指标
+         * @param transaction - 事务
+         * @param {Object} condition - 计算范围
+         * @param {Object} newParam - 更新的全局参数
+         * @returns {Promise<void>}
+         * @private
+         */
         async _calculateAllIndex(transaction, condition, newParam) {
             const globalParams = await this.ctx.service.tenderParam.getAllDataByCondition({
                 where: {lib_id: condition.lib_id, node_id: paramConst.globalParamNodeId}
             });
-            for (const gp of globalParams) {
-                if (gp.code === newParam.code) {
-                    gp.calc_value = newParam.value;
-                    break;
+            if (newParam) {
+                for (const gp of globalParams) {
+                    if (gp.code === newParam.code) {
+                        gp.calc_value = newParam.value;
+                        break;
+                    }
                 }
             }
-            const nodes = await this.ctx.tenderNode.getAllDataByCondition({where: condition});
+            const nodes = await this.ctx.service.tenderNode.getAllDataByCondition({where: condition});
             for (const node of nodes) {
                 condition.node_id = node.node_id;
                 await this._calculateNodeIndex(transaction, condition, globalParams);
@@ -76,8 +94,9 @@ module.exports = app => {
                 if (condition.lib_id < 0 || condition.node_id < 0) {
                     throw '提交数据错误';
                 }
+                data.value = parseFloat(data.value);
                 const updateData = {
-                    calc_value: parseFloat(data.value),
+                    calc_value: (isNaN(data.value) ? null : data.value),
                 };
                 await transaction.update(this.tableName, updateData, {where: condition});
                 if (condition.node_id === paramConst.globalParamNodeId) {