askbot-dragon 1.7.54-beta → 1.7.56-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.
@@ -5,11 +5,29 @@
5
5
  另外增加了在知识项目中预览当前文件的一些功能
6
6
  -->
7
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%'"
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
10
  custom-class="pdf-preview-drawer" v-if="drawer">
11
- <!-- v-else-if="drawer" -->
12
- <div class="drawer-header" :class="(isDownload || isHasChat) && isLiBang ? 'has_btn_libang_head' : (isLiBang ? 'libang_head' : (isDownload || isHasChat ? 'has_btn_head' : ''))" v-if="!isPc">
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>
13
31
  <div class="header_title">
14
32
  <template v-if="isDownload || isHasChat">
15
33
  <div class="top-header">
@@ -37,7 +55,7 @@
37
55
  </section>
38
56
  </div>
39
57
  <span class="title_left">
40
- {{ title ? title : "查看详情" }}
58
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
41
59
  </span>
42
60
  </template>
43
61
  <div class="header_close" v-else>
@@ -59,25 +77,25 @@
59
77
  <div class="header_title">
60
78
  <div :class="isLiBang && folderName ? 'header_close' : 'header_top'">
61
79
  <span class="title_left">
62
- {{ title ? title : "查看详情" }}
80
+ {{ title ? title : $t('dragonCommon.viewDetails') }}
63
81
  </span>
64
82
  <div class="header-btn">
65
83
  <div class="onload_btn" v-if="isDownload" @click="downLoad">
66
- 下载
84
+ {{ $t('dragonCommon.download') }}
67
85
  </div>
68
86
  <div class="summaryBtn" :class="showSummary ? 'summaryActiveBtn' : ''" @click="summaryFun"
69
87
  v-if="isHasChat || formKnowledgeManagement">
70
88
  <i class="iconfont guoran-tongyichicun-write-29-jiqiren"></i>
71
- <span>智能摘要</span>
89
+ <span>{{ $t('dragonCommon.smartSummary') }}</span>
72
90
  </div>
73
91
  <template v-if="isHasChat">
74
92
  <div class="chat" @click="previewToDialog(true)" v-if="!previewKnowledgeId">
75
93
  <i class="iconfont guoran-wendapingjia"></i>
76
- 聊一聊
94
+ {{ $t('dragonCommon.chat') }}
77
95
  </div>
78
96
  <div class="chat chat_active" @click="previewToDialog(false)" v-else>
79
97
  <i class="iconfont guoran-wendapingjia"></i>
80
- 聊一聊
98
+ {{ $t('dragonCommon.chat') }}
81
99
  </div>
82
100
  </template>
83
101
  <section @click="close">
@@ -93,12 +111,7 @@
93
111
  </div>
94
112
  </div>
95
113
  <div id="drawer_content_pre" :class="isLiBang && folderName ? 'libang_content_pre' : ''">
96
- <!-- :style="{marginTop:tagIds && tagIds.length != 0 && isPc ? '50px' : ''}" -->
97
- <intelligent-summary
98
- v-show="showSummary && (isHasChat || formKnowledgeManagement) && fileType !== 'VIDEO' && fileType !== 'IMAGE'"
99
- :tagIds="tagIds"
100
- :knowledgeId="knowledgeId"
101
- :formKnowledgeManagement="formKnowledgeManagement"
114
+ <intelligent-summary v-show="showSummary && isHasChat" :tagIds="tagIds" :knowledgeId="knowledgeId"
102
115
  @closeSummary="closeSummary" @recommendQues="recommendQues"
103
116
  @getSummarySuccess="getSummarySuccess"></intelligent-summary>
104
117
  <div class="pdf_positon" :style="pdfStyle" v-if="tagIds && tagIds.length != 0 && drawer && newVersion === false && newFileType !== 'PPT'">
@@ -117,7 +130,7 @@
117
130
  <video :src="url" controls width="100%;" height="98%"></video>
118
131
  </div>
119
132
  <div v-else-if="fileType == 'HTML'" style="width: 100%;">
120
- <div class="preview_iframe_html" style="text-algin:left" v-html="fileText"></div>
133
+ <div class="preview_iframe_html" style="text-align:left" v-html="fileText"></div>
121
134
  </div>
122
135
  <template v-else-if="url.includes('https://www') || url.includes('http://www')">
123
136
  <iframe class="preview_iframe" :src="url" width="100%" height="100%" scrolling="100%" frameborder="no"
@@ -140,9 +153,6 @@
140
153
  </template>
