意见反馈图片上传问题
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
9f124da272
commit
02df28b2fa
|
@ -97,6 +97,7 @@
|
||||||
<el-form-item :label="$t('feedBack:form:screenshot')" prop="screenshot">
|
<el-form-item :label="$t('feedBack:form:screenshot')" prop="screenshot">
|
||||||
<uploadImage
|
<uploadImage
|
||||||
:path.sync="form.ScreenshotList"
|
:path.sync="form.ScreenshotList"
|
||||||
|
:isUpload.sync="loading"
|
||||||
:disabled="type === 'detail'"
|
:disabled="type === 'detail'"
|
||||||
ref="uploadImage"
|
ref="uploadImage"
|
||||||
/>
|
/>
|
||||||
|
@ -209,6 +210,7 @@ export default {
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
isUpload: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
|
@ -15,13 +15,24 @@
|
||||||
list-type="picture-card"
|
list-type="picture-card"
|
||||||
>
|
>
|
||||||
<i slot="default" class="el-icon-plus"></i>
|
<i slot="default" class="el-icon-plus"></i>
|
||||||
<div slot="file" slot-scope="{ file }">
|
<div slot="file" slot-scope="{ file }" style="width: 100%; height: 100%">
|
||||||
<viewer :ref="file.url" :images="fileList">
|
<viewer
|
||||||
|
:ref="file.url"
|
||||||
|
:images="fileList"
|
||||||
|
style="
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
"
|
||||||
|
>
|
||||||
<img
|
<img
|
||||||
class="el-upload-list__item-thumbnail"
|
class="el-upload-list__item-thumbnail"
|
||||||
:src="`${file.url}`"
|
:src="`${file.url}`"
|
||||||
alt=""
|
alt=""
|
||||||
crossorigin="anonymous"
|
crossorigin="anonymous"
|
||||||
|
style="max-width: 100%; max-height: 100%"
|
||||||
/>
|
/>
|
||||||
<span class="el-upload-list__item-actions" v-if="!isUpload">
|
<span class="el-upload-list__item-actions" v-if="!isUpload">
|
||||||
<span
|
<span
|
||||||
|
@ -61,12 +72,15 @@ export default {
|
||||||
required: true,
|
required: true,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
isUpload: {
|
||||||
|
required: true,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
fileList: [],
|
fileList: [],
|
||||||
btnDisabled: false,
|
btnDisabled: false,
|
||||||
isUpload: false,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
@ -122,19 +136,29 @@ export default {
|
||||||
},
|
},
|
||||||
async uploadFile(param) {
|
async uploadFile(param) {
|
||||||
var fileName = param.file.name;
|
var fileName = param.file.name;
|
||||||
this.isUpload = true;
|
this.$emit("update:isUpload", true);
|
||||||
this.btnDisabled = true;
|
this.btnDisabled = true;
|
||||||
|
this.fileList.push({
|
||||||
|
url: param.file.url,
|
||||||
|
path: fileName,
|
||||||
|
uid: param.file.uid,
|
||||||
|
});
|
||||||
let file = await this.fileToBlob(param.file);
|
let file = await this.fileToBlob(param.file);
|
||||||
let res = await this.uploadToOSS(fileName, file);
|
let res = await this.uploadToOSS(fileName, file);
|
||||||
this.btnDisabled = false;
|
this.btnDisabled = false;
|
||||||
if (!res) return (this.isUpload = false);
|
let index = this.fileList.findIndex(
|
||||||
this.fileList.push({
|
(item) => item.uid === param.file.uid
|
||||||
url: this.OSSclientConfig.basePath + res.name,
|
);
|
||||||
path: res.name,
|
if (!res) {
|
||||||
uid: param.file.uid,
|
if (index >= 0) {
|
||||||
});
|
this.fileList.splice(index, 1);
|
||||||
|
}
|
||||||
|
return this.$emit("update:isUpload", false);
|
||||||
|
}
|
||||||
|
this.fileList[index].url = this.OSSclientConfig.basePath + res.name;
|
||||||
|
this.fileList[index].path = res.name;
|
||||||
this.$emit("update:path", [...this.path, res.name]);
|
this.$emit("update:path", [...this.path, res.name]);
|
||||||
this.isUpload = false;
|
this.$emit("update:isUpload", false);
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
beforeUpload(file, fileList) {
|
beforeUpload(file, fileList) {
|
||||||
|
@ -216,4 +240,8 @@ export default {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
}
|
}
|
||||||
|
.el-upload-list--picture-card .el-upload-list__item-thumbnail {
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue