askbot-dragon 1.5.74-beta → 1.5.76-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" id="pdf_view" :style="{
2
+ <div class="pdf_view" ref="pdfView" @scroll="pdfScroll" :style="{
3
3
  marginTop: isPC ? '50px' : '',
4
4
  marginBottom: tagIds.length > 1 ? '60px' : '0px',
5
5
  height: setHeight
@@ -17,7 +17,6 @@
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>
21
20
  <div class="btn_footer" v-if="tagIds.length > 1 && !isPC">
22
21
  <div class="prev" @click="prev">上一段</div>
23
22
  <div class="next" @click="next">下一段</div>
@@ -45,11 +44,10 @@ if (pdfjsLib) {
45
44
  // 'pdfjs-dist/build/pdf.worker';
46
45
  }
47
46
  const { TextLayerBuilder } = window['pdfjs-dist/web/pdf_viewer']
48
- const CSS_UNITS = 96.0 / 72.0
49
47
  // import { zoomElement } from '../assets/js/hammer'
50
48
  export default {
51
49
  name: 'pdfView',
52
- props: ['tagIds', 'isMessageRecord','fileName', "knowledgeItem"],
50
+ props: ['tagIds', 'isMessageRecord'],
53
51
  data () {
54
52
  return {
55
53
  url: '',
@@ -96,7 +94,6 @@ export default {
96
94
  },
97
95
  isTouchMoved: false,
98
96
  transformSalce: null,
99
- defaultTransform:0.8,
100
97
  isPC: false,
101
98
  handScale: 'auto',
102
99
  scaleList: [
@@ -251,20 +248,16 @@ export default {
251
248
  if (this.$refs.pdfView.clientWidth / this.pageSize.width >= 1 || this.isMessageRecord) {
252
249
  this.contentView.style.width = `${pageSize.width - 10}px`;
253
250
  this.contentView.style.height = `${(this.totalPageCount * (pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
254
- this.contentView.style.margin = '0 auto 0'
255
251
  } else {
256
- this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width / CSS_UNITS
252
+ this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
257
253
  this.contentView.style.width = `${pageSize.width * this.transformSalce - 10}px`;
258
254
  this.contentView.style.height = `${(this.totalPageCount * (pageSize.height * (this.transformSalce) + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
259
255
  }
260
- // this.contentView.style.margin = '0 auto 0'
256
+ this.contentView.style.margin = '0 auto 0'
261
257
  this.contentView.style.position = 'relative'
262
258
  this.contentView.style.paddingBottom = '60px'
263
259
  // contentView.style.overflowY = 'auto'
264
260
  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
- }
268
261
  }
269
262
  this.renderPages(pageIndex)
270
263
  },
@@ -288,41 +281,36 @@ export default {
288
281
  const { pdfPage, pageNo, dom } = page;
289
282
  // dom 元素已存在,无须重新渲染,直接返回
290
283
  if ((dom && dom.children.length != 0) || page.loading) {
291
- return;
284
+ return;
292
285
  }
293
286
  page.loading = true
294
287
  const viewport = pdfPage.getViewport({
295
- scale: this.scale,
296
- rotation: this.rotation,
288
+ scale: this.scale,
289
+ rotation: this.rotation,
297
290
  });
298
291
  // 创建新的canvas
299
292
  const canvas = document.createElement('canvas');
300
293
  const context = canvas.getContext('2d');
301
294
  // canvas.getContext('2d');
302
- canvas.height = this.pageSize.height * (this.fileName ? CSS_UNITS : 1);
303
- canvas.width = this.pageSize.width * (this.fileName ? CSS_UNITS : 1);
295
+ canvas.height = this.pageSize.height;
296
+ canvas.width = this.pageSize.width;
304
297
  canvas.style.position = 'relative'
305
298
  canvas.style.top = -3 + 'px'
306
299
  // 创建渲染的dom
307
300
  const pageDom = document.createElement('div');
308
301
  pageDom.style.position = 'absolute';
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`;
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`;
312
305
  pageDom.setAttribute('data-id', 'page' + pageNo)
313
- // pageDom.appendChild(canvas);
306
+ pageDom.appendChild(canvas);
314
307
  // 渲染内容
315
308
  let renderContext = {
316
309
  canvasContext: context,
317
310
  viewport: viewport,
318
- transform: this.fileName ? [CSS_UNITS, 0, 0, CSS_UNITS, 0, 0] : '',
319
311
  }
320
312
  await pdfPage.render(renderContext).promise.then(() => {
321
- const html = canvas.toDataURL();
322
- let image = document.createElement('img');
323
- image.setAttribute('src',html)
324
- pageDom.appendChild(image);
325
- return pdfPage.getTextContent()
313
+ return pdfPage.getTextContent()
326
314
  }).then(async (textContent) => {
327
315
  const textLayerDiv = document.createElement('div');
328
316
  textLayerDiv.setAttribute('class', 'textLayer');
@@ -352,35 +340,36 @@ export default {
352
340
  let postionArr = lines[index].location
353
341
  let div = document.createElement('div')
354
342
  div.style.position = 'absolute';
355
- div.style.left = postionArr[0] * this.scale * (this.fileName ? CSS_UNITS : 1) + 'px',
343
+ div.style.left = postionArr[0] * this.scale + 'px',
356
344
  // 后端返回的坐标有基线对齐的问题,top 值是后端算好(基线top - 文字高度),在此加上文字高度的 1/9 (大致比例)为实际展示出文字的top值
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'
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'
360
348
  div.style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
361
349
  div.classList.add('lineHeight')
362
350
  rectdom.appendChild(div)
363
351
  if (index == 0 && j == 0) {
364
352
  if (this.transformSalce !== null) {
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
- // }
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
+ }
372
366
  }
373
- }
374
- }
375
- if (rectdom.children.length > 0) {
376
- pageDom.appendChild(rectdom)
377
367
  }
378
- }
379
368
  }
380
- }
381
- textLayer.setTextContent(textContent);
382
- textLayer.render()
383
- pageDom.appendChild(textLayerDiv);
369
+ textLayer.setTextContent(textContent);
370
+ textLayer.render()
371
+ pageDom.appendChild(textLayerDiv);
372
+
384
373
  let backgroundDom = document.getElementById('backgroundLoad' + pageNo)
385
374
  if (backgroundDom) {
386
375
  this.contentView.removeChild(backgroundDom);
@@ -388,22 +377,8 @@ export default {
388
377
  page.dom = await pageDom;
389
378
  page.loading = false
390
379
  this.contentView.appendChild(pageDom);
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
-
380
+ if (this.transformSalce !== null) {
381
+ this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
407
382
  }
408
383
  if (this.changetoolbar) {
409
384
  setTimeout(() => {
@@ -415,21 +390,22 @@ export default {
415
390
  setTimeout(() => {
416
391
  let pageoffsetHeight = 0
417
392
  if (this.transformSalce !== null) {
418
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce * (this.fileName ? CSS_UNITS : 1)
393
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce
419
394
  } else {
420
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.defaultTransform *(this.fileName ? CSS_UNITS : 1)
395
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL)
421
396
  }
422
397
  if (this.$refs.pdfView.clientHeight - pageoffsetHeight > 0 && pageIndex == 1) {
423
398
  const height = this.$refs.pdfView.clientHeight;
424
399
  let startNum = 0
425
400
  let endNum = 0
426
401
  if (this.transformSalce !== null) {
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');
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
+ }
433
409
  for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
434
410
  if (pageIndex > 0 && pageIndex <= this.pages.length) {
435
411
  this.loadPdfData(pageIndex)
@@ -461,14 +437,14 @@ export default {
461
437
  let startNum = 0
462
438
  let endNum = 0
463
439
  if (this.transformSalce !== null) {
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)))
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))
466
442
  } else {
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))
443
+ startNum = Math.ceil(scrollTop / (that.pageSize.height + that.PAGE_INTVERVAL))
444
+ endNum = startNum + Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
469
445
  }
470
- for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
471
- if (pageIndex > 0 && pageIndex <= that.pages.length) {
446
+ for (let pageIndex = startNum; pageIndex < endNum; pageIndex++) {
447
+ if (pageIndex > 0 && pageIndex < that.pages.length) {
472
448
  that.loadPdfData(pageIndex)
473
449
  }
474
450
  }
@@ -553,10 +529,10 @@ export default {
553
529
  return
554
530
  }
555
531
  const pageDom = document.createElement('div');
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`;
532
+ pageDom.style.width = `${this.pageSize.width}px`;
533
+ pageDom.style.height = `${this.pageSize.height}px`;
558
534
  pageDom.style.position = 'absolute';
559
- pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * (this.fileName ? CSS_UNITS : 1)) + this.PAGE_INTVERVAL
535
+ pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
560
536
  }px`;
561
537
  pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
562
538
  pageDom.style.backgroundPosition = 'center'
@@ -631,9 +607,9 @@ export default {
631
607
  this.renderHighlights()
632
608
  })
633
609
  if (this.transformSalce !== null) {
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))}`
610
+ this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce) + (this.identifyTextPostion.top * this.scale * this.transformSalce)}`
635
611
  } else {
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))}`
612
+ this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + (this.identifyTextPostion.top * this.scale * this.transformSalce)}`
637
613
  }
638
614
  },
639
615
  scrollToExcalTop (currentPage) {
@@ -860,164 +836,6 @@ export default {
860
836
  this.contentView.style.transform = 'scale(' + this.transformSalce + ')';
861
837
  // this.getpdfResloutePage(this.cachePdf[0])
862
838
  },
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
- },
1021
839
  },
