Skip to content

Commit

Permalink
fix(@0.8.8-17): 修复时间选择器初始值bug
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Mar 9, 2021
1 parent 79fe40f commit e9b0b1b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "element-pro-crud",
"version": "0.8.8-16",
"version": "0.8.8-17",
"author": "BoBo<[email protected]>",
"main": "lib/ProCrud.umd.min.js",
"files": [
Expand Down
18 changes: 12 additions & 6 deletions src/component/form-designer/src/GenerateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -484,15 +484,21 @@ export default class GenerateForm extends Vue {
// 表单默认值回填单独拉出来封装
setDefaultValue(config) {
// 如果时间选择器需要默认值,默认回填当前日期
if (config.type === 'date' && config.options.defaultValue) {
const { format } = config.options;
if (format && format !== '') {
this.models[config.model] = this.dayjs().format(format.toUpperCase());
if (config.type === 'date') {
if (config.options.defaultValue) {
const { format } = config.options;
if (format && format !== '') {
this.models[config.model] = this.dayjs().format(format.toUpperCase());
}
} else {
this.models[config.model] = null;
}
} else {
let { defaultValue } = config.options;
if (typeof defaultValue === 'boolean') {
defaultValue = '';
// 如果默认值设置为$开头,则表示要读取vuex中的全局变量
// 如设置为 $deptname 则读取 this.$store.getters.deptname
if (typeof defaultValue === 'string' && defaultValue.includes('$')) {
defaultValue = this.$store.getters[defaultValue.replace('$', '')];
} else if (defaultValue === '') {
defaultValue = null;
}
Expand Down
1 change: 1 addition & 0 deletions src/component/form-designer/src/GenerateFormItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@
:format="widget.options.format"
:style="{ width: widget.options.width }"
:picker-options="pickerOptions"
:default-value="new Date()"
>
</el-date-picker>
</template>
Expand Down

0 comments on commit e9b0b1b

Please sign in to comment.