|
@@ -33,7 +33,7 @@
|
|
|
:min="min"
|
|
|
:max="max"
|
|
|
:form="form"
|
|
|
- :value="value"
|
|
|
+ :value="currentValue"
|
|
|
ref="input"
|
|
|
@input="handleInput"
|
|
|
@focus="handleFocus"
|
|
@@ -76,6 +76,13 @@
|
|
|
|
|
|
mixins: [emitter],
|
|
|
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ currentValue: this.value,
|
|
|
+ textareaStyle: {}
|
|
|
+ };
|
|
|
+ },
|
|
|
+
|
|
|
props: {
|
|
|
value: [String, Number],
|
|
|
placeholder: String,
|
|
@@ -108,10 +115,23 @@
|
|
|
min: {}
|
|
|
},
|
|
|
|
|
|
+ computed: {
|
|
|
+ validating() {
|
|
|
+ return this.$parent.validateState === 'validating';
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ watch: {
|
|
|
+ 'value'(val, oldValue) {
|
|
|
+ this.setCurrentValue(val);
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
methods: {
|
|
|
handleBlur(event) {
|
|
|
this.$emit('blur', event);
|
|
|
this.dispatch('ElFormItem', 'el.form.blur', [this.currentValue]);
|
|
|
+ this.currentValue = this.value;
|
|
|
},
|
|
|
inputSelect() {
|
|
|
this.$refs.input.select();
|
|
@@ -130,46 +150,29 @@
|
|
|
this.$emit('focus', event);
|
|
|
},
|
|
|
handleInput(event) {
|
|
|
- this.currentValue = event.target.value;
|
|
|
+ this.setCurrentValue(event.target.value);
|
|
|
},
|
|
|
handleIconClick(event) {
|
|
|
this.$emit('click', event);
|
|
|
+ },
|
|
|
+ setCurrentValue(value) {
|
|
|
+ if (value === this.currentValue) return;
|
|
|
+ this.$nextTick(_ => {
|
|
|
+ this.resizeTextarea();
|
|
|
+ });
|
|
|
+ this.currentValue = value;
|
|
|
+ this.$emit('input', value);
|
|
|
+ this.$emit('change', value);
|
|
|
+ this.dispatch('ElFormItem', 'el.form.change', [value]);
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- data() {
|
|
|
- return {
|
|
|
- currentValue: this.value,
|
|
|
- textareaStyle: {}
|
|
|
- };
|
|
|
- },
|
|
|
-
|
|
|
created() {
|
|
|
this.$on('inputSelect', this.inputSelect);
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
this.resizeTextarea();
|
|
|
- },
|
|
|
-
|
|
|
- computed: {
|
|
|
- validating() {
|
|
|
- return this.$parent.validateState === 'validating';
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- watch: {
|
|
|
- 'value'(val, oldValue) {
|
|
|
- this.currentValue = val;
|
|
|
- },
|
|
|
- 'currentValue'(val) {
|
|
|
- this.$nextTick(_ => {
|
|
|
- this.resizeTextarea();
|
|
|
- });
|
|
|
- this.$emit('input', val);
|
|
|
- this.$emit('change', val);
|
|
|
- this.dispatch('ElFormItem', 'el.form.change', [val]);
|
|
|
- }
|
|
|
}
|
|
|
};
|
|
|
</script>
|