From 2c8efad8a0b28f53dc61ebceed3ed81b8b39b8c1 Mon Sep 17 00:00:00 2001 From: shidongli Date: Fri, 3 Jan 2025 10:13:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=AE=A3=E6=95=99=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/Editor/index.vue | 8 ++ src/views/manage/propaganda/index.vue | 200 ++++++++++++++------------ 2 files changed, 116 insertions(+), 92 deletions(-) diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue index 5f7cb8d..1d12cad 100644 --- a/src/components/Editor/index.vue +++ b/src/components/Editor/index.vue @@ -324,6 +324,9 @@ export default { this.Quill = null; }, methods: { + getEditor() { + return this.Quill; + }, // 分页 updateCPagefour(index, size) { this.querymaterial.pageNum = index @@ -571,6 +574,11 @@ button.ql-scmages { margin-left: -14px; margin-top: -8px; width: 24px !important; + cursor: none; + -webkit-user-select: none; /* 针对WebKit浏览器的兼容性设置 */ + -moz-user-select: none; /* 针对Firefox浏览器的兼容性设置 */ + -ms-user-select: none; /* 针对IE浏览器的兼容性设置 */ + user-select: none; /* 标准属性 */ } .bodytopxjsc { width: 100%; diff --git a/src/views/manage/propaganda/index.vue b/src/views/manage/propaganda/index.vue index a76dc4d..c7e0f17 100644 --- a/src/views/manage/propaganda/index.vue +++ b/src/views/manage/propaganda/index.vue @@ -21,7 +21,7 @@ > - -
- - - - - - 搜索 + + - 重置 - - - - - - - 搜索 + 重置 + + + - - -
+ + + + + + +
知识卡片
-
-
+
+ @@ -893,15 +897,15 @@ export default { copyid: null,//复制id examineid: null,//审核id // 来源 - optionspublick:[ - { - value: 'PRIVATE', - label: '私有' - }, - { - value: 'PUBLIC', - label: '公共' - }, + optionspublick: [ + { + value: 'PRIVATE', + label: '私有' + }, + { + value: 'PUBLIC', + label: '公共' + }, ], optionstype: [{ @@ -980,7 +984,7 @@ export default { queryParams: { pageNum: 1, pageSize: 10, - source:'PRIVATE', + source: 'PRIVATE', patientId: null, propagandaId: null, departmentName: null, @@ -1108,7 +1112,7 @@ export default { this.$forceUpdate() }, // 粘贴事件 - handlePaste(event) { + async handlePaste(event) { console.log(event, 'event') const clipboardData = event.clipboardData || window.clipboardData; const pastedText = clipboardData.getData('text'); @@ -1124,15 +1128,30 @@ export default { }); } else { - event.preventDefault(); - // 将粘贴的文本插入到编辑器中 - event.target.outerText += pastedText; - // 光标聚焦到末尾 - const dom = document.getElementById('id') - dom && dom.focus() - // document.execCommand('selectAll', false, null); - // document.getSelection().collapseToEnd(); - console.log(event, '222222222222222') + const editor = this.$refs.quillEditor.getEditor(); + let length = editor.selection.savedRange.index; + const text = clipboardData.getData('text/plain'); + // 在光标位置插入文本,text为需要插入的文本 + console.log(text, 'length + text.length') + editor.insertEmbed(length, text); + + await setTimeout(() => { + // 将光标移动到插入文本的末尾 + editor.setSelection(length + text.length); + }, 10); // 使用 setTimeout 确保操作顺序 + + // editor.insertText(range.index, text); + // editor.setSelection(range.index + text.length); + // // 获取粘贴的文本内容 + // event.preventDefault(); + // // 将粘贴的文本插入到编辑器中 + // event.target.outerText += pastedText; + // // 光标聚焦到末尾 + // const dom = document.getElementById('id') + // dom && dom.focus() + // // document.execCommand('selectAll', false, null); + // // document.getSelection().collapseToEnd(); + // console.log(event, '222222222222222') } }, // checkContentLength(event) { @@ -1449,9 +1468,9 @@ export default { resetQuery() { this.queryParams.createTimeEnd = null this.queryParams.createTimeStart = null - this.queryParams.propagandaType=null - this.queryParams.propagandaStatus=null - this.queryParams.source=null + this.queryParams.propagandaType = null + this.queryParams.propagandaStatus = null + this.queryParams.source = null this.informationqueryParams.hospitalAgencyId = JSON.parse(localStorage.getItem('user')).hospitalAgencyId this.queryParams.hospitalAgencyId = JSON.parse(localStorage.getItem('user')).hospitalAgencyId this.resetForm("queryForms"); @@ -1614,20 +1633,17 @@ export default { };