Commit 6c33afc1235543b850f06fe41a70b2ca789d677a

Authored by Aaron
1 parent 79234e5a
Exists in master and in 1 other branch legacy

调整图片上传组件配置,Scheme组件自定义弹框增加关闭方法传值

packages/Image-upload/index.vue
... ... @@ -108,6 +108,11 @@ export default {
108 108 type: Boolean,
109 109 default: false
110 110 },
  111 + responseFormat: Function,
  112 + maxMB: {
  113 + type: Number,
  114 + default: 2
  115 + }
111 116 },
112 117 name: 'ImageUpload',
113 118 data() {
... ... @@ -118,17 +123,21 @@ export default {
118 123 },
119 124 methods: {
120 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 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 142 handleAdd() {
134 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 144 </template>
145 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 148 </el-dialog>
149 149 </div>
150 150 </template>
... ...