askbot-dragon 1.5.82-beta → 1.5.83-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.
@@ -1,5 +1,5 @@
1
1
  <template>
2
- <div class="pdf_view" ref="pdfView" @scroll="pdfScroll" :style="{
2
+ <div class="pdf_view" id="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,16 +251,20 @@ 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'
260
264
  this.$refs.pdfView.appendChild(this.contentView);
265
+ if (this.knowledgeItem && (this.knowledgeItem.source === 'CORP_LOCAL_FILE' || this.knowledgeItem.source === 'YUQUE' || this.knowledgeItem.source === 'FEISHU') && (this.knowledgeItem.visitorWatermarkValue || this.knowledgeItem.textWatermarkValue)){
266
+ this.watermark()
267
+ }
261
268
  }
262
269
  this.renderPages(pageIndex)
263
270
  },
@@ -281,36 +288,41 @@ export default {
281
288
  const { pdfPage, pageNo, dom } = page;
282
289
  // dom 元素已存在,无须重新渲染,直接返回
283
290
  if ((dom && dom.children.length != 0) || page.loading) {
284
- return;
291
+ return;
285
292
  }
286
293
  page.loading = true
287
294
  const viewport = pdfPage.getViewport({
288
- scale: this.scale,
289
- rotation: this.rotation,
295
+ scale: this.scale,
296
+ rotation: this.rotation,
290
297
  });
291
298
  // 创建新的canvas
292
299
  const canvas = document.createElement('canvas');
293
300
  const context = canvas.getContext('2d');
294
301
  // canvas.getContext('2d');
295
- canvas.height = this.pageSize.height;
296
- canvas.width = this.pageSize.width;
302
+ canvas.height = this.pageSize.height * (this.fileName ? CSS_UNITS : 1);
303
+ canvas.width = this.pageSize.width * (this.fileName ? CSS_UNITS : 1);
297
304
  canvas.style.position = 'relative'
298
305
  canvas.style.top = -3 + 'px'
299
306
  // 创建渲染的dom
300
307
  const pageDom = document.createElement('div');
301
308
  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`;
309
+ pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1)) + this.PAGE_INTVERVAL}px`;
310
+ pageDom.style.width = `${this.pageSize.width * (this.fileName ? CSS_UNITS : 1)}px`;
311
+ pageDom.style.height = `${this.pageSize.height * (this.fileName ? CSS_UNITS : 1)}px`;
305
312
  pageDom.setAttribute('data-id', 'page' + pageNo)
306
- pageDom.appendChild(canvas);
313
+ // pageDom.appendChild(canvas);
307
314
  // 渲染内容
308
315
  let renderContext = {
309
316
  canvasContext: context,
310
317
  viewport: viewport,
318
+ transform: this.fileName ? [CSS_UNITS, 0, 0, CSS_UNITS, 0, 0] : '',
311
319
  }
312
320
  await pdfPage.render(renderContext).promise.then(() => {
313
- return pdfPage.getTextContent()
321
+ const html = canvas.toDataURL();
322
+ let image = document.createElement('img');
323
+ image.setAttribute('src',html)
324
+ pageDom.appendChild(image);
325
+ return pdfPage.getTextContent()
314
326
  }).then(async (textContent) => {
315
327
  const textLayerDiv = document.createElement('div');
316
328
  textLayerDiv.setAttribute('class', 'textLayer');
@@ -340,36 +352,35 @@ export default {
340
352
  let postionArr = lines[index].location
341
353
  let div = document.createElement('div')
342
354
  div.style.position = 'absolute';
343
- div.style.left = postionArr[0] * this.scale + 'px',
355
+ div.style.left = postionArr[0] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px',
344
356
  // 后端返回的坐标有基线对齐的问题,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'
357
+ div.style.top = postionArr[1] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px'
358
+ div.style.height = postionArr[3] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px';
359
+ div.style.width = postionArr[2] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px'
348
360
  div.style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
349
361
  div.classList.add('lineHeight')
350
362
  rectdom.appendChild(div)
351
363
  if (index == 0 && j == 0) {
352
364
  if (this.transformSalce !== null) {
353
- rectdomTop = postionArr[1] * this.scale * this.transformSalce
354
- } else {
355
- rectdomTop = postionArr[1] * this.scale
356
- }
357
- // if(this.isPC) {
358
- // rectdomTop = rectdomTop - 50 < 0 ? 0 : rectdomTop - 50
359
- // }
360
- }
361
- }
362
- }
363
- if (rectdom.children.length > 0) {
364
- pageDom.appendChild(rectdom)
365
- }
365
+ rectdomTop = postionArr[1]* this.scale * (this.fileName ? CSS_UNITS : 1) * this.transformSalce
366
+ } else {
367
+ rectdomTop = postionArr[1] * this.scale * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform
368
+ }
369
+ // if(this.isPC) {
370
+ // rectdomTop = rectdomTop - 50 < 0 ? 0 : rectdomTop - 50
371
+ // }
366
372
  }