141
154
  </template>
142
155
  </template>
143
- <!-- <div class="mobile_onload_btn" v-if="isDownload && !isPc" @click="downLoad">
144
- 下载
145
- </div> -->
146
156
  </div>
147
157
  <div class="loading_img" v-show="loading">
148
158
  <img src="https://guoranopen-zjk.oss-cn-zhangjiakou.aliyuncs.com/cdn-common/images/loading.gif" alt="">
@@ -161,96 +171,97 @@ import { isMobile } from "../assets/js/common";
161
171
  import { Toast } from 'vant';
162
172
  import NewPositionPreview from "./preview/newPositionPreview";
163
173
  export default {
164
- data () {
174
+ data() {
165
175
  return {
166
- previewShowPopup: false,
167
- fileText: '',
168
- fileType: "",
169
- isPc: false,
170
- drawer: false,
171
- tagIds: [],
172
- // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
173
- loading: true,
174
- fileName:'',
175
- previewKnowledgeId:"",
176
- showSummary:false,
177
- iframeHeight:"100%",
178
- isDownload: false,
179
- textWatermarkStr:"",
180
- copy:'',
181
- newVersion:'',
182
- previewHref:"",
183
- newFileType:"",
184
- numberPage:0,
185
- pageChunkData:[],
186
- currentPage:0
176
+ previewShowPopup: false,
177
+ fileText: '',
178
+ fileType: "",
179
+ isPc: false,
180
+ drawer: false,
181
+ tagIds: [],
182
+ // '6454aa1a70573a6ead6f0f7d', '6454aa1a70573a6ead6f0f81',
183
+ loading: true,
184
+ fileName: '',
185
+ previewKnowledgeId: "",
186
+ showSummary: false,
187
+ iframeHeight: "100%",
188
+ isDownload: false,
189
+ textWatermarkStr: "",
190
+ copy: '',
191
+ newVersion: '',
192
+ previewHref: "",
193
+ newFileType: "",
194
+ numberPage: 0,
195
+ pageChunkData: [],
196
+ currentPage: 0
187
197
  }
188
- },
198
+ },
189
199
  mounted() {
190
- window.addEventListener('message',this.handleIframeMessage,false);
200
+ this.$i18n.locale = sessionStorage.getItem("systemLanguage") || 'cn';
201
+ window.addEventListener('message', this.handleIframeMessage, false);
191
202
  this.isPcFun();
192
203
  },
193
- props:{
194
- url:{
195
- type: String,
196
- required: true,
197
- },
198
- officePreviewType:{
199
- type: String,
200
- default: ''
201
- },
202
- isMessageRecord:{
203
- type: Boolean,
204
- default:false,
205
- },
206
- sourceFileType:{
207
- type: String,
208
- default: '',
209
- },
210
- title: {
211
- type: String,
212
- default: ''
213
- },
214
- isHasChat:{
215
- type:Boolean,
216
- default:false
217
- },
218
- knowledgeId:{
219
- type: String,
220
- default: '',
221
- },
222
- previewOssPath:{
223
- type: String,
224
- default: '',
225
- },
226
- folderName: {
227
- type: String,
228
- default: '',
229
- },
230
- folderUrl: {
231
- type: String,
232
- default: '',
204
+ props: {
205
+ url: {
206
+ type: String,
207
+ required: true,
208
+ },
209
+ officePreviewType: {
210
+ type: String,
211
+ default: ''
212
+ },
213
+ isMessageRecord: {
214
+ type: Boolean,
215
+ default: false,
216
+ },
217
+ sourceFileType: {
218
+ type: String,
219
+ default: '',
220
+ },
221
+ title: {
222
+ type: String,
223
+ default: ''
224
+ },
225
+ isHasChat: {
226
+ type: Boolean,
227
+ default: false
228
+ },
229
+ knowledgeId: {
230
+ type: String,
231
+ default: '',
232
+ },
233
+ previewOssPath: {
234
+ type: String,
235
+ default: '',
236
+ },
237
+ folderName: {
238
+ type: String,
239
+ default: '',
240
+ },
241
+ folderUrl: {
242
+ type: String,
243
+ default: '',
244
+ },
245
+ isLiBang: {
246
+ type: Boolean,
247
+ default: false
248
+ },
249
+ formKnowledgeManagement: {
250
+ type: Boolean,
251
+ default: false
252
+ }
233
253
  },
234
- isLiBang: {
235
- type: Boolean,
236
- default: false
254
+ components: {
255
+ NewPositionPreview,
256
+ IntelligentSummary,
257
+ pdfPosition
237
258
  },
238
- formKnowledgeManagement:{
239
- type: Boolean,
240
- default: false
241
- }
242
- },
243
- components: {
244
- NewPositionPreview,
245
- IntelligentSummary,
246
- pdfPosition
247
- },
248
- watch: {
249
- drawer (value) {
250
- if (value) {
251
- this.$emit('open')
252
- this.$nextTick(() => {
253
- if (this.tagIds && this.tagIds.length != 0){
259
+ watch: {
260
+ drawer(value) {
261
+ if (value) {
262
+ this.$emit('open')
263
+ this.$nextTick(() => {
264
+ if (this.tagIds && this.tagIds.length != 0) {
254
265
  zoomElement(document.getElementById('pdf_container_view'))
255
266
  }
256
267
  })
@@ -259,16 +270,16 @@ export default {
259
270
  }
260
271
  setTimeout(() => {
261
272
  let previewIframe = document.getElementsByClassName('preview_iframe')
262
- Array.from(previewIframe).forEach(item =>{
263
- item.onload = () =>{
264
- console.debug('previewIframe 106',previewIframe,this.drawer)
273
+ Array.from(previewIframe).forEach(item => {
274
+ item.onload = () => {
275
+ console.debug('previewIframe 106', previewIframe, this.drawer)
265
276
  item.style.backgroundImage = 'none'
266
277
  }
267
278
  })
268
279
  })
269
280
  },
270
- showSummary:{
271
- handler(val){
281
+ showSummary: {
282
+ handler(val) {
272
283
  // if (!val){
273
284
  // this.$nextTick(() => {
274
285
  // let preCon = document.querySelector('.pdf_view');
@@ -279,352 +290,352 @@ export default {
279
290
  // } else {
280
291
  // this.getSummarySuccess();
281
292
  // }
282
- if(val) {
293
+ if (val) {
283
294
  this.getSummarySuccess();
284
295
  }
285
296
  }
286
297
  },
287
- knowledgeId:{
288
- handler(val){
289
- if (val){
298
+ knowledgeId: {
299
+ handler(val) {
300
+ if (val) {
290
301
  this.getTextWatermark();
291
302
  }
292
303
  }
293
304
  }
294
305
  },
295
- computed:{
296
- pdfStyle() {
297
- return {
298
- paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
299
- paddingBottom: this.tagIds > 1 ? '60px' : '0',
300
- height: '100%'
301
- }
302
- },
303
- previewUrl() {
304
- console.debug('VUE_APP_ENV',process.env.VUE_APP_ENV)
305
- let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
306
- // if(this.url != '') {
307
- // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
308
- // url += btoa(encodeURIComponent(this.url))
309
- // } else {
310
- // url += btoa(this.url)
311
- // }
312
- // }
313
- url = url + this.url
314
- url += '&officePreviewType=pdf'
315
- if(this.watermark) {
316
- url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
317
- url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
318
- }
319
- console.log('textWatermarkStr 216', this.textWatermarkStr)
320
- if (this.textWatermarkStr) {
321
- url += '&textWatermarkValue=' + this.textWatermarkStr
322
- }
323
- return url
324
- },
325
- // fileType() {
326
- // const fileType = this.url.substring(this.url.lastIndexOf('.'));
327
- // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
328
- // return 'VIDEO'
329
- // } else {
330
- // return 'OTHER'
331
- // }
306
+ computed: {
307
+ pdfStyle() {
308
+ return {
309
+ paddingTop: this.isPc ? '30px' : '0', // 30px 是 加上外层的 20 流出 50的上边距展示 放大缩小操作栏
310
+ paddingBottom: this.tagIds > 1 ? '60px' : '0',
311
+ height: '100%'
312
+ }
313
+ },
314
+ previewUrl() {
315
+ console.debug('VUE_APP_ENV', process.env.VUE_APP_ENV)
316
+ let url = process.env.VUE_APP_ENV === 'production' ? 'https://kkfileview.askbot.cn/onlinePreview?url=' : 'https://test.open.askbot.cn/kkfileview/onlinePreview?url='
317
+ // if(this.url != '') {
318
+ // if(/[\u4E00-\u9FA5]+/g.test(this.url)) {
319
+ // url += btoa(encodeURIComponent(this.url))
320
+ // } else {
321
+ // url += btoa(this.url)
322
+ // }
323
+ // }
324
+ url = url + this.url
325
+ url += '&officePreviewType=pdf'
326
+ if (this.watermark) {
327
+ url = this.watermark.textWatermarkValue ? (url += '&textWatermarkValue=' + this.watermark.textWatermarkValue) : url
328
+ url = this.watermark.visitorWatermarkValue ? (url += '&visitorWatermarkValue=' + this.watermark.visitorWatermarkValue) : url
329
+ }
330
+ console.log('textWatermarkStr 216', this.textWatermarkStr)
331
+ if (this.textWatermarkStr) {
332
+ url += '&textWatermarkValue=' + this.textWatermarkStr
333
+ }
334
+ return url
335
+ },
336
+ // fileType() {
337
+ // const fileType = this.url.substring(this.url.lastIndexOf('.'));
338
+ // if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.mov') {
339
+ // return 'VIDEO'
340
+ // } else {
341
+ // return 'OTHER'
342
+ // }
332
343
 
333
- // }
334
- },
335
- methods: {
336
- close () {
337
- setTimeout(() => {
338
- this.previewShowPopup = false;
339
- this.fileType = ''
340
- }, 300)
341
- this.drawer = false;
342
- this.showSummary = false;
344
+ // }
343
345
  },
344
- loadIframe () {
346
+ methods: {
347
+ close() {
348
+ setTimeout(() => {
349
+ this.previewShowPopup = false;
350
+ this.fileType = ''
351
+ }, 300)
352
+ this.drawer = false;
353
+ this.showSummary = false;
354
+ },
355
+ loadIframe() {
345
356
 
346
- if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
347
- this.loading = false
348
- } else {
349
- let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
350
- if (iframe) {
351
- iframe.onload = () => {
352
- this.loading = false;
353
- document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
357
+ if (this.fileType == 'VIDEO' || this.fileType == 'WECHAT' || (this.tagIds && this.tagIds.length != 0 && this.newFileType !== 'PPT')) {
358
+ this.loading = false
359
+ } else {
360
+ let iframe = document.getElementsByClassName('preview_iframe')[0] || document.getElementsByClassName('preview_iframe_kk')[0];
361
+ if (iframe) {
362
+ iframe.onload = () => {
363
+ this.loading = false;
364
+ document.getElementById('drawer_content_pre').style.backgroundImage = 'none'
365
+ }
354
366
  }
367
+ // let time = setInterval(() =>{
368
+ //
369
+ // if(iframe) {
370
+ // this.loading = false
371
+ // clearInterval(time)
372
+ // }
373
+ // }, 500)
355
374
  }
356
- // let time = setInterval(() =>{
357
- //
358
- // if(iframe) {
359
- // this.loading = false
360
- // clearInterval(time)
361
- // }
362
- // }, 500)
363
- }
364
- },
365
- getBolb () {
366
- this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
367
- fileInOssPath: this.url,
368
- templateId: ''
369
- }).then(res => {
370
- if (res.data.code == 0) {
371
- this.fileText = res.data.data
372
- this.loading = false
375
+ },
376
+ getBolb() {
377
+ this.$http.post('/knowledge-api/knowledge/htmlTextDeal?onlyText=false', {
378
+ fileInOssPath: this.url,
379
+ templateId: ''
380
+ }).then(res => {
381
+ if (res.data.code == 0) {
382
+ this.fileText = res.data.data
383
+ this.loading = false
384
+ }
385
+ })
386
+ },
387
+ previewToDialog(flag) {
388
+ this.$emit('previewToDialog', flag)
389
+ },
390
+ closeSummary() {
391
+ this.showSummary = false;
392
+ },
393
+ recommendQues(item, knowledgeId) {
394
+ console.log('recommendQues', item, knowledgeId);
395
+ this.$emit('recommendQues', item, knowledgeId)
396
+ },
397
+ handleIframeMessage(res) {
398
+ if (res.data.type == 'getViewerHeight') {
399
+ let iframeHeight = this.iframeHeight.replace('px', '')
400
+ if (res.data.data && iframeHeight != (res.data.data + 50)) {
401
+ this.iframeHeight = res.data.data + 50 + 'px'
402
+ }
373
403
  }
374
- })
375
- },
376
- previewToDialog (flag) {
377
- this.$emit('previewToDialog', flag)
378
- },
379
- closeSummary () {
380
- this.showSummary = false;
381
- },
382
- recommendQues (item, knowledgeId) {
383
- console.log('recommendQues', item, knowledgeId);
384
- this.$emit('recommendQues', item, knowledgeId)
385
- },
386
- handleIframeMessage (res) {
387
- if (res.data.type == 'getViewerHeight') {
388
- let iframeHeight = this.iframeHeight.replace('px', '')
389
- if (res.data.data && iframeHeight != (res.data.data + 50)) {
390
- this.iframeHeight = res.data.data + 50 + 'px'
404
+ if (res.data.type == 'getViewPage' && res.data.data) {
405
+ this.numberPage = Number(res.data.data);
406
+ if (this.pageChunkData.length > 0) {
407
+ this.scrollPPTPage(this.pageChunkData[0])
408
+ }
391
409
  }
392
- }
393
- if (res.data.type == 'getViewPage' && res.data.data){
394
- this.numberPage = Number(res.data.data);
395
- if (this.pageChunkData.length > 0){
396
- this.scrollPPTPage(this.pageChunkData[0])
410
+ if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage') {
411
+ if (this.pageChunkData.length > 0) {
412
+ this.scrollPPTPage(this.pageChunkData[0])
413
+ }
397
414
  }
398
- }
399
- if (res.data.type == 'getViewerHeight' || res.data.type == 'getViewPage'){
400
- if (this.pageChunkData.length > 0){
401
- this.scrollPPTPage(this.pageChunkData[0])
415
+ },
416
+ summaryFun() {
417
+ this.showSummary = !this.showSummary;
418
+ if (this.showSummary) {
419
+ document.getElementById('drawer_content_pre').scrollTop = 0;
402
420
  }
403
- }
404
- },
405
- summaryFun () {
406
- this.showSummary = !this.showSummary;
407
- if (this.showSummary) {
408
- document.getElementById('drawer_content_pre').scrollTop = 0;
409
- }
410
- },
411
- getSummarySuccess () {
412
- this.$nextTick(() => {
413
- // if (this.tagIds.length > 0){
414
- // let intelligentSummary = document.getElementById('intelligentSummary');
415
- // let preCon = document.querySelector('.pdf_view')
416
- // if (intelligentSummary){
417
- // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
418
- // if (preCon){
419
- // preCon.style.height = 'calc(100% - ' + height + 'px)'
420
- // }
421
- // console.log('height',height,preCon)
422
- // }
423
- // }
424
- // let intelligentSummary = document.getElementById('intelligentSummary');
425
- // let height = intelligentSummary.offsetHeight
426
- // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
427
- })
428
- },
429
- getTextWatermark () {
430
- let url = '/knowledge-api/open/knowledge/getPermissionInfo';
431
- let obj = {
432
- "knowledgeId": this.knowledgeId,
433
- "userId": sessionStorage.getItem('_currentUserId'),
434
- "mainId": sessionStorage.getItem('_mainId'),
435
- "corpId": sessionStorage.getItem('_corpid')
436
- }
437
- this.$http.post(url, obj).then(res => {
438
- console.log('getTextWatermark', res.data.data)
439
- if (res.data.data) {
440
- this.textWatermarkStr = res.data.data.textWatermarkStr;
441
- this.isDownload = res.data.data.showDownloadBtn;
421
+ },
422
+ getSummarySuccess() {
423
+ this.$nextTick(() => {
424
+ // if (this.tagIds.length > 0){
425
+ // let intelligentSummary = document.getElementById('intelligentSummary');
426
+ // let preCon = document.querySelector('.pdf_view')
427
+ // if (intelligentSummary){
428
+ // let height = intelligentSummary.offsetHeight + (this.isPc ? 100 : 50 );
429
+ // if (preCon){
430
+ // preCon.style.height = 'calc(100% - ' + height + 'px)'
431
+ // }
432
+ // console.log('height',height,preCon)
433
+ // }
434
+ // }
435
+ // let intelligentSummary = document.getElementById('intelligentSummary');
436
+ // let height = intelligentSummary.offsetHeight
437
+ // this.pdfStyle.height = 'calc(100% - ' + height + 'px)'
438
+ })
439
+ },
440
+ getTextWatermark() {
441
+ let url = '/knowledge-api/open/knowledge/getPermissionInfo';
442
+ let obj = {
443
+ "knowledgeId": this.knowledgeId,
444
+ "userId": sessionStorage.getItem('_currentUserId'),
445
+ "mainId": sessionStorage.getItem('_mainId'),
446
+ "corpId": sessionStorage.getItem('_corpid')
442
447
  }
443
- })
444
- },
445
- downLoad () {
446
- if (this.formKnowledgeManagement){
447
- this.$emit('downLoad',this.previewOssPath);
448
- return
449
- }
450
- let url = this.previewOssPath
451
- if (decodeURIComponent(url) != url) {
452
- url = decodeURIComponent(url)
453
- }
454
- const fileType = url.substring(url.lastIndexOf('.'));
455
- this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
456
- headers: {
457
- "Content-Type": "application/json",
448
+ this.$http.post(url, obj).then(res => {
449
+ console.log('getTextWatermark', res.data.data)
450
+ if (res.data.data) {
451
+ this.textWatermarkStr = res.data.data.textWatermarkStr;
452
+ this.isDownload = res.data.data.showDownloadBtn;
453
+ }
454
+ })
455
+ },
456
+ downLoad() {
457
+ if (this.formKnowledgeManagement) {
458
+ this.$emit('downLoad', this.previewOssPath);
459
+ return
458
460
  }
459
- }).then(res => {
460
- console.log('downLoad 341', res)
461
- if (res.data|| res.bodyText) {
462
- if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
463
- this.copy = res.data
464
- if (isMobile()) {
465
- setTimeout(() =>{
466
- const range = document.createRange();
467
- range.selectNode(document.getElementById('text'));
468
- const selection = window.getSelection();
469
- //移除之前选中内容
470
- if (selection.rangeCount > 0) selection.removeAllRanges();
471
- selection.addRange(range);
472
- document.execCommand('copy');
473
- selection.removeAllRanges()
474
- Toast('下载地址已复制,请前往Safari浏览器访问下载');
475
- this.close()
476
- },100)
461
+ let url = this.previewOssPath
462
+ if (decodeURIComponent(url) != url) {
463
+ url = decodeURIComponent(url)
464
+ }
465
+ const fileType = url.substring(url.lastIndexOf('.'));
466
+ this.$http.post('/knowledge-api/temporary-certificate/or-origin?expired=10', url, {
467
+ headers: {
468
+ "Content-Type": "application/json",
469
+ }
470
+ }).then(res => {
471
+ console.log('downLoad 341', res)
472
+ if (res.data || res.bodyText) {
473
+ if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
474
+ this.copy = res.data
475
+ if (isMobile()) {
476
+ setTimeout(() => {
477
+ const range = document.createRange();
478
+ range.selectNode(document.getElementById('text'));
479
+ const selection = window.getSelection();
480
+ //移除之前选中内容
481
+ if (selection.rangeCount > 0) selection.removeAllRanges();
482
+ selection.addRange(range);
483
+ document.execCommand('copy');
484
+ selection.removeAllRanges()
485
+ Toast(this.$t('dragonCommon.Safaridownload'));
486
+ this.close()
487
+ }, 100)
488
+ } else {
489
+ let a = document.createElement('a')
490
+ a.href = res.data
491
+ a.download = (this.title) + fileType
492
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
493
+ }
494
+ return
477
495
  } else {
478
- let a = document.createElement('a')
479
- a.href = res.data
480
- a.download = (this.title) + fileType
481
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
482
- }
483
- return
484
- } else {
485
- // setTimeout(() =>{
486
- // window.open(res.data,'下载', 'noopener')
487
- // }, 2000)
488
- // window.open(res.data,'下载', 'noopener')
489
- if (isMobile()) {
496
+ // setTimeout(() =>{
497
+ // window.open(res.data,'下载', 'noopener')
498
+ // }, 2000)
499
+ // window.open(res.data,'下载', 'noopener')
500
+ if (isMobile()) {
490
501
 
491
- const iframe = document.createElement("iframe");
492
- iframe.setAttribute("hidden", "hidden");
493
- iframe.onload = () => {
494
- if (iframe) {
495
- console.log("iframe onload....")
496
- iframe.setAttribute('src', 'about:blank');
502
+ const iframe = document.createElement("iframe");
503
+ iframe.setAttribute("hidden", "hidden");
504
+ iframe.onload = () => {
505
+ if (iframe) {
506
+ console.log("iframe onload....")
507
+ iframe.setAttribute('src', 'about:blank');
508
+ }
509
+ };
510
+ document.body.insertBefore(iframe, null);
511
+ iframe.setAttribute("src", res.data);
512
+ } else {
513
+ let a = document.createElement('a')
514
+ a.href = res.data
515
+ a.download = (this.title) + fileType
516
+ a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
497
517
  }
498
- };
499
- document.body.insertBefore(iframe, null);
500
- iframe.setAttribute("src", res.data );
501
- } else {
502
- let a = document.createElement('a')
503
- a.href = res.data
504
- a.download = (this.title) + fileType
505
- a.dispatchEvent(new MouseEvent('click', { bubbles: true, cancelable: true, view: window }))
518
+ this.close()
506
519
  }
507
- this.close()
508
- }
520
+ }
521
+ })
522
+ },
523
+ isPcFun() {
524
+ if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
525
+ this.isPc = false
526
+ } else {
527
+ this.isPc = true
509
528
  }
510
- })
511
- },
512
- isPcFun () {
513
- if (/(iPhone|iPad|iPod|iOS|Android)/i.test(navigator.userAgent)) {
514
- this.isPc = false
515
- } else {
516
- this.isPc = true
517
- }
518
- },
519
- clickFloder() {
520
- this.$emit('previewClickFloder')
521
- },
522
- getOssPath(url){
523
- let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
524
- let type = this.getFileType(url)
525
- this.newFileType = type;
526
- if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
527
- httpUrl += '?needEncrypt=false'
528
- } else {
529
- httpUrl += '?needEncrypt=true'
530
- }
531
- this.$http.post(httpUrl, {
532
- "fileInOssPath": url
533
- }).then(res => {
534
- console.log('getOssPath',res)
535
- if (res.data.code == '0'){
536
- this.previewHref = res.data.data;
529
+ },
530
+ clickFloder() {
531
+ this.$emit('previewClickFloder')
532
+ },
533
+ getOssPath(url) {
534
+ let httpUrl = '/knowledge-api/knowledge/getTemporaryCertificate';
535
+ let type = this.getFileType(url)
536
+ this.newFileType = type;
537
+ if (type === 'VIDEO' || type === 'PDF' || type === 'EXCEL' || type === 'TXT' || type === 'DOC') {
538
+ httpUrl += '?needEncrypt=false'
539
+ } else {
540
+ httpUrl += '?needEncrypt=true'
537
541
  }
538
- })
539
- },
540
- getFileType(url){
541
- let index = url.lastIndexOf('?')
542
- let newFileInOssPath = url.substring(0, url.indexOf("?"))
543
- if (index == -1){
544
- newFileInOssPath = url
545
- }
546
- const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
547
- if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
548
- return 'VIDEO'
549
- } else if (fileType === '.html') {
550
- return 'HTML'
551
- } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
552
- return 'IMAGE'
553
- } else if (fileType === '.docx' || fileType === '.doc'){
554
- return 'DOC'
555
- } else if (fileType === '.ppt' || fileType === '.pptx'){
556
- return 'PPT'
557
- } else if (fileType === '.pdf'){
558
- return 'PDF'
559
- } else if (fileType === '.txt'){
560
- return 'TXT'
561
- } else {
562
- return 'OTHER'
563
- }
564
- },
565
- //判断是否使用新定位组件
566
- getLocationInfo(){
567
- this.newVersion = "";
568
- this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
569
- console.log('getLocationInfo',res)
570
- this.pageChunkData = [];
571
- if (res.data.code == 0){
572
- if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3'){
573
- this.newVersion = true;
574
- if (this.newFileType !== 'PPT'){
575
- this.loading = false;
576
- }
577
- for (let i=0;i<res.data.data.length;i++){
578
- if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData){
579
- this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
542
+ this.$http.post(httpUrl, {
543
+ "fileInOssPath": url
544
+ }).then(res => {
545
+ console.log('getOssPath', res)
546
+ if (res.data.code == '0') {
547
+ this.previewHref = res.data.data;
548
+ }
549
+ })
550
+ },
551
+ getFileType(url) {
552
+ let index = url.lastIndexOf('?')
553
+ let newFileInOssPath = url.substring(0, url.indexOf("?"))
554
+ if (index == -1) {
555
+ newFileInOssPath = url
556
+ }
557
+ const fileType = newFileInOssPath.substring(newFileInOssPath.lastIndexOf('.'));
558
+ if (fileType === '.mp4' || fileType === '.MP4' || fileType === '.MOV' || fileType === '.MOVC' || fileType === '.mov' || fileType === '.movc') {
559
+ return 'VIDEO'
560
+ } else if (fileType === '.html') {
561
+ return 'HTML'
562
+ } else if (fileType === '.png' || fileType === '.jpg' || fileType === '.jpeg' || fileType === '.PNG' || fileType === '.JPG' || fileType === '.JPEG') {
563
+ return 'IMAGE'
564
+ } else if (fileType === '.docx' || fileType === '.doc') {
565
+ return 'DOC'
566
+ } else if (fileType === '.ppt' || fileType === '.pptx') {
567
+ return 'PPT'
568
+ } else if (fileType === '.pdf') {
569
+ return 'PDF'
570
+ } else if (fileType === '.txt') {
571
+ return 'TXT'
572
+ } else {
573
+ return 'OTHER'
574
+ }
575
+ },
576
+ //判断是否使用新定位组件
577
+ getLocationInfo() {
578
+ this.newVersion = "";
579
+ this.$http.get('/knowledge-api/knowledge/knowledge-part-location-info/list?ids=' + this.tagIds.join(',')).then(res => {
580
+ console.log('getLocationInfo', res)
581
+ this.pageChunkData = [];
582
+ if (res.data.code == 0) {
583
+ if (res.data.data && res.data.data.length > 0 && res.data.data[0].extractVersion == 'v3') {
584
+ this.newVersion = true;
585
+ if (this.newFileType !== 'PPT') {
586
+ this.loading = false;
580
587
  }
581
- }
582
- if (this.pageChunkData.length > 1){
583
- let iframe = document.getElementsByClassName('preview_iframe_kk')
584
- if (iframe && iframe.length > 0){
585
- iframe[0].style.paddingBottom = '50px'
588
+ for (let i = 0; i < res.data.data.length; i++) {
589
+ if (res.data.data[i].paragraphChunkInfo && res.data.data[i].paragraphChunkInfo.pageChunkData) {
590
+ this.pageChunkData.push(res.data.data[i].paragraphChunkInfo.pageChunkData.page_number)
591
+ }
592
+ }
593
+ if (this.pageChunkData.length > 1) {
594
+ let iframe = document.getElementsByClassName('preview_iframe_kk')
595
+ if (iframe && iframe.length > 0) {
596
+ iframe[0].style.paddingBottom = '50px'
597
+ }
586
598
  }
599
+ } else {
600
+ this.newVersion = false;
587
601
  }
588
- } else {
589
- this.newVersion = false;
590
602
  }
603
+ })
604
+ },
605
+ currentChange(value) {
606
+ this.currentPage = value - 1;
607
+ this.scrollPPTPage()
608
+ },
609
+ prev() {
610
+ if (this.currentPage == 0) {
611
+ return
591
612
  }
592
- })
593
- },
594
- currentChange (value) {
595
- this.currentPage = value - 1;
596
- this.scrollPPTPage()
597
- },
598
- prev(){
599
- if (this.currentPage == 0){
600
- return
601
- }
602
- this.currentPage--;
603
- this.scrollPPTPage()
604
- },
605
- next(){
606
- if (this.currentPage === (this.pageChunkData.length - 1)){
607
- return;
608
- }
609
- this.currentPage++;
610
- this.scrollPPTPage()
611
- },
612
- scrollPPTPage(){
613
- if (this.numberPage > 0){
614
- let pageNumber = this.pageChunkData[this.currentPage];
615
- let height = Math.floor(Number(this.iframeHeight.replace('px',"")));
616
- let pageHeight = Math.floor(height / this.numberPage);
617
- let scrollHeight = (pageNumber - 1) * pageHeight;
618
- let dom = document.getElementById('drawer_content_pre');
619
- if (dom){
620
- dom.scrollTo(0,scrollHeight)
613
+ this.currentPage--;
614
+ this.scrollPPTPage()
615
+ },
616
+ next() {
617
+ if (this.currentPage === (this.pageChunkData.length - 1)) {
618
+ return;
619
+ }
620
+ this.currentPage++;
621
+ this.scrollPPTPage()
622
+ },
623
+ scrollPPTPage() {
624
+ if (this.numberPage > 0) {
625
+ let pageNumber = this.pageChunkData[this.currentPage];
626
+ let height = Math.floor(Number(this.iframeHeight.replace('px', "")));
627
+ let pageHeight = Math.floor(height / this.numberPage);
628
+ let scrollHeight = (pageNumber - 1) * pageHeight;
629
+ let dom = document.getElementById('drawer_content_pre');
630
+ if (dom) {
631
+ dom.scrollTo(0, scrollHeight)
632
+ }
621
633
  }
622
634
  }
623
- }
624
635
  },
625
- beforeDestroy () {
626
- window.removeEventListener('message', this.handleIframeMessage);
627
- }
636
+ beforeDestroy() {
637
+ window.removeEventListener('message', this.handleIframeMessage);
638
+ }
628
639
  }
629
640
  </script>
630
641