|
|
|
@ -1,13 +1,14 @@
|
|
|
|
|
<template>
|
|
|
|
|
<a-textarea
|
|
|
|
|
<textarea
|
|
|
|
|
class="ant-input"
|
|
|
|
|
v-model="value"
|
|
|
|
|
:auto-size="{ minRows: 2, maxRows: 5 }"
|
|
|
|
|
style="height: 120px"
|
|
|
|
|
style="width:100%;display:inline-block;height: 120px"
|
|
|
|
|
@blur="textareaBlur"
|
|
|
|
|
@change="textareaChange"
|
|
|
|
|
/>
|
|
|
|
|
@input="debounce(textareaChange, 300, $event)"
|
|
|
|
|
></textarea>
|
|
|
|
|
</template>
|
|
|
|
|
<script>
|
|
|
|
|
let timer;
|
|
|
|
|
export default {
|
|
|
|
|
name: '',
|
|
|
|
|
props: {
|
|
|
|
@ -22,16 +23,25 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
value: this.parentVal || ''
|
|
|
|
|
value: this.parentVal || '',
|
|
|
|
|
inEdit: false
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
watch: {
|
|
|
|
|
parentVal(nval, oval) {
|
|
|
|
|
if (this.inEdit) { return false }
|
|
|
|
|
console.log('== 回传赋值 ==', nval)
|
|
|
|
|
this.value = nval
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
mounted() {},
|
|
|
|
|
methods: {
|
|
|
|
|
debounce (func, wait, ...args) {
|
|
|
|
|
if (timer) clearTimeout(timer);
|
|
|
|
|
timer = setTimeout(() => {
|
|
|
|
|
func.apply(this, args);
|
|
|
|
|
}, wait);
|
|
|
|
|
},
|
|
|
|
|
textareaBlur() {
|
|
|
|
|
this.$emit('getTextareaChange', {
|
|
|
|
|
type: this.type,
|
|
|
|
@ -39,12 +49,14 @@ export default {
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
textareaChange(e) {
|
|
|
|
|
// if (e.type === 'click' && !this.value) {
|
|
|
|
|
this.inEdit = true
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.inEdit = false
|
|
|
|
|
}, 800)
|
|
|
|
|
this.$emit('getTextareaChange', {
|
|
|
|
|
type: this.type,
|
|
|
|
|
value: this.value
|
|
|
|
|
})
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|