DatePicker: add validate-event attribute (#13531)

pull/13540/head
hetech 2018-11-22 18:29:16 +08:00 committed by GitHub
parent 96d787dac9
commit d8d4dfedd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 8 deletions

View File

@ -495,6 +495,7 @@ When picking a date range, you can assign the time part for start date and end d
| unlink-panels | unlink two date-panels in range-picker | boolean | — | false | | unlink-panels | unlink two date-panels in range-picker | boolean | — | false |
| prefix-icon | Custom prefix icon class | string | — | el-icon-date | | prefix-icon | Custom prefix icon class | string | — | el-icon-date |
| clear-icon | Custom clear icon class | string | — | el-icon-circle-close | | clear-icon | Custom clear icon class | string | — | el-icon-circle-close |
| validate-event | whether to trigger form validation | boolean | - | true |
### Picker Options ### Picker Options
| Attribute | Description | Type | Accepted Values | Default | | Attribute | Description | Type | Accepted Values | Default |

View File

@ -666,7 +666,7 @@ Search data from server-side.
|form | same as `form` in native input | string | — | — | |form | same as `form` in native input | string | — | — |
| label | label text | string | — | — | | label | label text | string | — | — |
| tabindex | input tabindex | string | - | - | | tabindex | input tabindex | string | - | - |
| validate-event | whether to trigger form validation | boolean | - | - | | validate-event | whether to trigger form validation | boolean | - | true |
### Input slots ### Input slots

View File

@ -302,6 +302,7 @@ DateTimePicker se deriva de DatePicker y TimePicker. Por una explicación más d
| unlink-panels | desconectar dos date-panels en range-picker | boolean | — | false | | unlink-panels | desconectar dos date-panels en range-picker | boolean | — | false |
| prefix-icon | Clase personalizada para el icono prefijado | string | — | el-icon-date | | prefix-icon | Clase personalizada para el icono prefijado | string | — | el-icon-date |
| clear-icon | Clase personalizada para el icono `clear` | string | — | el-icon-circle-close | | clear-icon | Clase personalizada para el icono `clear` | string | — | el-icon-circle-close |
| validate-event | whether to trigger form validation | boolean | - | true |
### Picker Options ### Picker Options
| Atributo | Descripción | Tipo | Valores aceptados | Por defecto | | Atributo | Descripción | Tipo | Valores aceptados | Por defecto |

View File

@ -704,7 +704,7 @@ Búsqueda de datos desde el servidor.
| suffix-icon | suffix icon class | string | — | — | | suffix-icon | suffix icon class | string | — | — |
| hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false | | hide-loading | si se debe ocultar el icono de loading en la búsqueda remota | boolean | — | false |
| popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true | | popper-append-to-body | si añadir el desplegable al cuerpo. Si la posición del menú desplegable es incorrecta, puede intentar establecer este prop a false | boolean | - | true |
| validate-event | si se debe lanzar la validación de formulario | boolean | - | - | | validate-event | si se debe lanzar la validación de formulario | boolean | - | true |
### Autocomplete Slots ### Autocomplete Slots

View File

@ -450,6 +450,7 @@
| unlink-panels | 在范围选择器里取消两个日期面板之间的联动 | boolean | — | false | | unlink-panels | 在范围选择器里取消两个日期面板之间的联动 | boolean | — | false |
| prefix-icon | 自定义头部图标的类名 | string | — | el-icon-date | | prefix-icon | 自定义头部图标的类名 | string | — | el-icon-date |
| clear-icon | 自定义清空图标的类名 | string | — | el-icon-circle-close | | clear-icon | 自定义清空图标的类名 | string | — | el-icon-circle-close |
| validate-event | 输入时是否触发表单的校验 | boolean | - | true |
### Picker Options ### Picker Options
| 参数 | 说明 | 类型 | 可选值 | 默认值 | | 参数 | 说明 | 类型 | 可选值 | 默认值 |

View File

@ -822,7 +822,7 @@ export default {
| form | 原生属性 | string | — | — | | form | 原生属性 | string | — | — |
| label | 输入框关联的label文字 | string | — | — | | label | 输入框关联的label文字 | string | — | — |
| tabindex | 输入框的tabindex | string | - | - | | tabindex | 输入框的tabindex | string | - | - |
| validate-event | 输入时是否触发表单的校验 | boolean | - | - | | validate-event | 输入时是否触发表单的校验 | boolean | - | true |
### Input Slots ### Input Slots
| name | 说明 | | name | 说明 |

View File

@ -386,7 +386,11 @@ export default {
default: '-' default: '-'
}, },
pickerOptions: {}, pickerOptions: {},
unlinkPanels: Boolean unlinkPanels: Boolean,
validateEvent: {
type: Boolean,
default: true
}
}, },
components: { ElInput }, components: { ElInput },
@ -413,7 +417,9 @@ export default {
this.hidePicker(); this.hidePicker();
this.emitChange(this.value); this.emitChange(this.value);
this.userInput = null; this.userInput = null;
if (this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.blur'); this.dispatch('ElFormItem', 'el.form.blur');
}
this.$emit('blur', this); this.$emit('blur', this);
this.blur(); this.blur();
} }
@ -433,7 +439,7 @@ export default {
} }
}, },
value(val, oldVal) { value(val, oldVal) {
if (!valueEquals(val, oldVal) && !this.pickerVisible) { if (!valueEquals(val, oldVal) && !this.pickerVisible && this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.change', val); this.dispatch('ElFormItem', 'el.form.change', val);
} }
} }
@ -897,8 +903,10 @@ export default {
// determine user real change only // determine user real change only
if (!valueEquals(val, this.valueOnOpen)) { if (!valueEquals(val, this.valueOnOpen)) {
this.$emit('change', val); this.$emit('change', val);
this.dispatch('ElFormItem', 'el.form.change', val);
this.valueOnOpen = val; this.valueOnOpen = val;
if (this.validateEvent) {
this.dispatch('ElFormItem', 'el.form.change', val);
}
} }
}, },