Skip to content

Commit

Permalink
[feature]{el-data-pick}: 加入时间选择器默认值,默认为当前日期
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed May 26, 2019
1 parent 53959e5 commit cffdf4e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/components/FormDesigner/GenerateForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
// 常规组件
import GenerateFormItem from './GenerateFormItem';
import { DateTimeNowSplit } from '@/utils/index';
export default {
name: 'FmGenerateForm',
Expand Down Expand Up @@ -201,7 +202,11 @@ export default {
...genList[i].rules,
];
} else {
this.rules[genList[i].model] = [...genList[i].rules];
const config = genList[i];
// 如果时间选择器需要默认值,默认回填当前日期
if (config.type === 'date' && config.options.defaultValue) {
this.models[genList[i].model] = DateTimeNowSplit();
} else { this.models[genList[i].model] = genList[i].options.defaultValue; }
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/components/FormDesigner/WidgetConfig.vue
Original file line number Diff line number Diff line change
Expand Up @@ -276,9 +276,8 @@
v-model="data.options.defaultValue"
:show-alpha="data.options.showAlpha"
/>
<el-switch
v-if="data.type=='switch'"
v-model="data.options.defaultValue"/>
<el-switch v-if="data.type=='switch' || data.type == 'date'"
v-model="data.options.defaultValue"></el-switch>
</el-form-item>

<template v-if="data.type == 'time' || data.type == 'date'">
Expand Down
2 changes: 1 addition & 1 deletion src/components/FormDesigner/componentsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const basicComponents = [
icon: 'regular/calendar-alt',
hidden: false,
options: {
defaultValue: '',
defaultValue: false,
readonly: false,
disabled: false,
editable: true,
Expand Down

0 comments on commit cffdf4e

Please sign in to comment.