Skip to content

Commit 36052be

Browse files
committed
feat: 图片上传组件新增disabled属性
1 parent 3fb128a commit 36052be

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

ruoyi-fastapi-frontend/src/components/FileUpload/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export default {
103103
};
104104
},
105105
mounted() {
106-
if (this.drag) {
106+
if (this.drag && !this.disabled) {
107107
this.$nextTick(() => {
108108
const element = this.$refs.uploadFileList?.$el || this.$refs.uploadFileList
109109
Sortable.create(element, {

ruoyi-fastapi-frontend/src/components/ImageUpload/index.vue

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
<div class="component-upload-image">
33
<el-upload
44
multiple
5+
:disabled="disabled"
56
:action="uploadImgUrl"
67
list-type="picture-card"
78
:on-success="handleUploadSuccess"
@@ -22,7 +23,7 @@
2223
</el-upload>
2324

2425
<!-- 上传提示 -->
25-
<div class="el-upload__tip" slot="tip" v-if="showTip">
26+
<div class="el-upload__tip" slot="tip" v-if="showTip && !disabled">
2627
请上传
2728
<template v-if="fileSize"> 大小不超过 <b style="color: #f56c6c">{{ fileSize }}MB</b> </template>
2829
<template v-if="fileType"> 格式为 <b style="color: #f56c6c">{{ fileType.join("/") }}</b> </template>
@@ -80,6 +81,11 @@ export default {
8081
type: Boolean,
8182
default: true
8283
},
84+
// 禁用组件(仅查看图片)
85+
disabled: {
86+
type: Boolean,
87+
default: false
88+
},
8389
// 拖动排序
8490
drag: {
8591
type: Boolean,
@@ -102,7 +108,7 @@ export default {
102108
};
103109
},
104110
mounted() {
105-
if (this.drag) {
111+
if (this.drag && !this.disabled) {
106112
this.$nextTick(() => {
107113
const element = this.$refs.imageUpload?.$el?.querySelector('.el-upload-list')
108114
Sortable.create(element, {
@@ -245,12 +251,17 @@ export default {
245251
<style scoped lang="scss">
246252
// .el-upload--picture-card 控制加号部分
247253
::v-deep.hide .el-upload--picture-card {
248-
display: none;
254+
display: none;
249255
}
256+
257+
::v-deep .el-upload-list--picture-card.is-disabled + .el-upload--picture-card {
258+
display: none !important;
259+
}
260+
250261
// 去掉动画效果
251262
::v-deep .el-list-enter-active,
252263
::v-deep .el-list-leave-active {
253-
transition: all 0s;
264+
transition: all 0s;
254265
}
255266
256267
::v-deep .el-list-enter, .el-list-leave-active {

0 commit comments

Comments
 (0)