Explorar el Código

1. 更新全局参数
2. 匹配参数时,如果参数本身是数字,则取值为该数字

MaiXinRong hace 7 años
padre
commit
6faf235bfd

BIN
app/const/global_params.xls


+ 11 - 7
app/service/match.js

@@ -155,13 +155,17 @@ module.exports = app => {
          * @private
          */
         _getParamValue(param, nodeBills) {
-            switch (param.match_type) {
-                case paramConst.matchType.fixed_id: return this._getFixedIdParamValue(param);
-                case paramConst.matchType.node_default: return this._getNodeBillsValue(param, nodeBills);
-                case paramConst.matchType.parent_default: return this._getNodeBillsValue(param, this._getParentBills(nodeBills));
-                case paramConst.matchType.code: return this._getCodeParamValue(param);
-                // to do 匹配属性
-                default: return undefined;
+            if (!isNaN(Number(param.name))) {
+                return Number(param.name);
+            } else {
+                switch (param.match_type) {
+                    case paramConst.matchType.fixed_id: return this._getFixedIdParamValue(param);
+                    case paramConst.matchType.node_default: return this._getNodeBillsValue(param, nodeBills);
+                    case paramConst.matchType.parent_default: return this._getNodeBillsValue(param, this._getParentBills(nodeBills));
+                    case paramConst.matchType.code: return this._getCodeParamValue(param);
+                    // to do 匹配属性
+                    default: return undefined;
+                }
             }
         }
 

+ 1 - 1
test/app/const/template_param.test.js

@@ -12,7 +12,7 @@ const { app, assert } = require('egg-mock/bootstrap');
 describe('test/app/const/template_param.test.js', () => {
     it('defaultGlobalParams', function* () {
         const ctx = app.mockContext();
-        assert(app.paramConst.defaultGlobalParams.length === 39);
+        assert(app.paramConst.defaultGlobalParams.length === 38);
     });
 
 });

+ 2 - 2
test/app/service/template_node.test.js

@@ -54,7 +54,7 @@ describe('test/app/service/template_node.test.js', () => {
         const indexes = yield ctx.service.templateIndex.getAllDataByCondition({where: {template_id: templateId}});
         assert(indexes.length === 42);
         const params = yield ctx.service.templateParam.getAllDataByCondition({where: {template_id: templateId}});
-        assert(params.length === 103);
+        assert(params.length === 102);
     });
     it('importData test xlsx File', function* () {
         const ctx = app.mockContext();
@@ -68,6 +68,6 @@ describe('test/app/service/template_node.test.js', () => {
         const indexes = yield ctx.service.templateIndex.getAllDataByCondition({where: {template_id: templateId}});
         assert(indexes.length === 12);
         const params = yield ctx.service.templateParam.getAllDataByCondition({where: {template_id: templateId}});
-        assert(params.length === 65);
+        assert(params.length === 64);
     });
 });