@@ -199,7 +199,11 @@ export default {
199
199
},
200
200
beforeUpload: {
201
201
type: Function ,
202
- ' default ' : () => null
202
+ ' default ' : () => {}
203
+ },
204
+ cropUploadSuccess: {
205
+ type: Function ,
206
+ ' default ' : () => {}
203
207
}
204
208
},
205
209
data () {
@@ -800,7 +804,7 @@ export default {
800
804
},
801
805
// 上传图片
802
806
async upload () {
803
- await beforeUpload ()
807
+ await this . beforeUpload (this . createImgUrl , this . field , this . ki )
804
808
805
809
let that = this ,
806
810
{
@@ -817,7 +821,6 @@ export default {
817
821
method
818
822
} = this ,
819
823
fmData = new FormData ();
820
- fmData .append (field, data2blob (createImgUrl, mime), field + ' .' + imgFormat);
821
824
822
825
// 添加其他参数
823
826
if (typeof params == ' object' && params) {
@@ -826,6 +829,8 @@ export default {
826
829
})
827
830
}
828
831
832
+ fmData .append (field, data2blob (createImgUrl, mime), field + ' .' + imgFormat);
833
+
829
834
// 监听进度回调
830
835
const uploadProgress = function (event ) {
831
836
if (event .lengthComputable ) {
@@ -864,7 +869,7 @@ export default {
864
869
function (resData ) {
865
870
if (that .value ) {
866
871
that .loading = 2 ;
867
- that .$emit (' crop-upload-success' , resData, field, ki);
872
+ that .$emit (' crop-upload-success' , resData, field, ki, that . reset );
868
873
}
869
874
},
870
875
// 上传失败
@@ -873,7 +878,7 @@ export default {
873
878
that .loading = 3 ;
874
879
that .hasError = true ;
875
880
that .errorMsg = lang .fail ;
876
- that .$emit (' crop-upload-fail' , sts, field, ki);
881
+ that .$emit (' crop-upload-fail' , sts, field, ki, that . reset );
877
882
}
878
883
}
879
884
);
0 commit comments