From 07be5ceb2633279787380dfda88602f208a8e020 Mon Sep 17 00:00:00 2001
From: RuoYi <yzz_ivy@163.com>
Date: Tue, 06 May 2025 13:46:21 +0800
Subject: [PATCH] 修复上传组件被多次引用拖动仅对第一个有效的问题

---
 ruoyi-ui/src/components/FileUpload/index.vue  |    4 ++--
 ruoyi-ui/src/components/ImageUpload/index.vue |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/ruoyi-ui/src/components/FileUpload/index.vue b/ruoyi-ui/src/components/FileUpload/index.vue
index 557e128..ad28ca0 100644
--- a/ruoyi-ui/src/components/FileUpload/index.vue
+++ b/ruoyi-ui/src/components/FileUpload/index.vue
@@ -28,7 +28,7 @@
     </el-upload>
 
     <!-- 文件列表 -->
-    <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
+    <transition-group ref="uploadFileList" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
       <li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
         <el-link :href="file.url" :underline="false" target="_blank">
           <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
@@ -104,7 +104,7 @@
   mounted() {
     if (this.drag) {
       this.$nextTick(() => {
-        const element = document.querySelector('.upload-file-list')
+        const element = this.$refs.uploadFileList?.$el || this.$refs.uploadFileList
         Sortable.create(element, {
           ghostClass: 'file-upload-darg',
           onEnd: (evt) => {
diff --git a/ruoyi-ui/src/components/ImageUpload/index.vue b/ruoyi-ui/src/components/ImageUpload/index.vue
index 02bdaa6..8520b83 100644
--- a/ruoyi-ui/src/components/ImageUpload/index.vue
+++ b/ruoyi-ui/src/components/ImageUpload/index.vue
@@ -102,7 +102,7 @@
   mounted() {
     if (this.drag) {
       this.$nextTick(() => {
-        const element = document.querySelector('.el-upload-list')
+        const element = this.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
         Sortable.create(element, {
           onEnd: (evt) => {
             const movedItem = this.fileList.splice(evt.oldIndex, 1)[0]

--
Gitblit v1.9.3