|
@@ -100,10 +100,9 @@
|
|
<p>显示图标</p>
|
|
<p>显示图标</p>
|
|
<el-upload
|
|
<el-upload
|
|
class="avatar-uploader"
|
|
class="avatar-uploader"
|
|
- action="/#"
|
|
|
|
|
|
+ action="#"
|
|
:show-file-list="false"
|
|
:show-file-list="false"
|
|
- :before-upload="beforeAvatarUpload"
|
|
|
|
- :on-success="handleAvatarSuccess"
|
|
|
|
|
|
+ :http-request="uploadImage"
|
|
>
|
|
>
|
|
<img v-if="equipmentData.url" :src="equipmentData.imgUrl" class="avatar" />
|
|
<img v-if="equipmentData.url" :src="equipmentData.imgUrl" class="avatar" />
|
|
|
|
|
|
@@ -605,7 +604,8 @@ export default {
|
|
changeColor(val) {
|
|
changeColor(val) {
|
|
// // console.log("changeColor: ", val);
|
|
// // console.log("changeColor: ", val);
|
|
},
|
|
},
|
|
- beforeAvatarUpload(file) {
|
|
|
|
|
|
+ uploadImage(resData) {
|
|
|
|
+ const { file } = resData;
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
const that = this;
|
|
const that = this;
|
|
const fileReader = new FileReader();
|
|
const fileReader = new FileReader();
|
|
@@ -644,6 +644,7 @@ export default {
|
|
if (xhr.readyState == 4) {
|
|
if (xhr.readyState == 4) {
|
|
if (xhr.status == 200) {
|
|
if (xhr.status == 200) {
|
|
that.equipmentData.url = uploadKey + "." + imgType;
|
|
that.equipmentData.url = uploadKey + "." + imgType;
|
|
|
|
+ that.equipmentData.imgUrl = URL.createObjectURL(file);
|
|
// console.log(uploadKey + "." + imgType);
|
|
// console.log(uploadKey + "." + imgType);
|
|
// bus.$emit("updateStyle", "url", baseUrl + uploadKey + "." + imgType);
|
|
// bus.$emit("updateStyle", "url", baseUrl + uploadKey + "." + imgType);
|
|
}
|
|
}
|
|
@@ -654,10 +655,6 @@ export default {
|
|
reader.readAsArrayBuffer(file);
|
|
reader.readAsArrayBuffer(file);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
- handleAvatarSuccess(res, file) {
|
|
|
|
- // console.log(res, file);
|
|
|
|
- this.equipmentData.imgUrl = URL.createObjectURL(file.raw);
|
|
|
|
- },
|
|
|
|
dataURLtoBlob(dataURI, type) {
|
|
dataURLtoBlob(dataURI, type) {
|
|
const binary = atob(dataURI.split(",")[1]);
|
|
const binary = atob(dataURI.split(",")[1]);
|
|
const array = [];
|
|
const array = [];
|