Browse Source

兼容模板为空的情况

MaiXinRong 7 years ago
parent
commit
ef42f95b0c
2 changed files with 5 additions and 2 deletions
  1. 4 1
      app/controller/template_controller.js
  2. 1 1
      app/service/template_node.js

+ 4 - 1
app/controller/template_controller.js

@@ -31,7 +31,10 @@ module.exports = app => {
             }
             const treeNode = ctx.helper.convertData(node, true, 'node_id', 'node_pid');
             const condition = {template_id: 1, node_id: id};
-            const selectNode = await ctx.service.templateNode.getDataByCondition(condition);
+            let selectNode = await ctx.service.templateNode.getDataByCondition(condition);
+            if (!selectNode) {
+                selectNode = {template_id: null, node_id: null, node_pid: null, code: '', name: '', match_type: null, match_key: ''}
+            }
             const selectIndex = await ctx.service.templateIndex.getAllDataByCondition({ where: condition });
             const globalParams = await ctx.service.templateParam.getAllDataByCondition({ where: {template_id: 1, node_id: 0}});
             const nodeParams = await ctx.service.templateParam.getAllDataByCondition({ where: condition});

+ 1 - 1
app/service/template_node.js

@@ -70,7 +70,7 @@ module.exports = app => {
          * @private
          */
         _parseParam(rule, nodeId, params) {
-            if (rule === '') { return; }
+            if (rule === '') { return ['', '']; }
             const self = this;
             const ruleParams = rule.split('/');
             const nodeParams = this._filterNodeParams(params, nodeId);