Sfoglia il codice sorgente

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

RuoYi 11 mesi fa
parent
commit
07be5ceb26

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

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

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

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