Commit 6c33afc1235543b850f06fe41a70b2ca789d677a
1 parent
79234e5a
Exists in
master
and in
1 other branch
调整图片上传组件配置,Scheme组件自定义弹框增加关闭方法传值
Showing
2 changed files
with
18 additions
and
9 deletions
Show diff stats
packages/Image-upload/index.vue
| @@ -108,6 +108,11 @@ export default { | @@ -108,6 +108,11 @@ export default { | ||
| 108 | type: Boolean, | 108 | type: Boolean, |
| 109 | default: false | 109 | default: false |
| 110 | }, | 110 | }, |
| 111 | + responseFormat: Function, | ||
| 112 | + maxMB: { | ||
| 113 | + type: Number, | ||
| 114 | + default: 2 | ||
| 115 | + } | ||
| 111 | }, | 116 | }, |
| 112 | name: 'ImageUpload', | 117 | name: 'ImageUpload', |
| 113 | data() { | 118 | data() { |
| @@ -118,17 +123,21 @@ export default { | @@ -118,17 +123,21 @@ export default { | ||
| 118 | }, | 123 | }, |
| 119 | methods: { | 124 | methods: { |
| 120 | handleSuccess(response = {}, file, fileList) { | 125 | handleSuccess(response = {}, file, fileList) { |
| 121 | - const { result = [] } = response; | ||
| 122 | - const url = result[0]; | ||
| 123 | - this.$emit('input', url); | 126 | + if (this.responseFormat) { |
| 127 | + const url = this.responseFormat(response); | ||
| 128 | + this.$emit('input', url); | ||
| 129 | + } else { | ||
| 130 | + const { result = [] } = response; | ||
| 131 | + const url = result[0]; | ||
| 132 | + this.$emit('input', url); | ||
| 133 | + } | ||
| 124 | }, | 134 | }, |
| 125 | beforeUpload(file) { | 135 | beforeUpload(file) { |
| 126 | - const isLt2M = file.size / 1024 / 1024 < 2; | ||
| 127 | - | ||
| 128 | - if (!isLt2M) { | ||
| 129 | - this.$message.error('上传头像图片大小不能超过 2MB!'); | 136 | + const limit = file.size / 1024 / 1024 < this.maxMB; |
| 137 | + if (!limit) { | ||
| 138 | + this.$message.error(`上传头像图片大小不能超过 ${this.maxMB}MB!`); | ||
| 130 | } | 139 | } |
| 131 | - return isLt2M; | 140 | + return limit; |
| 132 | }, | 141 | }, |
| 133 | handleAdd() { | 142 | handleAdd() { |
| 134 | if (this.$refs.uploader && this.$refs.uploader.$el.children && this.$refs.uploader.$el.children[0]) { | 143 | if (this.$refs.uploader && this.$refs.uploader.$el.children && this.$refs.uploader.$el.children[0]) { |
packages/scheme/index.vue
| @@ -144,7 +144,7 @@ | @@ -144,7 +144,7 @@ | ||
| 144 | </template> | 144 | </template> |
| 145 | </eagle-detail> | 145 | </eagle-detail> |
| 146 | <!-- 自定义弹出框内容插槽 --> | 146 | <!-- 自定义弹出框内容插槽 --> |
| 147 | - <slot v-else :name="dialogType" :row="tableCurrentRow"></slot> | 147 | + <slot v-else :name="dialogType" :row="tableCurrentRow" :hideDialog="hideDialog"></slot> |
| 148 | </el-dialog> | 148 | </el-dialog> |
| 149 | </div> | 149 | </div> |
| 150 | </template> | 150 | </template> |