|
|
@@ -6,9 +6,7 @@
|
|
|
:before-upload="handleBeforeUpload"
|
|
|
:file-list="fileList"
|
|
|
:limit="limit"
|
|
|
- :on-error="handleUploadError"
|
|
|
- :on-exceed="handleExceed"
|
|
|
- :on-success="handleUploadSuccess"
|
|
|
+ :http-request="uploadFile"
|
|
|
:show-file-list="false"
|
|
|
:headers="headers"
|
|
|
class="upload-file-uploader"
|
|
|
@@ -41,6 +39,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
+import {upload} from "@/api/system/public";
|
|
|
|
|
|
export default {
|
|
|
name: "FileUpload",
|
|
|
@@ -60,7 +59,7 @@ export default {
|
|
|
// 文件类型, 例如['png', 'jpg', 'jpeg']
|
|
|
fileType: {
|
|
|
type: Array,
|
|
|
- default: () => ["doc", "xls", "ppt", "txt", "pdf"],
|
|
|
+ default: () => ["doc", "xls", "ppt", "txt", "pdf","et","zip"],
|
|
|
},
|
|
|
// 是否显示提示
|
|
|
isShowTip: {
|
|
|
@@ -179,6 +178,29 @@ export default {
|
|
|
return "";
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ //自定义上传方式(自带的成功回调及失败回调会失效)
|
|
|
+ uploadFile(fileObj){
|
|
|
+ console.log(fileObj,'fileObj')
|
|
|
+ let formData = new FormData();
|
|
|
+ formData.append('file',fileObj.file);
|
|
|
+ upload(formData,'image').then(res=>{
|
|
|
+ /*上传成功*/
|
|
|
+ this.$modal.closeLoading();
|
|
|
+ let imgUrl = process.env.VUE_APP_BASE_API + res.data.url;
|
|
|
+ let arr = [];
|
|
|
+ arr.push({ name: res.data.name, url: imgUrl})
|
|
|
+ this.fileList = arr;
|
|
|
+ this.$emit("input", this.listToString(this.fileList));
|
|
|
+ }).catch(err=>{
|
|
|
+ /*上传失败*/
|
|
|
+ this.$modal.closeLoading();
|
|
|
+ this.uploadedSuccessfully();
|
|
|
+ //this.$modal.msgError(res.msg);
|
|
|
+ //this.$refs.imageUpload.handleRemove(fileObj.file);
|
|
|
+ //this.uploadedSuccessfully();
|
|
|
+ })
|
|
|
+ },
|
|
|
// 对象转成指定字符串分隔
|
|
|
listToString(list, separator) {
|
|
|
let strs = "";
|
|
|
@@ -211,4 +233,4 @@ export default {
|
|
|
.ele-upload-list__item-content-action .el-link {
|
|
|
margin-right: 10px;
|
|
|
}
|
|
|
-</style>
|
|
|
+</style>
|