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

pull/1014/head
RuoYi 2025-05-06 13:10:37 +08:00
parent b6874d4320
commit eefe15e36b
2 changed files with 3 additions and 3 deletions

View File

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

View File

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