askbot-dragon 1.4.57 → 1.4.59

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.
Files changed (85) hide show
  1. package/README.md +27 -27
  2. package/babel.config.js +6 -6
  3. package/dragon.iml +7 -7
  4. package/package.json +58 -58
  5. package/public/index.html +59 -59
  6. package/src/App.vue +31 -31
  7. package/src/api/index.js +1 -1
  8. package/src/api/mock.http +2 -2
  9. package/src/api/requestUrl.js +185 -185
  10. package/src/assets/js/AliyunlssUtil.js +92 -92
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/common.js +11 -11
  13. package/src/assets/js/hammer.js +89 -89
  14. package/src/assets/js/script.js +36 -36
  15. package/src/assets/less/common.css +6773 -6773
  16. package/src/assets/less/converSationContainer/common.less +191 -191
  17. package/src/assets/less/converSationContainer/converSatonContainer.less +493 -493
  18. package/src/assets/less/iconfont.css +37 -37
  19. package/src/assets/less/ticketMessage.less +211 -211
  20. package/src/components/ActionAlertIframe.vue +112 -112
  21. package/src/components/AiGuide.vue +467 -467
  22. package/src/components/AnswerDocknowledge.vue +472 -472
  23. package/src/components/AnswerVoice.vue +285 -285
  24. package/src/components/AskIFrame.vue +15 -15
  25. package/src/components/ConversationContainer.vue +4060 -4060
  26. package/src/components/FileType.vue +86 -86
  27. package/src/components/Message.vue +27 -27
  28. package/src/components/actionSatisfaction.vue +107 -107
  29. package/src/components/actionSendToBot.vue +62 -62
  30. package/src/components/answerDissatisfaction.vue +62 -62
  31. package/src/components/answerRadio.vue +131 -131
  32. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  33. package/src/components/ask-components/Msgloading.vue +37 -37
  34. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  35. package/src/components/askVideo.vue +138 -138
  36. package/src/components/assetDetails.vue +370 -370
  37. package/src/components/assetMessage.vue +228 -228
  38. package/src/components/associationIntention.vue +347 -347
  39. package/src/components/attachmentPreview.vue +90 -90
  40. package/src/components/botActionSatisfactor.vue +68 -68
  41. package/src/components/chatContent.vue +513 -513
  42. package/src/components/feedBack.vue +136 -136
  43. package/src/components/fielListView.vue +349 -349
  44. package/src/components/file/AliyunOssComponents.vue +108 -108
  45. package/src/components/formTemplate.vue +3384 -3373
  46. package/src/components/loadingProcess.vue +164 -164
  47. package/src/components/message/ActionAlertIframe.vue +112 -112
  48. package/src/components/message/ShopMessage.vue +164 -164
  49. package/src/components/message/TextMessage.vue +924 -924
  50. package/src/components/message/TicketMessage.vue +177 -177
  51. package/src/components/message/swiper/index.js +4 -4
  52. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  53. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  54. package/src/components/msgLoading.vue +231 -231
  55. package/src/components/myPopup.vue +70 -70
  56. package/src/components/pdfPosition.vue +1106 -1106
  57. package/src/components/popup.vue +227 -227
  58. package/src/components/previewDoc.vue +228 -228
  59. package/src/components/previewPdf.vue +289 -289
  60. package/src/components/receiverMessagePlatform.vue +65 -65
  61. package/src/components/recommend.vue +89 -89
  62. package/src/components/selector/hOption.vue +20 -20
  63. package/src/components/selector/hSelector.vue +199 -199
  64. package/src/components/selector/hWrapper.vue +216 -216
  65. package/src/components/senderMessagePlatform.vue +50 -50
  66. package/src/components/source/BotMessage.vue +24 -24
  67. package/src/components/source/CustomMessage.vue +24 -24
  68. package/src/components/test.vue +260 -260
  69. package/src/components/tree.vue +294 -294
  70. package/src/components/utils/AliyunIssUtil.js +72 -72
  71. package/src/components/utils/ckeditor.js +155 -155
  72. package/src/components/utils/ckeditorImageUpload/command.js +109 -109
  73. package/src/components/utils/ckeditorImageUpload/editing.js +11 -11
  74. package/src/components/utils/ckeditorImageUpload/plugin-image.js +11 -11
  75. package/src/components/utils/ckeditorImageUpload/toolbar-ui.js +40 -40
  76. package/src/components/utils/ckeditorfileUpload/common.js +133 -133
  77. package/src/components/utils/ckeditorfileUpload/editing.js +11 -11
  78. package/src/components/utils/ckeditorfileUpload/plugin_file.js +11 -11
  79. package/src/components/utils/ckeditorfileUpload/toolbar_ui.js +34 -34
  80. package/src/components/utils/format_date.js +25 -25
  81. package/src/components/utils/index.js +6 -6
  82. package/src/components/utils/math_utils.js +29 -29
  83. package/src/components/voiceComponent.vue +119 -119
  84. package/src/main.js +60 -60
  85. package/vue.config.js +55 -55