1022
840
  computed: {
1023
841
  perviewUrl () {
@@ -1045,11 +863,8 @@ export default {
1045
863
  if (value && value.length) {
1046
864
  // 在 pdf_view 下创建 所有canvs的容器
1047
865
  this.contentView = document.createElement('div')
1048
- this.contentView.setAttribute('id','contentView')
1049
866
  this.contentView.style.transformOrigin = '0px 0px 0px'
1050
- this.contentView.setAttribute('id','contentView');
1051
-
1052
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res => {
867
+ this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res => {
1053
868
  // 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}
1054
869
  // 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}
1055
870
  // 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}
@@ -1215,9 +1030,9 @@ export default {
1215
1030
  // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
1216
1031
  // 缓存拿到的所有数据
1217
1032
  this.cachePdf = res.data.data
1218
- let publicPageFileUrl = res.data.data && res.data.data[0] ? res.data.data[0].publicPageFileUrl : ''
1033
+ let publicPageFileUrl = res.data.data[0].publicPageFileUrl
1219
1034
  this.currentPage = 0
1220
- if (publicPageFileUrl && publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
1035
+ if (publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
1221
1036
  this.preViewType = 'pdf'
1222
1037
  this.setPageAllLine(this.cachePdf)
1223
1038
  this.getpdfResloutePage(res.data.data[0])
@@ -1238,16 +1053,11 @@ export default {
1238
1053
  xhr.onload = ({ currentTarget }) => {
1239
1054
  // 请求完成
1240
1055
  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
- }
1245
1056
  this.contentView.innerHTML = currentTarget.response
1246
1057
  this.contentView.style.padding = '10px'
1247
1058
  // this.contentView.style.position = 'relative'
1248
1059
  this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
1249
1060
  this.$refs.pdfView.appendChild(this.contentView)
1250
-
1251
1061
  let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
1252
1062
  this.allTr = []
1253
1063
  for (let index = 0; index < allTr.length; index++) {
@@ -1290,14 +1100,10 @@ export default {
1290
1100
  width: 100%;
1291
1101
  height: calc(100% - 110px);
1292
1102
  overflow: auto;
1293
- //overflow-y: scroll;
1294
1103
  background-color: #f5f7fb;
1295
1104
  // margin-bottom: 60px;
1296
1105
  box-sizing: border-box;
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;
1106
+
1301
1107
  // position: relative;
1302
1108
  // > div {
1303
1109
  // width: 100%;
@@ -1486,12 +1292,6 @@ export default {
1486
1292
  background: rgba(221, 222, 223, 1);
1487
1293
  }
1488
1294
  }
1489
- .pdf_container_view{
1490
- height: 100%;
1491
- width: 100%;
1492
- position: relative;
1493
- overflow: auto;
1494
- }
1495
1295
  }
1496
1296
  </style>
1497
1297
  <style lang="less">
@@ -1504,6 +1304,7 @@ export default {
1504
1304
  0% {
1505
1305
  background: rgba(255, 136, 0, 0.3);
1506
1306
  }
1307
+
1507
1308
  25% {
1508
1309
  background: rgba(255, 136, 0, 0.6);
1509
1310
  }
@@ -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" :fileName="fileName" :knowledgeItem="watermark" ref="pdfPosition"></pdfPosition>
57
+ <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord"></pdfPosition>
58
58
  </template>
59
59
  <template v-else>
60
60
  <div v-if="fileType == 'VIDEO'" style="width: 100%;">
@@ -97,7 +97,6 @@ export default {
97
97
  tagIds: [],
98
98
  // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
99
99
  loading:true,
100
- fileName:''
101
100
  }
102
101
  },
103
102
  mounted() {
@@ -118,9 +117,6 @@ export default {
118
117
  sourceFileType:{
119
118
  type: String,
120
119
  default: '',
121
- },
122
- watermark:{
123
- type: Object
124
120
  }
125
121
  },
126
122
  components:{
@@ -130,20 +126,9 @@ export default {
130
126
  drawer(value) {
131
127
  if(value) {
132
128
  this.$nextTick(() =>{
133
- if (this.tagIds && this.tagIds.length != 0){
134
- zoomElement(document.getElementById('pdf_container_view'))
135
- }
129
+ zoomElement(document.getElementById('drawer_content_pre'))
136
130
  })
137
131
  }
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
- })
147
132
  }
148
133
  },
149
134
  computed:{
@@ -158,10 +143,8 @@ export default {
158
143
  // }
159
144
  // }
160
145
  url = url + this.url
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
146
+ if(this.sourceFileType == '.ppt' || this.sourceFileType == '.pptx') {
147
+ url += '&officePreviewType=pdf'
165
148
  }
166
149
  return url
167
150
  },
@@ -299,6 +282,10 @@ export default {
299
282
  overflow: auto;
300
283
  height: calc(100% - 50px);
301
284
  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;
302
289
  }
303
290
  }
304
291
  @media screen and (min-width: 768px) {