askbot-dragon 1.7.44-beta → 1.7.48-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.
Files changed (95) 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 +56 -56
  5. package/public/index.html +75 -73
  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 +117 -141
  11. package/src/assets/js/Base64Util.js +22 -22
  12. package/src/assets/js/common.js +252 -252
  13. package/src/assets/js/hammer.js +89 -100
  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 +192 -199
  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 +294 -294
  20. package/src/components/ActionAlertIframe.vue +154 -177
  21. package/src/components/AiGuide.vue +471 -438
  22. package/src/components/AnswerDocknowledge.vue +1088 -1091
  23. package/src/components/AnswerVoice.vue +285 -285
  24. package/src/components/AskIFrame.vue +15 -15
  25. package/src/components/ConversationContainer.vue +10873 -10766
  26. package/src/components/FileType.vue +86 -86
  27. package/src/components/Message.vue +27 -27
  28. package/src/components/MyEditor.vue +341 -342
  29. package/src/components/QwFeedback.vue +301 -301
  30. package/src/components/actionSatisfaction.vue +107 -107
  31. package/src/components/actionSendToBot.vue +62 -62
  32. package/src/components/answerDissatisfaction.vue +62 -62
  33. package/src/components/answerRadio.vue +211 -211
  34. package/src/components/ask-components/DissatisfactionOptions.vue +57 -57
  35. package/src/components/ask-components/Msgloading.vue +37 -37
  36. package/src/components/ask-components/SatisfactionV2.vue +15 -15
  37. package/src/components/askVideo.vue +139 -162
  38. package/src/components/assetDetails.vue +378 -378
  39. package/src/components/assetMessage.vue +226 -228
  40. package/src/components/associationIntention.vue +374 -378
  41. package/src/components/attachmentPreview.vue +90 -90
  42. package/src/components/botActionSatisfactor.vue +68 -68
  43. package/src/components/chatContent.vue +513 -513
  44. package/src/components/feedBack.vue +136 -136
  45. package/src/components/fielListView.vue +351 -351
  46. package/src/components/file/AliyunOssComponents.vue +108 -108
  47. package/src/components/formTemplate.vue +3497 -3501
  48. package/src/components/imgView.vue +31 -31
  49. package/src/components/intelligentSummary.vue +229 -231
  50. package/src/components/kkview.vue +1138 -1138
  51. package/src/components/loadingProcess.vue +164 -164
  52. package/src/components/markDownText.vue +197 -197
  53. package/src/components/message/ActionAlertIframe.vue +112 -112
  54. package/src/components/message/ShopMessage.vue +164 -164
  55. package/src/components/message/TextMessage.vue +924 -928
  56. package/src/components/message/TicketMessage.vue +201 -201
  57. package/src/components/message/swiper/index.js +4 -4
  58. package/src/components/message/swiper/ticketSwiper.vue +503 -503
  59. package/src/components/message/swiper/ticketSwiperItem.vue +61 -61
  60. package/src/components/msgLoading.vue +231 -231
  61. package/src/components/myPopup.vue +70 -70
  62. package/src/components/pdfPosition.vue +1342 -1514
  63. package/src/components/popup.vue +227 -227
  64. package/src/components/previewDoc.vue +247 -251
  65. package/src/components/previewPdf.vue +774 -1069
  66. package/src/components/receiverMessagePlatform.vue +66 -65
  67. package/src/components/recommend.vue +80 -80
  68. package/src/components/selector/hOption.vue +20 -20
  69. package/src/components/selector/hSelector.vue +199 -199
  70. package/src/components/selector/hWrapper.vue +216 -216
  71. package/src/components/senderMessagePlatform.vue +55 -50
  72. package/src/components/source/BotMessage.vue +24 -24
  73. package/src/components/source/CustomMessage.vue +24 -24
  74. package/src/components/test.vue +260 -260
  75. package/src/components/tree.vue +307 -307
  76. package/src/components/utils/AliyunIssUtil.js +103 -103
  77. package/src/components/utils/ckeditor.js +185 -185
  78. package/src/components/utils/format_date.js +25 -25
  79. package/src/components/utils/index.js +6 -6
  80. package/src/components/utils/math_utils.js +29 -29
  81. package/src/components/voiceComponent.vue +119 -119
  82. package/src/components/welcomeKnowledgeFile.vue +340 -344
  83. package/src/components/welcomeLlmCard.vue +140 -144
  84. package/src/components/welcomeSuggest.vue +97 -97
  85. package/src/locales/cn.json +61 -71
  86. package/src/locales/en.json +62 -73
  87. package/src/main.js +76 -75
  88. package/vue.config.js +54 -54
  89. package/src/components/newPdfPosition.vue +0 -878
  90. package/src/components/pagination.vue +0 -129
  91. package/src/components/preview/docView.vue +0 -107
  92. package/src/components/preview/excelView.vue +0 -177
  93. package/src/components/preview/newPositionPreview.vue +0 -351
  94. package/src/components/preview/pdfView.vue +0 -760
  95. package/src/locales/jp.json +0 -73
