diff --git a/src/components/xUpload/index.vue b/src/components/xUpload/index.vue
index 2edfe8e..9f013df 100644
--- a/src/components/xUpload/index.vue
+++ b/src/components/xUpload/index.vue
@@ -66,7 +66,7 @@
title: { type: String, default: "" },
icon: { type: String, default: "el-icon-plus" },
action: { type: String, default: "" },
- apiObj: { type: Object, default: () => {} },
+ api: { type: String, default: "" },
name: { type: String, default: config.filename },
data: { type: Object, default: () => {} },
accept: { type: String, default: "image/gif, image/jpeg, image/png" },
@@ -77,6 +77,7 @@
disabled: { type: Boolean, default: false },
round: { type: Boolean, default: false },
onSuccess: { type: Function, default: () => { return true } },
+ onRemove: { type: Function, default: () => { return true } },
cropper: { type: Boolean, default: false },
compress: {type: Number, default: 1},
aspectRatio: {type: Number, default: NaN}
@@ -148,6 +149,10 @@
delete this.cropperFile.tempCropperFile
},
handleRemove(){
+ var os = this.onRemove()
+ if(os!=undefined && os===false){
+ return false
+ }
this.clearFiles()
},
clearFiles(){
@@ -229,16 +234,13 @@
})
},
request(param){
- var apiObj = config.apiObj;
- if(this.apiObj){
- apiObj = this.apiObj;
- }
+ var api = this.api ? this.api : config.api;
const data = new FormData();
data.append(param.filename, param.file);
for (const key in param.data) {
data.append(key, param.data[key]);
}
- apiObj.post(data, {
+ this.$http.post(api,data, {
onUploadProgress: e => {
const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10)
param.onProgress({percent: complete})
@@ -249,7 +251,6 @@
param.onSuccess(response);
return ;
}
-
param.onError(response.message || "未知错误")
}).catch(err => {
param.onError(err)
@@ -262,9 +263,7 @@
+