zydx-plus 1.17.78 → 1.18.79

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.17.78",
3
+ "version": "1.18.79",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -32,7 +32,9 @@
32
32
  "html2json": "^1.0.2",
33
33
  "@tiptap/extension-image": "^2.0.3",
34
34
  "@tiptap/starter-kit": "^2.0.3",
35
- "@tiptap/vue-3": "^2.0.3"
35
+ "@tiptap/vue-3": "^2.0.3",
36
+ "@vue-office/docx": "^1.1.3",
37
+ "@vue-office/excel": "^1.1.3"
36
38
  },
37
39
  "peerDependencies": {
38
40
  "vue": "^3.2.13"
@@ -4,7 +4,7 @@
4
4
  <div class="ed-title" v-if="titleShow">{{ title }}</div>
5
5
  <div class="ed-but" v-if="readOnly">
6
6
  <div class="ed-head-but" v-for="(item,index) in toolbar">
7
- <button v-if="item.key === 'but'" class="but" @click="item.onClick(item)" :style="{color: (item.active)? '#00ff00' :'#000'}">{{ item.title }}</button>
7
+ <button v-if="item.key === 'but'" class="but" @click="item.onClick(item,info)" :style="{color: (item.active)? '#00ff00' :'#000'}">{{ item.title }}</button>
8
8
  <label v-else-if="item.key === 'upImg' || item.key === 'uploadAtt'">
9
9
  <input type="file" @change="upload($event,item.key)" :accept="(item.key === 'upImg')?'image/*':'application/*'" style="display: none;">
10
10
  <span class="but">{{ item.title }}</span>
@@ -105,6 +105,10 @@ export default {
105
105
  uploadType: {
106
106
  type: Boolean,
107
107
  default: false
108
+ },
109
+ info: {
110
+ type: String,
111
+ default: ''
108
112
  }
109
113
  },
110
114
  emits: ['see','complete','update:data'],
@@ -112,7 +116,7 @@ export default {
112
116
  data(e) {
113
117
  this.editor.commands.setContent(json2html({node: "root",child: (e.html === undefined)? [] : e.html}))
114
118
  this.uploadAttData = (e.enclosure === undefined)? [] : e.enclosure
115
- },
119
+ }
116
120
  },