@@ -1,1069 +1,774 @@
1
-
2
- <!-- preview-pdf
3
- 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
- 不携带定位信息的 也是走 kkview项目预览
5
- 另外增加了在知识项目中预览当前文件的一些功能
6
- -->
7
- <template>
8
- <el-drawer :title="'我是标题'" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
9
- :modal="formKnowledgeManagement ? true : false" :direction="previewShowPopup ? 'btt' : 'rtl'" :size="previewShowPopup ? '90%' : '65%'"
10
- custom-class="pdf-preview-drawer" v-if="drawer">
11
- <!-- v-else-if="drawer" -->
12
- <div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
13
- <div class="header-btn btn_position">
14
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
15
- 下载
16
- </div>
17
- <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
18
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
19
- <span>智能摘要</span>
20
- </div>
21
- <template v-if="isHasChat">
22
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
23
- <i class="iconfont guoran-wendapingjia"></i>
24
- 聊一聊
25
- </div>
26
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
27
- <i class="iconfont guoran-wendapingjia"></i>
28
- 聊一聊
29
- </div>
30
- </template>
31
- </div>
32
- <div class="header_title">
33
- <div class="header_close">
34
- <span class="title_left">
35
- {{ title ? title : '查看详情' }}
36
- </span>
37
- <section @click="close">
38
- <i class="iconfont guoran-shanchu"></i>
39
- </section>
40
- </div>
41
- <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
42
- <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
43
- {{ folderName }}
44
- <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
45
- </p>
46
- </div>
47
- </div>
48
- <div class="drawer-header" :class="isLiBang && folderName ? 'libang_head' : ''" v-else>
49
- <div class="header_title">
50
- <div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
51
- <span class="title_left">
52
- {{ title ? title : "查看详情" }}
53
- </span>
54
- <div class="header-btn">
55
- <div class="onload_btn" v-if="isDownload" @click="downLoad">
56
- 下载
57
- </div>
58
- <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
59
- v-if="isHasChat || formKnowledgeManagement">
60
- <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
61
- <span>智能摘要</span>
62
- </div>
63
- <template v-if="isHasChat">
64
- <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
65
- <i class="iconfont guoran-wendapingjia"></i>
66
- 聊一聊
67
- </div>
68
- <div class="chat chat_active" @click="previewToDialog(false)" v-else>
69
- <i class="iconfont guoran-wendapingjia"></i>
70
- 聊一聊
71
- </div>
72
- </template>
73
- <section @click="close">
74
- <i class="iconfont guoran-shanchu"></i>
75
- </section>
76
- </div>
77
- </div>
78
- <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
79
- <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
80
- {{ folderName }}
81
- <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
82
- </p>
83
- </div>
84
- </div>
85
- <div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
86
- <!-- :style="{marginTop:tagIds && tagIds.length != 0 && isPc ? '50px' : ''}" -->
87
- <intelligent-summary
88
- v-show="showSummary && (isHasChat || formKnowledgeManagement) && fileType !== 'VIDEO' && fileType !== 'IMAGE'"
89
- :tagIds="tagIds"
90
- :knowledgeId="knowledgeId"
91
- :formKnowledgeManagement="formKnowledgeManagement"
92
- @closeSummary="closeSummary" @recommendQues="recommendQues"
93
- @getSummarySuccess="getSummarySuccess"></intelligent-summary>
94
- <div class="pdf_positon" :style="pdfStyle" v-if="tagIds && tagIds.length != 0 && drawer && newVersion === false && newFileType !== 'PPT'">
95
- <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :textWatermarkStr="textWatermarkStr">
96
- </pdfPosition>
97
- </div>
98
- <new-position-preview
99
- ref="newPositionPreview"
100
- v-else-if="tagIds && tagIds.length!= 0 && newVersion && newFileType !== 'PPT'"
101
- :knowledgeId="knowledgeId"
102
- :tagIds="tagIds"
103
- :url="previewHref"
104
- ></new-position-preview>
105
- <template v-else>
106
- <div v-if="fileType == 'VIDEO'" style="width: 100%;height: 100%">
107
- <video :src="url" controls width="100%;" height="98%"></video>
108
- </div>
109
- <div v-else-if="fileType == 'HTML'" style="width: 100%;">
110
- <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
111
- </div>
112
- <template v-else-if="url.includes('https://www') || url.includes('http://www')">
113
- <iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
114
- border="0"></iframe>
115
- </template>
116
- <template v-else>
117
- <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;"
118
- :style="{ height: iframeHeight }"></iframe>
119
- <template v-if="(newFileType === 'PPT' && pageChunkData.length > 1)">
120
- <div class="btn_footer" v-if="!isPc">
121
- <div class="prev" @click="prev">上一段</div>
122
- <div class="next" @click="next">下一段</div>
123
- </div>
124
- <div id="pagination" v-if="isPc">
125
- <el-pagination :current-page="currentPage + 1" @current-change="currentChange" @prev-click="prev"
126
- @next-click="next" layout="slot, prev, pager, next" :page-size="1" :total="pageChunkData.length">
127
- <span class="total-class">答案由{{ pageChunkData.length }}段内容生成</span>
128
- </el-pagination>
129
- </div>
130
- </template>
131
- </template>
132
- </template>
133
- <!-- <div class="mobile_onload_btn" v-if="isDownload && !isPc" @click="downLoad">
134
- 下载
135
- </div> -->
136
- </div>
137
- <div class="loading_img" v-show="loading">
138
- <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
139
- </div>
140
- <div id="text">
141
- {{ copy }}
142
- </div>
143
- </el-drawer>
144
- </template>
145
-
146
- <script>
147
- import pdfPosition from './pdfPosition.vue'
148
- import { zoomElement } from '../assets/js/hammer'
149
- import IntelligentSummary from "./intelligentSummary";
150
- import { isMobile } from "../assets/js/common";
151
- import { Toast } from 'vant';
152
- import NewPositionPreview from "./preview/newPositionPreview";
153
- export default {
154
- data () {
155
- return {
156
- previewShowPopup: false,
157
- fileText: '',
158
- fileType: "",
159
- isPc: false,
160
- drawer: false,
161
- tagIds: [],
162
- // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
163
- loading: true,
164
- fileName:'',
165
- previewKnowledgeId:"",
166
- showSummary:false,
167
- iframeHeight:"100%",
168
- isDownload: false,
169
- textWatermarkStr:"",
170
- copy:'',
171
- newVersion:'',
172
- previewHref:"",
173
- newFileType:"",
174
- numberPage:0,
175
- pageChunkData:[],
176
- currentPage:0
177
- }
178
- },
179
- mounted() {
180
- window.addEventListener('message',this.handleIframeMessage,false);
181
- this.isPcFun();
182
- },
183
- props:{
184
- url:{
185
- type: String,
186
- required: true,
187
- },
188
- officePreviewType:{
189
- type: String,
190
- default: ''
191
- },
192
- isMessageRecord:{
193
- type: Boolean,
194
- default:false,
195
- },
196
- sourceFileType:{
197
- type: String,
198
- default: '',
199
- },
200
- title: {
201
- type: String,
202
- default: ''
203
- },
204
- isHasChat:{
205
- type:Boolean,
206
- default:false
207
- },
208
- knowledgeId:{
209
- type: String,
210
- default: '',
211
- },
212
- previewOssPath:{
213
- type: String,
214
- default: '',
215
- },
216
- folderName: {
217
- type: String,
218
- default: '',
219
- },
220
- folderUrl: {
221
- type: String,
222
- default: '',
223
- },
224
- isLiBang: {
225
- type: Boolean,
226
- default: false
227
- },
228
- formKnowledgeManagement:{
229
- type: Boolean,
230
- default: false
231
- }
232
- },
233
- components: {
234
- NewPositionPreview,
235
- IntelligentSummary,
236
- pdfPosition
237
- },
238
- watch: {
239
- drawer (value) {
240
- if (value) {
241
- this.$emit('open')
242
- this.$nextTick(() => {
243
- if (this.tagIds && this.tagIds.length != 0){
244
- zoomElement(document.getElementById('pdf_container_view'))
245
- }
246
- })
247
- } else {
248
- this.$emit('close')
249
- }
250
- setTimeout(() => {
251
- let previewIframe = document.getElementsByClassName('preview_iframe')
252
- Array.from(previewIframe).forEach(item =>{
253
- item.onload = () =>{
254
- console.debug('previewIframe 106',previewIframe,this.drawer)
255
- item.style.backgroundImage = 'none'
256
- }
257
- })
258
- })
259
- },
260
- showSummary:{
261
- handler(val){
262
- // if (!val){
263
- // this.$nextTick(() => {
264
- // let preCon = document.querySelector('.pdf_view');
265
- // if (preCon){
266
- // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
267
- // }
268
- // })
269
- // } else {
270
- // this.getSummarySuccess();
271
- // }
272
- if(val) {
273
- this.getSummarySuccess();
274
- }
275
- }
276
- },
277
- knowledgeId:{
278
- handler(val){
279
- if (val){
280
- this.getTextWatermark();
281
- }
282
- }
283
- }
284
- },
285
- computed:{
286
- pdfStyle() {
287
- return {
288
- paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
289
- paddingBottom: this.tagIds > 1 ? '60px' : '0',
290
- height: '100%'
291
- }
292
- },
293
- previewUrl() {
294
- console.debug('VUE_APP_ENV',process.env.VUE_APP_ENV)
295
- let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
296
- // if(this.url != '') {
297
- // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
298
- // url += btoa(encodeURIComponent(this.url))
299
- // } else {
300
- // url += btoa(this.url)
301
- // }
302
- // }
303
- url = url + this.url
304
- url += '&officePreviewType=pdf'
305
- if(this.watermark) {
306
- url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
307
- url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
308
- }
309
- console.log('textWatermarkStr 216', this.textWatermarkStr)
310
- if (this.textWatermarkStr) {
311
- url += '&textWatermarkValue=' + this.textWatermarkStr
312
- }
313
- return url
314
- },
315
- // fileType() {
316
- // const fileType = this.url.substring(this.url.lastIndexOf('.'));
317
- // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
318
- // return 'VIDEO'
319
- // } else {
320
- // return 'OTHER'
321
- // }
322
-
323
- // }
324
- },
325
- methods: {
326
- close () {
327
- setTimeout(() => {
328
- this.previewShowPopup = false;
329
- this.fileType = ''
330
- }, 300)
331
- this.drawer = false;
332
- this.showSummary = false;
333
- },
334
- loadIframe () {
335
-
336
- if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
337
- this.loading = false
338
- } else {
339
- let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
340
- if (iframe) {
341
- iframe.onload = () => {
342
- this.loading = false;
343
- document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
344
- }
345
- }
346
- // let time = setInterval(() =>{
347
- //
348
- // if(iframe) {
349
- // this.loading = false
350
- // clearInterval(time)
351
- // }
352
- // }, 500)
353
- }
354
- },
355
- getBolb () {
356
- this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
357
- fileInOssPath: this.url,
358
- templateId: ''
359
- }).then(res => {
360
- if (res.data.code == 0) {
361
- this.fileText = res.data.data
362
- this.loading = false
363
- }
364
- })
365
- },
366
- previewToDialog (flag) {
367
- this.$emit('previewToDialog', flag)
368
- },
369
- closeSummary () {
370
- this.showSummary = false;
371
- },
372
- recommendQues (item, knowledgeId) {
373
- console.log('recommendQues', item, knowledgeId);
374
- this.$emit('recommendQues', item, knowledgeId)
375
- },
376
- handleIframeMessage (res) {
377
- if (res.data.type == 'getViewerHeight') {
378
- let iframeHeight = this.iframeHeight.replace('px', '')
379
- if (res.data.data && iframeHeight != (res.data.data + 50)) {
380
- this.iframeHeight = res.data.data + 50 + 'px'
381
- }
382
- }
383
- if (res.data.type == 'getViewPage' && res.data.data){
384
- this.numberPage = Number(res.data.data);
385
- if (this.pageChunkData.length > 0){
386
- this.scrollPPTPage(this.pageChunkData[0])
387
- }
388
- }
389
- if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage'){
390
- if (this.pageChunkData.length > 0){
391
- this.scrollPPTPage(this.pageChunkData[0])
392
- }
393
- }
394
- },
395
- summaryFun () {
396
- this.showSummary = !this.showSummary;
397
- if (this.showSummary) {
398
- document.getElementById('drawer_content_pre').scrollTop = 0;
399
- }
400
- },
401
- getSummarySuccess () {
402
- this.$nextTick(() => {
403
- // if (this.tagIds.length > 0){
404
- // let intelligentSummary = document.getElementById('intelligentSummary');
405
- // let preCon = document.querySelector('.pdf_view')
406
- // if (intelligentSummary){
407
- // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
408
- // if (preCon){
409
- // preCon.style.height = 'calc(100% - ' + height + 'px)'
410
- // }
411
- // console.log('height',height,preCon)
412
- // }
413
- // }
414
- // let intelligentSummary = document.getElementById('intelligentSummary');
415
- // let height = intelligentSummary.offsetHeight
416
- // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
417
- })
418
- },
419
- getTextWatermark () {
420
- let url = '/knowledge-api/open/knowledge/getPermissionInfo';
421
- let obj = {
422
- "knowledgeId": this.knowledgeId,
423
- "userId": sessionStorage.getItem('_currentUserId'),
424
- "mainId": sessionStorage.getItem('_mainId'),
425
- "corpId": sessionStorage.getItem('_corpid')
426
- }
427
- this.$http.post(url, obj).then(res => {
428
- console.log('getTextWatermark', res.data.data)
429
- if (res.data.data) {
430
- this.textWatermarkStr = res.data.data.textWatermarkStr;
431
- this.isDownload = res.data.data.showDownloadBtn;
432
- }
433
- })
434
- },
435
- downLoad () {
436
- if (this.formKnowledgeManagement){
437
- this.$emit('downLoad',this.previewOssPath);
438
- return
439
- }
440
- let url = this.previewOssPath
441
- if (decodeURIComponent(url) != url) {
442
- url = decodeURIComponent(url)
443
- }
444
- const fileType = url.substring(url.lastIndexOf('.'));
445
- this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
446
- headers: {
447
- "Content-Type": "application/json",
448
- }
449
- }).then(res => {
450
- console.log('downLoad 341', res)
451
- if (res.data|| res.bodyText) {
452
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
453
- this.copy = res.data
454
- if (isMobile()) {
455
- setTimeout(() =>{
456
- const range = document.createRange();
457
- range.selectNode(document.getElementById('text'));
458
- const selection = window.getSelection();
459
- //移除之前选中内容
460
- if (selection.rangeCount > 0) selection.removeAllRanges();
461
- selection.addRange(range);
462
- document.execCommand('copy');
463
- selection.removeAllRanges()
464
- Toast('下载地址已复制,请前往Safari浏览器访问下载');
465
- this.close()
466
- },100)
467
- } else {
468
- let a = document.createElement('a')
469
- a.href = res.data
470
- a.download = (this.title) + fileType
471
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
472
- }
473
- return
474
- } else {
475
- // setTimeout(() =>{
476
- // window.open(res.data,'下载', 'noopener')
477
- // }, 2000)
478
- // window.open(res.data,'下载', 'noopener')
479
- if (isMobile()) {
480
-
481
- const iframe = document.createElement("iframe");
482
- iframe.setAttribute("hidden", "hidden");
483
- iframe.onload = () => {
484
- if (iframe) {
485
- console.log("iframe onload....")
486
- iframe.setAttribute('src', 'about:blank');
487
- }
488
- };
489
- document.body.insertBefore(iframe, null);
490
- iframe.setAttribute("src", res.data );
491
- } else {
492
- let a = document.createElement('a')
493
- a.href = res.data
494
- a.download = (this.title) + fileType
495
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
496
- }
497
- this.close()
498
- }
499
- }
500
- })
501
- },
502
- isPcFun () {
503
- if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
504
- this.isPc = false
505
- } else {
506
- this.isPc = true
507
- }
508
- },
509
- clickFloder() {
510
- this.$emit('previewClickFloder')
511
- },
512
- getOssPath(url){
513
- let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
514
- let type = this.getFileType(url)
515
- this.newFileType = type;
516
- if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
517
- httpUrl += '?needEncrypt=false'
518
- } else {
519
- httpUrl += '?needEncrypt=true'
520
- }
521
- this.$http.post(httpUrl, {
522
- "fileInOssPath": url
523
- }).then(res => {
524
- console.log('getOssPath',res)
525
- if (res.data.code == '0'){
526
- this.previewHref = res.data.data;
527
- }
528
- })
529
- },
530
- getFileType(url){
531
- let index = url.lastIndexOf('?')
532
- let newFileInOssPath = url.substring(0, url.indexOf("?"))
533
- if (index == -1){
534
- newFileInOssPath = url
535
- }
536
- const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
537
- if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
538
- return 'VIDEO'
539
- } else if (fileType === '.html') {
540
- return 'HTML'
541
- } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
542
- return 'IMAGE'
543
- } else if (fileType === '.docx' || fileType === '.doc'){
544
- return 'DOC'
545
- } else if (fileType === '.ppt' || fileType === '.pptx'){
546
- return 'PPT'
547
- } else if (fileType === '.pdf'){
548
- return 'PDF'
549
- } else if (fileType === '.txt'){
550
- return 'TXT'
551
- } else {
552
- return 'OTHER'
553
- }
554
- },
555
- //判断是否使用新定位组件
556
- getLocationInfo(){
557
- this.newVersion = "";
558
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
559
- console.log('getLocationInfo',res)
560
- if (res.data.code == 0){
561
- if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3'){
562
- this.newVersion = true;
563
- if (this.newFileType !== 'PPT'){
564
- this.loading = false;
565
- }
566
- for (let i=0;i<res.data.data.length;i++){
567
- if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData){
568
- this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
569
- }
570
- }
571
- if (this.pageChunkData.length > 1){
572
- let iframe = document.getElementsByClassName('preview_iframe_kk')
573
- if (iframe){
574
- iframe[0].style.paddingBottom = '50px'
575
- }
576
- }
577
- } else {
578
- this.newVersion = false;
579
- }
580
- }
581
- })
582
- },
583
- currentChange (value) {
584
- this.currentPage = value - 1;
585
- this.scrollPPTPage()
586
- },
587
- prev(){
588
- if (this.currentPage == 0){
589
- return
590
- }
591
- this.currentPage--;
592
- this.scrollPPTPage()
593
- },
594
- next(){
595
- if (this.currentPage === (this.pageChunkData.length - 1)){
596
- return;
597
- }
598
- this.currentPage++;
599
- this.scrollPPTPage()
600
- },
601
- scrollPPTPage(){
602
- if (this.numberPage > 0){
603
- let pageNumber = this.pageChunkData[this.currentPage];
604
- let height = Math.floor(Number(this.iframeHeight.replace('px',"")));
605
- let pageHeight = Math.floor(height / this.numberPage);
606
- let scrollHeight = (pageNumber - 1) * pageHeight;
607
- let dom = document.getElementById('drawer_content_pre');
608
- if (dom){
609
- dom.scrollTo(0,scrollHeight)
610
- }
611
- }
612
- }
613
- },
614
- beforeDestroy () {
615
- window.removeEventListener('message', this.handleIframeMessage);
616
- }
617
- }
618
- </script>
619
-
620
- <style lang="less" scoped>
621
- #drawer_content_pre {
622
- padding: 20px;
623
- scroll-behavior: smooth;
624
-
625
- .mobile_onload_btn {
626
- position: absolute;
627
- right: 0;
628
- bottom: 10%;
629
- width: 20px;
630
- height: 60px;
631
- display: flex;
632
- align-items: center;
633
- justify-content: center;
634
- cursor: pointer;
635
- border-top-left-radius: 10px;
636
- border-bottom-left-radius: 10px;
637
- color: #366aff;
638
- background: #ffffff;
639
- border: 1px solid #a1b9ff;
640
- font-size: 12px;
641
- border-right: none;
642
- text-align: center;
643
- }
644
-
645
- .pdf_positon {
646
- width: 100%;
647
- box-sizing: border-box;
648
- }
649
- }
650
-
651
- .onload_btn {
652
- width: 76px;
653
- height: 26px;
654
- display: flex;
655
- align-items: center;
656
- justify-content: center;
657
- cursor: pointer;
658
- margin-right: 10px;
659
- border-radius: 15px;
660
- color: #366aff;
661
- background: #ffffff;
662
- border: 1px solid #a1b9ff;
663
- box-sizing: border-box;
664
- }
665
-
666
- .preview_iframe {
667
- width: 100%;
668
- height: 100%;
669
- box-sizing: border-box;
670
- background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
671
- background-position: center;
672
- background-size: 50px;
673
- background-repeat: no-repeat;
674
- }
675
-
676
- .preview_iframe_kk {
677
- width: 100%;
678
- height: 100%;
679
- }
680
- .btn_footer {
681
- width: 100%;
682
- height: 60px;
683
- display: flex;
684
- align-items: center;
685
- justify-content: space-around;
686
- position: absolute;
687
- bottom: 0px;
688
- left: 0;
689
- z-index: 999;
690
- background: #ffffff;
691
-
692
- .prev,
693
- .next {
694
- width: 35%;
695
- height: 40px;
696
- display: flex;
697
- align-items: center;
698
- justify-content: center;
699
- border-radius: 50px;
700
- cursor: pointer;
701
- }
702
-
703
- .prev {
704
- background: #F2F5FA;
705
- color: #000;
706
- }
707
-
708
- .next {
709
- background: #366aff;
710
- color: #ffffff;
711
- }
712
- }
713
- #pagination {
714
- .total-class {
715
- margin-right: 13px;
716
- font-weight: 400;
717
- }
718
-
719
- position: absolute;
720
- bottom: 0px;
721
- right: 0;
722
- width: 100%;
723
- display: flex;
724
- align-items: center;
725
- justify-content: center;
726
- height: 50px;
727
- background-color: white;
728
- box-shadow: 0px 0px 18px 0px rgba(29, 55, 129, 0.07);
729
- border-radius: 5px;
730
- z-index: 1000;
731
-
732
-
733
-
734
- /deep/.el-pagination {
735
- margin-right: 110px;
736
- }
737
-
738
- /deep/.el-pager {
739
- background: #EDF0F6;
740
- border-radius: 15px;
741
- }
742
-
743
- /deep/.el-pagination.is-background .btn-next {
744
- width: 30px;
745
- height: 30px;
746
- background: #EDF0F6;
747
- border-radius: 50%;
748
- }
749
-
750
- /deep/.el-pagination .btn-next {
751
- width: 30px;
752
- height: 30px;
753
- background: #EDF0F6;
754
- border-radius: 50%;
755
- padding-left: 0;
756
- margin-left: 5px;
757
- }
758
-
759
- /deep/.el-pagination .btn-prev {
760
- width: 30px;
761
- height: 30px;
762
- background: #EDF0F6;
763
- border-radius: 50%;
764
- padding-right: 0;
765
- margin-right: 5px;
766
- }
767
-
768
- /deep/.el-pagination button {
769
- padding: 0;
770
- min-width: 30px;
771
- }
772
-
773
- /deep/.el-pager li {
774
- background: #EDF0F6;
775
- height: 30px;
776
- min-width: 30px;
777
- line-height: 30px;
778
- font-size: 12px;
779
- color: #717b90;
780
- }
781
-
782
- /deep/.el-pager li:first-child {
783
- border-bottom-left-radius: 15px !important;
784
- border-top-left-radius: 15px !important;
785
- }
786
-
787
- /deep/.el-pager li:last-child {
788
- border-top-right-radius: 15px !important;
789
- border-bottom-right-radius: 15px !important;
790
- }
791
-
792
- /deep/.el-pager li.active {
793
- width: 30px;
794
- height: 30px;
795
- min-width: 30px;
796
- background: #366AFF;
797
- border: 3px solid #A1B9FF;
798
- border-radius: 50%;
799
- line-height: 24px;
800
- color: white;
801
- }
802
-
803
- /deep/.el-pagination.is-background .el-pager li:not(.disabled).active {
804
- background: #366AFF;
805
- }
806
- }
807
- .preview_iframe_html {
808
- width: 100%;
809
- height: 100%;
810
- overflow-y: scroll;
811
- text-align: left;
812
- box-sizing: border-box;
813
- padding: 16px;
814
-
815
- /deep/.lake-content {
816
- margin-left: 10px;
817
- }
818
-
819
- /deep/a:link {
820
- color: #0000ee !important;
821
- }
822
-
823
- /deep/a:visited {
824
- color: #0000ee !important;
825
- }
826
-
827
- /deep/a:hover {
828
- color: #0000ee !important;
829
- }
830
-
831
- /deep/a:active {
832
- color: #0000ee !important;
833
- }
834
-
835
- /deep/li:not(.rich-text-li),
836
- ol:not(.list-paddingleft-2),
837
- ul:not(.list-paddingleft-2) {
838
- list-style-type: auto !important;
839
- }
840
-
841
- /deep/img {
842
- width: 100%;
843
- }
844
-
845
- /deep/.ne-table {
846
- width: 100% !important;
847
- }
848
- }
849
-
850
- .footer {
851
- width: calc(100% - 40px);
852
- height: 50px;
853
- display: flex;
854
- align-items: center;
855
- justify-content: space-between;
856
- cursor: pointer;
857
- padding: 0 20px;
858
- border-bottom: 1px solid #cccccc;
859
- }
860
-
861
- .loading_img {
862
- display: flex;
863
- align-items: center;
864
- justify-content: center;
865
- width: 100%;
866
- height: 100%;
867
- position: absolute;
868
- top: 0;
869
- left: 0;
870
- background: #FFF;
871
-
872
- img {
873
- width: 50px;
874
- height: 50px;
875
- }
876
- }
877
-
878
- .libang_head {
879
- height: 64px !important;
880
- }
881
-
882
- .drawer-header {
883
- width: 100%;
884
- height: 50px;
885
- cursor: pointer;
886
- padding: 6px 20px;
887
- border-bottom: 1px solid #cccccc;
888
- .btn_position {
889
- position: absolute;
890
- top: -34px;
891
- left: 12px;
892
- }
893
-
894
- .header-btn {
895
- display: flex;
896
- align-items: center;
897
- justify-content: space-between;
898
-
899
- .header-right {
900
- display: flex;
901
- }
902
-
903
- .summaryBtn {
904
- flex: none;
905
- //width: 95px;
906
- height: 26px;
907
- padding: 0 8px;
908
- background: #ffffff;
909
- display: flex;
910
- align-items: center;
911
- justify-content: center;
912
- box-sizing: border-box;
913
- border: 1px solid #a1b9ff;
914
- border-radius: 15px;
915
- cursor: pointer;
916
- color: #366aff;
917
- margin-right: 10px;
918
- font-size: 14px;
919
-
920
- i {
921
- font-size: 14px;
922
- margin-right: 5px;
923
- }
924
- }
925
-
926
- .summaryActiveBtn {
927
- background: #366aff !important;
928
- color: #ffffff !important;
929
- }
930
-
931
- .chat {
932
- flex: none;
933
- height: 26px;
934
- padding: 0 8px;
935
- background: #ffffff;
936
- display: flex;
937
- align-items: center;
938
- justify-content: center;
939
- box-sizing: border-box;
940
- border: 1px solid #a1b9ff;
941
- border-radius: 15px 0px 15px 15px;
942
- cursor: pointer;
943
- color: #366aff;
944
- margin-right: 10px;
945
- font-size: 14px;
946
-
947
- i {
948
- font-size: 14px;
949
- margin-right: 5px;
950
- margin-top: 2px;
951
- }
952
- }
953
-
954
- .chat_active {
955
- background: #366aff !important;
956
- color: #FFFFFF !important;
957
- }
958
- }
959
-
960
- .header_title {
961
- font-size: 14px;
962
- height: 100%;
963
- .header_close {
964
- display: flex;
965
- align-items: center;
966
- justify-content: space-between;
967
- line-height: 26px;
968
- .title_left {
969
- white-space: nowrap; /* 确保文本不会换行 */
970
- overflow: hidden; /* 隐藏超出容器的文本 */
971
- text-overflow: ellipsis; /* 当文本超出容器时显示省略号 */
972
- margin-right: 8px;
973
- }
974
- }
975
- .header_floder {
976
- display: flex;
977
- align-items: center;
978
- line-height: 26px;
979
- i {
980
- margin: 0 5px;
981
- color: #366aff;
982
- }
983
- }
984
- .header_top {
985
- height: 100%;
986
- display: flex;
987
- align-items: center;
988
- justify-content: space-between;
989
- }
990
- }
991
- }
992
-
993
- @media screen and (max-width: 767px) {
994
-
995
- /* 这里是针对移动设备的css样式设置 */
996
- /deep/.el-drawer__body {
997
- height: 100%;
998
- }
999
-
1000
- #drawer_content_pre {
1001
- overflow: auto;
1002
- height: calc(100% - 50px);
1003
- background: #FFF;
1004
- }
1005
-
1006
- .libang_content_pre {
1007
- height: calc(100% - 64px) !important;
1008
- }
1009
- }
1010
-
1011
- @media screen and (min-width: 768px) {
1012
-
1013
- /* 这里是针对pc设备的css样式设置 */
1014
- /deep/.el-drawer__body {
1015
- height: 100%;
1016
- }
1017
-
1018
- #drawer_content_pre {
1019
- overflow: auto;
1020
- height: calc(100% - 50px);
1021
- background: #FFF;
1022
- }
1023
-
1024
- .libang_content_pre {
1025
- height: calc(100% - 64px) !important;
1026
- }
1027
- }
1028
-
1029
- @media screen and (min-width: 1200px) {
1030
-
1031
- /* 这里是针对pc设备的css样式设置 */
1032
- .el-drawer__wrapper {
1033
- width: 55%;
1034
- left: calc(100vw - 55%);
1035
- right: 0;
1036
-
1037
- /deep/.pdf-preview-drawer {
1038
- width: 100% !important;
1039
- }
1040
- }
1041
-
1042
- /deep/.el-drawer__body {
1043
- height: 100%;
1044
- }
1045
-
1046
- #drawer_content_pre {
1047
- overflow: auto;
1048
- height: calc(100% - 50px);
1049
- background: #FFF;
1050
- }
1051
-
1052
- .libang_content_pre {
1053
- height: calc(100% - 64px) !important;
1054
- }
1055
- }
1056
- </style>
1057
- <style lang="less">
1058
- .pdf-preview-drawer {
1059
- overflow: visible !important;
1060
- }
1061
- .libang_content_pre {
1062
- .change_scale {
1063
- top: 64px !important;
1064
- }
1065
- .float_intelligentSummary {
1066
- top: 74px !important;
1067
- }
1068
- }
1069
- </style>
1
+
2
+ <!-- preview-pdf
3
+ 组件主要负责 知识项目中 文件的预览,携带定位信息参数 tagIds tagId 的会解析文件增加定位功能
4
+ 不携带定位信息的 也是走 kkview项目预览
5
+ 另外增加了在知识项目中预览当前文件的一些功能
6
+ -->
7
+ <template>
8
+ <el-drawer title="" :visible.sync="drawer" :with-header="false" :append-to-body="true" :destroy-on-close="true"
9
+ :modal="false" :direction="previewShowPopup ? 'btt' : 'rtl'" :size="previewShowPopup ? '90%' : '65%'"
10
+ custom-class="pdf-preview-drawer" v-if="drawer">
11
+ <div class="drawer-header" :class="isLiBang ? 'libang_head' : ''" v-if="!isPc">
12
+ <div class="header-btn btn_position">
13
+ <div class="onload_btn" v-if="isDownload" @click="downLoad">
14
+ {{ $t('dragonCommon.download') }}
15
+ </div>
16
+ <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun" v-if="isHasChat">
17
+ <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
18
+ <span>{{ $t('dragonCommon.smartSummary') }}</span>
19
+ </div>
20
+ <template v-if="isHasChat">
21
+ <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
22
+ <i class="iconfont guoran-wendapingjia"></i>
23
+ {{ $t('dragonCommon.chat') }}
24
+ </div>
25
+ <div class="chat chat_active" @click="previewToDialog(false)" v-else>
26
+ <i class="iconfont guoran-wendapingjia"></i>
27
+ {{ $t('dragonCommon.chat') }}
28
+ </div>
29
+ </template>
30
+ </div>
31
+ <div class="header_title">
32
+ <div class="header_close">
33
+ <span class="title_left">
34
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
35
+ </span>
36
+ <section @click="close">
37
+ <i class="iconfont guoran-shanchu"></i>
38
+ </section>
39
+ </div>
40
+ <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
41
+ <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
42
+ {{ folderName }}
43
+ <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
44
+ </p>
45
+ </div>
46
+ </div>
47
+ <div class="drawer-header" :class="isLiBang && folderName ? 'libang_head' : ''" v-else>
48
+ <div class="header_title">
49
+ <div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
50
+ <span class="title_left">
51
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
52
+ </span>
53
+ <div class="header-btn">
54
+ <div class="onload_btn" v-if="isDownload" @click="downLoad">
55
+ {{ $t('dragonCommon.download') }}
56
+ </div>
57
+ <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
58
+ v-if="isHasChat">
59
+ <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
60
+ <span>{{ $t('dragonCommon.smartSummary') }}</span>
61
+ </div>
62
+ <template v-if="isHasChat">
63
+ <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
64
+ <i class="iconfont guoran-wendapingjia"></i>
65
+ {{ $t('dragonCommon.chat') }}
66
+ </div>
67
+ <div class="chat chat_active" @click="previewToDialog(false)" v-else>
68
+ <i class="iconfont guoran-wendapingjia"></i>
69
+ {{ $t('dragonCommon.chat') }}
70
+ </div>
71
+ </template>
72
+ <section @click="close">
73
+ <i class="iconfont guoran-shanchu"></i>
74
+ </section>
75
+ </div>
76
+ </div>
77
+ <p v-if="folderName && isLiBang" class="header_floder" @click="clickFloder">
78
+ <i class="iconfont guoran-tongyichicun-wenjianjia-zhankaizhuangtai--folderOpen"></i>
79
+ {{ folderName }}
80
+ <i v-if="folderUrl" class="iconfont guoran-tongyichicun-dianjichakantuli"></i>
81
+ </p>
82
+ </div>
83
+ </div>
84
+ <div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
85
+ <intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
86
+ @closeSummary="closeSummary" @recommendQues="recommendQues"
87
+ @getSummarySuccess="getSummarySuccess"></intelligent-summary>
88
+ <div class="pdf_positon" :style="pdfStyle" v-if="tagIds && tagIds.length != 0 && drawer">
89
+ <pdfPosition :tagIds="tagIds" :isMessageRecord="isMessageRecord" :textWatermarkStr="textWatermarkStr">
90
+ </pdfPosition>
91
+ </div>
92
+ <template v-else>
93
+ <div v-if="fileType == 'VIDEO'" style="width: 100%;">
94
+ <video :src="url" controls width="100%;" height="98%"></video>
95
+ </div>
96
+ <div v-else-if="fileType == 'HTML'" style="width: 100%;">
97
+ <div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
98
+ </div>
99
+ <template v-else-if="url.includes('https://www') || url.includes('http://www')">
100
+ <iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
101
+ border="0"></iframe>
102
+ </template>
103
+ <template v-else>
104
+ <iframe class="preview_iframe_kk" :src="previewUrl" style="border:none;"
105
+ :style="{ height: iframeHeight }"></iframe>
106
+ </template>
107
+ </template>
108
+ </div>
109
+ <div class="loading_img" v-show="loading">
110
+ <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
111
+ </div>
112
+ <div id="text">
113
+ {{ copy }}
114
+ </div>
115
+ </el-drawer>
116
+ </template>
117
+
118
+ <script>
119
+ import pdfPosition from './pdfPosition.vue'
120
+ import { zoomElement } from '../assets/js/hammer'
121
+ import IntelligentSummary from "./intelligentSummary";
122
+ import { isMobile } from "../assets/js/common";
123
+ import { Toast } from 'vant';
124
+ export default {
125
+ data () {
126
+ return {
127
+ previewShowPopup: false,
128
+ fileText: '',
129
+ fileType: "",
130
+ isPc: false,
131
+ drawer: false,
132
+ tagIds: [],
133
+ // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
134
+ loading: true,
135
+ previewKnowledgeId: "",
136
+ showSummary: true,
137
+ iframeHeight: "100%",
138
+ isDownload: false,
139
+ textWatermarkStr: "",
140
+ copy:''
141
+ }
142
+ },
143
+ mounted () {
144
+ window.addEventListener('message', this.handleIframeMessage, false);
145
+ this.isPcFun();
146
+ },
147
+ props: {
148
+ url: {
149
+ type: String,
150
+ required: true,
151
+ },
152
+ officePreviewType: {
153
+ type: String,
154
+ default: ''
155
+ },
156
+ isMessageRecord: {
157
+ type: Boolean,
158
+ default: false,
159
+ },
160
+ sourceFileType: {
161
+ type: String,
162
+ default: '',
163
+ },
164
+ title: {
165
+ type: String,
166
+ default: ''
167
+ },
168
+ isHasChat: {
169
+ type: Boolean,
170
+ default: false
171
+ },
172
+ knowledgeId: {
173
+ type: String,
174
+ default: '',
175
+ },
176
+ previewOssPath: {
177
+ type: String,
178
+ default: '',
179
+ },
180
+ folderName: {
181
+ type: String,
182
+ default: '',
183
+ },
184
+ folderUrl: {
185
+ type: String,
186
+ default: '',
187
+ },
188
+ isLiBang: {
189
+ type: Boolean,
190
+ default: false
191
+ }},
192
+ components: {
193
+ IntelligentSummary,
194
+ pdfPosition
195
+ },
196
+ watch: {
197
+ drawer (value) {
198
+ if (value) {
199
+ this.$emit('open')
200
+ this.$nextTick(() => {
201
+ zoomElement(document.getElementById('drawer_content_pre'))
202
+ })
203
+ } else {
204
+ this.$emit('close')
205
+ }
206
+ },
207
+ showSummary: {
208
+ handler (val) {
209
+ // if (!val){
210
+ // this.$nextTick(() => {
211
+ // let preCon = document.querySelector('.pdf_view');
212
+ // if (preCon){
213
+ // preCon.style.height = 'calc(100% - ' + 50 + 'px)'
214
+ // }
215
+ // })
216
+ // } else {
217
+ // this.getSummarySuccess();
218
+ // }
219
+ if (val) {
220
+ this.getSummarySuccess();
221
+ }
222
+ }
223
+ },
224
+ knowledgeId: {
225
+ handler (val) {
226
+ if (val) {
227
+ this.getTextWatermark();
228
+ }
229
+ }
230
+ }
231
+ },
232
+ computed: {
233
+ pdfStyle () {
234
+ return {
235
+ paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
236
+ paddingBottom: this.tagIds > 1 ? '60px' : '0',
237
+ height: '100%'
238
+ }
239
+ },
240
+ previewUrl () {
241
+ console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
242
+ let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
243
+ // if(this.url != '') {
244
+ // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
245
+ // url += btoa(encodeURIComponent(this.url))
246
+ // } else {
247
+ // url += btoa(this.url)
248
+ // }
249
+ // }
250
+ url = url + this.url
251
+ if (this.sourceFileType == '.ppt' || this.sourceFileType == '.pptx' || this.sourceFileType == '.pdf') {
252
+ url += '&officePreviewType=pdf'
253
+ }
254
+ console.log('textWatermarkStr 216', this.textWatermarkStr)
255
+ if (this.textWatermarkStr) {
256
+ url += '&textWatermarkValue=' + this.textWatermarkStr
257
+ }
258
+ return url
259
+ },
260
+ // fileType() {
261
+ // const fileType = this.url.substring(this.url.lastIndexOf('.'));
262
+ // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
263
+ // return 'VIDEO'
264
+ // } else {
265
+ // return 'OTHER'
266
+ // }
267
+
268
+ // }
269
+ },
270
+ methods: {
271
+ close () {
272
+ setTimeout(() => {
273
+ this.previewShowPopup = false;
274
+ this.fileType = ''
275
+ }, 300)
276
+ this.drawer = false;
277
+ this.showSummary = false;
278
+ },
279
+ loadIframe () {
280
+
281
+ if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0)) {
282
+ this.loading = false
283
+ } else {
284
+ let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
285
+ if (iframe) {
286
+ iframe.onload = () => {
287
+ this.loading = false;
288
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
289
+ }
290
+ }
291
+ // let time = setInterval(() =>{
292
+ //
293
+ // if(iframe) {
294
+ // this.loading = false
295
+ // clearInterval(time)
296
+ // }
297
+ // }, 500)
298
+ }
299
+ },
300
+ getBolb () {
301
+ this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
302
+ fileInOssPath: this.url,
303
+ templateId: ''
304
+ }).then(res => {
305
+ if (res.data.code == 0) {
306
+ this.fileText = res.data.data
307
+ this.loading = false
308
+ }
309
+ })
310
+ },
311
+ previewToDialog (flag) {
312
+ this.$emit('previewToDialog', flag)
313
+ },
314
+ closeSummary () {
315
+ this.showSummary = false;
316
+ },
317
+ recommendQues (item, knowledgeId) {
318
+ console.log('recommendQues', item, knowledgeId);
319
+ this.$emit('recommendQues', item, knowledgeId)
320
+ },
321
+ handleIframeMessage (res) {
322
+ console.log('handleIframeMessage', res)
323
+ if (res.data.type == 'getViewerHeight') {
324
+ let iframeHeight = this.iframeHeight.replace('px', '')
325
+ if (res.data.data && iframeHeight != (res.data.data + 50)) {
326
+ this.iframeHeight = res.data.data + 50 + 'px'
327
+ }
328
+ }
329
+ },
330
+ summaryFun () {
331
+ this.showSummary = !this.showSummary;
332
+ if (this.showSummary) {
333
+ document.getElementById('drawer_content_pre').scrollTop = 0;
334
+ }
335
+ },
336
+ getSummarySuccess () {
337
+ this.$nextTick(() => {
338
+ // if (this.tagIds.length > 0){
339
+ // let intelligentSummary = document.getElementById('intelligentSummary');
340
+ // let preCon = document.querySelector('.pdf_view')
341
+ // if (intelligentSummary){
342
+ // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
343
+ // if (preCon){
344
+ // preCon.style.height = 'calc(100% - ' + height + 'px)'
345
+ // }
346
+ // console.log('height',height,preCon)
347
+ // }
348
+ // }
349
+ // let intelligentSummary = document.getElementById('intelligentSummary');
350
+ // let height = intelligentSummary.offsetHeight
351
+ // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
352
+ })
353
+ },
354
+ getTextWatermark () {
355
+ let url = '/knowledge-api/open/knowledge/getPermissionInfo';
356
+ let obj = {
357
+ "knowledgeId": this.knowledgeId,
358
+ "userId": sessionStorage.getItem('_currentUserId'),
359
+ "mainId": sessionStorage.getItem('_mainId'),
360
+ "corpId": sessionStorage.getItem('_corpid')
361
+ }
362
+ this.$http.post(url, obj).then(res => {
363
+ console.log('getTextWatermark', res.data.data)
364
+ if (res.data.data) {
365
+ this.textWatermarkStr = res.data.data.textWatermarkStr;
366
+ this.isDownload = res.data.data.showDownloadBtn;
367
+ }
368
+ })
369
+ },
370
+ downLoad () {
371
+ let url = this.previewOssPath
372
+ if (decodeURIComponent(url) != url) {
373
+ url = decodeURIComponent(url)
374
+ }
375
+ const fileType = url.substring(url.lastIndexOf('.'));
376
+ this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
377
+ headers: {
378
+ "Content-Type": "application/json",
379
+ }
380
+ }).then(res => {
381
+ console.log('downLoad 341', res)
382
+ if (res.data || res.bodyText) {
383
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
384
+ this.copy = res.data
385
+ if (isMobile()) {
386
+ setTimeout(() =>{
387
+ const range = document.createRange();
388
+ range.selectNode(document.getElementById('text'));
389
+ const selection = window.getSelection();
390
+ //移除之前选中内容
391
+ if (selection.rangeCount > 0) selection.removeAllRanges();
392
+ selection.addRange(range);
393
+ document.execCommand('copy');
394
+ selection.removeAllRanges()
395
+ Toast(this.$t('dragonCommon.Safaridownload'));
396
+ this.close()
397
+ },100)
398
+ } else {
399
+ let a = document.createElement('a')
400
+ a.href = res.data
401
+ a.download = (this.title) + fileType
402
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
403
+ }
404
+ return
405
+ } else {
406
+ // setTimeout(() =>{
407
+ // window.open(res.data,'下载', 'noopener')
408
+ // }, 2000)
409
+ // window.open(res.data,'下载', 'noopener')
410
+ if (isMobile()) {
411
+ const iframe = document.createElement("iframe");
412
+ iframe.setAttribute("hidden", "hidden");
413
+ iframe.onload = () => {
414
+ if (iframe) {
415
+ console.log("iframe onload....")
416
+ iframe.setAttribute('src', 'about:blank');
417
+ }
418
+ };
419
+ document.body.insertBefore(iframe, null);
420
+ iframe.setAttribute("src", res.data);
421
+ } else {
422
+ let a = document.createElement('a')
423
+ a.href = res.data
424
+ a.download = (this.title) + fileType
425
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
426
+ }
427
+ this.close()
428
+ }
429
+ }
430
+ })
431
+ },
432
+ isPcFun () {
433
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
434
+ this.isPc = false
435
+ } else {
436
+ this.isPc = true
437
+ }
438
+ },
439
+ clickFloder() {
440
+ this.$emit('previewClickFloder')
441
+ }},
442
+ beforeDestroy () {
443
+ window.removeEventListener('message', this.handleIframeMessage);
444
+ }
445
+ }
446
+ </script>
447
+
448
+ <style lang="less" scoped>
449
+ #drawer_content_pre {
450
+ padding: 20px;
451
+ scroll-behavior: smooth;
452
+
453
+ .mobile_onload_btn {
454
+ position: absolute;
455
+ right: 0;
456
+ bottom: 10%;
457
+ width: 20px;
458
+ height: 60px;
459
+ display: flex;
460
+ align-items: center;
461
+ justify-content: center;
462
+ cursor: pointer;
463
+ border-top-left-radius: 10px;
464
+ border-bottom-left-radius: 10px;
465
+ color: #366aff;
466
+ background: #ffffff;
467
+ border: 1px solid #a1b9ff;
468
+ font-size: 12px;
469
+ border-right: none;
470
+ text-align: center;
471
+ }
472
+
473
+ .pdf_positon {
474
+ width: 100%;
475
+ box-sizing: border-box;
476
+ }
477
+ }
478
+
479
+ .onload_btn {
480
+ width: 76px;
481
+ height: 26px;
482
+ display: flex;
483
+ align-items: center;
484
+ justify-content: center;
485
+ cursor: pointer;
486
+ margin-right: 10px;
487
+ border-radius: 15px;
488
+ color: #366aff;
489
+ background: #ffffff;
490
+ border: 1px solid #a1b9ff;
491
+ box-sizing: border-box;
492
+ }
493
+
494
+ .preview_iframe {
495
+ width: 100%;
496
+ height: 100%;
497
+ box-sizing: border-box;
498
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
499
+ background-position: center;
500
+ background-size: 50px;
501
+ background-repeat: no-repeat;
502
+ }
503
+
504
+ .preview_iframe_kk {
505
+ width: 100%;
506
+ height: 100%;
507
+ }
508
+
509
+ .preview_iframe_html {
510
+ width: 100%;
511
+ height: 100%;
512
+ overflow-y: scroll;
513
+ text-align: left;
514
+ box-sizing: border-box;
515
+ padding: 16px;
516
+
517
+ /deep/.lake-content {
518
+ margin-left: 10px;
519
+ }
520
+
521
+ /deep/a:link {
522
+ color: #0000ee !important;
523
+ }
524
+
525
+ /deep/a:visited {
526
+ color: #0000ee !important;
527
+ }
528
+
529
+ /deep/a:hover {
530
+ color: #0000ee !important;
531
+ }
532
+
533
+ /deep/a:active {
534
+ color: #0000ee !important;
535
+ }
536
+
537
+ /deep/li:not(.rich-text-li),
538
+ ol:not(.list-paddingleft-2),
539
+ ul:not(.list-paddingleft-2) {
540
+ list-style-type: auto !important;
541
+ }
542
+
543
+ /deep/img {
544
+ width: 100%;
545
+ }
546
+
547
+ /deep/.ne-table {
548
+ width: 100% !important;
549
+ }
550
+ }
551
+
552
+ .footer {
553
+ width: calc(100% - 40px);
554
+ height: 50px;
555
+ display: flex;
556
+ align-items: center;
557
+ justify-content: space-between;
558
+ cursor: pointer;
559
+ padding: 0 20px;
560
+ border-bottom: 1px solid #cccccc;
561
+ }
562
+
563
+ .loading_img {
564
+ display: flex;
565
+ align-items: center;
566
+ justify-content: center;
567
+ width: 100%;
568
+ height: 100%;
569
+ position: absolute;
570
+ top: 0;
571
+ left: 0;
572
+ background: #FFF;
573
+
574
+ img {
575
+ width: 50px;
576
+ height: 50px;
577
+ }
578
+ }
579
+
580
+ .libang_head {
581
+ height: 64px !important;
582
+ }
583
+
584
+ .drawer-header {
585
+ width: 100%;
586
+ height: 50px;
587
+ cursor: pointer;
588
+ padding: 6px 20px;
589
+ border-bottom: 1px solid #cccccc;
590
+ .btn_position {
591
+ position: absolute;
592
+ top: -34px;
593
+ left: 12px;
594
+ }
595
+
596
+ .header-btn {
597
+ display: flex;
598
+ align-items: center;
599
+ justify-content: space-between;
600
+
601
+ .header-right {
602
+ display: flex;
603
+ }
604
+ .summaryBtn {
605
+ flex: none;
606
+ //width: 95px;
607
+ height: 26px;
608
+ padding: 0 8px;
609
+ background: #ffffff;
610
+ display: flex;
611
+ align-items: center;
612
+ justify-content: center;
613
+ box-sizing: border-box;
614
+ border: 1px solid #a1b9ff;
615
+ border-radius: 15px;
616
+ cursor: pointer;
617
+ color: #366aff;
618
+ margin-right: 10px;
619
+ font-size: 14px;
620
+
621
+ i {
622
+ font-size: 14px;
623
+ margin-right: 5px;
624
+ }
625
+ }
626
+
627
+ .summaryActiveBtn {
628
+ background: #366aff !important;
629
+ color: #ffffff !important;
630
+ }
631
+
632
+ .chat {
633
+ flex: none;
634
+ height: 26px;
635
+ padding: 0 8px;
636
+ background: #ffffff;
637
+ display: flex;
638
+ align-items: center;
639
+ justify-content: center;
640
+ box-sizing: border-box;
641
+ border: 1px solid #a1b9ff;
642
+ border-radius: 15px 0px 15px 15px;
643
+ cursor: pointer;
644
+ color: #366aff;
645
+ margin-right: 10px;
646
+ font-size: 14px;
647
+
648
+ i {
649
+ font-size: 14px;
650
+ margin-right: 5px;
651
+ margin-top: 2px;
652
+ }
653
+ }
654
+
655
+ .chat_active {
656
+ background: #366aff !important;
657
+ color: #FFFFFF !important;
658
+ }
659
+ }
660
+
661
+ .header_title {
662
+ font-size: 14px;
663
+ height: 100%;
664
+ .header_close {
665
+ display: flex;
666
+ align-items: center;
667
+ justify-content: space-between;
668
+ line-height: 26px;
669
+ .title_left {
670
+ white-space: nowrap; /* 确保文本不会换行 */
671
+ overflow: hidden; /* 隐藏超出容器的文本 */
672
+ text-overflow: ellipsis; /* 当文本超出容器时显示省略号 */
673
+ margin-right: 8px;
674
+ }
675
+ }
676
+ .header_floder {
677
+ display: flex;
678
+ align-items: center;
679
+ line-height: 26px;
680
+ i {
681
+ margin: 0 5px;
682
+ color: #366aff;
683
+ }
684
+ }
685
+ .header_top {
686
+ height: 100%;
687
+ display: flex;
688
+ align-items: center;
689
+ justify-content: space-between;
690
+ }
691
+ }
692
+ }
693
+
694
+ @media screen and (max-width: 767px) {
695
+
696
+ /* 这里是针对移动设备的css样式设置 */
697
+ /deep/.el-drawer__body {
698
+ height: 100%;
699
+ }
700
+
701
+ #drawer_content_pre {
702
+ overflow: auto;
703
+ height: calc(100% - 50px);
704
+ background: #FFF;
705
+ background-image: url('https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif');
706
+ background-position: center;
707
+ background-size: 50px;
708
+ background-repeat: no-repeat;
709
+ }
710
+
711
+ .libang_content_pre {
712
+ height: calc(100% - 64px) !important;
713
+ }
714
+ }
715
+
716
+ @media screen and (min-width: 768px) {
717
+
718
+ /* 这里是针对pc设备的css样式设置 */
719
+ /deep/.el-drawer__body {
720
+ height: 100%;
721
+ }
722
+
723
+ #drawer_content_pre {
724
+ overflow: auto;
725
+ height: calc(100% - 50px);
726
+ background: #FFF;
727
+ }
728
+
729
+ .libang_content_pre {
730
+ height: calc(100% - 64px) !important;
731
+ }
732
+ }
733
+
734
+ @media screen and (min-width: 1200px) {
735
+
736
+ /* 这里是针对pc设备的css样式设置 */
737
+ .el-drawer__wrapper {
738
+ width: 55%;
739
+ left: calc(100vw - 55%);
740
+ right: 0;
741
+
742
+ /deep/.pdf-preview-drawer {
743
+ width: 100% !important;
744
+ }
745
+ }
746
+
747
+ /deep/.el-drawer__body {
748
+ height: 100%;
749
+ }
750
+
751
+ #drawer_content_pre {
752
+ overflow: auto;
753
+ height: calc(100% - 50px);
754
+ background: #FFF;
755
+ }
756
+
757
+ .libang_content_pre {
758
+ height: calc(100% - 64px) !important;
759
+ }
760
+ }
761
+ </style>
762
+ <style lang="less">
763
+ .pdf-preview-drawer {
764
+ overflow: visible !important;
765
+ }
766
+ .libang_content_pre {
767
+ .change_scale {
768
+ top: 64px !important;
769
+ }
770
+ .float_intelligentSummary {
771
+ top: 74px !important;
772
+ }
773
+ }
774
+ </style>