Explorar el Código

修复上传组件被多次引用拖动仅对第一个有效的问题

RuoYi hace 11 meses
padre
commit
07be5ceb26

+ 2 - 2
ruoyi-ui/src/components/FileUpload/index.vue

@@ -28,7 +28,7 @@
28 28
     </el-upload>
29 29
 
30 30
     <!-- 文件列表 -->
31
-    <transition-group class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
31
+    <transition-group ref="uploadFileList" class="upload-file-list el-upload-list el-upload-list--text" name="el-fade-in-linear" tag="ul">
32 32
       <li :key="file.url" class="el-upload-list__item ele-upload-list__item-content" v-for="(file, index) in fileList">
33 33
         <el-link :href="file.url" :underline="false" target="_blank">
34 34
           <span class="el-icon-document"> {{ getFileName(file.name) }} </span>
@@ -104,7 +104,7 @@ export default {
104 104
   mounted() {
105 105
     if (this.drag) {
106 106
       this.$nextTick(() => {
107
-        const element = document.querySelector('.upload-file-list')
107
+        const element = this.$refs.uploadFileList?.$el || this.$refs.uploadFileList
108 108
         Sortable.create(element, {
109 109
           ghostClass: 'file-upload-darg',
110 110
           onEnd: (evt) => {

+ 1 - 1
ruoyi-ui/src/components/ImageUpload/index.vue

@@ -102,7 +102,7 @@ export default {
102 102
   mounted() {
103 103
     if (this.drag) {
104 104
       this.$nextTick(() => {
105
-        const element = document.querySelector('.el-upload-list')
105
+        const element = this.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
106 106
         Sortable.create(element, {
107 107
           onEnd: (evt) => {
108 108
             const movedItem = this.fileList.splice(evt.oldIndex, 1)[0]