zydx-plus 1.35.474 → 1.35.475

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zydx-plus",
3
- "version": "1.35.474",
3
+ "version": "1.35.475",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -199,6 +199,7 @@ export default {
199
199
  this.x = this.left + (wid-this.initWidth)/2
200
200
  }
201
201
  });
202
+ this.dragTap()
202
203
  },
203
204
  computed: {
204
205
  position() {
@@ -215,10 +216,15 @@ export default {
215
216
  let pop = JSON.parse(sessionStorage.getItem('pop'))
216
217
  for(let i = 0; i< pop.length; i++) {
217
218
  if(document.getElementById(pop[i]) === null) continue
218
- document.getElementById(pop[i]).style.zIndex = '9999'
219
+ document.getElementById(pop[i]).classList.remove('zIndex10000')
220
+ // document.getElementById(pop[i]).style.zIndex = '9999'
221
+ document.getElementById(pop[i]).classList.add('zIndex9999')
222
+ // 获取所有具有指定class的元素并删除它们
219
223
  }
220
224
  if(document.getElementById(this.id)){
221
- document.getElementById(this.id).style.zIndex = '10000'
225
+ // document.getElementById(this.id).style.zIndex = '10000'
226
+ document.getElementById(this.id).classList.remove('zIndex9999')
227
+ document.getElementById(this.id).classList.add('zIndex10000')
222
228
  }
223
229
  },
224
230
  clean() {
@@ -520,4 +526,10 @@ export default {
520
526
  height: 100% !important;
521
527
  position: relative;
522
528
  }
529
+ .zIndex9999{
530
+ z-index: 9999;
531
+ }
532
+ .zIndex10000{
533
+ z-index: 10000;
534
+ }
523
535
  </style>
@@ -1,9 +1,9 @@
1
1
  <template>
2
- <div class="read" ref="read">
2
+ <div class="read" :ref="refSrc">
3
3
  <vue-office-docx v-if="fileType === 'docx'" :src="url" style="height: 100%;" @rendered="renderedHandler" @error="errorHandler" />
4
4
  <vue-office-excel v-if="fileType === 'xlsx' && xlsx" :src="url" style="height: 100%;" @rendered="renderedHandler" @error="errorHandler" />
5
5
  <div class="view-pdf" @scroll="scroll" ref="view-pdf" v-if="fileType === 'pdf'">
6
- <div class="pageContainer" v-for="(item,index) in idArr">
6
+ <div class="pageContainer" v-for="(item,index) in idArr[`${refSrc}`]" :key="index">
7
7
  <canvas :id="item"></canvas>
8
8
  <div class="pdfPage">{{ index + 1 }}/{{ pdfPages }}</div>
9
9
  </div>
@@ -36,27 +36,31 @@ import '@vue-office/excel/lib/index.css'
36
36
 
37
37
  import Mess from '../../tipBox/index'
38
38
  import {debounce} from "../../utils";
39
- let pdfs = null
39
+ let pdfs = {}
40
40
  export default {
41
41
  name: "zydx-read",
42
42
  components: {VueOfficeDocx,VueOfficeExcel},
43
43
  data() {
44
44
  return {
45
- fileType: null,
46
- PdfJs: null,
47
- svgArr: [],
48
- container: null,
49
- pdfPages: 0,
50
- loading: false,
51
- repeat: false,
52
- idArr: [],
53
- scales: 1.35,
45
+ fileType: null,
46
+ PdfJs: null,
47
+ svgArr: [],
48
+ container: null,
49
+ pdfPages: 0,
50
+ loading: false,
51
+ repeat: false,
52
+ idArr: {},
53
+ scales: 1.35,
54
54
  timer: null,
55
55
  pdf: null,
56
56
  page: 0,
57
57
  xlsx: true,
58
- canvasArr: [],
59
- pageIndex: 0
58
+ canvasArr: {},
59
+ pageIndex: 0,
60
+ refSrc:'',
61
+ resizeObserver:{},
62
+ loadingTask:{},
63
+ // pdfs:null
60
64
  }
61
65
  },
62
66
  props: {
@@ -75,8 +79,9 @@ export default {
75
79
  },
76
80
  watch: {
77
81
  url: {
78
- handler: function (val, oldVal) {
79
- this.idArr = []
82
+ handler: function () {
83
+ this.refSrc=this.randomId()
84
+ this.idArr[`${this.refSrc}`] = []
80
85
  this.repeatInit()
81
86
  },
82
87
  deep: true,
@@ -96,7 +101,7 @@ export default {
96
101
  }
97
102
  if(this.fileType === 'pdf') {
98
103
  if(val.width >= 800) return
99
- this.canvasArr.map(item => {
104
+ this.canvasArr[`${this.refSrc}`].map(item => {
100
105
  item.style.width = val.width + 'px'
101
106
  item.style.height = val.width*1.35 + 'px'
102
107
  })
@@ -113,7 +118,7 @@ export default {
113
118
  }
114
119
  },
115
120
  methods: {
116
- errorHandler() {
121
+ errorHandler() {
117
122
  Mess({
118
123
  promptContent: '文件加载错误',
119
124
  cancelShow: false
@@ -131,11 +136,11 @@ export default {
131
136
  if (this.fileType === 'pdf') {
132
137
  this.init()
133
138
  setTimeout(()=>{
134
- const el = this.$refs.read;
135
- const resizeObserver = new ResizeObserver(() => {
136
- this.refreshCanvas()
139
+ const el = this.$refs[`${this.refSrc}`];
140
+ this.resizeObserver[`${this.refSrc}`] = new ResizeObserver(() => {
141
+ this.refreshCanvas()
137
142
  });
138
- resizeObserver.observe(el);
143
+ this.resizeObserver[`${this.refSrc}`].observe(el);
139
144
  },300)
140
145
  }
141
146
  setTimeout(() => {
@@ -152,15 +157,14 @@ export default {
152
157
  });
153
158
  },
154
159
  init() {
155
- let that = this
156
- const loadingTask = PdfJs.getDocument({
160
+ let that = this
161
+ this.loadingTask[`${this.refSrc}`] = PdfJs.getDocument({
157
162
  url: this.url,
158
163
  cMapUrl: "/zydx/static/cmaps/",
159
164
  cMapPacked: true
160
165
  })
161
- loadingTask.promise.then((pdf) => {
162
- pdfs = pdf
163
- console.log('pdfs',pdfs)
166
+ this.loadingTask[`${this.refSrc}`].promise.then((pdf) => {
167
+ pdfs[`${that.refSrc}`] = pdf
164
168
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
165
169
  that.page = pdf.numPages
166
170
  that.pageIndex = that.page > 1? 2:1
@@ -183,22 +187,23 @@ export default {
183
187
  if(this.pageIndex >= this.page) return
184
188
  if((this.page - this.pageIndex) >= 2) {
185
189
  this.pageIndex += 2
186
- this.getPDF(pdfs,2)
190
+ this.getPDF(pdfs[`${this.refSrc}`],2)
187
191
  }else {
188
192
  this.pageIndex += 1
189
- this.getPDF(pdfs,1)
193
+ this.getPDF(pdfs[`${this.refSrc}`],1)
190
194
  }
191
195
  }
192
196
  },
193
197
  getPDF(pdf,page) {
194
- console.log('getPDF=====page',page)
195
198
  let that = this
196
199
  for (let i = 0; i < page; i++) {
197
200
  const id = 'canvas' + Math.random().toString(36).substr(2)
198
- that.idArr.push(id)
201
+ that.idArr[`${that.refSrc}`].push(id)
199
202
  pdf.getPage(this.pageIndex === 1? 1:this.pageIndex + i - 1).then(function (page) {
203
+ // let canvas = document.createElement('canvas')
200
204
  let canvas = document.getElementById(id)
201
- that.canvasArr.push(canvas)
205
+ that.canvasArr[`${that.refSrc}`]=[]
206
+ that.canvasArr[`${that.refSrc}`].push(canvas)
202
207
  let ctx = canvas.getContext('2d');
203
208
  // let viewport = page.getViewport({scale: that.scales})
204
209
  // canvas.width = viewport.width * 2
@@ -228,10 +233,12 @@ export default {
228
233
  },
229
234
  refreshCanvas:debounce(function (){
230
235
  let that = this
231
- that.idArr.forEach((item,index)=>{
232
- pdfs.getPage( index + 1).then(function (page) {
236
+ that.idArr[`${that.refSrc}`].forEach((item,index)=>{
237
+ pdfs[`${this.refSrc}`].getPage( index + 1).then(function (page) {
238
+ // let canvas = document.createElement('canvas')
233
239
  let canvas = document.getElementById(item)
234
- that.canvasArr.push(canvas)
240
+ that.canvasArr[`${that.refSrc}`]=[]
241
+ that.canvasArr[`${that.refSrc}`].push(canvas)
235
242
  let ctx = canvas.getContext('2d');
236
243
  let boxWidth = that.$refs['view-pdf'].offsetWidth
237
244
  let scales=(boxWidth/846)*(boxWidth/(boxWidth-(boxWidth*0.115*2)))
@@ -251,7 +258,11 @@ export default {
251
258
  page.render(renderContext)
252
259
  })
253
260
  })
254
- },50)
261
+ },50),
262
+ randomId() {
263
+ const id = Math.random().toString(36).substr(2)
264
+ return id.replace(/[0-9]/g, '')
265
+ }
255
266
  }
256
267
  }
257
268
  </script>
@@ -135,9 +135,12 @@ export default {
135
135
 
136
136
  .num {
137
137
  position: absolute;
138
- bottom: 10px;
139
- right: 10px;
138
+ bottom: 0;
139
+ right: 5px;
140
140
  z-index: 1;
141
+ font-size: 12px;
142
+ transform: scale(0.8);
143
+ color: #666;
141
144
  }
142
145
 
143
146
  .text {
package/src/index.js CHANGED
@@ -87,7 +87,7 @@ function install(app) {
87
87
  }
88
88
 
89
89
  export default {
90
- version: '1.35.474',
90
+ version: '1.35.475',
91
91
  install,
92
92
  Calendar,
93
93
  Message,