fix: 修改 chart diagram 第一次上传图片无法使用的问题

This commit is contained in:
zhangyu
2021-09-26 14:45:11 +08:00
parent f465b6b129
commit 5abda52fb1
2 changed files with 49 additions and 15 deletions

View File

@@ -825,8 +825,9 @@ export default {
opacity: data.data.opacity,
name: data.name
}
if (this.fromOverView) { // 优化从首页来的加载速度
if (this.fromOverView || this.fromChartBox) { // 优化从首页来的加载速度
const arr = data.pens.filter(item => !item.type)
this.imgInit = false
this.addNodeInit(arr)
}
const timer = setInterval(() => {
@@ -1577,7 +1578,7 @@ export default {
const group = this.tools.find(tool => tool.group === this.uploadPic.unit)
this.iconArray.push({
...iconInfo.data.list[0],
image: data
image: data.data
})
if (group) {
group.children.push({
@@ -1585,7 +1586,7 @@ export default {
data: {
...imageTemp2.data,
text: res.data.imageName,
image: data,
image: data.data,
imageId: res.data.id,
unit: this.uploadPic.unit
}
@@ -1598,7 +1599,7 @@ export default {
data: {
...imageTemp2.data,
text: res.data.imageName,
image: data,
image: data.data,
imageId: res.data.id,
unit: this.uploadPic.unit
}

View File

@@ -1588,7 +1588,7 @@ export default {
const group = this.tools.find(tool => tool.group === this.uploadPic.unit)
this.iconArray.push({
...iconInfo.data.list[0],
image: data
image: data.data
})
if (group) {
group.children.push({
@@ -1596,9 +1596,13 @@ export default {
data: {
...imageTemp.data,
text: res.data.imageName,
image: data,
image: data.data,
imageId: res.data.id,
unit: this.uploadPic.unit
unit: this.uploadPic.unit,
rect: {
width: data.width,
height: data.height
}
}
})
} else {
@@ -1609,9 +1613,13 @@ export default {
data: {
...imageTemp.data,
text: res.data.imageName,
image: data,
image: data.data,
imageId: res.data.id,
unit: this.uploadPic.unit
unit: this.uploadPic.unit,
rect: {
width: data.width,
height: data.height
}
}
}]
})
@@ -1686,9 +1694,13 @@ export default {
data: {
...imageTemp.data,
text: item.imageName,
image: res2[index],
image: res2[index].data,
imageId: item.id,
unit: item.unit
unit: item.unit,
rect: {
width: res2[index].width,
height: res2[index].height
}
}
})
} else {
@@ -1701,7 +1713,11 @@ export default {
text: item.imageName,
image: res2[index],
imageId: item.id,
unit: item.unit
unit: item.unit,
rect: {
width: res2[index].width,
height: res2[index].height
}
}
}]
})
@@ -1750,12 +1766,29 @@ export default {
this.$axios
.get(url)
.then((res) => {
return {
data: ('data:image/jpeg;base64,' + res.data)
const imageInfo = {
data: ('data:image/jpeg;base64,' + res.data),
// width: res.headers.width === -1 ? 100 : (res.headers.width > 900 ? 900 : res.headers.width),
// height: res.headers.height === -1 ? 100 : (res.headers.height > 900 ? 900 : res.headers.height)
width: res.headers.width === -1 ? 100 : Number(res.headers.width),
height: res.headers.height === -1 ? 100 : Number(res.headers.height)
}
if (imageInfo.width > 900 || imageInfo.height > 900) {
if (imageInfo.height > imageInfo.width) {
imageInfo.width = imageInfo.width * 900 / imageInfo.height
imageInfo.height = 900
} else if (imageInfo.height < imageInfo.width) {
imageInfo.height = imageInfo.height * 900 / imageInfo.width
imageInfo.width = 900
} else {
imageInfo.height = 900
imageInfo.width = 900
}
}
return imageInfo
})
.then(data => {
resolve(data.data, data.header)
resolve(data)
// changeImage(data,(img)=>{
// resolve(img)
// })