fix: 修改 text未正确保存的问题

This commit is contained in:
zhangyu
2021-12-24 14:13:58 +08:00
parent 9d2a4b8e8b
commit 765a6e6cc6
3 changed files with 16 additions and 20 deletions

View File

@@ -28,7 +28,7 @@
</span> </span>
<div class="chart-header__title" v-if="!isGroup">{{chartInfo.name}}</div> <div class="chart-header__title" v-if="!isGroup">{{chartInfo.name}}</div>
<div class="chart-header__title" v-else > <div class="chart-header__title" v-else >
<span @click="groupShow"> <i class="nz-icon" :class="chartInfo.param.collapse ? 'nz-icon-arrow-down': 'nz-icon-arrow-right'"></i></span> <span @click="groupShow"> <i class="nz-icon" :class="chartInfo.param.collapse ? 'nz-icon-arrow-right': 'nz-icon-arrow-down'"></i></span>
{{chartInfo.name}} {{chartInfo.name}}
</div> </div>
<div class="chart-header__tools" v-if="chartInfo.type !== 'endpointInfo' && chartInfo.type !== 'assetInfo'"> <div class="chart-header__tools" v-if="chartInfo.type !== 'endpointInfo' && chartInfo.type !== 'assetInfo'">

View File

@@ -59,10 +59,11 @@ export default {
$self.maxLength = $self.quill.getText().length $self.maxLength = $self.quill.getText().length
$self.tooLong = false $self.tooLong = false
} }
$self.$emit('textChange', $self.quill.root.innerHTML)
}) })
this.$nextTick(() => { this.$nextTick(() => {
this.$emit('after-init') this.$emit('after-init')
this.$emit('textChange') // this.$emit('textChange')
}) })
} }
}, },
@@ -84,19 +85,11 @@ export default {
return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4()) return (S4() + S4() + '-' + S4() + '-' + S4() + '-' + S4() + '-' + S4() + S4() + S4())
} }
}, },
watch: {
editData: {
immediate: true,
handler (n, o) {
this.$nextTick(() => {
this.initEditor()
this.quill.clipboard.dangerouslyPasteHTML(null, this.editData, 'api')
})
}
}
},
mounted () { mounted () {
this.initEditor() this.initEditor()
if (this.editData) {
this.quill.clipboard.dangerouslyPasteHTML(null, this.editData, 'api')
}
}, },
beforeDestroy () { beforeDestroy () {
this.quill.off('selection-change') this.quill.off('selection-change')

View File

@@ -139,11 +139,12 @@ export default {
richTextEditor richTextEditor
}, },
watch: { watch: {
'chartConfig.param.text': { // 'chartConfig.param.text': {
handler (n) { // handler (n) {
this.change() // console.log(n)
} // this.change()
} // }
// }
}, },
data () { data () {
return { return {
@@ -218,8 +219,10 @@ export default {
this.change() this.change()
} }
}, },
textChange () { textChange (val) {
this.chartConfig.param.text = this.$refs.richTextEditor.getContent() const html = `<div class="editor-core ql-container ql-snow"><div class="ql-editor">${val}</div></div>`
this.chartConfig.param.text = html
this.change()
} }
}, },
created () { created () {