prevent dispatch form event
when component import an Input, prevent dispatch event from Input to Form
This commit is contained in:
parent
4a5d5cc9f2
commit
21dad188c1
8 changed files with 92 additions and 54 deletions
|
@ -2,7 +2,7 @@
|
|||
<div :class="classes" :style="styles">
|
||||
<Notice
|
||||
v-for="notice in notices"
|
||||
:key="notice"
|
||||
:key="notice.name"
|
||||
:prefix-cls="prefixCls"
|
||||
:styles="notice.styles"
|
||||
:content="notice.content"
|
||||
|
@ -15,7 +15,6 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
// todo :key="notice"
|
||||
import Notice from './notice.vue';
|
||||
|
||||
const prefixCls = 'ivu-notification';
|
||||
|
|
|
@ -57,6 +57,7 @@
|
|||
const timePrefixCls = 'ivu-time-picker';
|
||||
|
||||
export default {
|
||||
name: 'TimePicker',
|
||||
mixins: [ Mixin, Locale ],
|
||||
components: { TimeSpinner, Confirm },
|
||||
data () {
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
const timePrefixCls = 'ivu-time-picker';
|
||||
|
||||
export default {
|
||||
name: 'TimePicker',
|
||||
mixins: [ Mixin, Locale ],
|
||||
components: { TimeSpinner, Confirm },
|
||||
data () {
|
||||
|
|
|
@ -139,6 +139,7 @@
|
|||
};
|
||||
|
||||
export default {
|
||||
name: 'CalendarPicker',
|
||||
mixins: [ Emitter ],
|
||||
components: { iInput, Drop },
|
||||
directives: { clickoutside },
|
||||
|
@ -344,6 +345,7 @@
|
|||
this.visualValue = correctValue;
|
||||
event.target.value = correctValue;
|
||||
this.internalValue = correctDate;
|
||||
this.currentValue = correctDate;
|
||||
|
||||
if (correctValue !== oldValue) this.emitChange(correctDate);
|
||||
},
|
||||
|
@ -418,6 +420,12 @@
|
|||
this.picker.resetView && this.picker.resetView();
|
||||
},
|
||||
emitChange (date) {
|
||||
const newDate = this.formattingDate(date);
|
||||
|
||||
this.$emit('on-change', newDate);
|
||||
this.dispatch('FormItem', 'on-form-change', newDate);
|
||||
},
|
||||
formattingDate (date) {
|
||||
const type = this.type;
|
||||
const format = this.format || DEFAULT_FORMATS[type];
|
||||
const formatter = (
|
||||
|
@ -429,9 +437,7 @@
|
|||
if (type === 'daterange' || type === 'timerange') {
|
||||
newDate = [newDate.split(RANGE_SEPARATOR)[0], newDate.split(RANGE_SEPARATOR)[1]];
|
||||
}
|
||||
|
||||
this.$emit('on-change', newDate);
|
||||
this.dispatch('FormItem', 'on-form-change', newDate);
|
||||
return newDate;
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
|
@ -450,7 +456,7 @@
|
|||
if (!val && this.picker && typeof this.picker.handleClear === 'function') {
|
||||
this.picker.handleClear();
|
||||
}
|
||||
this.$emit('input', val);
|
||||
// this.$emit('input', val);
|
||||
},
|
||||
value (val) {
|
||||
this.currentValue = val;
|
||||
|
@ -492,14 +498,5 @@
|
|||
mounted () {
|
||||
if (this.open !== null) this.visible = this.open;
|
||||
}
|
||||
// todo 事件
|
||||
// events: {
|
||||
// 'on-form-blur' () {
|
||||
// return false;
|
||||
// },
|
||||
// 'on-form-change' () {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
import { oneOf, findComponentUpward } from '../../utils/assist';
|
||||
import calcTextareaHeight from '../../utils/calcTextareaHeight';
|
||||
import Emitter from '../../mixins/emitter';
|
||||
|
||||
|
@ -152,7 +152,9 @@
|
|||
},
|
||||
handleBlur () {
|
||||
this.$emit('on-blur');
|
||||
this.dispatch('FormItem', 'on-form-blur', this.currentValue);
|
||||
if (!findComponentUpward(this, ['DatePicker', 'TimePicker'])) {
|
||||
this.dispatch('FormItem', 'on-form-blur', this.currentValue);
|
||||
}
|
||||
},
|
||||
handleInput (event) {
|
||||
const value = event.target.value;
|
||||
|
@ -169,7 +171,9 @@
|
|||
this.resizeTextarea();
|
||||
});
|
||||
this.currentValue = value;
|
||||
this.dispatch('FormItem', 'on-form-change', value);
|
||||
if (!findComponentUpward(this, ['DatePicker', 'TimePicker'])) {
|
||||
this.dispatch('FormItem', 'on-form-change', value);
|
||||
}
|
||||
},
|
||||
resizeTextarea () {
|
||||
const autosize = this.autosize;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue