zydx-plus 1.19.91 → 1.19.93

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.19.91",
3
+ "version": "1.19.93",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -22,7 +22,6 @@
22
22
  "dependencies": {
23
23
  "vue-draggable-next": "^2.1.1",
24
24
  "pdfjs-dist": "^2.0.943",
25
- "flipbook-vue": "^1.0.0-beta.4",
26
25
  "@wangeditor/editor": "^5.1.23",
27
26
  "@wangeditor/plugin-upload-attachment": "^1.1.0",
28
27
  "snabbdom": "^3.5.1",
@@ -59,8 +59,8 @@ export default {
59
59
  }
60
60
  },
61
61
  mounted() {
62
- let clientWidth = window.outerWidth;
63
- let clientHeight = window.outerHeight;
62
+ let clientWidth = document.documentElement.clientWidth;
63
+ let clientHeight = document.documentElement.clientHeight;
64
64
  this.x = clientWidth / 2 - this.footDownOffset / 2;
65
65
  this.y = clientHeight / 2 - this.footRightOffset / 2;
66
66
  },
@@ -24,7 +24,7 @@
24
24
  <p v-if="editorShow">附件列表:</p>
25
25
  <div class="enclosure-list" v-for="(item,index) in uploadAttData">
26
26
  <div class="enclosure-item">
27
- <span>{{ index + 1 }}. {{ (item.name)? item.name : item.fileName }}</span>
27
+ <span>{{ index + 1 }}. {{ (item.name)? item.name : item.annexName }}</span>
28
28
  </div>
29
29
  <div class="enclosure-item en-but">
30
30
  <div style="display: inline-block; height: 21px;">
@@ -73,6 +73,7 @@
73
73
  </div>
74
74
  </template>
75
75
  <script>
76
+
76
77
  import { html2json, json2html } from 'html2json'
77
78
  import { Editor, EditorContent } from '@tiptap/vue-3'
78
79
  import StarterKit from '@tiptap/starter-kit'
@@ -191,8 +192,16 @@ export default {
191
192
  del(index) {
192
193
  if(this.uploadAttData[index].name === undefined) {
193
194
  this.uploadAttData[index].active = false
194
- this.$emit('del', this.uploadAttData[index], () => {
195
- this.uploadAttData.splice(index, 1)
195
+ this.$emit('del', this.uploadAttData[index], (e) => {
196
+ if(e === undefined) {
197
+ this.uploadAttData.splice(index, 1)
198
+ }else {
199
+ if(e) {
200
+ this.uploadAttData.splice(index, 1)
201
+ }else {
202
+ this.uploadAttData[index].active = true
203
+ }
204
+ }
196
205
  })
197
206
  }else {
198
207
  this.uploadAttData.splice(index, 1)
@@ -1,45 +1,46 @@
1
1
  <template>
2
2
  <div id="docView">
3
- <div v-show="show" class="load-pop">
4
- <div class="load">
5
- <span>文件较大耐心等待</span>
6
- <div class="loading">
7
- <div class="loading-cont" :style="{'width': loadWidth +'%'}"></div>
3
+ <div style="height: 100%;">
4
+ <div class="book">
5
+ <div class="pages">
6
+ <div class="wrap" id="canvas-wrap"></div>
7
+ <div class="page-but-left" :style="{cursor: pageIndex === 1?'default':'pointer'}" @click="flipLeft(pageIndex-=1,false)"></div>
8
+ <div class="page-but-right" :style="{cursor: pageIndex === pdfPages?'default':'pointer'}" @click="flipRight(pageIndex+=1,false)"></div>
9
+ <!-- <div class="paper z-in" :class="{'data-right': pages}">-->
10
+ <!-- <div class="page page-2" id="canvas-wrap1"></div>-->
11
+ <!-- <div class="page page-2-back" id="canvas-wrap2"></div>-->
12
+ <!-- </div>-->
13
+ <!-- <div class="paper z-in-ac">-->
14
+ <!-- <div class="page page-2" id="canvas-wrap3"></div>-->
15
+ <!-- <div class="page page-2-back" id="canvas-wrap4"></div>-->
16
+ <!-- </div>-->
8
17
  </div>
9
18
  </div>
10
- </div>
11
- <div v-show="!show" style="height: 100%;">
12
- <div class="pdf-container">
13
- <canvas :id="'pdf-canvas'+ index" v-for="(item,index) in pdfPages" class="pdf-canvas"></canvas>
14
- </div>
15
- <div class="book">
16
- <flipbook class="flipbook" :startPage="pageIndex" :pages="imgArr" @flip-left-end="flipLeft($event,false)" @flip-right-end="flipRight($event,false)" v-slot="flipbook" :singlePage="singlePage" :ambient="0" :gloss="1" :dragToFlip="false" :pagesHiRes="0">
17
- <div class="but" v-if="butShow">
18
- <button class="but-brown" :class="{'but-act': pageIndex === 1}" @click="flipbook.flipLeft">上一页</button>
19
- <button class="but-brown" :class="{'but-act': pageIndex === pdfPages}" @click="flipbook.flipRight">下一页</button>
20
- </div>
21
- </flipbook>
19
+ <div class="but-wrap" v-if="butShow">
20
+ <button class="but-brown" :disabled="pageIndex === 1" :class="{'but-act': pageIndex === 1}" @click="flipLeft(pageIndex-=1,false)">上一页</button>
21
+ <button class="but-brown" :disabled="pageIndex === pdfPages" :class="{'but-act': pageIndex === pdfPages}" @click="flipRight(pageIndex+=1,false)">下一页</button>
22
22
  </div>
23
23
  </div>
24
24
  </div>
25
25
  </template>
26
26
 
27
27
  <script>
28
- import flipbook from 'flipbook-vue'
29
28
  import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
30
29
  PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
31
30
  export default {
32
31
  name: "zydx-flip",
33
- components: {flipbook},
34
32
  data() {
35
33
  return {
36
34
  pdfPages: 0,
37
- imgArr: [],
35
+ imgArr: {},
38
36
  hei: 0,
39
37
  pageIndex: this.page,
40
38
  show: false,
41
39
  load: 0,
42
- loadWidth: 0
40
+ loadWidth: 0,
41
+ pages: false,
42
+ pagesData: [],
43
+ opacity: 1
43
44
  }
44
45
  },
45
46
  props: {
@@ -60,79 +61,67 @@ export default {
60
61
  default: 1
61
62
  }
62
63
  },
64
+ watch: {
65
+ page: {
66
+ handler: function (val, oldVal) {
67
+ this.pageIndex = val
68
+ },
69
+ immediate: true
70
+ }
71
+ },
63
72
  emits: ['flip'],
64
73
  mounted() {
65
- this.$nextTick(() => {
66
- this.readPdf()
67
- })
74
+ this.readPdf()
68
75
  },
69
76
  methods: {
70
77
  flipLeft(e,v) {
71
- this.pageIndex = e
78
+ if(e <= 1) {
79
+ this.pageIndex = 1
80
+ }else {
81
+ this.pageIndex = e
82
+ }
83
+ this.readPdf()
72
84
  if(!v) {
73
85
  this.$emit('flip', {
74
- page: e,
86
+ page: this.pageIndex,
75
87
  total: this.pdfPages
76
88
  })
77
89
  }
78
90
  },
79
91
  flipRight(e,v) {
80
- this.pageIndex = e
92
+ if(e >= this.pdfPages) {
93
+ this.pageIndex = this.pdfPages
94
+ }else {
95
+ this.pageIndex = e
96
+ }
97
+ this.readPdf()
81
98
  if(!v) {
82
99
  this.$emit('flip', {
83
- page: e,
100
+ page: this.pageIndex,
84
101
  total: this.pdfPages
85
102
  })
86
103
  }
87
104
  },
88
105
  readPdf() {
89
106
  let that = this
90
- if(that.pdfPages > 30) that.show = true
91
107
  const loadingTask = PdfJs.getDocument(this.source)
92
108
  loadingTask.promise.then((pdf) => {
93
109
  that.pdfPages = pdf.numPages // 获取pdf文件的总页数
94
- for (let i = 0; i < that.pdfPages; i++) {
95
- pdf.getPage(i + 1).then(function (page) {
96
- const canvas = document.getElementById('pdf-canvas' + i)
97
- const ctx = canvas.getContext('2d')
98
- const dpr = window.devicePixelRatio || 1
99
- const bsr = ctx.webkitBackingStorePixelRatio || ctx.mozBackingStorePixelRatio || ctx.msBackingStorePixelRatio || ctx.oBackingStorePixelRatio || ctx.backingStorePixelRatio || 1
100
- const ratio = dpr / bsr
101
- const viewport = page.getViewport({scale: 1})
102
- canvas.width = viewport.width * ratio
103
- canvas.height = viewport.height * ratio
104
- canvas.style.width = viewport.width + 'px'
105
- canvas.style.height = viewport.height + 'px'
106
- ctx.setTransform(ratio, 0, 0, ratio, 0, 0)
107
- const renderContext = {
108
- canvasContext: ctx,
109
- viewport: viewport
110
- }
111
- page.render(renderContext)
112
- if(that.pdfPages > 30) {
113
- that.load = i + 1
114
- that.loadWidth = Math.floor(that.load / that.pdfPages * 100)
115
- }
116
- });
117
- }
118
- setTimeout(function () {
119
- for (let i = 0; i < that.pdfPages; i++) {
120
- const canvas = document.getElementById('pdf-canvas' + i)
121
- const dataURL = canvas.toDataURL("image/jpeg", 1); //获取Base64编码
122
- that.imgArr.push(dataURL)
123
- that.load = i + 1
124
- if(that.pdfPages > 30) {
125
- if(that.load >= that.pdfPages) {
126
- setTimeout(() => {
127
- that.show = false
128
- that.load = 0
129
- },100)
130
- }else {
131
- that.loadWidth = Math.floor(that.load / that.pdfPages * 100)
132
- }
133
- }
134
- }
135
- }, 500)
110
+ pdf.getPage(that.pageIndex).then(function (page) {
111
+ let viewport = page.getViewport({scale: 1})
112
+ document.getElementById('canvas-wrap').innerHTML = ''
113
+ let container = document.createElement('div')
114
+ container.style.width = viewport.width + 'px'
115
+ container.style.height = viewport.height + 'px'
116
+ container.style.margin = '0 auto'
117
+ document.getElementById('canvas-wrap').appendChild(container)
118
+ return page.getOperatorList().then(function(opList) {
119
+ let svgGfx = new PdfJs.SVGGraphics(page.commonObjs, page.objs)
120
+ return svgGfx.getSVG(opList, viewport).then(function(svg) {
121
+ container.appendChild(svg)
122
+ })
123
+ })
124
+ })
136
125
  })
137
126
  }
138
127
  }
@@ -140,39 +129,90 @@ export default {
140
129
  </script>
141
130
 
142
131
  <style scoped>
143
- .load-pop{
144
- width: 100%;
145
- height: 100%;
146
- display: flex;
147
- align-items: center;
132
+ .wrap{
133
+ width: 100%;
134
+ height: 100%;
148
135
  }
149
- .load{
150
- display: inline-block;
151
- margin: 0 auto;
136
+ .but-wrap{
137
+ text-align: center;
152
138
  }
153
- .load>span{
154
- display: inline-block;
139
+ .z-in{
140
+ z-index: 2;
141
+ }
142
+ .z-in-ac{
143
+ z-index: 1;
144
+ }
145
+ .pages{
146
+ width: 100%;
147
+ height: 100%;
148
+ position: relative;
149
+ }
150
+ .paper{
151
+ position: absolute;
152
+ right: 0;
153
+ transform-style: preserve-3d;
155
154
  width: 100%;
155
+ }
156
+ .page{
157
+ position: absolute;
156
158
  text-align: center;
157
- padding-bottom: 10px;
158
- font-size: 14px;
159
159
  }
160
- .loading{
161
- width: 200px;
162
- height: 10px;
163
- border-radius: 20px;
164
- position: relative;
165
- overflow: hidden;
166
- background-color: #ccc;
160
+ .page img{
161
+ width: 100%;
162
+ height: 100%;
163
+ }
164
+ .data-right {
165
+ opacity: 1;
166
+ transform-origin: left center;
167
+ animation: flip-to-left 1.5s ease-in-out forwards;
167
168
  }
168
- .loading-cont{
169
+ .data-left{
170
+ right: auto;
171
+ left: 0;
172
+ }
173
+ @keyframes flip-to-left {
174
+ 0% {
175
+ transform: perspective(3000px) rotateY(0);
176
+ }
177
+ 95% {
178
+ transform: perspective(3000px) rotateY(-180deg);
179
+ }
180
+ 100% {
181
+ transform: perspective(3000px) rotateY(-180deg);
182
+ }
183
+ }
184
+ .page-1-back, .page-2-back {
185
+ transform: scale(-1, 1);
186
+ }
187
+ .page-1, .page-2 {
188
+ transform: translateZ(1px);
189
+ }
190
+
191
+
192
+
193
+
194
+ .page-but-left{
169
195
  position: absolute;
170
196
  top: 0;
197
+ bottom: 0;
171
198
  left: 0;
172
199
  z-index: 1;
173
- background-color: #5daf34;
174
- height: 100%;
175
- border-radius: 20px;
200
+ width: 10%;
201
+ }
202
+ .page-but-right{
203
+ position: absolute;
204
+ top: 0;
205
+ bottom: 0;
206
+ right: 0;
207
+ z-index: 1;
208
+ width: 10%;
209
+ }
210
+ .load>span{
211
+ display: inline-block;
212
+ width: 100%;
213
+ text-align: center;
214
+ padding-bottom: 10px;
215
+ font-size: 14px;
176
216
  }
177
217
  #docView{
178
218
  height: 100%;
@@ -189,33 +229,10 @@ export default {
189
229
  cursor: pointer;
190
230
  margin-left: 10px;
191
231
  }
192
- .but{
193
- position: absolute;
194
- bottom: 0;
195
- left: 0;
196
- right: 0;
197
- z-index: 1;
198
- text-align: center;
199
- }
200
232
  .book{
201
233
  width: 100%;
202
234
  height: 100%;
203
235
  }
204
- .flipbook {
205
- width: 100%;
206
- height: 100%;
207
- position: relative;
208
- padding-bottom: 24px;
209
- }
210
- .pdf-container{
211
- position: relative;
212
- }
213
- .pdf-canvas{
214
- position: absolute;
215
- top: -100000px;
216
- left: 0;
217
- z-index: -100;
218
- }
219
236
  .but-act{
220
237
  background-color: #bbbbbb;
221
238
  color: #fff;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="read">
3
- <vue-office-docx v-if="fileType === 'docx'" :src="url" style="height: 100%;" />
4
- <vue-office-excel v-if="fileType === 'xlsx' || fileType === 'xls'" :src="url" style="height: 100%;" />
3
+ <vue-office-docx v-if="fileType === 'docx'" :src="url" style="height: 100%;" @rendered="renderedHandler" />
4
+ <vue-office-excel v-if="fileType === 'xlsx'" :src="url" style="height: 100%;" @rendered="renderedHandler" />
5
5
  <div class="view-pdf" v-if="fileType === 'pdf'" id="canvas-wrap"></div>
6
6
  <div class="mp4" v-if="fileType === 'mp4'">
7
7
  <video :src="url" controls></video>
@@ -9,6 +9,11 @@
9
9
  <div class="mp3" v-if="fileType === 'mp3'">
10
10
  <audio :src="url" controls></audio>
11
11
  </div>
12
+ <div v-if="loading" class="loading-back">
13
+ <div class="loading-cont">
14
+ <div class="loading">Loading</div>
15
+ </div>
16
+ </div>
12
17
  </div>
13
18
  </template>
14
19
 
@@ -32,7 +37,9 @@ export default {
32
37
  PdfJs: null,
33
38
  svgArr: [],
34
39
  container: null,
35
- pdfPages: 0
40
+ pdfPages: 0,
41
+ loading: true,
42
+ repeat: false,
36
43
  }
37
44
  },
38
45
  props: {
@@ -44,17 +51,28 @@ export default {
44
51
  watch: {
45
52
  url: {
46
53
  handler: function (val, oldVal) {
47
- this.fileType = val.split('.').pop()
48
- if(this.fileType === 'pdf') this.init()
54
+ this.repeatInit()
49
55
  },
50
56
  immediate: true
51
57
  }
52
58
  },
53
59
  mounted() {
54
- this.fileType = this.url.split('.').pop()
55
- if(this.fileType === 'pdf') this.init()
60
+ this.repeatInit()
56
61
  },
57
62
  methods: {
63
+ repeatInit() {
64
+ if(this.repeat) return // 防止重复加载
65
+ this.repeat = true
66
+ this.loading = true
67
+ this.fileType = this.url.split('.').pop()
68
+ if(this.fileType === 'pdf') this.init()
69
+ setTimeout(() => {
70
+ this.repeat = false
71
+ },1000)
72
+ },
73
+ renderedHandler() {
74
+ this.loading = false
75
+ },
58
76
  init() {
59
77
  let that = this
60
78
  const loadingTask = PdfJs.getDocument(this.url)
@@ -106,6 +124,7 @@ export default {
106
124
  document.getElementById('canvas-wrap').appendChild(container)
107
125
  container.appendChild(x.data)
108
126
  })
127
+ this.renderedHandler()
109
128
  },
110
129
  }
111
130
  }
@@ -130,6 +149,7 @@ export default {
130
149
  .read{
131
150
  width: 100%;
132
151
  height: 100%;
152
+ position: relative;
133
153
  }
134
154
  :deep(.vue-office-docx)::-webkit-scrollbar {
135
155
  width: 0
@@ -137,4 +157,50 @@ export default {
137
157
  :deep(.docx-wrapper) {
138
158
  background-color: #fff;
139
159
  }
160
+ .loading-back{
161
+ position: absolute;
162
+ top: 0;
163
+ left: 0;
164
+ right: 0;
165
+ bottom: 0;
166
+ z-index: 100;
167
+ display: flex;
168
+ align-items: center;
169
+ }
170
+ .loading-cont{
171
+ display: inline-block;
172
+ margin: 0 auto;
173
+ }
174
+ .loading {
175
+ display: inline-block;
176
+ font-size: 28px;
177
+ font-family: Arial, Helvetica, sans-serif;
178
+ font-weight: bold;
179
+ color: #fff;
180
+ text-shadow: 0 0 2px #ff3d00, 0 0 1px #ff3d00, 0 0 1px #ff3d00;
181
+ letter-spacing: 2px;
182
+ position: relative;
183
+ }
184
+
185
+ .loading::after {
186
+ content: "Loading";
187
+ position: absolute;
188
+ left: 0;
189
+ top: 0;
190
+ color: #ff3d00;
191
+ width: 0%;
192
+ height: 100%;
193
+ overflow: hidden;
194
+ animation: loading-animation 6s linear infinite;
195
+ }
196
+
197
+ @keyframes loading-animation {
198
+ 0% {
199
+ width: 0%;
200
+ }
201
+
202
+ 100% {
203
+ width: 100%;
204
+ }
205
+ }
140
206
  </style>
package/src/index.js CHANGED
@@ -57,7 +57,7 @@ function install(app) {
57
57
  }
58
58
 
59
59
  export default {
60
- version: '1.19.91',
60
+ version: '1.19.93',
61
61
  install,
62
62
  Calendar,
63
63
  Message,