|
@@ -2,6 +2,7 @@
|
|
<div>
|
|
<div>
|
|
<el-row>
|
|
<el-row>
|
|
<el-upload
|
|
<el-upload
|
|
|
|
+ :file-list="imgList"
|
|
v-loading.fullscreen.lock="mark"
|
|
v-loading.fullscreen.lock="mark"
|
|
ref="upload"
|
|
ref="upload"
|
|
action=""
|
|
action=""
|
|
@@ -17,16 +18,32 @@
|
|
<div slot="file" slot-scope="{ file }">
|
|
<div slot="file" slot-scope="{ file }">
|
|
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
|
<img class="el-upload-list__item-thumbnail" :src="file.url" alt="" />
|
|
<span class="el-upload-list__item-actions">
|
|
<span class="el-upload-list__item-actions">
|
|
- <span class="el-upload-list__item-preview" @click="handlePictureCardPreview(file)">
|
|
|
|
|
|
+ <span
|
|
|
|
+ class="el-upload-list__item-preview"
|
|
|
|
+ @click="handlePictureCardPreview(file)"
|
|
|
|
+ >
|
|
<i class="el-icon-zoom-in" />
|
|
<i class="el-icon-zoom-in" />
|
|
</span>
|
|
</span>
|
|
|
|
+ <span
|
|
|
|
+ class="el-upload-list__item-preview"
|
|
|
|
+ @click="handleDeleteItem(file)"
|
|
|
|
+ >
|
|
|
|
+ <i class="el-icon-delete" />
|
|
|
|
+ </span>
|
|
</span>
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</el-upload>
|
|
</el-upload>
|
|
</el-row>
|
|
</el-row>
|
|
|
|
|
|
<el-row style="text-align: right;">
|
|
<el-row style="text-align: right;">
|
|
- <el-button class="mt-40" style="margin-left: 10px;" size="small" type="success" @click="submitUpload">上传到服务器</el-button>
|
|
|
|
|
|
+ <el-button
|
|
|
|
+ class="mt-40"
|
|
|
|
+ style="margin-left: 10px;"
|
|
|
|
+ size="small"
|
|
|
|
+ type="success"
|
|
|
|
+ @click="submitUpload"
|
|
|
|
+ >上传到服务器</el-button
|
|
|
|
+ >
|
|
</el-row>
|
|
</el-row>
|
|
|
|
|
|
<el-dialog :visible.sync="dialogVisible" :modal="false">
|
|
<el-dialog :visible.sync="dialogVisible" :modal="false">
|
|
@@ -112,35 +129,43 @@ export default {
|
|
this.imgList.push(fileList);
|
|
this.imgList.push(fileList);
|
|
},
|
|
},
|
|
submitUpload() {
|
|
submitUpload() {
|
|
- 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 {
|
|
|
|
|
|
+ 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.$error('上传失败,请稍后重试...');
|
|
this.mark = false;
|
|
this.mark = false;
|
|
- }
|
|
|
|
- })
|
|
|
|
- .catch(err => {
|
|
|
|
- console.error(err);
|
|
|
|
- this.$error('上传失败,请稍后重试...');
|
|
|
|
- this.mark = false;
|
|
|
|
- });
|
|
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+ this.$error('未选择图片,请先选择图片');
|
|
|
|
+ }
|
|
},
|
|
},
|
|
handlePictureCardPreview(file) {
|
|
handlePictureCardPreview(file) {
|
|
this.dialogImageUrl = file.url;
|
|
this.dialogImageUrl = file.url;
|
|
this.dialogVisible = true;
|
|
this.dialogVisible = true;
|
|
|
|
+ },
|
|
|
|
+ handleDeleteItem(file) {
|
|
|
|
+ const index = this.imgList.findIndex(x => x.uid === file.uid);
|
|
|
|
+ this.imgList.splice(index, 1);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
};
|
|
};
|