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

This commit is contained in:
RuoYi 2025-05-06 13:44:42 +08:00
parent 4f32a048a4
commit 09ca07471f
2 changed files with 3 additions and 3 deletions

View File

@ -27,7 +27,7 @@
的文件
</div>
<!-- 文件列表 -->
<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.uid" 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>
@ -215,7 +215,7 @@ function listToString(list, separator) {
onMounted(() => {
if (props.drag) {
nextTick(() => {
const element = document.querySelector('.upload-file-list')
const element = proxy.$refs.uploadFileList?.$el || proxy.$refs.uploadFileList
Sortable.create(element, {
ghostClass: 'file-upload-darg',
onEnd: (evt) => {

View File

@ -222,7 +222,7 @@ function listToString(list, separator) {
onMounted(() => {
if (props.drag) {
nextTick(() => {
const element = document.querySelector('.el-upload-list')
const element = proxy.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
Sortable.create(element, {
onEnd: (evt) => {
const movedItem = fileList.value.splice(evt.oldIndex, 1)[0]