图片上传组件新增disabled属性

This commit is contained in:
RuoYi 2025-05-06 19:14:54 +08:00
parent 0dcd3e6183
commit 056cf94082
2 changed files with 18 additions and 7 deletions

View File

@ -84,7 +84,7 @@ export default {
type: Boolean,
default: false
},
//
//
drag: {
type: Boolean,
default: true
@ -102,7 +102,7 @@ export default {
}
},
mounted() {
if (this.drag) {
if (this.drag && !this.disabled) {
this.$nextTick(() => {
const element = this.$refs.uploadFileList?.$el || this.$refs.uploadFileList
Sortable.create(element, {

View File

@ -2,6 +2,7 @@
<div class="component-upload-image">
<el-upload
multiple
:disabled="disabled"
:action="uploadImgUrl"
list-type="picture-card"
:on-success="handleUploadSuccess"
@ -22,7 +23,7 @@
</el-upload>
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="showTip">
<div class="el-upload__tip" slot="tip" v-if="showTip && !disabled">
请上传
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
@ -79,7 +80,12 @@ export default {
type: Boolean,
default: true
},
//
//
disabled: {
type: Boolean,
default: false
},
//
drag: {
type: Boolean,
default: true
@ -100,7 +106,7 @@ export default {
}
},
mounted() {
if (this.drag) {
if (this.drag && !this.disabled) {
this.$nextTick(() => {
const element = this.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
Sortable.create(element, {
@ -239,12 +245,17 @@ export default {
<style scoped lang="scss">
// .el-upload--picture-card
::v-deep.hide .el-upload--picture-card {
display: none;
display: none;
}
::v-deep .el-upload-list--picture-card.is-disabled + .el-upload--picture-card {
display: none !important;
}
//
::v-deep .el-list-enter-active,
::v-deep .el-list-leave-active {
transition: all 0s;
transition: all 0s;
}
::v-deep .el-list-enter, .el-list-leave-active {