373
+ }
374
+ }
375
+ if (rectdom.children.length > 0) {
376
+ pageDom.appendChild(rectdom)
367
377
  }
378
+ }
368
379
  }
369
- textLayer.setTextContent(textContent);
370
- textLayer.render()
371
- pageDom.appendChild(textLayerDiv);
372
-
380
+ }
381
+ textLayer.setTextContent(textContent);
382
+ textLayer.render()
383
+ pageDom.appendChild(textLayerDiv);
373
384
  let backgroundDom = document.getElementById('backgroundLoad' + pageNo)
374
385
  if (backgroundDom) {
375
386
  this.contentView.removeChild(backgroundDom);
@@ -377,8 +388,22 @@ export default {
377
388
  page.dom = await pageDom;
378
389
  page.loading = false
379
390
  this.contentView.appendChild(pageDom);
380
- if (this.transformSalce !== null) {
381
- this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
391
+ let pdf_view = document.getElementsByClassName('pdf_view');
392
+ if (pdf_view && pdf_view[0]){
393
+ pdf_view[0].style.backgroundImage = 'none'
394
+ }
395
+ let postionArr = []
396
+ if (findPage){
397
+ let AllLines = findPage.allLines
398
+ if (AllLines.length){
399
+ postionArr = AllLines[0].lines[0].location
400
+ }
401
+ }
402
+ if(this.transformSalce !== null && this.fileName) {
403
+ this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
404
+ } else {
405
+ this.contentView.style.transform = `scale(${this.defaultTransform})`;
406
+
382
407
  }
383
408
  if (this.changetoolbar) {
384
409
  setTimeout(() => {
@@ -390,22 +415,21 @@ export default {
390
415
  setTimeout(() => {
391
416
  let pageoffsetHeight = 0
392
417
  if (this.transformSalce !== null) {
393
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce
418
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)
394
419
  } else {
395
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL)
420
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.defaultTransform *(this.fileName ? CSS_UNITS : 1)
396
421
  }
397
422
  if (this.$refs.pdfView.clientHeight - pageoffsetHeight > 0 && pageIndex == 1) {
398
423
  const height = this.$refs.pdfView.clientHeight;
399
424
  let startNum = 0
400
425
  let endNum = 0
401
426
  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
- } else {
405
- startNum = Math.ceil(this.$refs.pdfView.scrollTop / (this.pageSize.height + this.PAGE_INTVERVAL))
406
- endNum = startNum + Math.ceil(height / (this.pageSize.height + this.PAGE_INTVERVAL))
407
-
408
- }
427
+ startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce* (this.fileName ? CSS_UNITS : 1)))
428
+ endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce* (this.fileName ? CSS_UNITS : 1)))
429
+ } else {
430
+ startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
431
+ endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))}
432
+ console.log(this.$refs.pdfView.scrollTop, startNum, endNum, 'endNumendNum');
409
433
  for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
410
434
  if (pageIndex > 0 && pageIndex <= this.pages.length) {
411
435
  this.loadPdfData(pageIndex)
@@ -437,14 +461,14 @@ export default {
437
461
  let startNum = 0
438
462
  let endNum = 0
439
463
  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))
464
+ startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)))
465
+ endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)))
442
466
  } else {
443
- startNum = Math.ceil(scrollTop / (that.pageSize.height + that.PAGE_INTVERVAL))
444
- endNum = startNum + Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
467
+ startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
468
+ endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1) * this.defaultTransform))
445
469
  }
