修复导出bug
This commit is contained in:
@@ -277,7 +277,6 @@
|
|||||||
<div>all</div>
|
<div>all</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="SRExport_img">
|
<div class="SRExport_img">
|
||||||
<div class="SRExport_img_item_box" v-for="item in allExportSR" @click="selectImg(item)">
|
<div class="SRExport_img_item_box" v-for="item in allExportSR" @click="selectImg(item)">
|
||||||
<input type="checkbox" v-model="item.checked">
|
<input type="checkbox" v-model="item.checked">
|
||||||
@@ -310,6 +309,7 @@ import { exportSele,JSRectUpdata,JSchangeType,JScanvasMouseDown,JScanvasMouseMov
|
|||||||
import { useI18n } from "vue-i18n";
|
import { useI18n } from "vue-i18n";
|
||||||
import {isMoible,calculateGradientCoordinate,base64ToFile} from '@/tool/util'
|
import {isMoible,calculateGradientCoordinate,base64ToFile} from '@/tool/util'
|
||||||
import publish from "@/component/WorksPage/publish.vue";
|
import publish from "@/component/WorksPage/publish.vue";
|
||||||
|
import { connect } from "echarts";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
components: {
|
components: {
|
||||||
@@ -326,7 +326,7 @@ export default defineComponent({
|
|||||||
})
|
})
|
||||||
|
|
||||||
let showUpgradePlan = ref(false);
|
let showUpgradePlan = ref(false);
|
||||||
let canvas = reactive({});
|
let canvas = ref({});
|
||||||
// let canvasDom = ref()
|
// let canvasDom = ref()
|
||||||
let canvasWH = ref({
|
let canvasWH = ref({
|
||||||
width: 400,
|
width: 400,
|
||||||
@@ -363,11 +363,11 @@ export default defineComponent({
|
|||||||
let isLoadCanvas = false//撤回或者反撤回false为撤回
|
let isLoadCanvas = false//撤回或者反撤回false为撤回
|
||||||
let userlikeGroupId = 0
|
let userlikeGroupId = 0
|
||||||
let init = (productData) => {
|
let init = (productData) => {
|
||||||
|
showUpgradePlan.value = true;
|
||||||
userlikeGroupId = productData.userlikeGroupId
|
userlikeGroupId = productData.userlikeGroupId
|
||||||
canvasWH.value.height = 100
|
canvasWH.value.height = 100
|
||||||
normalCanvasState.value = []
|
normalCanvasState.value = []
|
||||||
reverseCanvasState.value = []
|
reverseCanvasState.value = []
|
||||||
showUpgradePlan.value = true;
|
|
||||||
allBoardData.value.likeDesignCollectionList =
|
allBoardData.value.likeDesignCollectionList =
|
||||||
likeDesignCollectionList;
|
likeDesignCollectionList;
|
||||||
allBoardData.value[productData.key] = productData.imgList;
|
allBoardData.value[productData.key] = productData.imgList;
|
||||||
@@ -470,6 +470,7 @@ export default defineComponent({
|
|||||||
//循环渲染顺序
|
//循环渲染顺序
|
||||||
|
|
||||||
let imgWidth = setImageWidth(key); //这是设置画布等宽
|
let imgWidth = setImageWidth(key); //这是设置画布等宽
|
||||||
|
// alert(imgWidth)
|
||||||
let sketchGroupingItem = [];
|
let sketchGroupingItem = [];
|
||||||
if (
|
if (
|
||||||
item == "moodboardFiles" &&
|
item == "moodboardFiles" &&
|
||||||
@@ -501,62 +502,66 @@ export default defineComponent({
|
|||||||
allItem.designOutfitUrl;
|
allItem.designOutfitUrl;
|
||||||
}
|
}
|
||||||
fabric.Image.fromURL(itemCanvasImg,(img) => {
|
fabric.Image.fromURL(itemCanvasImg,(img) => {
|
||||||
let scaleWH = imgWidth / img.width; //计算放到画布上缩小倍率
|
img.on('added', () => {
|
||||||
if(key == "sketchboardFiles"){
|
img.set({ crossOrigin: 'anonymous' });
|
||||||
if(allItemIndex == 0){
|
let scaleWH = imgWidth / img.width; //计算放到画布上缩小倍率
|
||||||
position.x = 0;
|
if(key == "sketchboardFiles"){
|
||||||
position.y = maxHeight;
|
if(allItemIndex == 0){
|
||||||
}
|
position.x = 0;
|
||||||
}else{
|
position.y = maxHeight;
|
||||||
if (position.x + img.width * scaleWH > canvasWH.value.width || oldKey != key) {
|
}
|
||||||
position.x = 0;
|
}else{
|
||||||
position.y = maxHeight;
|
if (position.x + img.width * scaleWH > canvasWH.value.width || oldKey != key) {
|
||||||
}
|
position.x = 0;
|
||||||
}
|
position.y = maxHeight;
|
||||||
setCanvasImage(img,key,position.x,position.y,allItem)//设置图片
|
|
||||||
position.height = img.height * scaleWH + margin;
|
|
||||||
if (key == "sketchboardFiles") {
|
|
||||||
if (sketchGroupingItem.length <3) {
|
|
||||||
sketchGroupingItem.push(JSON.parse(JSON.stringify(position)));
|
|
||||||
}
|
|
||||||
if (sketchGroupingItem.length >2) {
|
|
||||||
let sketchXyIndex = {
|
|
||||||
maxIndex: 0,
|
|
||||||
maxNum: 0,
|
|
||||||
minNum: 999999,
|
|
||||||
minIndex: 0,
|
|
||||||
};
|
|
||||||
sketchGroupingItem.forEach(
|
|
||||||
(sketchItem,sketchIndex) => {
|
|
||||||
if (sketchItem.y + sketchItem.height < sketchXyIndex.minNum) {
|
|
||||||
sketchXyIndex.minNum = sketchItem.y + sketchItem.height
|
|
||||||
sketchXyIndex.minIndex = sketchIndex;
|
|
||||||
}
|
|
||||||
if (sketchItem.y + sketchItem.height > sketchXyIndex.maxNum) {
|
|
||||||
sketchXyIndex.maxNum = sketchItem.y + sketchItem.height
|
|
||||||
sketchXyIndex.maxIndex = sketchIndex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
sketchGroupingItem[sketchXyIndex.minIndex].y = sketchXyIndex.minNum
|
|
||||||
// sketchGroupingItem[sketchXyIndex.maxIndex].y = sketchXyIndex.maxNum
|
|
||||||
if (allBoardData.value[key].length == allItemIndex + 1) {
|
|
||||||
maxHeight = sketchXyIndex.maxNum
|
|
||||||
} else {
|
|
||||||
position = sketchGroupingItem[sketchXyIndex.minIndex];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
setCanvasImage(img,key,position.x,position.y,allItem)//设置图片
|
||||||
if(key == "sketchboardFiles" && sketchGroupingItem.length >2){
|
position.height = img.height * scaleWH + margin;
|
||||||
}else{
|
if (key == "sketchboardFiles") {
|
||||||
position.x += img.width * scaleWH + margin;
|
if (sketchGroupingItem.length <3) {
|
||||||
}
|
sketchGroupingItem.push(JSON.parse(JSON.stringify(position)));
|
||||||
img.lock_rotation = true;
|
}
|
||||||
canvas.add(img);
|
if (sketchGroupingItem.length >2) {
|
||||||
oldKey = key;
|
let sketchXyIndex = {
|
||||||
// setTimeout(() => {
|
maxIndex: 0,
|
||||||
|
maxNum: 0,
|
||||||
|
minNum: 999999,
|
||||||
|
minIndex: 0,
|
||||||
|
};
|
||||||
|
sketchGroupingItem.forEach(
|
||||||
|
(sketchItem,sketchIndex) => {
|
||||||
|
if (sketchItem.y + sketchItem.height < sketchXyIndex.minNum) {
|
||||||
|
sketchXyIndex.minNum = sketchItem.y + sketchItem.height
|
||||||
|
sketchXyIndex.minIndex = sketchIndex;
|
||||||
|
}
|
||||||
|
if (sketchItem.y + sketchItem.height > sketchXyIndex.maxNum) {
|
||||||
|
sketchXyIndex.maxNum = sketchItem.y + sketchItem.height
|
||||||
|
sketchXyIndex.maxIndex = sketchIndex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
sketchGroupingItem[sketchXyIndex.minIndex].y = sketchXyIndex.minNum
|
||||||
|
// sketchGroupingItem[sketchXyIndex.maxIndex].y = sketchXyIndex.maxNum
|
||||||
|
if (allBoardData.value[key].length == allItemIndex + 1) {
|
||||||
|
maxHeight = sketchXyIndex.maxNum
|
||||||
|
} else {
|
||||||
|
position = sketchGroupingItem[sketchXyIndex.minIndex];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(key == "sketchboardFiles" && sketchGroupingItem.length >2){
|
||||||
|
}else{
|
||||||
|
position.x += img.width * scaleWH + margin;
|
||||||
|
}
|
||||||
|
let str = `${img.width} + ${scaleWH}`
|
||||||
|
img.lock_rotation = true;
|
||||||
|
oldKey = key;
|
||||||
resolve()
|
resolve()
|
||||||
// }, 1000);
|
})
|
||||||
|
|
||||||
|
canvas.add(img);
|
||||||
|
|
||||||
},{ crossOrigin: "Anonymous" });
|
},{ crossOrigin: "Anonymous" });
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -793,6 +798,7 @@ export default defineComponent({
|
|||||||
let xmlhttp = new XMLHttpRequest();
|
let xmlhttp = new XMLHttpRequest();
|
||||||
xmlhttp.open("GET", url, true);
|
xmlhttp.open("GET", url, true);
|
||||||
xmlhttp.responseType = "blob";
|
xmlhttp.responseType = "blob";
|
||||||
|
xmlhttp.withCredentials = false;
|
||||||
xmlhttp.onload = function () {
|
xmlhttp.onload = function () {
|
||||||
if (this.status == 200) {
|
if (this.status == 200) {
|
||||||
resolve(this.response);
|
resolve(this.response);
|
||||||
@@ -812,15 +818,27 @@ export default defineComponent({
|
|||||||
// 下载文件, 并存成ArrayBuffer对象(blob)
|
// 下载文件, 并存成ArrayBuffer对象(blob)
|
||||||
zip.file(item.name, data, { binary: true }); // 逐个添加文件
|
zip.file(item.name, data, { binary: true }); // 逐个添加文件
|
||||||
cache[item.title] = data;
|
cache[item.title] = data;
|
||||||
});
|
})
|
||||||
promises.push(promise);
|
promises.push(promise);
|
||||||
}
|
}
|
||||||
Promise.all(promises)
|
Promise.all(promises)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
function downloadBlob(blob, filename) {
|
||||||
|
const link = document.createElement('a');
|
||||||
|
const url = URL.createObjectURL(blob);
|
||||||
|
link.href = url;
|
||||||
|
link.download = filename;
|
||||||
|
document.body.appendChild(link);
|
||||||
|
link.click();
|
||||||
|
URL.revokeObjectURL(url);
|
||||||
|
document.body.removeChild(link);
|
||||||
|
}
|
||||||
zip.generateAsync({ type: "blob" }).then((content) => {
|
zip.generateAsync({ type: "blob" }).then((content) => {
|
||||||
// 生成二进制流
|
// 生成二进制流
|
||||||
FileSaver.saveAs(content, "DesignFiles"); // 利用file-saver保存文件 自定义文件名
|
downloadBlob(content,'DesignFiles')
|
||||||
|
// FileSaver.saveAs(content, "DesignFiles"); // 利用file-saver保存文件 自定义文件名
|
||||||
isShowMark.value = false;
|
isShowMark.value = false;
|
||||||
|
|
||||||
});
|
});
|
||||||
setSubmit()//导出的时候保存
|
setSubmit()//导出的时候保存
|
||||||
initAligningGuidelines(canvas,true)
|
initAligningGuidelines(canvas,true)
|
||||||
|
|||||||
Reference in New Issue
Block a user