feat: v3版疗休养优化6
This commit is contained in:
+16
-5
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<el-upload action="/platform/inclusiveTherapyV3/common/uploadFile" name="file" list-type="picture-card"
|
||||
<el-upload action="/platform/sys/file/uploadDynamicReturnUrl" name="file" list-type="picture-card"
|
||||
:file-list="fileList" :limit="limit" :before-upload="beforeUpload"
|
||||
:on-success="success" :on-remove="remove" :on-preview="open"
|
||||
:on-success="success" :on-error="error" :on-exceed="exceed" :on-remove="remove" :on-preview="open"
|
||||
:style="{'--therapy-width': width + 'px', '--therapy-height': height + 'px'}">
|
||||
<i class="el-icon-plus"></i>
|
||||
</el-upload>
|
||||
@@ -30,16 +30,27 @@ module.exports = {
|
||||
list.splice(list.indexOf(file), 1);
|
||||
this.$message.error(result.msg); return;
|
||||
}
|
||||
file.url = result.data.filepath;
|
||||
file.storedValue = result.data.filepath;
|
||||
if (typeof result.data !== 'string' || !result.data) {
|
||||
list.splice(list.indexOf(file), 1);
|
||||
this.$message.error('上传未返回图片地址'); return;
|
||||
}
|
||||
file.url = result.data;
|
||||
file.storedValue = result.data;
|
||||
this.emit(list);
|
||||
},
|
||||
error() { this.$message.error('图片上传失败,请重试'); },
|
||||
exceed() { this.$message.warning('最多上传' + this.limit + '张图片'); },
|
||||
remove(file, list) { this.emit(list); },
|
||||
emit(list) {
|
||||
const values = list.map(file => file.storedValue).filter(Boolean);
|
||||
this.$emit('input', Array.isArray(this.value) ? values : values[0] || '');
|
||||
},
|
||||
open(file) { window.open(file.url); }
|
||||
open(file) {
|
||||
const img = new Image();
|
||||
img.src = file.url;
|
||||
const viewer = new Viewer(img, {hidden() { viewer.destroy(); }});
|
||||
viewer.show();
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user