From e181f04c642204e79749af93fa921875ff6c21ba Mon Sep 17 00:00:00 2001
From: baoshiwei <baoshiwei@shlanbao.cn>
Date: 星期二, 20 五月 2025 10:46:35 +0800
Subject: [PATCH] refactor(qms): 重构趋势图展示逻辑

---
 src/components/Editor/index.vue |   34 +++++++++++++++++-----------------
 1 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/src/components/Editor/index.vue b/src/components/Editor/index.vue
index 05b574f..ba70fbb 100644
--- a/src/components/Editor/index.vue
+++ b/src/components/Editor/index.vue
@@ -2,7 +2,6 @@
   <div>
     <el-upload
       v-if="type === 'url'"
-      ref="uploadRef"
       :action="upload.url"
       :before-upload="handleBeforeUpload"
       :on-success="handleUploadSuccess"
@@ -12,17 +11,18 @@
       :show-file-list="false"
       :headers="upload.headers"
     >
+      <i ref="uploadRef"></i>
     </el-upload>
-    <div class="editor">
-      <quill-editor
-        ref="quillEditorRef"
-        v-model:content="content"
-        content-type="html"
-        :options="options"
-        :style="styles"
-        @text-change="(e: any) => $emit('update:modelValue', content)"
-      />
-    </div>
+  </div>
+  <div class="editor">
+    <quill-editor
+      ref="quillEditorRef"
+      v-model:content="content"
+      content-type="html"
+      :options="options"
+      :style="styles"
+      @text-change="(e: any) => $emit('update:modelValue', content)"
+    />
   </div>
 </template>
 
@@ -57,6 +57,7 @@
   url: import.meta.env.VITE_APP_BASE_API + '/resource/oss/upload'
 });
 const quillEditorRef = ref();
+const uploadRef = ref<HTMLDivElement>();
 
 const options = ref<any>({
   theme: 'snow',
@@ -78,10 +79,10 @@
         ['link', 'image', 'video'] // 閾炬帴銆佸浘鐗囥�佽棰�
       ],
       handlers: {
-        image: function (value: any) {
+        image: (value: boolean) => {
           if (value) {
             // 璋冪敤element鍥剧墖涓婁紶
-            (document.querySelector('.editor-img-uploader>.el-upload') as HTMLDivElement)?.click();
+            uploadRef.value.click();
           } else {
             Quill.format('image', true);
           }
@@ -107,9 +108,9 @@
 const content = ref('');
 watch(
   () => props.modelValue,
-  (v) => {
+  (v: string) => {
     if (v !== content.value) {
-      content.value = v === undefined ? '<p></p>' : v;
+      content.value = v || '<p></p>';
     }
   },
   { immediate: true }
@@ -129,7 +130,7 @@
     quill.setSelection(length + 1);
     proxy?.$modal.closeLoading();
   } else {
-    proxy?.$modal.loading(res.msg);
+    proxy?.$modal.msgError('鍥剧墖鎻掑叆澶辫触');
     proxy?.$modal.closeLoading();
   }
 };
@@ -157,7 +158,6 @@
 
 // 鍥剧墖澶辫触鎷︽埅
 const handleUploadError = (err: any) => {
-  console.error(err);
   proxy?.$modal.msgError('涓婁紶鏂囦欢澶辫触');
 };
 </script>

--
Gitblit v1.9.3