fl-web-component 2.1.2 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/fl-web-component.common.js +229 -287
- package/dist/fl-web-component.common.js.map +1 -1
- package/dist/fl-web-component.css +1 -1
- package/package.json +1 -1
- package/packages/components/com-flcanvas/components/entityFormatting.js +28 -14
- package/packages/components/com-flcanvas/index.vue +159 -260
- package/packages/components/com-graphics/mock.json +57 -83
|
@@ -177,6 +177,7 @@ export default {
|
|
|
177
177
|
});
|
|
178
178
|
this.konvaStage.on('click', e => {
|
|
179
179
|
let target = this.konvaStage.mouseClickEndShape;
|
|
180
|
+
console.log(e)
|
|
180
181
|
this.$emit('leftClick', target ? target.attrs : null);
|
|
181
182
|
});
|
|
182
183
|
});
|
|
@@ -197,7 +198,7 @@ export default {
|
|
|
197
198
|
this.konvaStage.position({ x: x, y: y });
|
|
198
199
|
this.konvaStage.scale({ x: scale, y: scale });
|
|
199
200
|
|
|
200
|
-
this.konvaStage.batchDraw();
|
|
201
|
+
// this.konvaStage.batchDraw();
|
|
201
202
|
}
|
|
202
203
|
},
|
|
203
204
|
calculateScaleAndPosition(contentBounds, stageWidth, stageHeight, padding = 0.1) {
|
|
@@ -260,12 +261,14 @@ export default {
|
|
|
260
261
|
},
|
|
261
262
|
updateBounds1(v) {
|
|
262
263
|
if (this.bounds1 === null) {
|
|
263
|
-
this.bounds1 = { minX: v.x, maxX: v.x, minY: v.y, maxY: v.y }
|
|
264
|
+
this.bounds1 = { minX: v.x, maxX: v.x, minY: v.y, maxY: v.y }
|
|
264
265
|
} else {
|
|
265
266
|
if (v.x < this.bounds1.minX) {
|
|
266
267
|
this.bounds1.minX = v.x;
|
|
268
|
+
|
|
267
269
|
} else if (v.x > this.bounds1.maxX) {
|
|
268
270
|
this.bounds1.maxX = v.x;
|
|
271
|
+
|
|
269
272
|
}
|
|
270
273
|
if (v.y < this.bounds1.minY) {
|
|
271
274
|
this.bounds1.minY = v.y;
|
|
@@ -276,20 +279,104 @@ export default {
|
|
|
276
279
|
},
|
|
277
280
|
//思路是计算居中包围盒,然后排除脏数据。
|
|
278
281
|
loadDxf(data) {
|
|
279
|
-
let _this = this;
|
|
280
282
|
this.bounds = null;
|
|
281
283
|
this.konvaLayer.destroyChildren();
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
// 在这里处理数据为空的时候
|
|
285
|
-
if (dxf.entities.length === 0) {
|
|
284
|
+
let flag = this.formatDrawData(data, 'updateBounds')
|
|
285
|
+
if (!flag) {
|
|
286
286
|
this.$emit('error', {
|
|
287
287
|
type: 'entityEmpty'
|
|
288
288
|
})
|
|
289
289
|
return
|
|
290
290
|
}
|
|
291
|
+
|
|
292
|
+
//缩放视口
|
|
293
|
+
let scale = 1;
|
|
294
|
+
const boundingRect = this.konvaLayer.getClientRect();
|
|
295
|
+
let ratio = Number((this.$refs.svgDraw?.clientWidth / boundingRect.width).toFixed(1));
|
|
296
|
+
if (ratio > 2) {
|
|
297
|
+
scale = Number((boundingRect.width / boundingRect.height).toFixed(1));
|
|
298
|
+
scale = scale < 2 ? 2 : scale;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
const boundingScale = this.konvaLayer.getClientRect();
|
|
302
|
+
//平移视口
|
|
303
|
+
const x =
|
|
304
|
+
this.$refs.svgDraw?.clientWidth / 2 -
|
|
305
|
+
(Math.ceil(boundingScale.width) / 2 + boundingScale.x / 2);
|
|
306
|
+
const y =
|
|
307
|
+
this.$refs.svgDraw.clientHeight / 2 -
|
|
308
|
+
(Math.ceil(boundingScale.height) / 2 + boundingScale.y);
|
|
309
|
+
|
|
310
|
+
// this.konvaStage.scale({
|
|
311
|
+
// x: 2,
|
|
312
|
+
// y: 2,
|
|
313
|
+
// });
|
|
314
|
+
// this.konvaStage.setX(0);
|
|
315
|
+
// this.konvaStage.setY(750); // 750
|
|
316
|
+
|
|
317
|
+
// this.activedSvgPan.zoom.x = 0;
|
|
318
|
+
// this.activedSvgPan.zoom.y = 750;
|
|
319
|
+
// this.activedSvgPan.x = x;
|
|
320
|
+
// this.activedSvgPan.y = x;
|
|
321
|
+
setTimeout(() => {
|
|
322
|
+
this.centerDraw();
|
|
323
|
+
this.$emit('loaded');
|
|
324
|
+
}, 100);
|
|
325
|
+
},
|
|
326
|
+
toPdf(name) {
|
|
327
|
+
//this.konvaStage.scale({
|
|
328
|
+
//x: this.activedSvgPan.zoom.x,
|
|
329
|
+
//y: this.activedSvgPan.zoom.y,
|
|
330
|
+
//});
|
|
331
|
+
//this.konvaStage.setX(this.activedSvgPan.x);
|
|
332
|
+
//this.konvaStage.setY(this.activedSvgPan.y);
|
|
333
|
+
// get data URL with default settings
|
|
334
|
+
|
|
335
|
+
// open in new window
|
|
336
|
+
this.konvaLayer.getCanvas().setPixelRatio(2);
|
|
337
|
+
const jpegURL = this.konvaStage.toDataURL({
|
|
338
|
+
mimeType: 'image/jpeg',
|
|
339
|
+
quality: 1,
|
|
340
|
+
pixelRatio: 2,
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
let pageData = this.konvaLayer.canvas.toDataURL('image/jpeg', 2);
|
|
344
|
+
|
|
345
|
+
let img = new Image();
|
|
346
|
+
img.src = jpegURL;
|
|
347
|
+
const pdf = new jsPDF('l', 'px', [this.konvaStage.width(), this.konvaStage.height()]);
|
|
348
|
+
|
|
349
|
+
pdf.addImage(
|
|
350
|
+
this.konvaStage.toDataURL({ pixelRatio: 2 }),
|
|
351
|
+
0,
|
|
352
|
+
0,
|
|
353
|
+
this.konvaStage.width(),
|
|
354
|
+
this.konvaStage.height()
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
pdf.save(name + '.pdf');
|
|
358
|
+
// var imgData = canvas.toDataURL('image/png');
|
|
359
|
+
//doc.text("Hello world!", 10, 10);
|
|
360
|
+
//doc.save("a4.pdf");
|
|
361
|
+
},
|
|
362
|
+
// 处理图纸数据
|
|
363
|
+
formatDrawData(data, fn) {
|
|
364
|
+
let _this = this;
|
|
291
365
|
const parser2 = new DxfParser2();
|
|
292
366
|
let dxf2 = parser2.parseSync(data);
|
|
367
|
+
// const parser = new DxfParser();
|
|
368
|
+
// let dxf = parser.parse(data);
|
|
369
|
+
// 在这里处理数据为空的时候
|
|
370
|
+
// if (dxf.entities.length === 0) {
|
|
371
|
+
// this.$emit('error', {
|
|
372
|
+
// type: 'entityEmpty'
|
|
373
|
+
// })
|
|
374
|
+
// return
|
|
375
|
+
// }
|
|
376
|
+
if (dxf2.entities.length === 0) {
|
|
377
|
+
return false
|
|
378
|
+
}
|
|
379
|
+
console.log(dxf2)
|
|
293
380
|
let hatchEntitys = dxf2.entities.filter(item => item.type === 'HATCH');
|
|
294
381
|
// 处理HATCH部分
|
|
295
382
|
for (let i = 0; i < hatchEntitys.length; i++) {
|
|
@@ -425,7 +512,7 @@ export default {
|
|
|
425
512
|
// }
|
|
426
513
|
}
|
|
427
514
|
//加载图纸
|
|
428
|
-
let entities = formatEntity(
|
|
515
|
+
let entities = formatEntity(dxf2.entities);
|
|
429
516
|
for (let key in entities) {
|
|
430
517
|
if (entities[key]) {
|
|
431
518
|
let group = [];
|
|
@@ -437,13 +524,13 @@ export default {
|
|
|
437
524
|
let type = entities[key][i].type;
|
|
438
525
|
handleFn(
|
|
439
526
|
type,
|
|
440
|
-
|
|
527
|
+
dxf2,
|
|
441
528
|
entities[key][i],
|
|
442
529
|
group,
|
|
443
530
|
key,
|
|
444
531
|
configParams,
|
|
445
532
|
this.konvaLayer,
|
|
446
|
-
|
|
533
|
+
dxf2.tables.lineType.lineTypes
|
|
447
534
|
// this.recordLayerConfig
|
|
448
535
|
);
|
|
449
536
|
}
|
|
@@ -456,9 +543,6 @@ export default {
|
|
|
456
543
|
}
|
|
457
544
|
let shapeGroup = group.filter(item => item.type !== 'text')
|
|
458
545
|
if (shapeGroup.length > 0) {
|
|
459
|
-
// if (group[0]?.stroke) {
|
|
460
|
-
// group[0].stroke = '#000';
|
|
461
|
-
// }
|
|
462
546
|
// 根据颜色分组
|
|
463
547
|
let colorGroup = _.groupBy(shapeGroup, 'stroke');
|
|
464
548
|
for (const colorKey in colorGroup) {
|
|
@@ -492,8 +576,8 @@ export default {
|
|
|
492
576
|
let v2 = {};
|
|
493
577
|
v2.x = x2;
|
|
494
578
|
v2.y = y2;
|
|
495
|
-
_this
|
|
496
|
-
_this
|
|
579
|
+
_this[fn](v1);
|
|
580
|
+
_this[fn](v2);
|
|
497
581
|
}
|
|
498
582
|
if (entity.type === 'polyline') {
|
|
499
583
|
context.strokeStyle = entity.stroke;
|
|
@@ -512,7 +596,7 @@ export default {
|
|
|
512
596
|
let point = {};
|
|
513
597
|
point.x = x;
|
|
514
598
|
point.y = y;
|
|
515
|
-
_this
|
|
599
|
+
_this[fn](point);
|
|
516
600
|
|
|
517
601
|
if (j === 0) {
|
|
518
602
|
context.moveTo(x, y);
|
|
@@ -537,269 +621,43 @@ export default {
|
|
|
537
621
|
},
|
|
538
622
|
shapeType: 'shape',
|
|
539
623
|
});
|
|
540
|
-
if (this.konvaLayer)
|
|
624
|
+
if (this.konvaLayer) {
|
|
625
|
+
this.konvaLayer.add(customShape);
|
|
626
|
+
// 直接在这里调用draw 能拿到最新数据 不执行的话 就会导致最后执行 导致bounds的数据出错
|
|
627
|
+
this.konvaLayer.draw()
|
|
628
|
+
};
|
|
541
629
|
}
|
|
542
|
-
|
|
543
630
|
}
|
|
544
631
|
|
|
545
632
|
}
|
|
546
633
|
}
|
|
547
|
-
|
|
548
|
-
let scale = 1;
|
|
549
|
-
const boundingRect = this.konvaLayer.getClientRect();
|
|
550
|
-
let ratio = Number((this.$refs.svgDraw?.clientWidth / boundingRect.width).toFixed(1));
|
|
551
|
-
if (ratio > 2) {
|
|
552
|
-
scale = Number((boundingRect.width / boundingRect.height).toFixed(1));
|
|
553
|
-
scale = scale < 2 ? 2 : scale;
|
|
554
|
-
}
|
|
555
|
-
// this.konvaStage.scale({
|
|
556
|
-
// x: scale,
|
|
557
|
-
// y: scale,
|
|
558
|
-
//})
|
|
559
|
-
const boundingScale = this.konvaLayer.getClientRect();
|
|
560
|
-
//平移视口
|
|
561
|
-
const x =
|
|
562
|
-
this.$refs.svgDraw?.clientWidth / 2 -
|
|
563
|
-
(Math.ceil(boundingScale.width) / 2 + boundingScale.x / 2);
|
|
564
|
-
const y =
|
|
565
|
-
this.$refs.svgDraw.clientHeight / 2 -
|
|
566
|
-
(Math.ceil(boundingScale.height) / 2 + boundingScale.y);
|
|
567
|
-
|
|
568
|
-
// this.konvaStage.scale({
|
|
569
|
-
// x: 2,
|
|
570
|
-
// y: 2,
|
|
571
|
-
// });
|
|
572
|
-
// this.konvaStage.setX(0);
|
|
573
|
-
// this.konvaStage.setY(750); // 750
|
|
574
|
-
|
|
575
|
-
// this.activedSvgPan.zoom.x = 0;
|
|
576
|
-
// this.activedSvgPan.zoom.y = 750;
|
|
577
|
-
// this.activedSvgPan.x = x;
|
|
578
|
-
// this.activedSvgPan.y = x;
|
|
579
|
-
setTimeout(() => {
|
|
580
|
-
this.centerDraw();
|
|
581
|
-
this.$emit('loaded');
|
|
582
|
-
}, 100);
|
|
583
|
-
},
|
|
584
|
-
toPdf(name) {
|
|
585
|
-
//this.konvaStage.scale({
|
|
586
|
-
//x: this.activedSvgPan.zoom.x,
|
|
587
|
-
//y: this.activedSvgPan.zoom.y,
|
|
588
|
-
//});
|
|
589
|
-
//this.konvaStage.setX(this.activedSvgPan.x);
|
|
590
|
-
//this.konvaStage.setY(this.activedSvgPan.y);
|
|
591
|
-
// get data URL with default settings
|
|
592
|
-
|
|
593
|
-
// open in new window
|
|
594
|
-
this.konvaLayer.getCanvas().setPixelRatio(2);
|
|
595
|
-
const jpegURL = this.konvaStage.toDataURL({
|
|
596
|
-
mimeType: 'image/jpeg',
|
|
597
|
-
quality: 1,
|
|
598
|
-
pixelRatio: 2,
|
|
599
|
-
});
|
|
600
|
-
|
|
601
|
-
let pageData = this.konvaLayer.canvas.toDataURL('image/jpeg', 2);
|
|
602
|
-
|
|
603
|
-
let img = new Image();
|
|
604
|
-
img.src = jpegURL;
|
|
605
|
-
const pdf = new jsPDF('l', 'px', [this.konvaStage.width(), this.konvaStage.height()]);
|
|
606
|
-
|
|
607
|
-
pdf.addImage(
|
|
608
|
-
this.konvaStage.toDataURL({ pixelRatio: 2 }),
|
|
609
|
-
0,
|
|
610
|
-
0,
|
|
611
|
-
this.konvaStage.width(),
|
|
612
|
-
this.konvaStage.height()
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
pdf.save(name + '.pdf');
|
|
616
|
-
// var imgData = canvas.toDataURL('image/png');
|
|
617
|
-
//doc.text("Hello world!", 10, 10);
|
|
618
|
-
//doc.save("a4.pdf");
|
|
634
|
+
return true
|
|
619
635
|
},
|
|
620
636
|
toPdfs(list) {
|
|
621
|
-
|
|
622
|
-
return new Promise((resolve, reject) => {
|
|
637
|
+
return new Promise( (resolve, reject) => {
|
|
623
638
|
const pdf = new jsPDF('l', 'px', [this.konvaStage.width(), this.konvaStage.height()]);
|
|
624
639
|
const exportPixelRatio = 2; // 可以 2/3/4 自己调
|
|
625
640
|
let index = 0;
|
|
626
|
-
|
|
627
|
-
|
|
641
|
+
let length = list.length;
|
|
642
|
+
do {
|
|
643
|
+
let data = list[index];
|
|
628
644
|
//先绘制图面
|
|
645
|
+
|
|
629
646
|
this.konvaLayer.destroyChildren();
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
if (
|
|
633
|
-
let entities = formatEntity(dxf.entities);
|
|
634
|
-
let layers = dxf.tables.layer.layers;
|
|
635
|
-
//先计算包围
|
|
636
|
-
for (let key in entities) {
|
|
637
|
-
if (entities[key]) {
|
|
638
|
-
let group = [];
|
|
639
|
-
let l = entities[key].length;
|
|
640
|
-
let layerConfig = this.recordLayerConfig[key];
|
|
641
|
-
let configParams =
|
|
642
|
-
layerConfig && Object.keys(layerConfig).length > 0 ? layerConfig : null;
|
|
643
|
-
for (let i = 0; i < l; i++) {
|
|
644
|
-
let type = entities[key][i].type;
|
|
645
|
-
handleFn(
|
|
646
|
-
type,
|
|
647
|
-
dxf,
|
|
648
|
-
entities[key][i],
|
|
649
|
-
group,
|
|
650
|
-
key,
|
|
651
|
-
configParams,
|
|
652
|
-
this.konvaLayer,
|
|
653
|
-
this.recordLayerConfig
|
|
654
|
-
);
|
|
655
|
-
}
|
|
656
|
-
|
|
657
|
-
for (let i = 0; i < group.length; i++) {
|
|
658
|
-
let entity = group[i];
|
|
659
|
-
if (entity.type === 'line') {
|
|
660
|
-
let x1 = entity.x1;
|
|
661
|
-
let y1 = entity.y1;
|
|
662
|
-
let x2 = entity.x2;
|
|
663
|
-
let y2 = entity.y2;
|
|
664
|
-
let v1 = {};
|
|
665
|
-
v1.x = x1;
|
|
666
|
-
v1.y = y1;
|
|
667
|
-
let v2 = {};
|
|
668
|
-
v2.x = x2;
|
|
669
|
-
v2.y = y2;
|
|
670
|
-
_this.updateBounds1(v1);
|
|
671
|
-
_this.updateBounds1(v2);
|
|
672
|
-
}
|
|
673
|
-
if (entity.type === 'polyline') {
|
|
674
|
-
let flag = false;
|
|
675
|
-
let points = entity.points;
|
|
676
|
-
let closed = entity.closed;
|
|
677
|
-
|
|
678
|
-
for (let j = 0; j < points.length; j++) {
|
|
679
|
-
let index = j % 2;
|
|
680
|
-
if (index === 0) {
|
|
681
|
-
let x = points[j];
|
|
682
|
-
let y = points[j + 1];
|
|
683
|
-
let point = {};
|
|
684
|
-
point.x = x;
|
|
685
|
-
point.y = y;
|
|
686
|
-
_this.updateBounds1(point);
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
}
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
for (let key in entities) {
|
|
695
|
-
if (entities[key]) {
|
|
696
|
-
let group = [];
|
|
697
|
-
let l = entities[key].length;
|
|
698
|
-
let layerConfig = this.recordLayerConfig[key];
|
|
699
|
-
let configParams =
|
|
700
|
-
layerConfig && Object.keys(layerConfig).length > 0 ? layerConfig : null;
|
|
701
|
-
for (let i = 0; i < l; i++) {
|
|
702
|
-
let type = entities[key][i].type;
|
|
703
|
-
handleFn(
|
|
704
|
-
type,
|
|
705
|
-
dxf,
|
|
706
|
-
entities[key][i],
|
|
707
|
-
group,
|
|
708
|
-
key,
|
|
709
|
-
configParams,
|
|
710
|
-
this.konvaLayer,
|
|
711
|
-
this.recordLayerConfig
|
|
712
|
-
);
|
|
713
|
-
}
|
|
714
|
-
if (!this.konvaLayer) return;
|
|
715
|
-
for (let i = 0; i < group.length; i++) {
|
|
716
|
-
let entity = group[i];
|
|
717
|
-
if (entity.type === 'text') {
|
|
718
|
-
if (this.konvaLayer) this.konvaLayer.add(entity.obj);
|
|
719
|
-
}
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
if (group.length > 0) {
|
|
723
|
-
if (group[0]?.stroke) {
|
|
724
|
-
group[0].stroke = '#000';
|
|
725
|
-
}
|
|
726
|
-
|
|
727
|
-
let customShape = new Konva.Shape({
|
|
728
|
-
x: 0,
|
|
729
|
-
y: 0,
|
|
730
|
-
strokeWidth: 0.2,
|
|
731
|
-
name: key.replace(/\s*/g, ''),
|
|
732
|
-
entityId: key,
|
|
733
|
-
stroke: group[0].stroke,
|
|
734
|
-
customColor: configParams ? configParams.color : '',
|
|
735
|
-
//visible: configParams ? configParams.visible :true,
|
|
736
|
-
sceneFunc(context, shape) {
|
|
737
|
-
context.beginPath();
|
|
738
|
-
for (let i = 0; i < group.length; i++) {
|
|
739
|
-
let entity = group[i];
|
|
740
|
-
|
|
741
|
-
if (entity.type === 'line') {
|
|
742
|
-
context.strokeStyle = entity.stroke;
|
|
743
|
-
let x1 = entity.x1;
|
|
744
|
-
let y1 = entity.y1;
|
|
745
|
-
let x2 = entity.x2;
|
|
746
|
-
let y2 = entity.y2;
|
|
747
|
-
if (x1 != undefined && y1 != undefined && x2 != undefined && y2 != undefined) {
|
|
748
|
-
context.moveTo(x1, -parseFloat(y1));
|
|
749
|
-
context.lineTo(x2, -parseFloat(y2));
|
|
750
|
-
}
|
|
751
|
-
}
|
|
752
|
-
if (entity.type === 'polyline') {
|
|
753
|
-
context.strokeStyle = entity.stroke;
|
|
754
|
-
|
|
755
|
-
let flag = false;
|
|
756
|
-
|
|
757
|
-
let points = entity.points;
|
|
758
|
-
let closed = entity.closed;
|
|
759
|
-
|
|
760
|
-
for (let j = 0; j < points.length; j++) {
|
|
761
|
-
let index = j % 2;
|
|
762
|
-
if (index === 0) {
|
|
763
|
-
let x = points[j];
|
|
764
|
-
let y = points[j + 1];
|
|
765
|
-
|
|
766
|
-
if (j === 0) {
|
|
767
|
-
context.moveTo(x, y);
|
|
768
|
-
} else {
|
|
769
|
-
context.lineTo(x, y);
|
|
770
|
-
}
|
|
771
|
-
}
|
|
772
|
-
|
|
773
|
-
if (closed) {
|
|
774
|
-
if (j === points.length - 1) {
|
|
775
|
-
context.lineTo(points[0], points[1]);
|
|
776
|
-
}
|
|
777
|
-
}
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
// context.closePath();
|
|
782
|
-
context.fillStrokeShape(shape);
|
|
783
|
-
},
|
|
784
|
-
});
|
|
785
|
-
if (this.konvaLayer) this.konvaLayer.add(customShape);
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
|
|
647
|
+
let flag = this.formatDrawData(data, 'updateBounds1')
|
|
648
|
+
// 这步还没执行完就执行下面的代码了
|
|
649
|
+
if (flag) {
|
|
790
650
|
const { scale, x, y } = this.calculateScaleAndPosition(
|
|
791
|
-
|
|
651
|
+
this.bounds1,
|
|
792
652
|
this.konvaStage.width(),
|
|
793
653
|
this.konvaStage.height(),
|
|
794
654
|
0.05 // 5% 边距
|
|
795
655
|
);
|
|
796
|
-
|
|
797
|
-
_this.bounds1 = null;
|
|
798
|
-
|
|
656
|
+
this.bounds1 = null;
|
|
799
657
|
this.konvaStage.position({ x: x, y: y });
|
|
800
658
|
this.konvaStage.scale({ x: scale, y: scale });
|
|
801
659
|
|
|
802
|
-
this.konvaStage.batchDraw();
|
|
660
|
+
// this.konvaStage.batchDraw();
|
|
803
661
|
//添加成功移动视口位置 pageIdx === 0
|
|
804
662
|
|
|
805
663
|
if (index === 0) {
|
|
@@ -822,8 +680,49 @@ export default {
|
|
|
822
680
|
}
|
|
823
681
|
index++
|
|
824
682
|
}
|
|
683
|
+
} while (index < length)
|
|
684
|
+
// for (let pageIdx = 0; pageIdx < list.length; pageIdx++) {
|
|
685
|
+
// let data = list[pageIdx];
|
|
686
|
+
// //先绘制图面
|
|
687
|
+
// this.bounds1 = null;
|
|
688
|
+
// this.konvaLayer.destroyChildren();
|
|
689
|
+
// let flag = this.formatDrawData(data, 'updateBounds1')
|
|
690
|
+
// // 这步还没执行完就执行下面的代码了
|
|
691
|
+
// if (flag) {
|
|
692
|
+
// const { scale, x, y } = this.calculateScaleAndPosition(
|
|
693
|
+
// this.bounds1,
|
|
694
|
+
// this.konvaStage.width(),
|
|
695
|
+
// this.konvaStage.height(),
|
|
696
|
+
// 0.05 // 5% 边距
|
|
697
|
+
// );
|
|
698
|
+
// this.konvaStage.position({ x: x, y: y });
|
|
699
|
+
// this.konvaStage.scale({ x: scale, y: scale });
|
|
700
|
+
|
|
701
|
+
// this.konvaStage.batchDraw();
|
|
702
|
+
// //添加成功移动视口位置 pageIdx === 0
|
|
703
|
+
|
|
704
|
+
// if (index === 0) {
|
|
705
|
+
// pdf.addImage(
|
|
706
|
+
// this.konvaStage.toDataURL({ pixelRatio: 2 }),
|
|
707
|
+
// 0,
|
|
708
|
+
// 0,
|
|
709
|
+
// this.konvaStage.width(),
|
|
710
|
+
// this.konvaStage.height()
|
|
711
|
+
// );
|
|
712
|
+
// } else {
|
|
713
|
+
// pdf.addPage();
|
|
714
|
+
// pdf.addImage(
|
|
715
|
+
// this.konvaStage.toDataURL({ pixelRatio: 2 }),
|
|
716
|
+
// 0,
|
|
717
|
+
// 0,
|
|
718
|
+
// this.konvaStage.width(),
|
|
719
|
+
// this.konvaStage.height()
|
|
720
|
+
// );
|
|
721
|
+
// }
|
|
722
|
+
// index++
|
|
723
|
+
// }
|
|
825
724
|
|
|
826
|
-
}
|
|
725
|
+
// }
|
|
827
726
|
if (index > 0) {
|
|
828
727
|
pdf.save('批量导出.pdf');
|
|
829
728
|
resolve()
|