446
- for (let pageIndex = startNum; pageIndex < endNum; pageIndex++) {
447
- if (pageIndex > 0 && pageIndex < that.pages.length) {
470
+ for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
471
+ if (pageIndex > 0 && pageIndex <= that.pages.length) {
448
472
  that.loadPdfData(pageIndex)
449
473
  }
450
474
  }
@@ -529,10 +553,10 @@ export default {
529
553
  return
530
554
  }
531
555
  const pageDom = document.createElement('div');
532
- pageDom.style.width = `${this.pageSize.width}px`;
533
- pageDom.style.height = `${this.pageSize.height}px`;
556
+ pageDom.style.width = `${this.pageSize.width * (this.fileName ? CSS_UNITS : 1)}px`;
557
+ pageDom.style.height = `${this.pageSize.height * (this.fileName ? CSS_UNITS : 1)}px`;
534
558
  pageDom.style.position = 'absolute';
535
- pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
559
+ pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1)) + this.PAGE_INTVERVAL
536
560
  }px`;
537
561
  pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
538
562
  pageDom.style.backgroundPosition = 'center'
@@ -607,9 +631,9 @@ export default {
607
631
  this.renderHighlights()
608
632
  })
609
633
  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)}`
634
+ 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
635
  } else {
612
- this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + (this.identifyTextPostion.top * this.scale * this.transformSalce)}`
636
+ 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
637
  }
614
638
  },
615
639
  scrollToExcalTop (currentPage) {
@@ -836,6 +860,164 @@ export default {
836
860
  this.contentView.style.transform = 'scale(' + this.transformSalce + ')';
837
861
  // this.getpdfResloutePage(this.cachePdf[0])
838
862
  },
863
+ //添加水印
864
+ watermark() {
865
+ //默认设置
866
+ var defaultSettings = {
867
+ watermark_txt:"",
868
+ watermark_x: 0,//水印起始位置x轴坐标
869
+ watermark_y: 0,//水印起始位置Y轴坐标
870
+ watermark_rows: 0,//水印行数
871
+ watermark_cols: 0,//水印列数
872
+ watermark_x_space: 40,//水印x轴间隔
873
+ watermark_y_space: 60,//水印y轴间隔
874
+ watermark_color: 'black',//水印字体颜色
875
+ watermark_alpha: .3,//水印透明度
876
+ watermark_fontsize: 12,//水印字体大小
877
+ watermark_font: '微软雅黑',//水印字体
878
+ watermark_width: 100,//水印宽度
879
+ watermark_height: 80,//水印长度
880
+ watermark_angle: 20,//水印倾斜度数***
881
+ visitorWatermark_txt:""
882
+ };
883
+ if(this.knowledgeItem.textWatermarkValue){
884
+ defaultSettings.watermark_txt = this.knowledgeItem.textWatermarkValue;
885
+ }
886
+ if (this.knowledgeItem.visitorWatermarkValue){
887
+ defaultSettings.visitorWatermark_txt = this.knowledgeItem.visitorWatermarkValue
888
+ }
889
+ //采用配置项替换默认值,作用类似jquery.extend
890
+ if (arguments.length === 1 && typeof arguments[0] === "object") {
891
+ console.log("arguments = " + JSON.stringify(arguments[0]));
892
+ // 获取参数配置
893
+ var src = arguments[0];
894
+ for (let key in src) {
895
+ if (src[key] && defaultSettings[key] && src[key] === defaultSettings[key])
896
+ continue;
897
+ else if (src[key])
898
+ defaultSettings[key] = src[key];
899
+ }
900
+ }
901
+ var oTemp = document.createDocumentFragment();
902
+ //获取页面最大宽度
903
+ console.debug('pdf_view',document.getElementById('pdf_view'))
904
+ let scrollWidth = document.getElementById('pdf_view').scrollWidth;
905
+ let clientWidth = document.getElementById('pdf_view').clientWidth;
906
+ var page_width = Math.max(scrollWidth, clientWidth);
907
+
908
+ var cutWidth = page_width * 0.0150;
909
+
910
+ page_width = page_width - cutWidth;
911
+
912
+ //获取页面最大高度
913
+ let height = parseInt(this.totalPageCount * this.pageSize.height)
914
+ var page_height = Math.max(document.getElementById('pdf_container_view').scrollHeight,height);
915
+
916
+ console.debug('page_height',page_height,this.totalPageCount * this.pageSize.height);
917
+
918
+ // var page_height = document.body.scrollHeight+document.body.scrollTop;
919
+
920
+ //如果将水印列数设置为0,或水印列数设置过大,超过页面最大宽度,则重新计算水印列数和水印x轴间隔
921
+
922
+ if (defaultSettings.watermark_cols == 0 || (parseInt(defaultSettings.watermark_x + defaultSettings
923
+ .watermark_width * defaultSettings.watermark_cols + defaultSettings.watermark_x_space *
924
+ (defaultSettings.watermark_cols - 1)) > page_width)) {
925
+ defaultSettings.watermark_cols = parseInt((page_width - defaultSettings.watermark_x + defaultSettings
926
+ .watermark_x_space) / (defaultSettings.watermark_width + defaultSettings
927
+ .watermark_x_space));
928
+ defaultSettings.watermark_x_space = parseInt((page_width - defaultSettings.watermark_x -
929
+ defaultSettings
930
+ .watermark_width * defaultSettings.watermark_cols) / (defaultSettings.watermark_cols - 1));
931
+ }
932
+
933
+ //如果将水印行数设置为0,或水印行数设置过大,超过页面最大长度,则重新计算水印行数和水印y轴间隔
934
+
935
+ if (defaultSettings.watermark_rows == 0 || (parseInt(defaultSettings.watermark_y + defaultSettings
936
+
937
+ .watermark_height * defaultSettings.watermark_rows + defaultSettings.watermark_y_space * (
938
+
939
+ defaultSettings.watermark_rows - 1)) > page_height)) {
940
+
941
+ defaultSettings.watermark_rows = parseInt((defaultSettings.watermark_y_space + page_height -
942
+
943
+ defaultSettings
944
+
945
+ .watermark_y) / (defaultSettings.watermark_height + defaultSettings.watermark_y_space));
946
+
947
+ defaultSettings.watermark_y_space = parseInt(((page_height - defaultSettings.watermark_y) -
948
+
949
+ defaultSettings
950
+
951
+ .watermark_height * defaultSettings.watermark_rows) / (defaultSettings.watermark_rows - 1));
952
+
953
+ }
954
+
955
+ var x;
956
+
957
+ var y;
958
+
959
+ for (var i = 0; i < defaultSettings.watermark_rows; i++) {
960
+ y = defaultSettings.watermark_y + (defaultSettings.watermark_y_space + defaultSettings.watermark_height) * i;
961
+ for (var j = 0; j < defaultSettings.watermark_cols; j++) {
962
+ x = defaultSettings.watermark_x + (defaultSettings.watermark_width + defaultSettings.watermark_x_space) * j;
963
+
964
+ var mask_div = document.createElement('div');
965
+ mask_div.id = 'mask_div' + i + j;
966
+ mask_div.className = 'mask_div';
967
+
968
+ //注意看这里加了图片水印
969
+ mask_div.style.webkitTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
970
+ mask_div.style.MozTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
971
+ mask_div.style.msTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
972
+ mask_div.style.OTransform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
973
+ mask_div.style.transform = "rotate(-" + defaultSettings.watermark_angle + "deg)";
974
+ mask_div.style.visibility = "";
975
+ mask_div.style.position = "absolute";
976
+ //奇偶行错开,这样水印就不对齐,显的不呆板
977
+ console.debug('x',x)
978
+ if (i % 2 != 0) {
979
+ mask_div.style.left = x + 'px';
980
+ if (j % 2 != 0 && this.knowledgeItem.visitorWatermarkValue){
981
+ mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
982
+ } else {
983
+ if (!this.knowledgeItem.textWatermarkValue){
984
+ mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
985
+ } else {
986
+ mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
987
+ }
988
+ }
989
+ } else {
990
+ mask_div.style.left = x + 'px';
991
+ if (j % 2 != 0 && this.knowledgeItem.textWatermarkValue){
992
+ mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
993
+ } else {
994
+ if (!this.knowledgeItem.visitorWatermarkValue){
995
+ mask_div.appendChild(document.createTextNode(defaultSettings.watermark_txt));
996
+ } else {
997
+ mask_div.appendChild(document.createTextNode(defaultSettings.visitorWatermark_txt));
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ mask_div.style.top = y + 'px';
1003
+ mask_div.style.overflow = "hidden";
1004
+ mask_div.style.zIndex = "9999";
1005
+ mask_div.style.pointerEvents = 'none'; //让水印不遮挡页面的点击事件
1006
+ mask_div.style.opacity = defaultSettings.watermark_alpha;
1007
+ mask_div.style.fontSize = defaultSettings.watermark_fontsize;
1008
+ mask_div.style.fontFamily = defaultSettings.watermark_font;
1009
+ mask_div.style.color = defaultSettings.watermark_color;
1010
+ mask_div.style.textAlign = "center";
1011
+ mask_div.style.width = defaultSettings.watermark_width + 'px';
1012
+ mask_div.style.height = defaultSettings.watermark_height + 'px';
1013
+ mask_div.style.display = "block";
1014
+ oTemp.appendChild(mask_div);
1015
+ }
1016
+ }
1017
+ let pageDom = document.getElementById('pdf_container_view')
1018
+ pageDom.appendChild(oTemp);
1019
+
1020
+ },
839
1021
  },
840
1022
  computed: {
841
1023
  perviewUrl () {
@@ -863,8 +1045,11 @@ export default {
863
1045
  if (value && value.length) {
864
1046
  // 在 pdf_view 下创建 所有canvs的容器
865
1047
  this.contentView = document.createElement('div')
1048
+ this.contentView.setAttribute('id','contentView')
866
1049
  this.contentView.style.transformOrigin = '0px 0px 0px'
867
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res => {
1050
+ this.contentView.setAttribute('id','contentView');
1051
+
1052
+ this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res => {
868
1053
  // 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
1054
  // 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
1055
  // 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}
@@ -1030,9 +1215,9 @@ export default {
1030
1215
  // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
1031
1216
  // 缓存拿到的所有数据
1032
1217
  this.cachePdf = res.data.data
1033
- let publicPageFileUrl = res.data.data[0].publicPageFileUrl
1218
+ let publicPageFileUrl = res.data.data && res.data.data[0] ? res.data.data[0].publicPageFileUrl : ''
1034
1219
  this.currentPage = 0
1035
- if (publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
1220
+ if (publicPageFileUrl && publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
1036
1221
  this.preViewType = 'pdf'
1037
1222
  this.setPageAllLine(this.cachePdf)
1038
1223
  this.getpdfResloutePage(res.data.data[0])
@@ -1053,11 +1238,16 @@ export default {
1053
1238
  xhr.onload = ({ currentTarget }) => {
1054
1239
  // 请求完成
1055
1240
  if (currentTarget.status === 200) { // 返回200
1241
+ let pdf_view = document.getElementsByClassName('pdf_view');
1242
+ if (pdf_view && pdf_view[0]){
1243
+ pdf_view[0].style.backgroundImage = 'none'
1244
+ }
1056
1245
  this.contentView.innerHTML = currentTarget.response
1057
1246
  this.contentView.style.padding = '10px'
1058
1247
  // this.contentView.style.position = 'relative'
1059
1248
  this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
1060
1249
  this.$refs.pdfView.appendChild(this.contentView)
1250
+
1061
1251
  let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
1062
1252
  this.allTr = []
1063
1253
  for (let index = 0; index < allTr.length; index++) {
@@ -1100,10 +1290,14 @@ export default {
1100
1290
  width: 100%;
1101
1291
  height: calc(100% - 110px);
1102
1292
  overflow: auto;
1293
+ //overflow-y: scroll;
1103
1294
  background-color: #f5f7fb;
1104
1295
  // margin-bottom: 60px;
1105
1296
  box-sizing: border-box;
1106
-
1297
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
1298
+ background-position: center;
1299
+ background-size: 50px;
1300
+ background-repeat: no-repeat;
1107
1301
  // position: relative;
1108
1302
  // > div {
1109
1303
  // width: 100%;
@@ -1292,6 +1486,12 @@ export default {
1292
1486
  background: rgba(221, 222, 223, 1);
1293
1487
  }
1294
1488
  }
1489
+ .pdf_container_view{
1490
+ height: 100%;
1491
+ width: 100%;
1492
+ position: relative;
1493
+ overflow: auto;
1494
+ }
1295
1495
  }
1296
1496
  </style>
1297
1497
  <style lang="less">
@@ -1304,7 +1504,6 @@ export default {
1304
1504
  0% {
1305
1505
  background: rgba(255, 136, 0, 0.3);
1306
1506
  }
1307
-
1308
1507
  25% {
1309
1508
  background: rgba(255, 136, 0, 0.6);
1310
1509
  }
@@ -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
- zoomElement(document.getElementById('drawer_content_pre'))
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
- if(this.sourceFileType == '.ppt' || this.sourceFileType == '.pptx') {
147
- url += '&officePreviewType=pdf'
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) {