askbot-dragon 1.5.66-beta → 1.5.68-beta
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/package.json +1 -1
- package/src/assets/js/hammer.js +13 -2
- package/src/assets/less/converSationContainer/common.less +7 -0
- package/src/components/AnswerDocknowledge.vue +42 -3
- package/src/components/ConversationContainer.vue +46 -14
- package/src/components/askVideo.vue +24 -1
- package/src/components/associationIntention.vue +1 -1
- package/src/components/newPdfPosition.vue +878 -0
- package/src/components/pdfPosition.vue +256 -60
- package/src/components/previewPdf.vue +21 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<div
|
|
2
|
+
<div id="pdf_view" class="pdf_view" :style="{
|
|
3
3
|
marginTop: isPC ? '50px' : '',
|
|
4
4
|
marginBottom: tagIds.length > 1 ? '60px' : '0px',
|
|
5
5
|
height: setHeight
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
</el-option>
|
|
18
18
|
</el-select>
|
|
19
19
|
</div>
|
|
20
|
+
<div class="pdf_container_view" id="pdf_container_view" @scroll="pdfScroll" ref="pdfView"></div>
|
|
20
21
|
<div class="btn_footer" v-if="tagIds.length > 1 && !isPC">
|
|
21
22
|
<div class="prev" @click="prev">上一段</div>
|
|
22
23
|
<div class="next" @click="next">下一段</div>
|
|
@@ -44,10 +45,11 @@ if (pdfjsLib) {
|
|
|
44
45
|
// 'pdfjs-dist/build/pdf.worker';
|
|
45
46
|
}
|
|
46
47
|
const { TextLayerBuilder } = window['pdfjs-dist/web/pdf_viewer']
|
|
48
|
+
const CSS_UNITS = 96.0 / 72.0
|
|
47
49
|
// import { zoomElement } from '../assets/js/hammer'
|
|
48
50
|
export default {
|
|
49
51
|
name: 'pdfView',
|
|
50
|
-
props: ['tagIds', 'isMessageRecord'],
|
|
52
|
+
props: ['tagIds', 'isMessageRecord','fileName', "knowledgeItem"],
|
|
51
53
|
data () {
|
|
52
54
|
return {
|
|
53
55
|
url: '',
|
|
@@ -94,6 +96,7 @@ export default {
|
|
|
94
96
|
},
|
|
95
97
|
isTouchMoved: false,
|
|
96
98
|
transformSalce: null,
|
|
99
|
+
defaultTransform:0.8,
|
|
97
100
|
isPC: false,
|
|
98
101
|
handScale: 'auto',
|
|
99
102
|
scaleList: [
|
|
@@ -248,12 +251,13 @@ export default {
|
|
|
248
251
|
if (this.$refs.pdfView.clientWidth / this.pageSize.width >= 1 || this.isMessageRecord) {
|
|
249
252
|
this.contentView.style.width = `${pageSize.width - 10}px`;
|
|
250
253
|
this.contentView.style.height = `${(this.totalPageCount * (pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
|
|
254
|
+
this.contentView.style.margin = '0 auto 0'
|
|
251
255
|
} else {
|
|
252
|
-
this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
|
|
256
|
+
this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width / CSS_UNITS
|
|
253
257
|
this.contentView.style.width = `${pageSize.width * this.transformSalce - 10}px`;
|
|
254
258
|
this.contentView.style.height = `${(this.totalPageCount * (pageSize.height * (this.transformSalce) + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
|
|
255
259
|
}
|
|
256
|
-
this.contentView.style.margin = '0 auto 0'
|
|
260
|
+
// this.contentView.style.margin = '0 auto 0'
|
|
257
261
|
this.contentView.style.position = 'relative'
|
|
258
262
|
this.contentView.style.paddingBottom = '60px'
|
|
259
263
|
// contentView.style.overflowY = 'auto'
|
|
@@ -281,36 +285,41 @@ export default {
|
|
|
281
285
|
const { pdfPage, pageNo, dom } = page;
|
|
282
286
|
// dom 元素已存在,无须重新渲染,直接返回
|
|
283
287
|
if ((dom && dom.children.length != 0) || page.loading) {
|
|
284
|
-
|
|
288
|
+
return;
|
|
285
289
|
}
|
|
286
290
|
page.loading = true
|
|
287
291
|
const viewport = pdfPage.getViewport({
|
|
288
|
-
|
|
289
|
-
|
|
292
|
+
scale: this.scale,
|
|
293
|
+
rotation: this.rotation,
|
|
290
294
|
});
|
|
291
295
|
// 创建新的canvas
|
|
292
296
|
const canvas = document.createElement('canvas');
|
|
293
297
|
const context = canvas.getContext('2d');
|
|
294
298
|
// canvas.getContext('2d');
|
|
295
|
-
canvas.height = this.pageSize.height;
|
|
296
|
-
canvas.width = this.pageSize.width;
|
|
299
|
+
canvas.height = this.pageSize.height * (this.fileName ? CSS_UNITS : 1);
|
|
300
|
+
canvas.width = this.pageSize.width * (this.fileName ? CSS_UNITS : 1);
|
|
297
301
|
canvas.style.position = 'relative'
|
|
298
302
|
canvas.style.top = -3 + 'px'
|
|
299
303
|
// 创建渲染的dom
|
|
300
304
|
const pageDom = document.createElement('div');
|
|
301
305
|
pageDom.style.position = 'absolute';
|
|
302
|
-
pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
|
|
303
|
-
pageDom.style.width = `${this.pageSize.width}px`;
|
|
304
|
-
pageDom.style.height = `${this.pageSize.height}px`;
|
|
306
|
+
pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1)) + this.PAGE_INTVERVAL}px`;
|
|
307
|
+
pageDom.style.width = `${this.pageSize.width * (this.fileName ? CSS_UNITS : 1)}px`;
|
|
308
|
+
pageDom.style.height = `${this.pageSize.height * (this.fileName ? CSS_UNITS : 1)}px`;
|
|
305
309
|
pageDom.setAttribute('data-id', 'page' + pageNo)
|
|
306
|
-
pageDom.appendChild(canvas);
|
|
310
|
+
// pageDom.appendChild(canvas);
|
|
307
311
|
// 渲染内容
|
|
308
312
|
let renderContext = {
|
|
309
313
|
canvasContext: context,
|
|
310
314
|
viewport: viewport,
|
|
315
|
+
transform: this.fileName ? [CSS_UNITS, 0, 0, CSS_UNITS, 0, 0] : '',
|
|
311
316
|
}
|
|
312
317
|
await pdfPage.render(renderContext).promise.then(() => {
|
|
313
|
-
|
|
318
|
+
const html = canvas.toDataURL();
|
|
319
|
+
let image = document.createElement('img');
|
|
320
|
+
image.setAttribute('src',html)
|
|
321
|
+
pageDom.appendChild(image);
|
|
322
|
+
return pdfPage.getTextContent()
|
|
314
323
|
}).then(async (textContent) => {
|
|
315
324
|
const textLayerDiv = document.createElement('div');
|
|
316
325
|
textLayerDiv.setAttribute('class', 'textLayer');
|
|
@@ -340,36 +349,35 @@ export default {
|
|
|
340
349
|
let postionArr = lines[index].location
|
|
341
350
|
let div = document.createElement('div')
|
|
342
351
|
div.style.position = 'absolute';
|
|
343
|
-
div.style.left = postionArr[0] * this.scale + 'px',
|
|
352
|
+
div.style.left = postionArr[0] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px',
|
|
344
353
|
// 后端返回的坐标有基线对齐的问题,top 值是后端算好(基线top - 文字高度),在此加上文字高度的 1/9 (大致比例)为实际展示出文字的top值
|
|
345
|
-
div.style.top = postionArr[1] * this.scale + 'px'
|
|
346
|
-
div.style.height = postionArr[3] * this.scale + 'px';
|
|
347
|
-
div.style.width = postionArr[2] * this.scale + 'px'
|
|
354
|
+
div.style.top = postionArr[1] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px'
|
|
355
|
+
div.style.height = postionArr[3] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px';
|
|
356
|
+
div.style.width = postionArr[2] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px'
|
|
348
357
|
div.style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
|
|
349
358
|
div.classList.add('lineHeight')
|
|
350
359
|
rectdom.appendChild(div)
|
|
351
360
|
if (index == 0 && j == 0) {
|
|
352
361
|
if (this.transformSalce !== null) {
|
|
353
|
-
rectdomTop = postionArr[1]
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
if (rectdom.children.length > 0) {
|
|
364
|
-
pageDom.appendChild(rectdom)
|
|
365
|
-
}
|
|
362
|
+
rectdomTop = postionArr[1]* this.scale * (this.fileName ? CSS_UNITS : 1) * this.transformSalce
|
|
363
|
+
} else {
|
|
364
|
+
rectdomTop = postionArr[1] * this.scale * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform
|
|
365
|
+
}
|
|
366
|
+
// if(this.isPC) {
|
|
367
|
+
// rectdomTop = rectdomTop - 50 < 0 ? 0 : rectdomTop - 50
|
|
368
|
+
// }
|
|
366
369
|
}
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
if (rectdom.children.length > 0) {
|
|
373
|
+
pageDom.appendChild(rectdom)
|
|
367
374
|
}
|
|
375
|
+
}
|
|
368
376
|
}
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
377
|
+
}
|
|
378
|
+
textLayer.setTextContent(textContent);
|
|
379
|
+
textLayer.render()
|
|
380
|
+
pageDom.appendChild(textLayerDiv);
|
|
373
381
|
let backgroundDom = document.getElementById('backgroundLoad' + pageNo)
|
|
374
382
|
if (backgroundDom) {
|
|
375
383
|
this.contentView.removeChild(backgroundDom);
|
|
@@ -377,8 +385,22 @@ export default {
|
|
|
377
385
|
page.dom = await pageDom;
|
|
378
386
|
page.loading = false
|
|
379
387
|
this.contentView.appendChild(pageDom);
|
|
380
|
-
|
|
381
|
-
|
|
388
|
+
let pdf_view = document.getElementsByClassName('pdf_view');
|
|
389
|
+
if (pdf_view && pdf_view[0]){
|
|
390
|
+
pdf_view[0].style.backgroundImage = 'none'
|
|
391
|
+
}
|
|
392
|
+
let postionArr = []
|
|
393
|
+
if (findPage){
|
|
394
|
+
let AllLines = findPage.allLines
|
|
395
|
+
if (AllLines.length){
|
|
396
|
+
postionArr = AllLines[0].lines[0].location
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
if(this.transformSalce !== null && this.fileName) {
|
|
400
|
+
this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
|
|
401
|
+
} else {
|
|
402
|
+
this.contentView.style.transform = `scale(${this.defaultTransform})`;
|
|
403
|
+
|
|
382
404
|
}
|
|
383
405
|
if (this.changetoolbar) {
|
|
384
406
|
setTimeout(() => {
|
|
@@ -390,22 +412,21 @@ export default {
|
|
|
390
412
|
setTimeout(() => {
|
|
391
413
|
let pageoffsetHeight = 0
|
|
392
414
|
if (this.transformSalce !== null) {
|
|
393
|
-
pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce
|
|
415
|
+
pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)
|
|
394
416
|
} else {
|
|
395
|
-
pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL)
|
|
417
|
+
pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.defaultTransform *(this.fileName ? CSS_UNITS : 1)
|
|
396
418
|
}
|
|
397
419
|
if (this.$refs.pdfView.clientHeight - pageoffsetHeight > 0 && pageIndex == 1) {
|
|
398
420
|
const height = this.$refs.pdfView.clientHeight;
|
|
399
421
|
let startNum = 0
|
|
400
422
|
let endNum = 0
|
|
401
423
|
if (this.transformSalce !== null) {
|
|
402
|
-
startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
|
|
403
|
-
endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
endNum = startNum + Math.ceil(height / (this.pageSize.height + this.PAGE_INTVERVAL))
|
|
407
|
-
|
|
408
|
-
}
|
|
424
|
+
startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce* (this.fileName ? CSS_UNITS : 1)))
|
|
425
|
+
endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce* (this.fileName ? CSS_UNITS : 1)))
|
|
426
|
+
} else {
|
|
427
|
+
startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
|
|
428
|
+
endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))}
|
|
429
|
+
console.log(this.$refs.pdfView.scrollTop, startNum, endNum, 'endNumendNum');
|
|
409
430
|
for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
|
|
410
431
|
if (pageIndex > 0 && pageIndex <= this.pages.length) {
|
|
411
432
|
this.loadPdfData(pageIndex)
|
|
@@ -437,14 +458,14 @@ export default {
|
|
|
437
458
|
let startNum = 0
|
|
438
459
|
let endNum = 0
|
|
439
460
|
if (this.transformSalce !== null) {
|
|
440
|
-
startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
|
|
441
|
-
endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
|
|
461
|
+
startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)))
|
|
462
|
+
endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)))
|
|
442
463
|
} else {
|
|
443
|
-
startNum = Math.ceil(scrollTop / (that.pageSize.height + that.PAGE_INTVERVAL))
|
|
444
|
-
endNum = startNum + Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
|
|
464
|
+
startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
|
|
465
|
+
endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
|
|
445
466
|
}
|
|
446
|
-
for (let pageIndex = startNum; pageIndex
|
|
447
|
-
if (pageIndex > 0 && pageIndex
|
|
467
|
+
for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
|
|
468
|
+
if (pageIndex > 0 && pageIndex <= that.pages.length) {
|
|
448
469
|
that.loadPdfData(pageIndex)
|
|
449
470
|
}
|
|
450
471
|
}
|
|
@@ -529,10 +550,10 @@ export default {
|
|
|
529
550
|
return
|
|
530
551
|
}
|
|
531
552
|
const pageDom = document.createElement('div');
|
|
532
|
-
pageDom.style.width = `${this.pageSize.width}px`;
|
|
533
|
-
pageDom.style.height = `${this.pageSize.height}px`;
|
|
553
|
+
pageDom.style.width = `${this.pageSize.width * (this.fileName ? CSS_UNITS : 1)}px`;
|
|
554
|
+
pageDom.style.height = `${this.pageSize.height * (this.fileName ? CSS_UNITS : 1)}px`;
|
|
534
555
|
pageDom.style.position = 'absolute';
|
|
535
|
-
pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
|
|
556
|
+
pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1)) + this.PAGE_INTVERVAL
|
|
536
557
|
}px`;
|
|
537
558
|
pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
|
|
538
559
|
pageDom.style.backgroundPosition = 'center'
|
|
@@ -607,9 +628,9 @@ export default {
|
|
|
607
628
|
this.renderHighlights()
|
|
608
629
|
})
|
|
609
630
|
if (this.transformSalce !== null) {
|
|
610
|
-
this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce) + (this.identifyTextPostion.top * this.scale * this.transformSalce)}`
|
|
631
|
+
this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)) + (this.identifyTextPostion.top * this.scale * this.transformSalce * (this.fileName ? CSS_UNITS : 1))}`
|
|
611
632
|
} else {
|
|
612
|
-
this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + (this.identifyTextPostion.top * this.scale * this.
|
|
633
|
+
this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.defaultTransform * (this.fileName ? CSS_UNITS : 1)) + (this.identifyTextPostion.top * this.scale * this.defaultTransform * (this.fileName ? CSS_UNITS : 1))}`
|
|
613
634
|
}
|
|
614
635
|
},
|
|
615
636
|
scrollToExcalTop (currentPage) {
|
|
@@ -836,6 +857,160 @@ export default {
|
|
|
836
857
|
this.contentView.style.transform = 'scale(' + this.transformSalce + ')';
|
|
837
858
|
// this.getpdfResloutePage(this.cachePdf[0])
|
|
838
859
|
},
|
|
860
|
+
//添加水印
|
|
861
|
+
watermark() {
|
|
862
|
+
//默认设置
|
|
863
|
+
var defaultSettings = {
|
|
864
|
+
watermark_txt:"",
|
|
865
|
+
watermark_x: 0,//水印起始位置x轴坐标
|
|
866
|
+
watermark_y: 0,//水印起始位置Y轴坐标
|
|
867
|
+
watermark_rows: 0,//水印行数
|
|
868
|
+
watermark_cols: 0,//水印列数
|
|
869
|
+
watermark_x_space: 40,//水印x轴间隔
|
|
870
|
+
watermark_y_space: 60,//水印y轴间隔
|
|
871
|
+
watermark_color: 'black',//水印字体颜色
|
|
872
|
+
watermark_alpha: .3,//水印透明度
|
|
873
|
+
watermark_fontsize: 12,//水印字体大小
|
|
874
|
+
watermark_font: '微软雅黑',//水印字体
|
|
875
|
+
watermark_width: 100,//水印宽度
|
|
876
|
+
watermark_height: 80,//水印长度
|
|
877
|
+
watermark_angle: 20,//水印倾斜度数***
|
|
878
|
+
visitorWatermark_txt:""
|
|
879
|
+
};
|
|
880
|
+
if(this.knowledgeItem.textWatermarkValue){
|
|
881
|
+
defaultSettings.watermark_txt = this.knowledgeItem.textWatermarkValue;
|
|
882
|
+
}
|
|
883
|
+
if (this.knowledgeItem.visitorWatermarkValue){
|
|
884
|
+
defaultSettings.visitorWatermark_txt = this.knowledgeItem.visitorWatermarkValue
|
|
885
|
+
}
|
|
886
|
+
//采用配置项替换默认值,作用类似jquery.extend
|
|
887
|
+
if (arguments.length === 1 && typeof arguments[0] === "object") {
|
|
888
|
+
console.log("arguments = " + JSON.stringify(arguments[0]));
|
|
889
|
+
// 获取参数配置
|
|
890
|
+
var src = arguments[0];
|
|
891
|
+
for (let key in src) {
|
|
892
|
+
if (src[key] && defaultSettings[key] && src[key] === defaultSettings[key])
|
|
893
|
+
continue;
|
|
894
|
+
else if (src[key])
|
|
895
|
+
defaultSettings[key] = src[key];
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
var oTemp = document.createDocumentFragment();
|
|
899
|
+
//获取页面最大宽度
|
|
900
|
+
console.debug('pdf_view',document.getElementById('pdf_view'))
|
|
901
|
+
let scrollWidth = document.getElementById('pdf_view').scrollWidth;
|
|
902
|
+
let clientWidth = document.getElementById('pdf_view').clientWidth;
|
|
903
|
+
var page_width = Math.max(scrollWidth, clientWidth);
|
|
904
|
+
|
|
905
|
+
var cutWidth = page_width * 0.0150;
|
|
906
|
+
|
|
907
|
+
page_width = page_width - cutWidth;
|
|
908
|
+
|
|
909
|
+
//获取页面最大高度
|
|
910
|
+
var page_height = Math.max(document.body.scrollHeight, document.body.clientHeight) + 2860;
|
|
911
|
+
|
|
912
|
+
// var page_height = document.body.scrollHeight+document.body.scrollTop;
|
|
913
|
+
|
|
914
|
+
//如果将水印列数设置为0,或水印列数设置过大,超过页面最大宽度,则重新计算水印列数和水印x轴间隔
|
|
915
|
+
|
|
916
|
+
if (defaultSettings.watermark_cols == 0 || (parseInt(defaultSettings.watermark_x + defaultSettings
|
|
917
|
+
.watermark_width * defaultSettings.watermark_cols + defaultSettings.watermark_x_space *
|
|
918
|
+
(defaultSettings.watermark_cols - 1)) > page_width)) {
|
|
919
|
+
defaultSettings.watermark_cols = parseInt((page_width - defaultSettings.watermark_x + defaultSettings
|
|
920
|
+
.watermark_x_space) / (defaultSettings.watermark_width + defaultSettings
|
|
921
|
+
.watermark_x_space));
|
|
922
|
+
defaultSettings.watermark_x_space = parseInt((page_width - defaultSettings.watermark_x -
|
|
923
|
+
defaultSettings
|
|
924
|
+
.watermark_width * defaultSettings.watermark_cols) / (defaultSettings.watermark_cols - 1));
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
//如果将水印行数设置为0,或水印行数设置过大,超过页面最大长度,则重新计算水印行数和水印y轴间隔
|
|
928
|
+
|
|
929
|
+
if (defaultSettings.watermark_rows == 0 || (parseInt(defaultSettings.watermark_y + defaultSettings
|
|
930
|
+
|
|
931
|
+
.watermark_height * defaultSettings.watermark_rows + defaultSettings.watermark_y_space * (
|
|
932
|
+
|
|
933
|
+
defaultSettings.watermark_rows - 1)) > page_height)) {
|
|
934
|
+
|
|
935
|
+
defaultSettings.watermark_rows = parseInt((defaultSettings.watermark_y_space + page_height -
|
|
936
|
+
|
|
937
|
+
defaultSettings
|
|
938
|
+
|
|
939
|
+
.watermark_y) / (defaultSettings.watermark_height + defaultSettings.watermark_y_space));
|
|
940
|
+
|
|
941
|
+
defaultSettings.watermark_y_space = parseInt(((page_height - defaultSettings.watermark_y) -
|
|
942
|
+
|
|
943
|
+
defaultSettings
|
|
944
|
+
|
|
945
|
+
.watermark_height * defaultSettings.watermark_rows) / (defaultSettings.watermark_rows - 1));
|
|
946
|
+
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
var x;
|
|
950
|
+
|
|
951
|
+
var y;
|
|
952
|
+
|
|
953
|
+
for (var i = 0; i < defaultSettings.watermark_rows; i++) {
|
|
954
|
+
y = defaultSettings.watermark_y + (defaultSettings.watermark_y_space + defaultSettings.watermark_height) * i;
|
|
955
|
+
for (var j = 0; j < defaultSettings.watermark_cols; j++) {
|
|
956
|
+
x = defaultSettings.watermark_x + (defaultSettings.watermark_width + defaultSettings.watermark_x_space) * j;
|
|
957
|
+
|
|
958
|
+
var mask_div = document.createElement('div');
|
|
959
|
+
mask_div.id = 'mask_div' + i + j;
|
|
960
|
+
mask_div.className = 'mask_div';
|
|
961
|
+
|
|
962
|
+
//注意看这里加了图片水印
|
|
963
|
+
mask_div.style.webkitTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
|
|
964
|
+
mask_div.style.MozTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
|
|
965
|
+
mask_div.style.msTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
|
|
966
|
+
mask_div.style.OTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
|
|
967
|
+
mask_div.style.transform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
|
|
968
|
+
mask_div.style.visibility = "";
|
|
969
|
+
mask_div.style.position = "absolute";
|
|
970
|
+
//奇偶行错开,这样水印就不对齐,显的不呆板
|
|
971
|
+
console.debug('x',x)
|
|
972
|
+
if (i % 2 != 0) {
|
|
973
|
+
mask_div.style.left = x + 'px';
|
|
974
|
+
if (j % 2 != 0 && this.knowledgeItem.visitorWatermarkValue){
|
|
975
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
|
|
976
|
+
} else {
|
|
977
|
+
if (!this.knowledgeItem.textWatermarkValue){
|
|
978
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
|
|
979
|
+
} else {
|
|
980
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
|
|
981
|
+
}
|
|
982
|
+
}
|
|
983
|
+
} else {
|
|
984
|
+
mask_div.style.left = x + 'px';
|
|
985
|
+
if (j % 2 != 0 && this.knowledgeItem.textWatermarkValue){
|
|
986
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
|
|
987
|
+
} else {
|
|
988
|
+
if (!this.knowledgeItem.visitorWatermarkValue){
|
|
989
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
|
|
990
|
+
} else {
|
|
991
|
+
mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
|
|
992
|
+
}
|
|
993
|
+
}
|
|
994
|
+
}
|
|
995
|
+
|
|
996
|
+
mask_div.style.top = y + 'px';
|
|
997
|
+
mask_div.style.overflow = "hidden";
|
|
998
|
+
mask_div.style.zIndex = "9999";
|
|
999
|
+
mask_div.style.pointerEvents = 'none'; //让水印不遮挡页面的点击事件
|
|
1000
|
+
mask_div.style.opacity = defaultSettings.watermark_alpha;
|
|
1001
|
+
mask_div.style.fontSize = defaultSettings.watermark_fontsize;
|
|
1002
|
+
mask_div.style.fontFamily = defaultSettings.watermark_font;
|
|
1003
|
+
mask_div.style.color = defaultSettings.watermark_color;
|
|
1004
|
+
mask_div.style.textAlign = "center";
|
|
1005
|
+
mask_div.style.width = defaultSettings.watermark_width + 'px';
|
|
1006
|
+
mask_div.style.height = defaultSettings.watermark_height + 'px';
|
|
1007
|
+
mask_div.style.display = "block";
|
|
1008
|
+
oTemp.appendChild(mask_div);
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
this.contentView.appendChild(oTemp);
|
|
1012
|
+
|
|
1013
|
+
},
|
|
839
1014
|
},
|
|
840
1015
|
computed: {
|
|
841
1016
|
perviewUrl () {
|
|
@@ -863,8 +1038,15 @@ export default {
|
|
|
863
1038
|
if (value && value.length) {
|
|
864
1039
|
// 在 pdf_view 下创建 所有canvs的容器
|
|
865
1040
|
this.contentView = document.createElement('div')
|
|
1041
|
+
this.contentView.setAttribute('id','contentView')
|
|
866
1042
|
this.contentView.style.transformOrigin = '0px 0px 0px'
|
|
867
|
-
this
|
|
1043
|
+
this.contentView.setAttribute('id','contentView');
|
|
1044
|
+
this.$nextTick(() => {
|
|
1045
|
+
if (this.knowledgeItem && (this.knowledgeItem.source === 'CORP_LOCAL_FILE' || this.knowledgeItem.source === 'YUQUE' || this.knowledgeItem.source === 'FEISHU') && (this.knowledgeItem.visitorWatermarkValue || this.knowledgeItem.textWatermarkValue)){
|
|
1046
|
+
this.watermark()
|
|
1047
|
+
}
|
|
1048
|
+
})
|
|
1049
|
+
this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res => {
|
|
868
1050
|
// res.data = {"data":[{"id":"64591b7d8bb8ab1b91c65f24","knowledgeId":"64591a9c8da27649473f3b4b","mainId":"fb348d095c0b4fd7bbd37826563dac7d","page":3,"total":18,"pageHeight":540.0,"pageWidth":960.00946,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/fb348d095c0b4fd7bbd37826563dac7d/2023/05/08/11/55/18/64591b638bb8ab1b91c65eed/3.pdf","extractInfo":{"location":[280.488,161.32,398.71573,61.99298],"content":"黄花城水长城旅游区位于北京市怀柔区九渡河镇境内,距北京市区65公里,是以奇而著称,融山川、碧水、古长城为一体的旅游休闲胜地。而这里的“三绝景”更是引人入","lines":[{"content":"黄花城水长城旅游区位于北京市怀柔区九渡河镇境内,距","location":[280.488,161.32,398.71573,15.9869995]},{"content":"北京市区65公里,是以奇而著称,融山川、碧水、古长","location":[283.691,184.30899,392.3055,15.9869995]},{"content":"城为一体的旅游休闲胜地。而这里的“三绝景”更是引人入","location":[282.699,207.32599,394.3033,15.9869995]}],"tagId":null}}],"code":"0","msg":null,"traceId":null}
|
|
869
1051
|
// res.data = {"data":[{"id":"64590ce1eb1320043401cc90","knowledgeId":"64590cd5017b461d67e282e1","mainId":"fb348d095c0b4fd7bbd37826563dac7d","page":2,"total":5,"pageHeight":841.8898,"pageWidth":595.30396,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/fb348d095c0b4fd7bbd37826563dac7d/2023/05/08/10/53/20/64590ce0eb1320043401cc7b/2.pdf","extractInfo":{"location":[89.32981,638.1907,415.15512,98.63251],"content":":北京地铁 13\r号线 :藤黄\r色 :西直门站—\r东直门站 :17 :41.\r5 :6\r准\rB :2002年\r09月\r28日 ","lines":[{"content":":北京地铁 13\r号线 ","location":[89.32981,638.1907,99.44599,98.63251]},{"content":":藤黄\r色 ","location":[188.7758,638.1907,46.79959,98.63251]},{"content":":西直门站—\r东直门站 ","location":[235.5754,638.1907,86.09996,98.63251]},{"content":":17 ","location":[321.67535,638.1907,36.200012,98.63251]},{"content":":41.\r5 ","location":[357.87537,638.1907,39.400696,98.63251]},{"content":":6\r准\rB ","location":[397.27606,638.1907,41.099,98.63251]},{"content":":2002年\r09月\r28日 ","location":[438.37506,638.1907,66.10986,98.63251]}],"tagId":null}}],"code":"0","msg":null,"traceId":null}
|
|
870
1052
|
// res.data = {"data":[{"id":"64591b7d8bb8ab1b91c65f24","knowledgeId":"64591a9c8da27649473f3b4b","mainId":"fb348d095c0b4fd7bbd37826563dac7d","page":3,"total":18,"pageHeight":540.0,"pageWidth":960.00946,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/fb348d095c0b4fd7bbd37826563dac7d/2023/05/08/11/55/18/64591b638bb8ab1b91c65eed/3.pdf","extractInfo":{"location":[280.488,161.32,398.71573,61.99298],"content":"黄花城水长城旅游区位于北京市怀柔区九渡河镇境内,距北京市区65公里,是以奇而著称,融山川、碧水、古长城为一体的旅游休闲胜地。而这里的“三绝景”更是引人入","lines":[{"content":"黄花城水长城旅游区位于北京市怀柔区九渡河镇境内,距","location":[280.488,161.32,398.71573,15.9869995]},{"content":"北京市区65公里,是以奇而著称,融山川、碧水、古长","location":[283.691,184.30899,392.3055,15.9869995]},{"content":"城为一体的旅游休闲胜地。而这里的“三绝景”更是引人入","location":[282.699,207.32599,394.3033,15.9869995]}],"tagId":null}}],"code":"0","msg":null,"traceId":null}
|
|
@@ -1053,11 +1235,16 @@ export default {
|
|
|
1053
1235
|
xhr.onload = ({ currentTarget }) => {
|
|
1054
1236
|
// 请求完成
|
|
1055
1237
|
if (currentTarget.status === 200) { // 返回200
|
|
1238
|
+
let pdf_view = document.getElementsByClassName('pdf_view');
|
|
1239
|
+
if (pdf_view && pdf_view[0]){
|
|
1240
|
+
pdf_view[0].style.backgroundImage = 'none'
|
|
1241
|
+
}
|
|
1056
1242
|
this.contentView.innerHTML = currentTarget.response
|
|
1057
1243
|
this.contentView.style.padding = '10px'
|
|
1058
1244
|
// this.contentView.style.position = 'relative'
|
|
1059
1245
|
this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
|
|
1060
1246
|
this.$refs.pdfView.appendChild(this.contentView)
|
|
1247
|
+
|
|
1061
1248
|
let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
|
|
1062
1249
|
this.allTr = []
|
|
1063
1250
|
for (let index = 0; index < allTr.length; index++) {
|
|
@@ -1100,10 +1287,14 @@ export default {
|
|
|
1100
1287
|
width: 100%;
|
|
1101
1288
|
height: calc(100% - 110px);
|
|
1102
1289
|
overflow: auto;
|
|
1290
|
+
//overflow-y: scroll;
|
|
1103
1291
|
background-color: #f5f7fb;
|
|
1104
1292
|
// margin-bottom: 60px;
|
|
1105
1293
|
box-sizing: border-box;
|
|
1106
|
-
|
|
1294
|
+
background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
|
|
1295
|
+
background-position: center;
|
|
1296
|
+
background-size: 50px;
|
|
1297
|
+
background-repeat: no-repeat;
|
|
1107
1298
|
// position: relative;
|
|
1108
1299
|
// > div {
|
|
1109
1300
|
// width: 100%;
|
|
@@ -1292,6 +1483,12 @@ export default {
|
|
|
1292
1483
|
background: rgba(221, 222, 223, 1);
|
|
1293
1484
|
}
|
|
1294
1485
|
}
|
|
1486
|
+
.pdf_container_view{
|
|
1487
|
+
height: 100%;
|
|
1488
|
+
width: 100%;
|
|
1489
|
+
position: relative;
|
|
1490
|
+
overflow: auto;
|
|
1491
|
+
}
|
|
1295
1492
|
}
|
|
1296
1493
|
</style>
|
|
1297
1494
|
<style lang="less">
|
|
@@ -1304,7 +1501,6 @@ export default {
|
|
|
1304
1501
|
0% {
|
|
1305
1502
|
background: rgba(255, 136, 0, 0.3);
|
|
1306
1503
|
}
|
|
1307
|
-
|
|
1308
1504
|
25% {
|
|
1309
1505
|
background: rgba(255, 136, 0, 0.6);
|
|
1310
1506
|
}
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
</div>
|
|
55
55
|
<div id="drawer_content_pre">
|
|
56
56
|
<template v-if="tagIds && tagIds.length != 0 && drawer">
|
|
57
|
-
<pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord"></pdfPosition>
|
|
57
|
+
<pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :fileName="fileName" :knowledgeItem="watermark" ref="pdfPosition"></pdfPosition>
|
|
58
58
|
</template>
|
|
59
59
|
<template v-else>
|
|
60
60
|
<div v-if="fileType == 'VIDEO'" style="width: 100%;">
|
|
@@ -97,6 +97,7 @@ export default {
|
|
|
97
97
|
tagIds: [],
|
|
98
98
|
// '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
|
|
99
99
|
loading:true,
|
|
100
|
+
fileName:''
|
|
100
101
|
}
|
|
101
102
|
},
|
|
102
103
|
mounted() {
|
|
@@ -117,6 +118,9 @@ export default {
|
|
|
117
118
|
sourceFileType:{
|
|
118
119
|
type: String,
|
|
119
120
|
default: '',
|
|
121
|
+
},
|
|
122
|
+
watermark:{
|
|
123
|
+
type: Object
|
|
120
124
|
}
|
|
121
125
|
},
|
|
122
126
|
components:{
|
|
@@ -126,9 +130,20 @@ export default {
|
|
|
126
130
|
drawer(value) {
|
|
127
131
|
if(value) {
|
|
128
132
|
this.$nextTick(() =>{
|
|
129
|
-
|
|
133
|
+
if (this.tagIds && this.tagIds.length != 0){
|
|
134
|
+
zoomElement(document.getElementById('pdf_container_view'))
|
|
135
|
+
}
|
|
130
136
|
})
|
|
131
137
|
}
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
let previewIframe = document.getElementsByClassName('preview_iframe')
|
|
140
|
+
Array.from(previewIframe).forEach(item =>{
|
|
141
|
+
item.onload = () =>{
|
|
142
|
+
console.debug('previewIframe 106',previewIframe,this.drawer)
|
|
143
|
+
item.style.backgroundImage = 'none'
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
})
|
|
132
147
|
}
|
|
133
148
|
},
|
|
134
149
|
computed:{
|
|
@@ -143,8 +158,10 @@ export default {
|
|
|
143
158
|
// }
|
|
144
159
|
// }
|
|
145
160
|
url = url + this.url
|
|
146
|
-
|
|
147
|
-
|
|
161
|
+
url += '&officePreviewType=pdf'
|
|
162
|
+
if(this.watermark) {
|
|
163
|
+
url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
|
|
164
|
+
url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
|
|
148
165
|
}
|
|
149
166
|
return url
|
|
150
167
|
},
|
|
@@ -282,10 +299,6 @@ export default {
|
|
|
282
299
|
overflow: auto;
|
|
283
300
|
height: calc(100% - 50px);
|
|
284
301
|
background: #FFF;
|
|
285
|
-
background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
|
|
286
|
-
background-position: center;
|
|
287
|
-
background-size: 50px;
|
|
288
|
-
background-repeat: no-repeat;
|
|
289
302
|
}
|
|
290
303
|
}
|
|
291
304
|
@media screen and (min-width: 768px) {
|