diff --git a/jero-web/src/views/businessSupport/problemKnowledgeBase/components/problemKnowledgeBaseAdd.vue b/jero-web/src/views/businessSupport/problemKnowledgeBase/components/problemKnowledgeBaseAdd.vue index 8aebde02f..0fc3fa9f4 100644 --- a/jero-web/src/views/businessSupport/problemKnowledgeBase/components/problemKnowledgeBaseAdd.vue +++ b/jero-web/src/views/businessSupport/problemKnowledgeBase/components/problemKnowledgeBaseAdd.vue @@ -139,12 +139,16 @@
{{$t('content')}}
- + I am Example', @@ -345,53 +351,14 @@ }, mounted() { this.getBase() - let quill = this.$refs.myQuillEditor.quill - this.$forceUpdate() - quill.root.addEventListener( - 'paste', - (evt) => { - if ( - evt.clipboardData && - evt.clipboardData.files && - evt.clipboardData.files.length - ) { - evt.preventDefault(); - [].forEach.call(evt.clipboardData.files, (file) => { - if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) { - return - } - const formData = new FormData() - formData.append('file', file) - axios({ - url: this.uploadAction, - method: 'post', - data: formData, - headers: { - 'Content-Type': 'multipart/form-data', - 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) - } - }) - .then((res) => { - if (res.data.success) { - let quill = this.$refs.myQuillEditor.quill - let length = quill.getSelection().index - let fileName = res.data.result.fileName - let index1 = fileName.lastIndexOf('.') - let index2 = fileName.length - let fileSuffix = fileName.substring(index1, index2) - quill.insertEmbed(length, 'image', window._CONFIG['domianWebImgURL'] + '/sys/common/download/' + res.data.result.id + fileSuffix) - quill.setSelection(length + 1) - } - }) - }) - } - }, - false - ) if (this.$route.query.id) { this.queryById() document.title = this.$t('problemKnowledgeBase') + this.$t('edit') } else { + this.isDisplayIndex = true + this.$nextTick(()=>{ + this.myQuillEditor() + }) document.title = this.$t('problemKnowledgeBase') + this.$t('newlyAdded') } }, @@ -408,6 +375,51 @@ Delta.ops = ops return Delta }, + myQuillEditor() { + let quill = this.$refs.myQuillEditor.quill + this.$forceUpdate() + quill.root.addEventListener( + 'paste', + (evt) => { + if ( + evt.clipboardData && + evt.clipboardData.files && + evt.clipboardData.files.length + ) { + evt.preventDefault(); + [].forEach.call(evt.clipboardData.files, (file) => { + if (!file.type.match(/^image\/(gif|jpe?g|a?png|bmp)/i)) { + return + } + const formData = new FormData() + formData.append('file', file) + axios({ + url: this.uploadAction, + method: 'post', + data: formData, + headers: { + 'Content-Type': 'multipart/form-data', + 'X-Access-Token': Vue.ls.get(ACCESS_TOKEN) + } + }) + .then((res) => { + if (res.data.success) { + let quill = this.$refs.myQuillEditor.quill + let length = quill.getSelection().index + let fileName = res.data.result.fileName + let index1 = fileName.lastIndexOf('.') + let index2 = fileName.length + let fileSuffix = fileName.substring(index1, index2) + quill.insertEmbed(length, 'image', window._CONFIG['domianWebImgURL'] + '/sys/common/download/' + res.data.result.id + fileSuffix) + quill.setSelection(length + 1) + } + }) + }) + } + }, + false + ) + }, quilleditorBlur() { this.$refs.ruleForm.validateField('content') }, @@ -428,12 +440,15 @@ this.formInline = { ...this.formInline } }, queryById() { + this.loading = true + this.isDisplayIndex = false let query = { id: this.$route.query.id } getAction('/problemKnowledgeBase/problemKnowledgeBaseEO/queryById', query).then((res) => { if (res.success) { this.formInline = res.result || {} + this.formInlineOne = JSON.parse(JSON.stringify(res.result)) if (this.formInline.showPermissions == 'Privacy') { this.isDisplay = true if (this.formInline.permissionUserList && this.formInline.permissionUserList.length > 0) { @@ -465,11 +480,21 @@ } else { this.formInline = {} } + this.isDisplayIndex = true + this.$nextTick(() => { + this.myQuillEditor() + }) + this.loading = false }) }, backClick() { this.$router.go(-1) }, + onEditorReady(quill) { + if (this.formInlineOne.content){ + document.getElementsByClassName('ql-editor')[0].innerHTML = this.formInlineOne.content + } + }, showPermissionsChange(event, name) { if (event == 'Open') { this.isDisplay = false @@ -483,9 +508,6 @@ onEditorFocus(quill) { console.log('editor focus!', quill) }, - onEditorReady(quill) { - console.log('editor ready!', quill) - }, PersonnelSelectionChange(value, id) { this.formInline[value] = id this.formInline = { ...this.formInline } @@ -577,9 +599,11 @@ this.$refs.ruleForm.validate(valid => { if (valid) { let formInline = JSON.parse(JSON.stringify(this.formInline)) - if (formInline.standNumber && formInline.standNumber.length > 0) { + // if (formInline.standNumber && formInline.standNumber.length > 0) { + if (formInline.standNumber instanceof Array){ formInline.standNumber = formInline.standNumber.join(',') } + // } this.loading = true this.confirmLoading = true let url = ''