117
121
  mounted() {
118
122
  this.uploadAttData = (this.data.enclosure === undefined)? [] : this.data.enclosure
@@ -0,0 +1,6 @@
1
+ import main from './src/read.vue';
2
+
3
+ main.install = function(Vue) {
4
+ Vue.component(main.name, main);
5
+ };
6
+ export default main;
@@ -0,0 +1,131 @@
1
+ <template>
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%;" />
5
+ <div class="view-pdf" v-if="fileType === 'pdf'" id="canvas-wrap"></div>
6
+ <div class="mp4" v-if="fileType === 'mp4'">
7
+ <video :src="url" controls></video>
8
+ </div>
9
+ <div class="mp3" v-if="fileType === 'mp3'">
10
+ <audio :src="url" controls></audio>
11
+ </div>
12
+ </div>
13
+ </template>
14
+
15
+ <script>
16
+ import * as PdfJs from 'pdfjs-dist/legacy/build/pdf.js' // 注意导入的写法
17
+ PdfJs.GlobalWorkerOptions.workerSrc = require('pdfjs-dist/build/pdf.worker.entry')
18
+ //引入VueOfficeDocx组件
19
+ import VueOfficeDocx from '@vue-office/docx'
20
+ //引入VueOfficeExcel组件
21
+ import VueOfficeExcel from '@vue-office/excel'
22
+ //引入相关样式
23
+ import '@vue-office/docx/lib/index.css'
24
+ //引入相关样式
25
+ import '@vue-office/excel/lib/index.css'
26
+ export default {
27
+ name: "zydx-read",
28
+ components: {VueOfficeDocx,VueOfficeExcel},
29
+ data() {
30
+ return {
31
+ fileType: null,
32
+ PdfJs: null,
33
+ svgArr: [],
34
+ container: null
35
+ }
36
+ },
37
+ props: {
38
+ url: {
39
+ type: String,
40
+ default: '',
41
+ pdfPages: 0
42
+ }
43
+ },
44
+ mounted() {
45
+ this.fileType = this.url.split('.').pop()
46
+ if(this.fileType === 'pdf') this.init()
47
+ },
48
+ methods: {
49
+ init() {
50
+ let that = this
51
+ const loadingTask = PdfJs.getDocument(this.url)
52
+ loadingTask.promise.then((pdf) => {
53
+ that.pdfPages = pdf.numPages // 获取pdf文件的总页数
54
+ for (let i = 0; i < that.pdfPages; i++) {
55
+ let inx = i+1
56
+ pdf.getPage(inx).then(function (page) {
57
+ let viewport = page.getViewport({scale: 1})
58
+ return page.getOperatorList().then(function(opList) {
59
+ let svgGfx = new PdfJs.SVGGraphics(page.commonObjs, page.objs)
60
+ return svgGfx.getSVG(opList, viewport).then(function(svg) {
61
+ that.svgArr.push({
62
+ index: inx,
63
+ width: viewport.width,
64
+ height: viewport.height,
65
+ data: svg
66
+ })
67
+ })
68
+ })
69
+ })
70
+ }
71
+ })
72
+ setTimeout(() => {
73
+ that.sortArr()
74
+ },100)
75
+ },
76
+ // 数组根据索引排序
77
+ sortArr() {
78
+ for(let j = 0; j < this.svgArr.length;j++){
79
+ let temp = this.svgArr[j],
80
+ val = temp['index'],
81
+ i = j-1;
82
+ while(i >=0 && this.svgArr[i]['index']>val){
83
+ this.svgArr[i+1] = this.svgArr[i];
84
+ i = i-1;
85
+ }
86
+ this.svgArr[i+1] = temp;
87
+ }
88
+ this.svgArr.forEach(x => {
89
+ let container = document.createElement('div')
90
+ container.id = 'canvas_' + x.index
91
+ container.className = 'pageContainer'
92
+ container.style.width = x.width + 'px'
93
+ container.style.height = x.height + 'px'
94
+ container.style.display = 'inline-block'
95
+ container.style.boxShadow = '0 0 10px rgba(0, 0, 0, 0.5)'
96
+ container.style.marginBottom = '5px'
97
+ document.getElementById('canvas-wrap').appendChild(container)
98
+ container.appendChild(x.data)
99
+ })
100
+ },
101
+ }
102
+ }
103
+ </script>
104
+
105
+ <style scoped>
106
+ .mp4,.mp3{
107
+ width: 100%;
108
+ }
109
+ .mp4 video,.mp3 audio{
110
+ width: 100%;
111
+ }
112
+ .view-pdf{
113
+ text-align: center;
114
+ height: 100%;
115
+ overflow: auto;
116
+ padding: 10px;
117
+ }
118
+ .view-pdf::-webkit-scrollbar {
119
+ width: 0
120
+ }
121
+ .read{
122
+ width: 100%;
123
+ height: 100%;
124
+ }
125
+ :deep(.vue-office-docx)::-webkit-scrollbar {
126
+ width: 0
127
+ }
128
+ :deep(.docx-wrapper) {
129
+ background-color: #fff;
130
+ }
131
+ </style>
package/src/index.js CHANGED
@@ -20,6 +20,7 @@ import bizHeader from './components/biz_header/index';
20
20
  import editor2 from './components/editor2/index';
21
21
  import dragPopup from './components/dragPopup/index';
22
22
  import bizTaskInfo from './components/biz_taskInfo/index';
23
+ import read from './components/read/index';
23
24
 
24
25
  const components = [
25
26
  Calendar,
@@ -41,7 +42,8 @@ const components = [
41
42
  bizHeader,
42
43
  editor2,
43
44
  dragPopup,
44
- bizTaskInfo
45
+ bizTaskInfo,
46
+ read
45
47
  ];
46
48
 
47
49
  function install(app) {
@@ -53,7 +55,7 @@ function install(app) {
53
55
  }
54
56
 
55
57
  export default {
56
- version: '1.17.77',
58
+ version: '1.18.79',
57
59
  install,
58
60
  Calendar,
59
61
  Message,
@@ -76,6 +78,7 @@ export default {
76
78
  bizHeader,
77
79
  editor2,
78
80
  dragPopup,
79
- bizTaskInfo
81
+ bizTaskInfo,
82
+ read
80
83
  };
81
84