|
@@ -129,35 +129,34 @@ export default {
|
|
|
this.imgList.push(fileList);
|
|
|
},
|
|
|
submitUpload() {
|
|
|
- if (this.imgList > 0) {
|
|
|
- this.mark = true;
|
|
|
- let form = new FormData();
|
|
|
- for (let key in this.paramsData) {
|
|
|
- form.append(key, this.paramsData[key]);
|
|
|
- }
|
|
|
- console.log(this.imgList);
|
|
|
- this.imgList.forEach(file => {
|
|
|
- form.append('file', file.raw);
|
|
|
- });
|
|
|
- // this.mark = false;
|
|
|
- this.api(form)
|
|
|
- .then(({ success }) => {
|
|
|
- if (success) {
|
|
|
- this.mark = false;
|
|
|
- this.$emit('finish');
|
|
|
- } else {
|
|
|
- this.$error('上传失败,请稍后重试...');
|
|
|
- this.mark = false;
|
|
|
- }
|
|
|
- })
|
|
|
- .catch(err => {
|
|
|
- console.error(err);
|
|
|
- this.$error('上传失败,请稍后重试...');
|
|
|
- this.mark = false;
|
|
|
- });
|
|
|
- } else {
|
|
|
+ if (this.imgList == 0) {
|
|
|
this.$error('未选择图片,请先选择图片');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.mark = true;
|
|
|
+ let form = new FormData();
|
|
|
+ for (let key in this.paramsData) {
|
|
|
+ form.append(key, this.paramsData[key]);
|
|
|
}
|
|
|
+
|
|
|
+ this.imgList.forEach(file => {
|
|
|
+ form.append('file', file.raw);
|
|
|
+ });
|
|
|
+
|
|
|
+ this.api(form).then(({ success }) => {
|
|
|
+ if (success) {
|
|
|
+ this.mark = false;
|
|
|
+ this.$emit('finish');
|
|
|
+ } else {
|
|
|
+ this.$error('上传失败,请稍后重试...');
|
|
|
+ this.mark = false;
|
|
|
+ }
|
|
|
+ }).catch(err => {
|
|
|
+ console.error(err);
|
|
|
+ this.$error('上传失败,请稍后重试...');
|
|
|
+ this.mark = false;
|
|
|
+ });
|
|
|
},
|
|
|
handlePictureCardPreview(file) {
|
|
|
this.dialogImageUrl = file.url;
|