From 3b73c6d15fc65c777e63eb06cf128f7799120bc5 Mon Sep 17 00:00:00 2001
From: 曹睿 <360930172@qq.com>
Date: 星期五, 27 六月 2025 10:52:18 +0800
Subject: [PATCH] fix: 销售台账采购台账修复表格无法展开问题。

---
 src/components/Editor/index.vue |   70 +++++++++++++++++++++-------------
 1 files changed, 43 insertions(+), 27 deletions(-)

diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue
index c5e2185..c283e42 100644
--- a/src/components/Editor/index.vue
+++ b/src/components/Editor/index.vue
@@ -27,7 +27,7 @@
 </template>
 
 <script setup>
-import axios from 'axios';
+import axios from "axios";
 import { QuillEditor } from "@vueup/vue-quill";
 import "@vueup/vue-quill/dist/vue-quill.snow.css";
 import { getToken } from "@/utils/auth";
@@ -37,7 +37,7 @@
 const quillEditorRef = ref();
 const uploadUrl = ref(import.meta.env.VITE_APP_BASE_API + "/common/upload"); // 涓婁紶鐨勫浘鐗囨湇鍔″櫒鍦板潃
 const headers = ref({
-  Authorization: "Bearer " + getToken()
+  Authorization: "Bearer " + getToken(),
 });
 
 const props = defineProps({
@@ -69,7 +69,7 @@
   type: {
     type: String,
     default: "url",
-  }
+  },
 });
 
 const options = ref({
@@ -79,20 +79,20 @@
   modules: {
     // 宸ュ叿鏍忛厤缃�
     toolbar: [
-      ["bold", "italic", "underline", "strike"],      // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾�
-      ["blockquote", "code-block"],                   // 寮曠敤  浠g爜鍧�
-      [{ list: "ordered" }, { list: "bullet" }],      // 鏈夊簭銆佹棤搴忓垪琛�
-      [{ indent: "-1" }, { indent: "+1" }],           // 缂╄繘
-      [{ size: ["small", false, "large", "huge"] }],  // 瀛椾綋澶у皬
-      [{ header: [1, 2, 3, 4, 5, 6, false] }],        // 鏍囬
-      [{ color: [] }, { background: [] }],            // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹�
-      [{ align: [] }],                                // 瀵归綈鏂瑰紡
-      ["clean"],                                      // 娓呴櫎鏂囨湰鏍煎紡
-      ["link", "image", "video"]                      // 閾炬帴銆佸浘鐗囥�佽棰�
+      ["bold", "italic", "underline", "strike"], // 鍔犵矖 鏂滀綋 涓嬪垝绾� 鍒犻櫎绾�
+      ["blockquote", "code-block"], // 寮曠敤  浠g爜鍧�
+      [{ list: "ordered" }, { list: "bullet" }], // 鏈夊簭銆佹棤搴忓垪琛�
+      [{ indent: "-1" }, { indent: "+1" }], // 缂╄繘
+      [{ size: ["small", false, "large", "huge"] }], // 瀛椾綋澶у皬
+      [{ header: [1, 2, 3, 4, 5, 6, false] }], // 鏍囬
+      [{ color: [] }, { background: [] }], // 瀛椾綋棰滆壊銆佸瓧浣撹儗鏅鑹�
+      [{ align: [] }], // 瀵归綈鏂瑰紡
+      ["clean"], // 娓呴櫎鏂囨湰鏍煎紡
+      ["link", "image", "video"], // 閾炬帴銆佸浘鐗囥�佽棰�
     ],
   },
   placeholder: "璇疯緭鍏ュ唴瀹�",
-  readOnly: props.readOnly
+  readOnly: props.readOnly,
 });
 
 const styles = computed(() => {
@@ -107,15 +107,19 @@
 });
 
 const content = ref("");
-watch(() => props.modelValue, (v) => {
-  if (v !== content.value) {
-    content.value = v == undefined ? "<p></p>" : v;
-  }
-}, { immediate: true });
+watch(
+  () => props.modelValue,
+  (v) => {
+    if (v !== content.value) {
+      content.value = v == undefined ? "<p></p>" : v;
+    }
+  },
+  { immediate: true }
+);
 
 // 濡傛灉璁剧疆浜嗕笂浼犲湴鍧�鍒欒嚜瀹氫箟鍥剧墖涓婁紶浜嬩欢
 onMounted(() => {
-  if (props.type == 'url') {
+  if (props.type == "url") {
     let quill = quillEditorRef.value.getQuill();
     let toolbar = quill.getModule("toolbar");
     toolbar.addHandler("image", (value) => {
@@ -125,7 +129,7 @@
         quill.format("image", false);
       }
     });
-    quill.root.addEventListener('paste', handlePasteCapture, true);
+    quill.root.addEventListener("paste", handlePasteCapture, true);
   }
 });
 
@@ -158,7 +162,11 @@
     // 鑾峰彇鍏夋爣浣嶇疆
     let length = quill.selection.savedRange.index;
     // 鎻掑叆鍥剧墖锛宺es.url涓烘湇鍔″櫒杩斿洖鐨勫浘鐗囬摼鎺ュ湴鍧�
-    quill.insertEmbed(length, "image", import.meta.env.VITE_APP_BASE_API + res.fileName);
+    quill.insertEmbed(
+      length,
+      "image",
+      import.meta.env.VITE_APP_BASE_API + res.fileName
+    );
     // 璋冩暣鍏夋爣鍒版渶鍚�
     quill.setSelection(length + 1);
   } else {
@@ -177,7 +185,7 @@
   if (clipboard && clipboard.items) {
     for (let i = 0; i < clipboard.items.length; i++) {
       const item = clipboard.items[i];
-      if (item.type.indexOf('image') !== -1) {
+      if (item.type.indexOf("image") !== -1) {
         e.preventDefault();
         const file = item.getAsFile();
         insertImage(file);
@@ -189,9 +197,16 @@
 function insertImage(file) {
   const formData = new FormData();
   formData.append("file", file);
-  axios.post(uploadUrl.value, formData, { headers: { "Content-Type": "multipart/form-data", Authorization: headers.value.Authorization } }).then(res => {
-    handleUploadSuccess(res.data);
-  })
+  axios
+    .post(uploadUrl.value, formData, {
+      headers: {
+        "Content-Type": "multipart/form-data",
+        Authorization: headers.value.Authorization,
+      },
+    })
+    .then((res) => {
+      handleUploadSuccess(res.data);
+    });
 }
 </script>
 
@@ -199,7 +214,8 @@
 .editor-img-uploader {
   display: none;
 }
-.editor, .ql-toolbar {
+.editor,
+.ql-toolbar {
   white-space: pre-wrap !important;
   line-height: normal !important;
 }

--
Gitblit v1.9.3