Skip to content

Commit

Permalink
[feature]{GenerateForm}: 默认值支持读取store中的变量 以$开头 如( $deptname )
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed May 27, 2019
1 parent 09dba3e commit 6c5f613
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/components/FormDesigner/GenerateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,15 @@ export default {
// 如果时间选择器需要默认值,默认回填当前日期
if (config.type === 'date' && config.options.defaultValue) {
this.models[genList[i].model] = DateTimeNowSplit();
} else { this.models[genList[i].model] = genList[i].options.defaultValue; }
} else {
let { defaultValue } = genList[i].options;
// 如果默认值设置为$开头,则表示要读取vuex中的全局变量
// 如设置为 $deptname 则读取 this.$store.getters.deptname
if (defaultValue.includes('$')) {
defaultValue = this.$store.getters[defaultValue.replace('$', '')];
}
this.models[genList[i].model] = defaultValue;
}
}
}
}
Expand Down

0 comments on commit 6c5f613

Please sign in to comment.