feat: v3版疗休养优化4
This commit is contained in:
+12
-4
@@ -8,11 +8,12 @@
|
||||
</template>
|
||||
<script>
|
||||
module.exports = {
|
||||
props: {value: {type: Array, default: () => []}, limit: {type: Number, default: 1},
|
||||
props: {value: {type: [String, 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)}));
|
||||
const items = Array.isArray(values) ? values : values ? [values] : [];
|
||||
this.fileList = items.map((value, index) => ({name: '图片' + (index + 1), url: therapyPreview(value), storedValue: value}));
|
||||
}}},
|
||||
methods: {
|
||||
beforeUpload(file) {
|
||||
@@ -25,12 +26,19 @@ module.exports = {
|
||||
return true;
|
||||
},
|
||||
success(result, file, list) {
|
||||
if (result.code !== 0) { this.$message.error(result.msg); return; }
|
||||
if (result.code !== 0) {
|
||||
list.splice(list.indexOf(file), 1);
|
||||
this.$message.error(result.msg); return;
|
||||
}
|
||||
file.url = result.data.filepath;
|
||||
file.storedValue = 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)); },
|
||||
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); }
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user