feat: v3版疗休养
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<template>
|
||||
<el-upload action="/platform/staffTherapyRecuperation/common/uploadFile" name="file" list-type="picture-card"
|
||||
:file-list="fileList" :limit="limit" :before-upload="beforeUpload"
|
||||
:on-success="success" :on-remove="remove" :on-preview="open"
|
||||
:style="{'--therapy-width': width + 'px', '--therapy-height': height + 'px'}">
|
||||
<i class="el-icon-plus"></i>
|
||||
</el-upload>
|
||||
</template>
|
||||
<script>
|
||||
module.exports = {
|
||||
props: {value: {type: Array, default: () => []}, limit: {type: Number, default: 1},
|
||||
width: {type: Number, default: 100}, height: {type: Number, default: 100}, fileType: Array, fileSize: Number},
|
||||
data() { return {fileList: []}; },
|
||||
watch: {value: {immediate: true, deep: true, handler(values) {
|
||||
this.fileList = (values || []).map((value, index) => ({name: '图片' + (index + 1), url: therapyPreview(value)}));
|
||||
}}},
|
||||
methods: {
|
||||
beforeUpload(file) {
|
||||
if (this.fileType && !this.fileType.includes(file.name.split('.').pop().toLowerCase())) {
|
||||
this.$message.warning('图片格式不符合要求'); return false;
|
||||
}
|
||||
if (this.fileSize && file.size > this.fileSize * 1024 * 1024) {
|
||||
this.$message.warning('图片大小超过限制'); return false;
|
||||
}
|
||||
return true;
|
||||
},
|
||||
success(result, file, list) {
|
||||
if (result.code !== 0) { this.$message.error(result.msg); return; }
|
||||
file.url = result.data.filepath;
|
||||
this.emit(list);
|
||||
},
|
||||
remove(file, list) { this.emit(list); },
|
||||
emit(list) { this.$emit('input', list.map(file => file.response ? file.response.data.filepath : file.url)); },
|
||||
open(file) { window.open(file.url); }
|
||||
}
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.el-upload-list--picture-card .el-upload-list__item, .el-upload--picture-card {
|
||||
width: var(--therapy-width); height: var(--therapy-height); line-height: var(--therapy-height);
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user