|
@@ -1,6 +1,6 @@
|
|
|
<template>
|
|
|
<el-upload :action="action" :data="data" name="filedata" :limit="$props.limit" :on-success="handleSuccess"
|
|
|
- :before-upload="beforeUpload" :file-list="FILE_LIST">
|
|
|
+ :before-upload="beforeUpload" :file-list="FILE_LIST" :on-preview="handlePreview">
|
|
|
<template #default>
|
|
|
<slot>
|
|
|
<el-button size="small" type="primary">点击上传</el-button>
|
|
@@ -66,7 +66,7 @@ export default ({
|
|
|
methods: {
|
|
|
handleSuccess(response, file, fileList) {
|
|
|
console.log('handleSuccess :>> ', response, file, fileList);
|
|
|
- this.$emit("success", fileList);
|
|
|
+ this.$emit("success", fileList.map((item) => ({ ...item, url: item.response.data.url, })))
|
|
|
},
|
|
|
beforeUpload() {
|
|
|
if (this.$props.size) {
|
|
@@ -77,7 +77,11 @@ export default ({
|
|
|
return isLtSize;
|
|
|
}
|
|
|
},
|
|
|
-
|
|
|
+ handlePreview(file) {
|
|
|
+ console.log('file :>> ', file);
|
|
|
+ const { part_url, name } = file;
|
|
|
+ window.open(`${window.globalVariables.api}/openapi/download.php?path=${part_url}&name=${name}`);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
})
|