@@ -1,1107 +1,1107 @@
1
- <template>
2
- <div
3
- class="pdf_view"
4
- ref="pdfView"
5
- @scroll="pdfScroll"
6
- :style="{
7
- marginTop: isPC ? '50px' : ''
8
- }">
9
- <div class="change_scale" v-if="isPC">
10
- <section @click="changeScale('reduce')">
11
- <i class="el-icon-minus"></i>
12
- </section>
13
- <el-divider direction="vertical"></el-divider>
14
- <section @click="changeScale('zoom')">
15
- <i class="el-icon-plus"></i>
16
- </section>
17
- <el-select size="small" v-model="handScale" @change="changeScale" placeholder="请选择">
18
- <el-option
19
- v-for="item in scaleList"
20
- :key="item.value"
21
- :label="item.label"
22
- :value="item.value">
23
- </el-option>
24
- </el-select>
25
- </div>
26
- <div class="btn_footer" v-if="tagIds.length > 1 && !isPC">
27
- <div class="prev" @click="prev">上一段</div>
28
- <div class="next" @click="next">下一段</div>
29
- </div>
30
- <div id="pagination" v-if="tagIds.length > 1 && isPC">
31
- <el-pagination :current-page="currentPage + 1" @current-change="currentChange" @prev-click="prev"
32
- @next-click="next" layout="slot, prev, pager, next" :page-size="1" :total="tagIds.length">
33
- <span class="total-class">答案由{{ tagIds.length }}段内容生成</span>
34
- </el-pagination>
35
- </div>
36
- </div>
37
- </template>
38
-
39
- <script>
40
- import _ from 'lodash'
41
- // import * as pdfjsLib from 'pdfjs-dist'
42
- // pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs-dist/build/pdf.worker';
43
- // import { TextLayerBuilder } from "pdfjs-dist/web/pdf_viewer";
44
- // EventBus pdf_viewer 支持绑定自定义事件,一版不做
45
- // import 'pdfjs-dist/web/pdf_viewer.css'
46
- /* eslint-disable */
47
- const pdfjsLib = window['pdfjsLib']
48
- if(pdfjsLib) {
49
- pdfjsLib.GlobalWorkerOptions.workerSrc = window['pdfjs-dist/build/pdf.worker']
50
- // 'pdfjs-dist/build/pdf.worker';
51
- }
52
- const { TextLayerBuilder } = window['pdfjs-dist/web/pdf_viewer']
53
- // import { zoomElement } from '../assets/js/hammer'
54
- export default {
55
- name: 'pdfView',
56
- props:['tagIds','isMessageRecord'],
57
- data() {
58
- return {
59
- url: '',
60
- pages: [],
61
- pageLoadStatus: {
62
- WAIT: 0,
63
- LOADED: 1,
64
- },
65
- scale: 1,
66
- rotation: 0,
67
- pageSize: {},
68
- PAGE_INTVERVAL: 15,
69
- SLICE_COUNT: 5,
70
- contentView: null,
71
- fisrtLoad: true,
72
- TextLayerBuilder: null,
73
- totalPageCount: 0,
74
- identifyTextPostion: {
75
- top: 0,
76
- left: 0,
77
- width: 100,
78
- height: 0,
79
- page: 1,
80
- pageHeight: 0,
81
- pageWidth: 0,
82
- extractInfo: {},
83
- currentPageAllLine: []
84
- },
85
- currentPageAllLine: [],
86
- pdfUrl: '',
87
- cachePdf: [],
88
- newViewer: null,
89
- currentPage: 0,
90
- changetoolbar: false,
91
- allTr:[],
92
- preViewType: 'pdf',
93
- displacement:{
94
- pageX: 0,
95
- pageY: 0,
96
- moveable: false,
97
- pageX2: 0,
98
- pageY2: 0,
99
- originScale: 1,
100
- },
101
- isTouchMoved: false,
102
- transformSalce: null,
103
- isPC: false,
104
- handScale: 'auto',
105
- scaleList:[
106
- {
107
- label:'自动缩放',
108
- value:'auto'
109
- },
110
- {
111
- label:'实际比例',
112
- value:'reality'
113
- },
114
- {
115
- label:'100%',
116
- value: 1
117
- },
118
- {
119
- label:'120%',
120
- value: 1.2
121
- },
122
- {
123
- label:'150%',
124
- value: 1.5
125
- },
126
- {
127
- label:'170%',
128
- value: 1.7
129
- }
130
- ,
131
- {
132
- label:'200%',
133
- value: 2
134
- }
135
- ],
136
- scrollTop:0,
137
- scrollLeft:0
138
- }
139
- },
140
- methods: {
141
- getpdfResloutePage (pdfResloute) {
142
- // 根据当前页面宽度设置缩放比例
143
- // this.scale = Math.round(this.$refs.pdfView.clientWidth / pdfResloute.pageWidth * 100) / 100
144
- // console.log(this.scale,'this.scale');
145
- if(this.isMessageRecord) {
146
- this.scale = Math.round(this.$refs.pdfView.clientWidth / pdfResloute.pageWidth * 100) / 100
147
- } else {
148
- this.scale = 2
149
- }
150
- // 从后端获取到当前分片后所有的pdf页码,初始化数组,数组下{} 对应每页pdf文件
151
- this.pdfUrl = pdfResloute.publicPageFileUrl.substring(0, pdfResloute.publicPageFileUrl.lastIndexOf('/') + 1)
152
- this.initPages(pdfResloute.total)
153
- // 定位功能,加载对应页码位置
154
- this.loadPdfData(pdfResloute.page)
155
- },
156
- async loadPdfData (loadPage) {
157
- if(this.pages[loadPage - 1] && this.pages[loadPage - 1].dom && this.pages[loadPage - 1].dom.children.length > 0) {
158
- return
159
- }
160
- // pdfjsLib.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/legacy/build/pdf.worker.entry.js");
161
- // 拿到第一个分片
162
- const { startPage, url } = await this.fetchPdfFragment(loadPage);
163
- let loadingTask = pdfjsLib.getDocument(url)
164
- loadingTask.promise.then((pdfDoc) => {
165
- // 将已经下载的分片保存到 pages 数组中
166
- for (let i = 0; i < pdfDoc.numPages; i += 1) {
167
- const pageIndex = startPage + i;
168
- const page = this.pages[pageIndex - 1];
169
- // 不在缓存列表内,重新获取本页pdf
170
- if (page.loadStatus !== this.pageLoadStatus.LOADED) {
171
- pdfDoc.getPage(i + 1).then((pdfPage) => {
172
- page.pdfPage = pdfPage;
173
- page.loadStatus = this.pageLoadStatus.LOADED;
174
- // 通知可以进行渲染了
175
- this.startRenderPages(pdfPage, page, pageIndex)
176
- });
177
- } else {
178
- if (this.changetoolbar) {
179
- this.$nextTick(() => {
180
- this.renderHighlights()
181
- })
182
- this.changetoolbar = false
183
- }
184
- }
185
- }
186
- });
187
- },
188
- initPages (totalPage) {
189
- // const pages = [];
190
- this.totalPageCount = totalPage
191
- for (let i = 0; i < totalPage; i += 1) {
192
- this.pages.push({
193
- pageNo: i + 1,
194
- loadStatus: this.pageLoadStatus.WAIT,
195
- pdfPage: null,
196
- dom: null
197
- });
198
- }
199
- },
200
- async fetchPdfFragment (pageIndex) {
201
- // 置换加签后的文件地址。
202
- let obj = {}
203
- await this.$http.post(
204
- '/knowledge-api/temporary-certificate/or-origin?expired=30',
205
- this.pdfUrl + pageIndex + '.pdf',
206
- {
207
- headers: {
208
- "Content-Type": "application/json",
209
- },
210
- }).then(async res => {
211
- if(res.bodyText) {
212
- // 最后返回一个 包含这4个参数的对象
213
- obj = await {
214
- "startPage": pageIndex, // 分片的开始页码
215
- "endPage": pageIndex + 5, // 分片结束页码
216
- "totalPage": this.totalPageCount, // pdf 总页数
217
- "url": res.bodyText // 分片内容下载地址
218
- }
219
- }
220
- if (res.data) {
221
- // 最后返回一个 包含这4个参数的对象
222
- obj = await {
223
- "startPage": pageIndex, // 分片的开始页码
224
- "endPage": pageIndex + 5, // 分片结束页码
225
- "totalPage": this.totalPageCount, // pdf 总页数
226
- "url": res.data // 分片内容下载地址
227
- }
228
- }
229
- })
230
- return obj
231
- },
232
- startRenderPages (pdfPage, page, pageIndex) {
233
- const viewport = pdfPage.getViewport({
234
- scale: this.scale, // 缩放的比例
235
- rotation: this.rotation, // 旋转的角度
236
- });
237
- // 记录pdf页面高度
238
- const pageSize = {
239
- width: viewport.width,
240
- height: viewport.height,
241
- }
242
- this.pageSize = pageSize
243
- // 创建内容绘制区,并设置大小
244
- if(this.$refs.pdfView.clientWidth / this.pageSize.width >= 1 || this.isMessageRecord) {
245
- this.contentView.style.width = `${pageSize.width }px`;
246
- this.contentView.style.height = `${(this.totalPageCount * (pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
247
- } else {
248
- this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
249
- this.contentView.style.width = `${pageSize.width * this.transformSalce}px`;
250
- this.contentView.style.height = `${(this.totalPageCount * (pageSize.height * (this.transformSalce) + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
251
- }
252
- this.contentView.style.margin = '0 auto 0'
253
- console.log(this.transformSalce);
254
- this.contentView.style.position = 'relative'
255
- this.contentView.style.paddingBottom = '60px'
256
- // contentView.style.overflowY = 'auto'
257
- this.$refs.pdfView.appendChild(this.contentView);
258
- this.renderPages(pageIndex)
259
- },
260
- renderPageContent (page, pageIndex) {
261
- const { pdfPage, pageNo, dom } = page;
262
- // dom 元素已存在,无须重新渲染,直接返回
263
- console.log(dom, 'dom');
264
- if (dom && dom.children.length != 0) {
265
- return;
266
- }
267
- const viewport = pdfPage.getViewport({
268
- scale: this.scale,
269
- rotation: this.rotation,
270
- });
271
- // 创建新的canvas
272
- const canvas = document.createElement('canvas');
273
- const context = canvas.getContext('2d');
274
- // canvas.getContext('2d');
275
- canvas.height = this.pageSize.height;
276
- canvas.width = this.pageSize.width;
277
- // 创建渲染的dom
278
- const pageDom = document.createElement('div');
279
- pageDom.style.position = 'absolute';
280
- pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
281
- pageDom.style.width = `${this.pageSize.width}px`;
282
- pageDom.style.height = `${this.pageSize.height}px`;
283
- pageDom.appendChild(canvas);
284
- // 渲染内容
285
- let renderContext = {
286
- canvasContext: context,
287
- viewport: viewport,
288
- }
289
- pdfPage.render(renderContext).promise.then(() => {
290
- console.log(pdfPage.getTextContent(), 'getTextContent');
291
- return pdfPage.getTextContent()
292
- }).then((textContent) => {
293
- const textLayerDiv = document.createElement('div');
294
- textLayerDiv.setAttribute('class', 'textLayer');
295
- // 将文本图层div添加至每页pdf的div中
296
- // 创建新的TextLayerBuilder实例
297
- let textLayer = new TextLayerBuilder({
298
- textLayerDiv: textLayerDiv,
299
- pageIndex: pdfPage._pageIndex,
300
- viewport: viewport,
301
- });
302
- let findPage = this.currentPageAllLine.find(l => { return l.page == pageIndex })
303
- if (findPage) {
304
- let AllLines = findPage.allLines
305
- // setTimeout(() => {
306
- if (AllLines.length > 0) {
307
- for (let j = 0; j < AllLines.length; j++) {
308
- let lines = AllLines[j].lines
309
- let rectdom = document.createElement('div')
310
- rectdom.setAttribute('react-count', AllLines[j].pageCount);
311
- rectdom.style.position = 'absolute';
312
- rectdom.style.top = 0
313
- rectdom.style.left = 0
314
- rectdom.classList.add('rectdom')
315
- for (let index = 0; index < lines.length; index++) {
316
- if (!/^\s+$/g.test(lines[index].content)) {
317
- let postionArr = lines[index].location
318
- let div = document.createElement('div')
319
- div.style.position = 'absolute';
320
- div.style.left = postionArr[0] * this.scale + 'px',
321
- // 后端返回的坐标有基线对齐的问题,top 值是后端算好(基线top - 文字高度),在此加上文字高度的 1/9 (大致比例)为实际展示出文字的top值
322
- div.style.top = (postionArr[1] + postionArr[3] / 9) * this.scale + 'px'
323
- div.style.height = postionArr[3] * this.scale + 'px';
324
- div.style.width = postionArr[2] * this.scale + 'px'
325
- div.style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
326
- div.classList.add('lineHeight')
327
- rectdom.appendChild(div)
328
- }
329
- }
330
- if (rectdom.children.length > 0) {
331
- pageDom.appendChild(rectdom)
332
- }
333
- }
334
- }
335
- }
336
- textLayer.setTextContent(textContent);
337
- textLayer.render()
338
- pageDom.appendChild(textLayer.textLayerDiv);
339
- page.dom = pageDom;
340
- this.contentView.appendChild(pageDom);
341
- if(this.transformSalce !== null) {
342
- this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
343
- }
344
- if (this.changetoolbar) {
345
- setTimeout(() => {
346
- this.renderHighlights()
347
- this.changetoolbar = false
348
- }, 100)
349
- }
350
- if (this.fisrtLoad) {
351
- setTimeout(() => {
352
- let pageoffsetHeight = 0
353
- if(this.transformSalce !== null) {
354
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce
355
- } else {
356
- pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL)
357
- }
358
- if (this.$refs.pdfView.clientHeight - pageoffsetHeight > 0) {
359
- const height = this.$refs.pdfView.clientHeight;
360
- let startNum = 0
361
- let endNum = 0
362
- if(this.transformSalce !== null) {
363
- startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
364
- endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
365
- console.log( Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce)),this.pageSize.height , this.PAGE_INTVERVAL, height, this.transformSalce,'startNum');
366
-
367
- } else {
368
- startNum = Math.ceil(this.$refs.pdfView.scrollTop / (this.pageSize.height + this.PAGE_INTVERVAL))
369
- endNum = startNum + Math.ceil(height / (this.pageSize.height + this.PAGE_INTVERVAL))
370
-
371
- }
372
- for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
373
- if(pageIndex > 0 && pageIndex <= this.pages.length) {
374
- this.loadPdfData(pageIndex)
375
- }
376
- }
377
- }
378
- if (this.$refs.pdfView.scrollTop == Math.floor((pageNo - 1) * pageoffsetHeight)) {
379
- this.fisrtLoad = false
380
- } else {
381
- this.$refs.pdfView.scrollTop = `${((pageNo - 1) * pageoffsetHeight)}`
382
- this.fisrtLoad = false
383
- }
384
- this.renderHighlights()
385
- // zoomElement(this.contentView)
386
- }, 100)
387
- }
388
- })
389
- },
390
- // 监听容器的滚动事件,触发 scrollPdf 方法
391
- // 这里加了防抖保证不会一次产生过多请求
392
- debounceScrollPdf: _.debounce(function (e, that) {
393
- if (this.fisrtLoad) {
394
- this.fisrtLoad = false
395
- return
396
- }
397
- const scrollTop = e.target.scrollTop;
398
- const height = e.target.clientHeight;
399
- let startNum = 0
400
- let endNum = 0
401
- if(this.transformSalce !== null) {
402
- startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
403
- endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
404
- } else {
405
- startNum = Math.ceil(scrollTop / (that.pageSize.height + that.PAGE_INTVERVAL))
406
- endNum = startNum + Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
407
- }
408
- for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
409
- console.log(pageIndex,pageIndex >= 0 && pageIndex <= that.pages.length, 'pageIndexpageIndexpageIndex');
410
- if(pageIndex > 0 && pageIndex <= that.pages.length) {
411
- that.loadPdfData(pageIndex)
412
- }
413
- }
414
- console.log('=======');
415
- }, 200),
416
- directScrolling (e, that) {
417
- if (this.fisrtLoad) {
418
- this.fisrtLoad = false
419
- return
420
- }
421
- const scrollTop = e.target.scrollTop;
422
- const height = e.target.clientHeight;
423
- // 根据内容可视区域中心点计算页码, 没有滚动时,指向第一页
424
- const pageIndex = scrollTop > 0 ?
425
- Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
426
- 1;
427
- this.loadPdfData(pageIndex)
428
- },
429
- pdfScroll (e) {
430
- if(this.preViewType !== 'pdf' || this.isTouchMoved) {
431
- return
432
- }
433
- if(this.scrollLeft != e.target.scrollLeft) {
434
- this.scrollLeft = e.target.scrollLeft
435
- }
436
- if(this.scrollTop != e.target.scrollTop) {
437
- this.scrollTop = e.target.scrollTop
438
- this.debounceScrollPdf(e, this)
439
- }
440
- },
441
- // 分片每次只做一次处理,所以不考虑多片情况
442
- loadBefore (pageIndex) {
443
- this.loadPdfData(pageIndex)
444
- },
445
- loadAfter (pageIndex) {
446
- this.loadPdfData(pageIndex)
447
- },
448
- // 首先我们获取到需要渲染的范围
449
- // 根据当前的可视范围内的页码,我们前后只保留 8 页
450
- getRenderScope (pageIndex) {
451
- const pagesToRender = [];
452
- let i = pageIndex - 1;
453
- let j = pageIndex + 1;
454
- // pageIndex - 1 表示当前页码数 对应的下标位置
455
- pagesToRender.push(this.pages[pageIndex - 1]);
456
- while (pagesToRender.length < 8 && pagesToRender.length < this.pages.length) {
457
- if (i > 0) {
458
- pagesToRender.push(this.pages[i - 1]);
459
- i -= 1;
460
- }
461
- if (pagesToRender.length >= 8) {
462
- break;
463
- }
464
- if (j <= this.pages.length) {
465
- pagesToRender.push(this.pages[j - 1]);
466
- j += 1;
467
- }
468
- }
469
- return pagesToRender;
470
- },
471
- // 渲染需要展示的页面,不需展示的页码将其清除
472
- renderPages (pageIndex) {
473
- const pagesToRender = this.getRenderScope(pageIndex);
474
- for (const i of this.pages) {
475
- if (pagesToRender.includes(i)) {
476
- i.loadStatus === this.pageLoadStatus.LOADED ?
477
- this.renderPageContent(i, pageIndex) :
478
- this.renderPageLoading(i);
479
- } else {
480
- this.clearPage(i);
481
- }
482
- }
483
- },
484
- // 清除页面 dom
485
- clearPage (page) {
486
- if (page.dom) {
487
- this.contentView.removeChild(page.dom);
488
- page.loadStatus = 0
489
- page.dom = undefined;
490
- }
491
- },
492
- // 页面正在下载时渲染loading视图
493
- renderPageLoading (page) {
494
- const { pageNo, dom } = page;
495
- if (dom && dom.children.length != 0) {
496
- return;
497
- }
498
- const pageDom = document.createElement('div');
499
- pageDom.style.width = `${this.pageSize.width}px`;
500
- pageDom.style.height = `${this.pageSize.height}px`;
501
- pageDom.style.position = 'absolute';
502
- pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
503
- }px`;
504
- pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
505
- pageDom.style.backgroundPosition = 'center'
506
- pageDom.style.backgroundRepeat = 'no-repeat'
507
- pageDom.style.backgroundColor = '#FFF'
508
- page.dom = pageDom;
509
- this.contentView.appendChild(pageDom);
510
- },
511
- prev () {
512
- this.currentPage--
513
- if (this.currentPage < 0) {
514
- this.currentPage = 0
515
- if(!this.isPC) {
516
- this.$toast({
517
- message:'当前已经是第一段了',
518
- duration:2000,
519
- })
520
- return
521
- }
522
- }
523
- if(this.preViewType == 'pdf') {
524
- this.scrollToUplaodePage(this.currentPage)
525
- } else {
526
- this.scrollToExcalTop(this.currentPage)
527
- }
528
- // this.getpdfResloutePage(this.cachePdf[this.currentPage - 1])
529
- },
530
- next () {
531
- this.currentPage++
532
- if (this.currentPage >= this.tagIds.length) {
533
- this.currentPage = this.tagIds.length - 1
534
- if(!this.isPC) {
535
- this.$toast({
536
- message:'当前已经是最后一段了',
537
- duration:2000,
538
- })
539
- return
540
- }
541
- }
542
- if(this.preViewType == 'pdf') {
543
- this.scrollToUplaodePage(this.currentPage)
544
- } else {
545
- this.scrollToExcalTop(this.currentPage)
546
- }
547
- },
548
- currentChange (value) {
549
- this.currentPage = value - 1
550
- if(this.preViewType == 'pdf') {
551
- this.scrollToUplaodePage(this.currentPage)
552
- } else {
553
- this.scrollToExcalTop(this.currentPage)
554
- }
555
- },
556
- scrollToUplaodePage (currentPage) {
557
- this.changetoolbar = true
558
- if(this.preViewType !== 'pdf') {
559
- return
560
- }
561
- let pdfResloute = this.cachePdf[currentPage]
562
- this.identifyTextPostion.extractInfo = pdfResloute.extractInfo
563
- this.identifyTextPostion.left = pdfResloute.extractInfo.location[0]
564
- this.identifyTextPostion.top = pdfResloute.extractInfo.location[1]
565
- this.identifyTextPostion.width = pdfResloute.extractInfo.location[2]
566
- this.identifyTextPostion.height = pdfResloute.extractInfo.location[3]
567
- this.identifyTextPostion.page = pdfResloute.page
568
- this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
569
- this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
570
- // 在当前段落在最后一页pdf时,根据计算的高度并不能触发滚动,在此执行重新渲染方法,非次情况会执行两次,待优化
571
- this.$nextTick(() => {
572
- this.renderHighlights()
573
- })
574
- if(this.transformSalce !== null) {
575
- this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce)}`
576
- } else {
577
- this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
578
- }
579
- },
580
- scrollToExcalTop(currentPage) {
581
- for (let index = 0; index < this.allTr.length; index++) {
582
- if(index == currentPage) {
583
- Array.from(this.allTr[index].children).forEach(item =>{
584
- item.style.background = 'rgba(255, 136, 0, 0.6)'
585
- item.classList.add('animation')
586
- setTimeout(() =>{
587
- item.classList.remove('animation')
588
- }, 4000)
589
- })
590
- // getBoundingClientRect().top 当前元素距离屏幕顶部的高度 + 弹窗header 高度
591
- if(!this.isPC) {
592
- let top = this.allTr[index].getBoundingClientRect().top - this.$refs.pdfView.getBoundingClientRect().top
593
- this.$refs.pdfView.scrollTop = top
594
- } else {
595
- let top = this.allTr[index].getBoundingClientRect().top
596
- this.$refs.pdfView.scrollTop = top - 50
597
- }
598
- } else {
599
- Array.from(this.allTr[index].children).forEach(item =>{
600
- item.style.background = 'rgba(54, 106, 255, 0.6)'
601
- item.classList.remove('animation')
602
- })
603
- }
604
- }
605
- },
606
- // pdf是否需要重新渲染高亮位置
607
- renderHighlights () {
608
- let lineHeightDom = Array.from(document.getElementsByClassName('rectdom'))
609
- console.log(lineHeightDom, this.currentPage, 'this.currentPage');
610
- if (lineHeightDom) {
611
- lineHeightDom.forEach((d) => {
612
- for (let i = 0; i < d.children.length; i++) {
613
- if (d.getAttribute('react-count') == this.currentPage) {
614
- d.children[i].style.backgroundColor = 'rgba(255, 136, 0, 0.3)'
615
- d.children[i].classList.add('animation')
616
- setTimeout(() =>{
617
- d.children[i].classList.remove('animation')
618
- }, 4000)
619
- } else {
620
- d.children[i].style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
621
- d.children[i].classList.remove('animation')
622
- }
623
- }
624
- })
625
- }
626
- },
627
- displayHiglight (pageIndex) {
628
- let lineHeightDom = Array.from(document.getElementsByClassName('rectdom'))
629
- if (lineHeightDom) {
630
- lineHeightDom.forEach((d) => {
631
- if (d.getAttribute('page-index') == pageIndex) {
632
- d.style.display = 'none'
633
- }
634
- })
635
- }
636
- },
637
- // 前端暂时缓存多页
638
- autoLoadMore (pageIndex) {
639
- let pdfResloute = this.cachePdf.find(cache => {
640
- return cache.page == pageIndex
641
- })
642
- if (pdfResloute) {
643
- this.getpdfResloutePage(pdfResloute)
644
- } else {
645
- this.loadPdfData(pageIndex)
646
- }
647
- },
648
- setPageAllLine (arr) {
649
- this.currentPageAllLine = []
650
- arr.forEach((item, index) => {
651
- let i = this.currentPageAllLine.findIndex(l => { return l.page && l.page == item.page })
652
- if (i != -1) {
653
- // this.currentPageAllLine[i].allLines.lines.push(item.extractInfo.lines)
654
- this.currentPageAllLine[i].allLines.push({
655
- pageCount: index,
656
- lines: item.extractInfo.lines
657
- })
658
- } else {
659
- this.currentPageAllLine.push({
660
- page: item.page,
661
- allLines: [{
662
- pageCount: index,
663
- lines: item.extractInfo.lines
664
- }],
665
- })
666
- }
667
- })
668
- },
669
- openTouch() {
670
- // this.$nextTick()将回调延迟到下次 DOM 更新循环之后执行
671
- let that = this;
672
- this.$nextTick(() => {
673
- // setInterval(() => {
674
- // this.scale = this.scale + 0.1
675
- // that.pages.forEach((item, index) =>{
676
- // if(item.dom) {
677
- // item.dom.children.forEach( childDom =>{
678
- // if(childDom.getAttribute('react-count')) {
679
- // childDom.style.transform = "scale(" + this.scale + ")";
680
- // childDom.style.transformOrigin = "0px 0px 0px";
681
- // } else {
682
- // item.dom = null
683
- // this.startRenderPages(item.pdfPage, null, index)
684
- // }
685
- // } )
686
- // }
687
- // })
688
- // }, 100);
689
- // 获取放大或缩小的区域DOM
690
- let matrix_box = this.contentView
691
- matrix_box.addEventListener("touchstart", function (event) {
692
- this.isTouchMoved = true
693
- let touches = event.touches;
694
- let events = touches[0];
695
- let events2 = touches[1];
696
-
697
- // event.preventDefault();
698
-
699
- // 第一个触摸点的坐标
700
- that.displacement.pageX = events.pageX;
701
- that.displacement.pageY = events.pageY;
702
-
703
- that.displacement.moveable = true;
704
-
705
- if (events2) {
706
- that.displacement.pageX2 = events2.pageX;
707
- that.displacement.pageY2 = events2.pageY;
708
- }
709
-
710
- that.displacement.originScale = this.scale || 1;
711
- // console.log(that.displacement);
712
- });
713
- document.addEventListener("touchmove", function (event) {
714
- if (!that.displacement.moveable) {
715
- return;
716
- }
717
- // event.preventDefault();
718
- let touches = event.touches;
719
- let events = touches[0];
720
- let events2 = touches[1];
721
- // 双指移动
722
- if (events2) {
723
- // 第2个指头坐标在touchmove时候获取
724
- if (!that.displacement.pageX2) {
725
- that.displacement.pageX2 = events2.pageX;
726
- }
727
- if (!that.displacement.pageY2) {
728
- that.displacement.pageY2 = events2.pageY;
729
- }
730
- // 双指缩放比例计算
731
- let zoom = that.getDistance({
732
- x: events.pageX,
733
- y: events.pageY
734
- },
735
- {
736
- x: events2.pageX,
737
- y: events2.pageY
738
- }
739
- ) / that.getDistance(
740
- {
741
- x: that.displacement.pageX,
742
- y: that.displacement.pageY
743
- },
744
- {
745
- x: that.displacement.pageX2,
746
- y: that.displacement.pageY2
747
- }
748
- );
749
- // 应用在元素上的缩放比例
750
- let newScale = that.displacement.originScale * zoom;
751
- console.log(zoom, newScale , this.scale, 'newScale');
752
- // 最大缩放比例限制
753
- if (newScale > 2) {
754
- newScale = 2;
755
- }
756
- // 最大缩放比例限制
757
- if(newScale < 1) {
758
- newScale = 1;
759
- }
760
- // 记住使用的缩放值
761
- that.displacement.scale = newScale;
762
- // console.log(newScale);
763
- matrix_box.style.transform = "scale(" + newScale + ")";
764
- // 设置旋转元素的基点位置
765
- matrix_box.style.transformOrigin = "0px 0px 0px";
766
- }
767
- },{ passive: false });
768
- document.addEventListener('touchend',function() {
769
- that.isTouchMoved = false
770
- },{ passive: false })
771
- });
772
- },
773
- getDistance(start, stop) {
774
- // Math.hypot()计算参数的平方根
775
- return Math.hypot(stop.x - start.x, stop.y - start.y);
776
- },
777
- setupCanvas(canvas, width, height) {
778
- const dpr = 1;
779
- // const rect = canvas.getBoundingClientRect();
780
- canvas.width = width
781
- canvas.height = height
782
- const ctx = canvas.getContext('2d');
783
- console.log(canvas.width, canvas.height, dpr, this.scale);
784
- ctx?.scale(dpr, dpr );
785
- return ctx;
786
- },
787
- changeScale(value) {
788
- if(value == 'zoom') {
789
- this.handScale = 'auto'
790
- this.transformSalce = (this.transformSalce + 0.2).toFixed(1)
791
- } else if(value == 'reduce') {
792
- if((this.transformSalce - 0.2).toFixed(1) <= 0) {
793
- return
794
- }
795
- this.handScale = 'auto'
796
- this.transformSalce = (this.transformSalce - 0.2).toFixed(1)
797
- } else if(value == 'auto') {
798
- this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
799
- } else if(value == 'reality') {
800
- this.transformSalce = 0.5
801
- } else {
802
- this.transformSalce = (value / 2).toFixed(1)
803
- }
804
- this.transformSalce = Number(this.transformSalce)
805
- this.contentView.style.transform = 'scale(' + this.transformSalce + ')';
806
- // this.getpdfResloutePage(this.cachePdf[0])
807
- },
808
- },
809
- computed:{
810
- perviewUrl() {
811
- return '/web/viewer.html?file=' + '/pdflist/pdf4split-1.pdf'
812
- }
813
- },
814
- watch:{
815
- tagIds: {
816
- handler(value) {
817
- if(value && value.length) {
818
- // 在 pdf_view 下创建 所有canvs的容器
819
- this.contentView = document.createElement('div')
820
- this.contentView.style.transformOrigin = '0px 0px 0px'
821
-
822
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res =>{
823
- // 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}
824
- // 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}
825
- // 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}
826
- // res.data = {"data":[{"id":"6475eab868110215ab821a80","knowledgeId":"6475e7eac724c54c46cbfa2d","mainId":"5ecf2fcd704541149201ab9c1c31162d","page":0,"total":1,"pageHeight":0.0,"pageWidth":0.0,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/5ecf2fcd704541149201ab9c1c31162d/2023/05/30/08/23/20/6475eab63339db423f26b196/0.html","extractInfo":{"location":null,"content":"产品:系统配置,产品型号:存储,VX30:4G+16G,VX50:16G+256G","lines":null,"tagId":"6475eab868110215ab821a80"}}],"code":"0","msg":null,"traceId":null}
827
- // res.data = {"data":[{"id":"6475e9393339db423f26af01","knowledgeId":"6475e44fc724c54c46cbfa21","mainId":"5ecf2fcd704541149201ab9c1c31162d","page":2,"total":2,"pageHeight":510.25,"pageWidth":1559.05,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/5ecf2fcd704541149201ab9c1c31162d/2023/05/30/08/00/29/6475e55d3339db423f26a9b8/2.pdf","extractInfo":{"location":[327.70532,288.0498,414.9734,12.241608],"content":"三、指示灯状态说明1.白色常亮:开机/开机中2.红色常亮:待机3.白色呼吸:息屏4.红色闪烁:升级1.LAN:通过网线连接到主机的Camera端口2.电源开关:电源切换开关","lines":[{"content":"三、指示灯状态说明","location":[634.3203,288.0498,108.3584,12.0]},{"content":"1.白色常亮:开机/开机中","location":[634.3203,320.08978,108.23407,9.0]},{"content":"2.红色常亮:待机","location":[634.3204,341.3298,78.597046,9.0]},{"content":"3.白色呼吸:息屏","location":[634.32043,362.45282,78.597046,9.0]},{"content":"4.红色闪烁:升级","location":[634.3205,383.6928,78.597046,9.0]},{"content":"1.LAN:通过网线连接到主机的","location":[327.70535,291.2914,144.35995,9.0]},{"content":"Camera端口","location":[327.70532,306.88843,55.322998,9.0]},{"content":"2.电源开关:电源切换开关","location":[482.74832,291.2914,105.36301,9.0]}],"tagId":null}}],"code":"0","msg":null,"traceId":null}
828
- // if(value.length === 1) {
829
- // this.$refs.pdfView.style.height = 'calc(100% - 50px)'
830
- // }
831
- if (res.data.code == 0) {
832
- // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
833
- // 缓存拿到的所有数据
834
- this.cachePdf = res.data.data
835
- let publicPageFileUrl = res.data.data[0].publicPageFileUrl
836
- this.currentPage = 0
837
- // console.log(publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')));
838
- if (publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
839
- this.preViewType = 'pdf'
840
- this.setPageAllLine(this.cachePdf)
841
- this.getpdfResloutePage(res.data.data[0])
842
- } else {
843
- this.preViewType = 'excal'
844
- this.$http.post(
845
- '/knowledge-api/temporary-certificate/or-origin?expired=30',
846
- publicPageFileUrl,
847
- {
848
- headers: {
849
- "Content-Type": "application/json",
850
- },
851
- }).then(res => {
852
- // 使用原声请求方式 axios会带有不需要的请求头
853
- let xhr = new XMLHttpRequest();
854
- xhr.open('GET', res.data || res.bodyText , true);
855
- // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
856
- xhr.onload = ({ currentTarget }) => {
857
- // 请求完成
858
- if (currentTarget.status === 200) { // 返回200
859
- this.contentView.innerHTML = currentTarget.response
860
- this.contentView.style.padding = '10px'
861
- // this.contentView.style.position = 'relative'
862
- this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
863
- this.$refs.pdfView.appendChild(this.contentView)
864
- let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
865
- this.allTr = []
866
- for (let index = 0; index < allTr.length; index++) {
867
- if(value.includes(allTr[index].getAttribute('tag-id'))) {
868
- this.allTr.push(allTr[index])
869
- }
870
- }
871
- this.currentChange(1)
872
-
873
- }
874
- }
875
- xhr.send();
876
- })
877
- }
878
- } else {
879
- let div = document.createElement('div')
880
- div.innerText = '文件加载异常'
881
- this.contentView.appendChild(div)
882
- this.$refs.pdfView.appendChild(this.contentView)
883
- }
884
- })
885
- }
886
- },
887
- deep:true,
888
- immediate:true
889
- }
890
- },
891
- mounted () {
892
- if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
893
- this.isPC = false
894
- } else {
895
- this.isPC = true
896
- }
897
- }
898
- }
899
- </script>
900
-
901
- <style lang="less" scoped>
902
- .pdf_view {
903
- width: 100%;
904
- height: calc(100% - 110px);
905
- overflow: auto;
906
- background-color: #f5f7fb;
907
- margin-bottom: 60px;
908
- box-sizing: border-box;
909
- // position: relative;
910
- // > div {
911
- // width: 100%;
912
- // height: 100%;
913
- // overflow: hidden;
914
- // overflow-y: auto;
915
- // position: relative;
916
- // }
917
- > iframe {
918
- width: 100%;
919
- height: 100%;
920
- }
921
- a:link {
922
- color: none;
923
- }
924
- a:visited {
925
- color: none;
926
- }
927
- a:hover {
928
- color: none;
929
- }
930
- a:active {
931
- color: none;
932
- }
933
- .btn_footer {
934
- width: 100%;
935
- height: 60px;
936
- display: flex;
937
- align-items: center;
938
- justify-content: space-around;
939
- position: absolute;
940
- bottom: 0px;
941
- left: 0;
942
- z-index: 999;
943
- background: #ffffff;
944
- .prev, .next {
945
- width: 35%;
946
- height: 40px;
947
- display: flex;
948
- align-items: center;
949
- justify-content: center;
950
- border-radius: 50px;
951
- cursor: pointer;
952
- }
953
- .prev {
954
- background: #F2F5FA;
955
- color: #000;
956
- }
957
- .next {
958
- background: #366aff;
959
- color: #ffffff;
960
- }
961
- }
962
- #pagination {
963
- .total-class {
964
- margin-right: 13px;
965
- font-weight: 400;
966
- }
967
-
968
- position: absolute;
969
- bottom: 0px;
970
- right: 0;
971
- width: 100%;
972
- display: flex;
973
- align-items: center;
974
- justify-content: center;
975
- height: 50px;
976
- background-color: white;
977
- box-shadow: 0px 0px 18px 0px rgba(29, 55, 129, 0.07);
978
- border-radius: 5px;
979
- z-index: 1000;
980
-
981
- /deep/.el-pagination {
982
- margin-right: 110px;
983
- }
984
-
985
- /deep/.el-pager {
986
- background: #EDF0F6;
987
- border-radius: 15px;
988
- }
989
-
990
- /deep/.el-pagination.is-background .btn-next {
991
- width: 30px;
992
- height: 30px;
993
- background: #EDF0F6;
994
- border-radius: 50%;
995
- }
996
-
997
- /deep/.el-pagination .btn-next {
998
- width: 30px;
999
- height: 30px;
1000
- background: #EDF0F6;
1001
- border-radius: 50%;
1002
- padding-left: 0;
1003
- margin-left: 5px;
1004
- }
1005
-
1006
- /deep/.el-pagination .btn-prev {
1007
- width: 30px;
1008
- height: 30px;
1009
- background: #EDF0F6;
1010
- border-radius: 50%;
1011
- padding-right: 0;
1012
- margin-right: 5px;
1013
- }
1014
-
1015
- /deep/.el-pagination button {
1016
- padding: 0;
1017
- min-width: 30px;
1018
- }
1019
-
1020
- /deep/.el-pager li {
1021
- background: #EDF0F6;
1022
- height: 30px;
1023
- min-width: 30px;
1024
- line-height: 30px;
1025
- font-size: 12px;
1026
- color: #717b90;
1027
- }
1028
-
1029
- /deep/.el-pager li:first-child {
1030
- border-bottom-left-radius: 15px !important;
1031
- border-top-left-radius: 15px !important;
1032
- }
1033
-
1034
- /deep/.el-pager li:last-child {
1035
- border-top-right-radius: 15px !important;
1036
- border-bottom-right-radius: 15px !important;
1037
- }
1038
-
1039
- /deep/.el-pager li.active {
1040
- width: 30px;
1041
- height: 30px;
1042
- min-width: 30px;
1043
- background: #366AFF;
1044
- border: 3px solid #A1B9FF;
1045
- border-radius: 50%;
1046
- line-height: 24px;
1047
- color: white;
1048
- }
1049
-
1050
- /deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
1051
- background: #366AFF;
1052
- }
1053
- }
1054
- .change_scale {
1055
- width: 100%;
1056
- height: 50px;
1057
- position: absolute;
1058
- top: 50px;
1059
- left: 0;
1060
- background: #ffffff;
1061
- display: flex;
1062
- align-items: center;
1063
- padding: 0 10px;
1064
- box-sizing: border-box;
1065
- section {
1066
- cursor: pointer;
1067
- width: 30px;
1068
- height: 30px;
1069
- margin-right: 5px;
1070
- border-radius: 5px;
1071
- display: flex;
1072
- align-items: center;
1073
- justify-content: center;
1074
- i {
1075
- font-weight: 900;
1076
- }
1077
- }
1078
- section:hover {
1079
- background: rgba(221, 222, 223, 1);
1080
- }
1081
- }
1082
- }
1083
-
1084
- </style>
1085
- <style lang="less">
1086
- .animation {
1087
- animation-name: highlight;
1088
- animation-duration: 4s;
1089
- }
1090
- @keyframes highlight {
1091
- 0% {
1092
- background:rgba(255, 136, 0, 0.3);
1093
- }
1094
- 25% {
1095
- background:rgba(255, 136, 0, 0.6);
1096
- }
1097
- 50% {
1098
- background:rgba(255, 136, 0, 0.3);
1099
- }
1100
- 75% {
1101
- background:rgba(255, 136, 0, 0.6);
1102
- }
1103
- 100% {
1104
- background:rgba(255, 136, 0, 0.3);
1105
- }
1106
- }
1
+ <template>
2
+ <div
3
+ class="pdf_view"
4
+ ref="pdfView"
5
+ @scroll="pdfScroll"
6
+ :style="{
7
+ marginTop: isPC ? '50px' : ''
8
+ }">
9
+ <div class="change_scale" v-if="isPC">
10
+ <section @click="changeScale('reduce')">
11
+ <i class="el-icon-minus"></i>
12
+ </section>
13
+ <el-divider direction="vertical"></el-divider>
14
+ <section @click="changeScale('zoom')">
15
+ <i class="el-icon-plus"></i>
16
+ </section>
17
+ <el-select size="small" v-model="handScale" @change="changeScale" placeholder="请选择">
18
+ <el-option
19
+ v-for="item in scaleList"
20
+ :key="item.value"
21
+ :label="item.label"
22
+ :value="item.value">
23
+ </el-option>
24
+ </el-select>
25
+ </div>
26
+ <div class="btn_footer" v-if="tagIds.length > 1 && !isPC">
27
+ <div class="prev" @click="prev">上一段</div>
28
+ <div class="next" @click="next">下一段</div>
29
+ </div>
30
+ <div id="pagination" v-if="tagIds.length > 1 && isPC">
31
+ <el-pagination :current-page="currentPage + 1" @current-change="currentChange" @prev-click="prev"
32
+ @next-click="next" layout="slot, prev, pager, next" :page-size="1" :total="tagIds.length">
33
+ <span class="total-class">答案由{{ tagIds.length }}段内容生成</span>
34
+ </el-pagination>
35
+ </div>
36
+ </div>
37
+ </template>
38
+
39
+ <script>
40
+ import _ from 'lodash'
41
+ // import * as pdfjsLib from 'pdfjs-dist'
42
+ // pdfjsLib.GlobalWorkerOptions.workerSrc = 'pdfjs-dist/build/pdf.worker';
43
+ // import { TextLayerBuilder } from "pdfjs-dist/web/pdf_viewer";
44
+ // EventBus pdf_viewer 支持绑定自定义事件,一版不做
45
+ // import 'pdfjs-dist/web/pdf_viewer.css'
46
+ /* eslint-disable */
47
+ const pdfjsLib = window['pdfjsLib']
48
+ if(pdfjsLib) {
49
+ pdfjsLib.GlobalWorkerOptions.workerSrc = window['pdfjs-dist/build/pdf.worker']
50
+ // 'pdfjs-dist/build/pdf.worker';
51
+ }
52
+ const { TextLayerBuilder } = window['pdfjs-dist/web/pdf_viewer']
53
+ // import { zoomElement } from '../assets/js/hammer'
54
+ export default {
55
+ name: 'pdfView',
56
+ props:['tagIds','isMessageRecord'],
57
+ data() {
58
+ return {
59
+ url: '',
60
+ pages: [],
61
+ pageLoadStatus: {
62
+ WAIT: 0,
63
+ LOADED: 1,
64
+ },
65
+ scale: 1,
66
+ rotation: 0,
67
+ pageSize: {},
68
+ PAGE_INTVERVAL: 15,
69
+ SLICE_COUNT: 5,
70
+ contentView: null,
71
+ fisrtLoad: true,
72
+ TextLayerBuilder: null,
73
+ totalPageCount: 0,
74
+ identifyTextPostion: {
75
+ top: 0,
76
+ left: 0,
77
+ width: 100,
78
+ height: 0,
79
+ page: 1,
80
+ pageHeight: 0,
81
+ pageWidth: 0,
82
+ extractInfo: {},
83
+ currentPageAllLine: []
84
+ },
85
+ currentPageAllLine: [],
86
+ pdfUrl: '',
87
+ cachePdf: [],
88
+ newViewer: null,
89
+ currentPage: 0,
90
+ changetoolbar: false,
91
+ allTr:[],
92
+ preViewType: 'pdf',
93
+ displacement:{
94
+ pageX: 0,
95
+ pageY: 0,
96
+ moveable: false,
97
+ pageX2: 0,
98
+ pageY2: 0,
99
+ originScale: 1,
100
+ },
101
+ isTouchMoved: false,
102
+ transformSalce: null,
103
+ isPC: false,
104
+ handScale: 'auto',
105
+ scaleList:[
106
+ {
107
+ label:'自动缩放',
108
+ value:'auto'
109
+ },
110
+ {
111
+ label:'实际比例',
112
+ value:'reality'
113
+ },
114
+ {
115
+ label:'100%',
116
+ value: 1
117
+ },
118
+ {
119
+ label:'120%',
120
+ value: 1.2
121
+ },
122
+ {
123
+ label:'150%',
124
+ value: 1.5
125
+ },
126
+ {
127
+ label:'170%',
128
+ value: 1.7
129
+ }
130
+ ,
131
+ {
132
+ label:'200%',
133
+ value: 2
134
+ }
135
+ ],
136
+ scrollTop:0,
137
+ scrollLeft:0
138
+ }
139
+ },
140
+ methods: {
141
+ getpdfResloutePage (pdfResloute) {
142
+ // 根据当前页面宽度设置缩放比例
143
+ // this.scale = Math.round(this.$refs.pdfView.clientWidth / pdfResloute.pageWidth * 100) / 100
144
+ // console.log(this.scale,'this.scale');
145
+ if(this.isMessageRecord) {
146
+ this.scale = Math.round(this.$refs.pdfView.clientWidth / pdfResloute.pageWidth * 100) / 100
147
+ } else {
148
+ this.scale = 2
149
+ }
150
+ // 从后端获取到当前分片后所有的pdf页码,初始化数组,数组下{} 对应每页pdf文件
151
+ this.pdfUrl = pdfResloute.publicPageFileUrl.substring(0, pdfResloute.publicPageFileUrl.lastIndexOf('/') + 1)
152
+ this.initPages(pdfResloute.total)
153
+ // 定位功能,加载对应页码位置
154
+ this.loadPdfData(pdfResloute.page)
155
+ },
156
+ async loadPdfData (loadPage) {
157
+ if(this.pages[loadPage - 1] && this.pages[loadPage - 1].dom && this.pages[loadPage - 1].dom.children.length > 0) {
158
+ return
159
+ }
160
+ // pdfjsLib.GlobalWorkerOptions.workerSrc = require("pdfjs-dist/legacy/build/pdf.worker.entry.js");
161
+ // 拿到第一个分片
162
+ const { startPage, url } = await this.fetchPdfFragment(loadPage);
163
+ let loadingTask = pdfjsLib.getDocument(url)
164
+ loadingTask.promise.then((pdfDoc) => {
165
+ // 将已经下载的分片保存到 pages 数组中
166
+ for (let i = 0; i < pdfDoc.numPages; i += 1) {
167
+ const pageIndex = startPage + i;
168
+ const page = this.pages[pageIndex - 1];
169
+ // 不在缓存列表内,重新获取本页pdf
170
+ if (page.loadStatus !== this.pageLoadStatus.LOADED) {
171
+ pdfDoc.getPage(i + 1).then((pdfPage) => {
172
+ page.pdfPage = pdfPage;
173
+ page.loadStatus = this.pageLoadStatus.LOADED;
174
+ // 通知可以进行渲染了
175
+ this.startRenderPages(pdfPage, page, pageIndex)
176
+ });
177
+ } else {
178
+ if (this.changetoolbar) {
179
+ this.$nextTick(() => {
180
+ this.renderHighlights()
181
+ })
182
+ this.changetoolbar = false
183
+ }
184
+ }
185
+ }
186
+ });
187
+ },
188
+ initPages (totalPage) {
189
+ // const pages = [];
190
+ this.totalPageCount = totalPage
191
+ for (let i = 0; i < totalPage; i += 1) {
192
+ this.pages.push({
193
+ pageNo: i + 1,
194
+ loadStatus: this.pageLoadStatus.WAIT,
195
+ pdfPage: null,
196
+ dom: null
197
+ });
198
+ }
199
+ },
200
+ async fetchPdfFragment (pageIndex) {
201
+ // 置换加签后的文件地址。
202
+ let obj = {}
203
+ await this.$http.post(
204
+ '/knowledge-api/temporary-certificate/or-origin?expired=30',
205
+ this.pdfUrl + pageIndex + '.pdf',
206
+ {
207
+ headers: {
208
+ "Content-Type": "application/json",
209
+ },
210
+ }).then(async res => {
211
+ if(res.bodyText) {
212
+ // 最后返回一个 包含这4个参数的对象
213
+ obj = await {
214
+ "startPage": pageIndex, // 分片的开始页码
215
+ "endPage": pageIndex + 5, // 分片结束页码
216
+ "totalPage": this.totalPageCount, // pdf 总页数
217
+ "url": res.bodyText // 分片内容下载地址
218
+ }
219
+ }
220
+ if (res.data) {
221
+ // 最后返回一个 包含这4个参数的对象
222
+ obj = await {
223
+ "startPage": pageIndex, // 分片的开始页码
224
+ "endPage": pageIndex + 5, // 分片结束页码
225
+ "totalPage": this.totalPageCount, // pdf 总页数
226
+ "url": res.data // 分片内容下载地址
227
+ }
228
+ }
229
+ })
230
+ return obj
231
+ },
232
+ startRenderPages (pdfPage, page, pageIndex) {
233
+ const viewport = pdfPage.getViewport({
234
+ scale: this.scale, // 缩放的比例
235
+ rotation: this.rotation, // 旋转的角度
236
+ });
237
+ // 记录pdf页面高度
238
+ const pageSize = {
239
+ width: viewport.width,
240
+ height: viewport.height,
241
+ }
242
+ this.pageSize = pageSize
243
+ // 创建内容绘制区,并设置大小
244
+ if(this.$refs.pdfView.clientWidth / this.pageSize.width >= 1 || this.isMessageRecord) {
245
+ this.contentView.style.width = `${pageSize.width }px`;
246
+ this.contentView.style.height = `${(this.totalPageCount * (pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
247
+ } else {
248
+ this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
249
+ this.contentView.style.width = `${pageSize.width * this.transformSalce}px`;
250
+ this.contentView.style.height = `${(this.totalPageCount * (pageSize.height * (this.transformSalce) + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
251
+ }
252
+ this.contentView.style.margin = '0 auto 0'
253
+ console.log(this.transformSalce);
254
+ this.contentView.style.position = 'relative'
255
+ this.contentView.style.paddingBottom = '60px'
256
+ // contentView.style.overflowY = 'auto'
257
+ this.$refs.pdfView.appendChild(this.contentView);
258
+ this.renderPages(pageIndex)
259
+ },
260
+ renderPageContent (page, pageIndex) {
261
+ const { pdfPage, pageNo, dom } = page;
262
+ // dom 元素已存在,无须重新渲染,直接返回
263
+ console.log(dom, 'dom');
264
+ if (dom && dom.children.length != 0) {
265
+ return;
266
+ }
267
+ const viewport = pdfPage.getViewport({
268
+ scale: this.scale,
269
+ rotation: this.rotation,
270
+ });
271
+ // 创建新的canvas
272
+ const canvas = document.createElement('canvas');
273
+ const context = canvas.getContext('2d');
274
+ // canvas.getContext('2d');
275
+ canvas.height = this.pageSize.height;
276
+ canvas.width = this.pageSize.width;
277
+ // 创建渲染的dom
278
+ const pageDom = document.createElement('div');
279
+ pageDom.style.position = 'absolute';
280
+ pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL}px`;
281
+ pageDom.style.width = `${this.pageSize.width}px`;
282
+ pageDom.style.height = `${this.pageSize.height}px`;
283
+ pageDom.appendChild(canvas);
284
+ // 渲染内容
285
+ let renderContext = {
286
+ canvasContext: context,
287
+ viewport: viewport,
288
+ }
289
+ pdfPage.render(renderContext).promise.then(() => {
290
+ console.log(pdfPage.getTextContent(), 'getTextContent');
291
+ return pdfPage.getTextContent()
292
+ }).then((textContent) => {
293
+ const textLayerDiv = document.createElement('div');
294
+ textLayerDiv.setAttribute('class', 'textLayer');
295
+ // 将文本图层div添加至每页pdf的div中
296
+ // 创建新的TextLayerBuilder实例
297
+ let textLayer = new TextLayerBuilder({
298
+ textLayerDiv: textLayerDiv,
299
+ pageIndex: pdfPage._pageIndex,
300
+ viewport: viewport,
301
+ });
302
+ let findPage = this.currentPageAllLine.find(l => { return l.page == pageIndex })
303
+ if (findPage) {
304
+ let AllLines = findPage.allLines
305
+ // setTimeout(() => {
306
+ if (AllLines.length > 0) {
307
+ for (let j = 0; j < AllLines.length; j++) {
308
+ let lines = AllLines[j].lines
309
+ let rectdom = document.createElement('div')
310
+ rectdom.setAttribute('react-count', AllLines[j].pageCount);
311
+ rectdom.style.position = 'absolute';
312
+ rectdom.style.top = 0
313
+ rectdom.style.left = 0
314
+ rectdom.classList.add('rectdom')
315
+ for (let index = 0; index < lines.length; index++) {
316
+ if (!/^\s+$/g.test(lines[index].content)) {
317
+ let postionArr = lines[index].location
318
+ let div = document.createElement('div')
319
+ div.style.position = 'absolute';
320
+ div.style.left = postionArr[0] * this.scale + 'px',
321
+ // 后端返回的坐标有基线对齐的问题,top 值是后端算好(基线top - 文字高度),在此加上文字高度的 1/9 (大致比例)为实际展示出文字的top值
322
+ div.style.top = (postionArr[1] + postionArr[3] / 9) * this.scale + 'px'
323
+ div.style.height = postionArr[3] * this.scale + 'px';
324
+ div.style.width = postionArr[2] * this.scale + 'px'
325
+ div.style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
326
+ div.classList.add('lineHeight')
327
+ rectdom.appendChild(div)
328
+ }
329
+ }
330
+ if (rectdom.children.length > 0) {
331
+ pageDom.appendChild(rectdom)
332
+ }
333
+ }
334
+ }
335
+ }
336
+ textLayer.setTextContent(textContent);
337
+ textLayer.render()
338
+ pageDom.appendChild(textLayer.textLayerDiv);
339
+ page.dom = pageDom;
340
+ this.contentView.appendChild(pageDom);
341
+ if(this.transformSalce !== null) {
342
+ this.contentView.style.transform = `scale(${this.transformSalce}, ${this.transformSalce})`
343
+ }
344
+ if (this.changetoolbar) {
345
+ setTimeout(() => {
346
+ this.renderHighlights()
347
+ this.changetoolbar = false
348
+ }, 100)
349
+ }
350
+ if (this.fisrtLoad) {
351
+ setTimeout(() => {
352
+ let pageoffsetHeight = 0
353
+ if(this.transformSalce !== null) {
354
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce
355
+ } else {
356
+ pageoffsetHeight = (this.pageSize.height + this.PAGE_INTVERVAL)
357
+ }
358
+ if (this.$refs.pdfView.clientHeight - pageoffsetHeight > 0) {
359
+ const height = this.$refs.pdfView.clientHeight;
360
+ let startNum = 0
361
+ let endNum = 0
362
+ if(this.transformSalce !== null) {
363
+ startNum = Math.ceil(this.$refs.pdfView.scrollTop / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
364
+ endNum = startNum + Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce))
365
+ console.log( Math.ceil(height / ((this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce)),this.pageSize.height , this.PAGE_INTVERVAL, height, this.transformSalce,'startNum');
366
+
367
+ } else {
368
+ startNum = Math.ceil(this.$refs.pdfView.scrollTop / (this.pageSize.height + this.PAGE_INTVERVAL))
369
+ endNum = startNum + Math.ceil(height / (this.pageSize.height + this.PAGE_INTVERVAL))
370
+
371
+ }
372
+ for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
373
+ if(pageIndex > 0 && pageIndex <= this.pages.length) {
374
+ this.loadPdfData(pageIndex)
375
+ }
376
+ }
377
+ }
378
+ if (this.$refs.pdfView.scrollTop == Math.floor((pageNo - 1) * pageoffsetHeight)) {
379
+ this.fisrtLoad = false
380
+ } else {
381
+ this.$refs.pdfView.scrollTop = `${((pageNo - 1) * pageoffsetHeight)}`
382
+ this.fisrtLoad = false
383
+ }
384
+ this.renderHighlights()
385
+ // zoomElement(this.contentView)
386
+ }, 100)
387
+ }
388
+ })
389
+ },
390
+ // 监听容器的滚动事件,触发 scrollPdf 方法
391
+ // 这里加了防抖保证不会一次产生过多请求
392
+ debounceScrollPdf: _.debounce(function (e, that) {
393
+ if (this.fisrtLoad) {
394
+ this.fisrtLoad = false
395
+ return
396
+ }
397
+ const scrollTop = e.target.scrollTop;
398
+ const height = e.target.clientHeight;
399
+ let startNum = 0
400
+ let endNum = 0
401
+ if(this.transformSalce !== null) {
402
+ startNum = Math.ceil(scrollTop / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
403
+ endNum = startNum + Math.ceil(height / ((that.pageSize.height + that.PAGE_INTVERVAL) * this.transformSalce))
404
+ } else {
405
+ startNum = Math.ceil(scrollTop / (that.pageSize.height + that.PAGE_INTVERVAL))
406
+ endNum = startNum + Math.ceil(height / (that.pageSize.height + that.PAGE_INTVERVAL))
407
+ }
408
+ for (let pageIndex = startNum; pageIndex <= endNum; pageIndex++) {
409
+ console.log(pageIndex,pageIndex >= 0 && pageIndex <= that.pages.length, 'pageIndexpageIndexpageIndex');
410
+ if(pageIndex > 0 && pageIndex <= that.pages.length) {
411
+ that.loadPdfData(pageIndex)
412
+ }
413
+ }
414
+ console.log('=======');
415
+ }, 200),
416
+ directScrolling (e, that) {
417
+ if (this.fisrtLoad) {
418
+ this.fisrtLoad = false
419
+ return
420
+ }
421
+ const scrollTop = e.target.scrollTop;
422
+ const height = e.target.clientHeight;
423
+ // 根据内容可视区域中心点计算页码, 没有滚动时,指向第一页
424
+ const pageIndex = scrollTop > 0 ?
425
+ Math.ceil((scrollTop + (height / 2)) / (that.pageSize.height + that.PAGE_INTVERVAL)) :
426
+ 1;
427
+ this.loadPdfData(pageIndex)
428
+ },
429
+ pdfScroll (e) {
430
+ if(this.preViewType !== 'pdf' || this.isTouchMoved) {
431
+ return
432
+ }
433
+ if(this.scrollLeft != e.target.scrollLeft) {
434
+ this.scrollLeft = e.target.scrollLeft
435
+ }
436
+ if(this.scrollTop != e.target.scrollTop) {
437
+ this.scrollTop = e.target.scrollTop
438
+ this.debounceScrollPdf(e, this)
439
+ }
440
+ },
441
+ // 分片每次只做一次处理,所以不考虑多片情况
442
+ loadBefore (pageIndex) {
443
+ this.loadPdfData(pageIndex)
444
+ },
445
+ loadAfter (pageIndex) {
446
+ this.loadPdfData(pageIndex)
447
+ },
448
+ // 首先我们获取到需要渲染的范围
449
+ // 根据当前的可视范围内的页码,我们前后只保留 8 页
450
+ getRenderScope (pageIndex) {
451
+ const pagesToRender = [];
452
+ let i = pageIndex - 1;
453
+ let j = pageIndex + 1;
454
+ // pageIndex - 1 表示当前页码数 对应的下标位置
455
+ pagesToRender.push(this.pages[pageIndex - 1]);
456
+ while (pagesToRender.length < 8 && pagesToRender.length < this.pages.length) {
457
+ if (i > 0) {
458
+ pagesToRender.push(this.pages[i - 1]);
459
+ i -= 1;
460
+ }
461
+ if (pagesToRender.length >= 8) {
462
+ break;
463
+ }
464
+ if (j <= this.pages.length) {
465
+ pagesToRender.push(this.pages[j - 1]);
466
+ j += 1;
467
+ }
468
+ }
469
+ return pagesToRender;
470
+ },
471
+ // 渲染需要展示的页面,不需展示的页码将其清除
472
+ renderPages (pageIndex) {
473
+ const pagesToRender = this.getRenderScope(pageIndex);
474
+ for (const i of this.pages) {
475
+ if (pagesToRender.includes(i)) {
476
+ i.loadStatus === this.pageLoadStatus.LOADED ?
477
+ this.renderPageContent(i, pageIndex) :
478
+ this.renderPageLoading(i);
479
+ } else {
480
+ this.clearPage(i);
481
+ }
482
+ }
483
+ },
484
+ // 清除页面 dom
485
+ clearPage (page) {
486
+ if (page.dom) {
487
+ this.contentView.removeChild(page.dom);
488
+ page.loadStatus = 0
489
+ page.dom = undefined;
490
+ }
491
+ },
492
+ // 页面正在下载时渲染loading视图
493
+ renderPageLoading (page) {
494
+ const { pageNo, dom } = page;
495
+ if (dom && dom.children.length != 0) {
496
+ return;
497
+ }
498
+ const pageDom = document.createElement('div');
499
+ pageDom.style.width = `${this.pageSize.width}px`;
500
+ pageDom.style.height = `${this.pageSize.height}px`;
501
+ pageDom.style.position = 'absolute';
502
+ pageDom.style.top = `${((pageNo - 1) * (this.pageSize.height + this.PAGE_INTVERVAL)) + this.PAGE_INTVERVAL
503
+ }px`;
504
+ pageDom.style.backgroundImage = `url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif')`
505
+ pageDom.style.backgroundPosition = 'center'
506
+ pageDom.style.backgroundRepeat = 'no-repeat'
507
+ pageDom.style.backgroundColor = '#FFF'
508
+ page.dom = pageDom;
509
+ this.contentView.appendChild(pageDom);
510
+ },
511
+ prev () {
512
+ this.currentPage--
513
+ if (this.currentPage < 0) {
514
+ this.currentPage = 0
515
+ if(!this.isPC) {
516
+ this.$toast({
517
+ message:'当前已经是第一段了',
518
+ duration:2000,
519
+ })
520
+ return
521
+ }
522
+ }
523
+ if(this.preViewType == 'pdf') {
524
+ this.scrollToUplaodePage(this.currentPage)
525
+ } else {
526
+ this.scrollToExcalTop(this.currentPage)
527
+ }
528
+ // this.getpdfResloutePage(this.cachePdf[this.currentPage - 1])
529
+ },
530
+ next () {
531
+ this.currentPage++
532
+ if (this.currentPage >= this.tagIds.length) {
533
+ this.currentPage = this.tagIds.length - 1
534
+ if(!this.isPC) {
535
+ this.$toast({
536
+ message:'当前已经是最后一段了',
537
+ duration:2000,
538
+ })
539
+ return
540
+ }
541
+ }
542
+ if(this.preViewType == 'pdf') {
543
+ this.scrollToUplaodePage(this.currentPage)
544
+ } else {
545
+ this.scrollToExcalTop(this.currentPage)
546
+ }
547
+ },
548
+ currentChange (value) {
549
+ this.currentPage = value - 1
550
+ if(this.preViewType == 'pdf') {
551
+ this.scrollToUplaodePage(this.currentPage)
552
+ } else {
553
+ this.scrollToExcalTop(this.currentPage)
554
+ }
555
+ },
556
+ scrollToUplaodePage (currentPage) {
557
+ this.changetoolbar = true
558
+ if(this.preViewType !== 'pdf') {
559
+ return
560
+ }
561
+ let pdfResloute = this.cachePdf[currentPage]
562
+ this.identifyTextPostion.extractInfo = pdfResloute.extractInfo
563
+ this.identifyTextPostion.left = pdfResloute.extractInfo.location[0]
564
+ this.identifyTextPostion.top = pdfResloute.extractInfo.location[1]
565
+ this.identifyTextPostion.width = pdfResloute.extractInfo.location[2]
566
+ this.identifyTextPostion.height = pdfResloute.extractInfo.location[3]
567
+ this.identifyTextPostion.page = pdfResloute.page
568
+ this.identifyTextPostion.pageHeight = pdfResloute.pageHeight
569
+ this.identifyTextPostion.pageWidth = pdfResloute.pageWidth
570
+ // 在当前段落在最后一页pdf时,根据计算的高度并不能触发滚动,在此执行重新渲染方法,非次情况会执行两次,待优化
571
+ this.$nextTick(() => {
572
+ this.renderHighlights()
573
+ })
574
+ if(this.transformSalce !== null) {
575
+ this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL) * this.transformSalce)}`
576
+ } else {
577
+ this.$refs.pdfView.scrollTop = `${((pdfResloute.page - 1) * (this.pageSize.height + this.PAGE_INTVERVAL))}`
578
+ }
579
+ },
580
+ scrollToExcalTop(currentPage) {
581
+ for (let index = 0; index < this.allTr.length; index++) {
582
+ if(index == currentPage) {
583
+ Array.from(this.allTr[index].children).forEach(item =>{
584
+ item.style.background = 'rgba(255, 136, 0, 0.6)'
585
+ item.classList.add('animation')
586
+ setTimeout(() =>{
587
+ item.classList.remove('animation')
588
+ }, 4000)
589
+ })
590
+ // getBoundingClientRect().top 当前元素距离屏幕顶部的高度 + 弹窗header 高度
591
+ if(!this.isPC) {
592
+ let top = this.allTr[index].getBoundingClientRect().top - this.$refs.pdfView.getBoundingClientRect().top
593
+ this.$refs.pdfView.scrollTop = top
594
+ } else {
595
+ let top = this.allTr[index].getBoundingClientRect().top
596
+ this.$refs.pdfView.scrollTop = top - 50
597
+ }
598
+ } else {
599
+ Array.from(this.allTr[index].children).forEach(item =>{
600
+ item.style.background = 'rgba(54, 106, 255, 0.6)'
601
+ item.classList.remove('animation')
602
+ })
603
+ }
604
+ }
605
+ },
606
+ // pdf是否需要重新渲染高亮位置
607
+ renderHighlights () {
608
+ let lineHeightDom = Array.from(document.getElementsByClassName('rectdom'))
609
+ console.log(lineHeightDom, this.currentPage, 'this.currentPage');
610
+ if (lineHeightDom) {
611
+ lineHeightDom.forEach((d) => {
612
+ for (let i = 0; i < d.children.length; i++) {
613
+ if (d.getAttribute('react-count') == this.currentPage) {
614
+ d.children[i].style.backgroundColor = 'rgba(255, 136, 0, 0.3)'
615
+ d.children[i].classList.add('animation')
616
+ setTimeout(() =>{
617
+ d.children[i].classList.remove('animation')
618
+ }, 4000)
619
+ } else {
620
+ d.children[i].style.backgroundColor = 'rgba(54, 106, 255, 0.3)'
621
+ d.children[i].classList.remove('animation')
622
+ }
623
+ }
624
+ })
625
+ }
626
+ },
627
+ displayHiglight (pageIndex) {
628
+ let lineHeightDom = Array.from(document.getElementsByClassName('rectdom'))
629
+ if (lineHeightDom) {
630
+ lineHeightDom.forEach((d) => {
631
+ if (d.getAttribute('page-index') == pageIndex) {
632
+ d.style.display = 'none'
633
+ }
634
+ })
635
+ }
636
+ },
637
+ // 前端暂时缓存多页
638
+ autoLoadMore (pageIndex) {
639
+ let pdfResloute = this.cachePdf.find(cache => {
640
+ return cache.page == pageIndex
641
+ })
642
+ if (pdfResloute) {
643
+ this.getpdfResloutePage(pdfResloute)
644
+ } else {
645
+ this.loadPdfData(pageIndex)
646
+ }
647
+ },
648
+ setPageAllLine (arr) {
649
+ this.currentPageAllLine = []
650
+ arr.forEach((item, index) => {
651
+ let i = this.currentPageAllLine.findIndex(l => { return l.page && l.page == item.page })
652
+ if (i != -1) {
653
+ // this.currentPageAllLine[i].allLines.lines.push(item.extractInfo.lines)
654
+ this.currentPageAllLine[i].allLines.push({
655
+ pageCount: index,
656
+ lines: item.extractInfo.lines
657
+ })
658
+ } else {
659
+ this.currentPageAllLine.push({
660
+ page: item.page,
661
+ allLines: [{
662
+ pageCount: index,
663
+ lines: item.extractInfo.lines
664
+ }],
665
+ })
666
+ }
667
+ })
668
+ },
669
+ openTouch() {
670
+ // this.$nextTick()将回调延迟到下次 DOM 更新循环之后执行
671
+ let that = this;
672
+ this.$nextTick(() => {
673
+ // setInterval(() => {
674
+ // this.scale = this.scale + 0.1
675
+ // that.pages.forEach((item, index) =>{
676
+ // if(item.dom) {
677
+ // item.dom.children.forEach( childDom =>{
678
+ // if(childDom.getAttribute('react-count')) {
679
+ // childDom.style.transform = "scale(" + this.scale + ")";
680
+ // childDom.style.transformOrigin = "0px 0px 0px";
681
+ // } else {
682
+ // item.dom = null
683
+ // this.startRenderPages(item.pdfPage, null, index)
684
+ // }
685
+ // } )
686
+ // }
687
+ // })
688
+ // }, 100);
689
+ // 获取放大或缩小的区域DOM
690
+ let matrix_box = this.contentView
691
+ matrix_box.addEventListener("touchstart", function (event) {
692
+ this.isTouchMoved = true
693
+ let touches = event.touches;
694
+ let events = touches[0];
695
+ let events2 = touches[1];
696
+
697
+ // event.preventDefault();
698
+
699
+ // 第一个触摸点的坐标
700
+ that.displacement.pageX = events.pageX;
701
+ that.displacement.pageY = events.pageY;
702
+
703
+ that.displacement.moveable = true;
704
+
705
+ if (events2) {
706
+ that.displacement.pageX2 = events2.pageX;
707
+ that.displacement.pageY2 = events2.pageY;
708
+ }
709
+
710
+ that.displacement.originScale = this.scale || 1;
711
+ // console.log(that.displacement);
712
+ });
713
+ document.addEventListener("touchmove", function (event) {
714
+ if (!that.displacement.moveable) {
715
+ return;
716
+ }
717
+ // event.preventDefault();
718
+ let touches = event.touches;
719
+ let events = touches[0];
720
+ let events2 = touches[1];
721
+ // 双指移动
722
+ if (events2) {
723
+ // 第2个指头坐标在touchmove时候获取
724
+ if (!that.displacement.pageX2) {
725
+ that.displacement.pageX2 = events2.pageX;
726
+ }
727
+ if (!that.displacement.pageY2) {
728
+ that.displacement.pageY2 = events2.pageY;
729
+ }
730
+ // 双指缩放比例计算
731
+ let zoom = that.getDistance({
732
+ x: events.pageX,
733
+ y: events.pageY
734
+ },
735
+ {
736
+ x: events2.pageX,
737
+ y: events2.pageY
738
+ }
739
+ ) / that.getDistance(
740
+ {
741
+ x: that.displacement.pageX,
742
+ y: that.displacement.pageY
743
+ },
744
+ {
745
+ x: that.displacement.pageX2,
746
+ y: that.displacement.pageY2
747
+ }
748
+ );
749
+ // 应用在元素上的缩放比例
750
+ let newScale = that.displacement.originScale * zoom;
751
+ console.log(zoom, newScale , this.scale, 'newScale');
752
+ // 最大缩放比例限制
753
+ if (newScale > 2) {
754
+ newScale = 2;
755
+ }
756
+ // 最大缩放比例限制
757
+ if(newScale < 1) {
758
+ newScale = 1;
759
+ }
760
+ // 记住使用的缩放值
761
+ that.displacement.scale = newScale;
762
+ // console.log(newScale);
763
+ matrix_box.style.transform = "scale(" + newScale + ")";
764
+ // 设置旋转元素的基点位置
765
+ matrix_box.style.transformOrigin = "0px 0px 0px";
766
+ }
767
+ },{ passive: false });
768
+ document.addEventListener('touchend',function() {
769
+ that.isTouchMoved = false
770
+ },{ passive: false })
771
+ });
772
+ },
773
+ getDistance(start, stop) {
774
+ // Math.hypot()计算参数的平方根
775
+ return Math.hypot(stop.x - start.x, stop.y - start.y);
776
+ },
777
+ setupCanvas(canvas, width, height) {
778
+ const dpr = 1;
779
+ // const rect = canvas.getBoundingClientRect();
780
+ canvas.width = width
781
+ canvas.height = height
782
+ const ctx = canvas.getContext('2d');
783
+ console.log(canvas.width, canvas.height, dpr, this.scale);
784
+ ctx?.scale(dpr, dpr );
785
+ return ctx;
786
+ },
787
+ changeScale(value) {
788
+ if(value == 'zoom') {
789
+ this.handScale = 'auto'
790
+ this.transformSalce = (this.transformSalce + 0.2).toFixed(1)
791
+ } else if(value == 'reduce') {
792
+ if((this.transformSalce - 0.2).toFixed(1) <= 0) {
793
+ return
794
+ }
795
+ this.handScale = 'auto'
796
+ this.transformSalce = (this.transformSalce - 0.2).toFixed(1)
797
+ } else if(value == 'auto') {
798
+ this.transformSalce = this.$refs.pdfView.clientWidth / this.pageSize.width
799
+ } else if(value == 'reality') {
800
+ this.transformSalce = 0.5
801
+ } else {
802
+ this.transformSalce = (value / 2).toFixed(1)
803
+ }
804
+ this.transformSalce = Number(this.transformSalce)
805
+ this.contentView.style.transform = 'scale(' + this.transformSalce + ')';
806
+ // this.getpdfResloutePage(this.cachePdf[0])
807
+ },
808
+ },
809
+ computed:{
810
+ perviewUrl() {
811
+ return '/web/viewer.html?file=' + '/pdflist/pdf4split-1.pdf'
812
+ }
813
+ },
814
+ watch:{
815
+ tagIds: {
816
+ handler(value) {
817
+ if(value && value.length) {
818
+ // 在 pdf_view 下创建 所有canvs的容器
819
+ this.contentView = document.createElement('div')
820
+ this.contentView.style.transformOrigin = '0px 0px 0px'
821
+
822
+ this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + value.join(',')).then(res =>{
823
+ // 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}
824
+ // 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}
825
+ // 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}
826
+ // res.data = {"data":[{"id":"6475eab868110215ab821a80","knowledgeId":"6475e7eac724c54c46cbfa2d","mainId":"5ecf2fcd704541149201ab9c1c31162d","page":0,"total":1,"pageHeight":0.0,"pageWidth":0.0,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/5ecf2fcd704541149201ab9c1c31162d/2023/05/30/08/23/20/6475eab63339db423f26b196/0.html","extractInfo":{"location":null,"content":"产品:系统配置,产品型号:存储,VX30:4G+16G,VX50:16G+256G","lines":null,"tagId":"6475eab868110215ab821a80"}}],"code":"0","msg":null,"traceId":null}
827
+ // res.data = {"data":[{"id":"6475e9393339db423f26af01","knowledgeId":"6475e44fc724c54c46cbfa21","mainId":"5ecf2fcd704541149201ab9c1c31162d","page":2,"total":2,"pageHeight":510.25,"pageWidth":1559.05,"publicPageFileUrl":"https://askbot-pdf-all.oss-cn-zhangjiakou.aliyuncs.com/5ecf2fcd704541149201ab9c1c31162d/2023/05/30/08/00/29/6475e55d3339db423f26a9b8/2.pdf","extractInfo":{"location":[327.70532,288.0498,414.9734,12.241608],"content":"三、指示灯状态说明1.白色常亮:开机/开机中2.红色常亮:待机3.白色呼吸:息屏4.红色闪烁:升级1.LAN:通过网线连接到主机的Camera端口2.电源开关:电源切换开关","lines":[{"content":"三、指示灯状态说明","location":[634.3203,288.0498,108.3584,12.0]},{"content":"1.白色常亮:开机/开机中","location":[634.3203,320.08978,108.23407,9.0]},{"content":"2.红色常亮:待机","location":[634.3204,341.3298,78.597046,9.0]},{"content":"3.白色呼吸:息屏","location":[634.32043,362.45282,78.597046,9.0]},{"content":"4.红色闪烁:升级","location":[634.3205,383.6928,78.597046,9.0]},{"content":"1.LAN:通过网线连接到主机的","location":[327.70535,291.2914,144.35995,9.0]},{"content":"Camera端口","location":[327.70532,306.88843,55.322998,9.0]},{"content":"2.电源开关:电源切换开关","location":[482.74832,291.2914,105.36301,9.0]}],"tagId":null}}],"code":"0","msg":null,"traceId":null}
828
+ // if(value.length === 1) {
829
+ // this.$refs.pdfView.style.height = 'calc(100% - 50px)'
830
+ // }
831
+ if (res.data.code == 0) {
832
+ // tagIds 会按照gpt识别的生成有序的数组,前端直接按照下标的顺序取就可以了
833
+ // 缓存拿到的所有数据
834
+ this.cachePdf = res.data.data
835
+ let publicPageFileUrl = res.data.data[0].publicPageFileUrl
836
+ this.currentPage = 0
837
+ // console.log(publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')));
838
+ if (publicPageFileUrl.substring(publicPageFileUrl.lastIndexOf('.')) === '.pdf') {
839
+ this.preViewType = 'pdf'
840
+ this.setPageAllLine(this.cachePdf)
841
+ this.getpdfResloutePage(res.data.data[0])
842
+ } else {
843
+ this.preViewType = 'excal'
844
+ this.$http.post(
845
+ '/knowledge-api/temporary-certificate/or-origin?expired=30',
846
+ publicPageFileUrl,
847
+ {
848
+ headers: {
849
+ "Content-Type": "application/json",
850
+ },
851
+ }).then(res => {
852
+ // 使用原声请求方式 axios会带有不需要的请求头
853
+ let xhr = new XMLHttpRequest();
854
+ xhr.open('GET', res.data || res.bodyText , true);
855
+ // 定义请求完成的处理函数,请求前也可以增加加载框/禁用下载按钮逻辑
856
+ xhr.onload = ({ currentTarget }) => {
857
+ // 请求完成
858
+ if (currentTarget.status === 200) { // 返回200
859
+ this.contentView.innerHTML = currentTarget.response
860
+ this.contentView.style.padding = '10px'
861
+ // this.contentView.style.position = 'relative'
862
+ this.$refs.pdfView.style.backgroundColor = '#FFFFFF'
863
+ this.$refs.pdfView.appendChild(this.contentView)
864
+ let allTr = Array.from(this.$refs.pdfView.getElementsByTagName('tr'))
865
+ this.allTr = []
866
+ for (let index = 0; index < allTr.length; index++) {
867
+ if(value.includes(allTr[index].getAttribute('tag-id'))) {
868
+ this.allTr.push(allTr[index])
869
+ }
870
+ }
871
+ this.currentChange(1)
872
+
873
+ }
874
+ }
875
+ xhr.send();
876
+ })
877
+ }
878
+ } else {
879
+ let div = document.createElement('div')
880
+ div.innerText = '文件加载异常'
881
+ this.contentView.appendChild(div)
882
+ this.$refs.pdfView.appendChild(this.contentView)
883
+ }
884
+ })
885
+ }
886
+ },
887
+ deep:true,
888
+ immediate:true
889
+ }
890
+ },
891
+ mounted () {
892
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
893
+ this.isPC = false
894
+ } else {
895
+ this.isPC = true
896
+ }
897
+ }
898
+ }
899
+ </script>
900
+
901
+ <style lang="less" scoped>
902
+ .pdf_view {
903
+ width: 100%;
904
+ height: calc(100% - 110px);
905
+ overflow: auto;
906
+ background-color: #f5f7fb;
907
+ margin-bottom: 60px;
908
+ box-sizing: border-box;
909
+ // position: relative;
910
+ // > div {
911
+ // width: 100%;
912
+ // height: 100%;
913
+ // overflow: hidden;
914
+ // overflow-y: auto;
915
+ // position: relative;
916
+ // }
917
+ > iframe {
918
+ width: 100%;
919
+ height: 100%;
920
+ }
921
+ a:link {
922
+ color: none;
923
+ }
924
+ a:visited {
925
+ color: none;
926
+ }
927
+ a:hover {
928
+ color: none;
929
+ }
930
+ a:active {
931
+ color: none;
932
+ }
933
+ .btn_footer {
934
+ width: 100%;
935
+ height: 60px;
936
+ display: flex;
937
+ align-items: center;
938
+ justify-content: space-around;
939
+ position: absolute;
940
+ bottom: 0px;
941
+ left: 0;
942
+ z-index: 999;
943
+ background: #ffffff;
944
+ .prev, .next {
945
+ width: 35%;
946
+ height: 40px;
947
+ display: flex;
948
+ align-items: center;
949
+ justify-content: center;
950
+ border-radius: 50px;
951
+ cursor: pointer;
952
+ }
953
+ .prev {
954
+ background: #F2F5FA;
955
+ color: #000;
956
+ }
957
+ .next {
958
+ background: #366aff;
959
+ color: #ffffff;
960
+ }
961
+ }
962
+ #pagination {
963
+ .total-class {
964
+ margin-right: 13px;
965
+ font-weight: 400;
966
+ }
967
+
968
+ position: absolute;
969
+ bottom: 0px;
970
+ right: 0;
971
+ width: 100%;
972
+ display: flex;
973
+ align-items: center;
974
+ justify-content: center;
975
+ height: 50px;
976
+ background-color: white;
977
+ box-shadow: 0px 0px 18px 0px rgba(29, 55, 129, 0.07);
978
+ border-radius: 5px;
979
+ z-index: 1000;
980
+
981
+ /deep/.el-pagination {
982
+ margin-right: 110px;
983
+ }
984
+
985
+ /deep/.el-pager {
986
+ background: #EDF0F6;
987
+ border-radius: 15px;
988
+ }
989
+
990
+ /deep/.el-pagination.is-background .btn-next {
991
+ width: 30px;
992
+ height: 30px;
993
+ background: #EDF0F6;
994
+ border-radius: 50%;
995
+ }
996
+
997
+ /deep/.el-pagination .btn-next {
998
+ width: 30px;
999
+ height: 30px;
1000
+ background: #EDF0F6;
1001
+ border-radius: 50%;
1002
+ padding-left: 0;
1003
+ margin-left: 5px;
1004
+ }
1005
+
1006
+ /deep/.el-pagination .btn-prev {
1007
+ width: 30px;
1008
+ height: 30px;
1009
+ background: #EDF0F6;
1010
+ border-radius: 50%;
1011
+ padding-right: 0;
1012
+ margin-right: 5px;
1013
+ }
1014
+
1015
+ /deep/.el-pagination button {
1016
+ padding: 0;
1017
+ min-width: 30px;
1018
+ }
1019
+
1020
+ /deep/.el-pager li {
1021
+ background: #EDF0F6;
1022
+ height: 30px;
1023
+ min-width: 30px;
1024
+ line-height: 30px;
1025
+ font-size: 12px;
1026
+ color: #717b90;
1027
+ }
1028
+
1029
+ /deep/.el-pager li:first-child {
1030
+ border-bottom-left-radius: 15px !important;
1031
+ border-top-left-radius: 15px !important;
1032
+ }
1033
+
1034
+ /deep/.el-pager li:last-child {
1035
+ border-top-right-radius: 15px !important;
1036
+ border-bottom-right-radius: 15px !important;
1037
+ }
1038
+
1039
+ /deep/.el-pager li.active {
1040
+ width: 30px;
1041
+ height: 30px;
1042
+ min-width: 30px;
1043
+ background: #366AFF;
1044
+ border: 3px solid #A1B9FF;
1045
+ border-radius: 50%;
1046
+ line-height: 24px;
1047
+ color: white;
1048
+ }
1049
+
1050
+ /deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
1051
+ background: #366AFF;
1052
+ }
1053
+ }
1054
+ .change_scale {
1055
+ width: 100%;
1056
+ height: 50px;
1057
+ position: absolute;
1058
+ top: 50px;
1059
+ left: 0;
1060
+ background: #ffffff;
1061
+ display: flex;
1062
+ align-items: center;
1063
+ padding: 0 10px;
1064
+ box-sizing: border-box;
1065
+ section {
1066
+ cursor: pointer;
1067
+ width: 30px;
1068
+ height: 30px;
1069
+ margin-right: 5px;
1070
+ border-radius: 5px;
1071
+ display: flex;
1072
+ align-items: center;
1073
+ justify-content: center;
1074
+ i {
1075
+ font-weight: 900;
1076
+ }
1077
+ }
1078
+ section:hover {
1079
+ background: rgba(221, 222, 223, 1);
1080
+ }
1081
+ }
1082
+ }
1083
+
1084
+ </style>
1085
+ <style lang="less">
1086
+ .animation {
1087
+ animation-name: highlight;
1088
+ animation-duration: 4s;
1089
+ }
1090
+ @keyframes highlight {
1091
+ 0% {
1092
+ background:rgba(255, 136, 0, 0.3);
1093
+ }
1094
+ 25% {
1095
+ background:rgba(255, 136, 0, 0.6);
1096
+ }
1097
+ 50% {
1098
+ background:rgba(255, 136, 0, 0.3);
1099
+ }
1100
+ 75% {
1101
+ background:rgba(255, 136, 0, 0.6);
1102
+ }
1103
+ 100% {
1104
+ background:rgba(255, 136, 0, 0.3);
1105
+ }
1106
+ }
1107
1107
  </style>