zydx-plus 1.32.208 → 1.32.210

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.32.208",
3
+ "version": "1.32.210",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -182,6 +182,12 @@ export default {
182
182
  }
183
183
  },
184
184
  deep: true
185
+ },
186
+ menusText: {
187
+ handler: function (e, oldVal) {
188
+ this.organizeButton()
189
+ },
190
+ deep: true
185
191
  }
186
192
  },
187
193
  mounted() {
@@ -317,7 +317,7 @@ export default {
317
317
  xhr.send(param)
318
318
  })
319
319
  },
320
- upload(e,v) {
320
+ upload(e,v) { // 上传文件
321
321
  const file = e.target.files[0]
322
322
  if(this.uploadType) {
323
323
  if(v === 'uploadAtt') {
@@ -345,7 +345,7 @@ export default {
345
345
  }
346
346
  e.target.value = ''
347
347
  },
348
- imgHtml(data) {
348
+ imgHtml(data) { // 插入图片
349
349
  const url = this.uploadImage.url + data
350
350
  const cla = this.randomId()
351
351
  const html = `<p class="imgCont ${cla}"><img src="${url}" alt="" /></p>`
@@ -569,6 +569,7 @@ export default {
569
569
  height: 20px;
570
570
  display: inline-block;
571
571
  line-height: 16px;
572
+ box-sizing: border-box;
572
573
  }
573
574
  .but-f{
574
575
  float: left;
@@ -69,6 +69,7 @@
69
69
  width: 80%;
70
70
  height: 80%;
71
71
  margin: 0 auto;
72
+ text-align: justify;
72
73
  }
73
74
  .right-menu{
74
75
  position: fixed;
@@ -187,4 +188,34 @@
187
188
  top: -9999px;
188
189
  opacity: 1;
189
190
  z-index: -1;
190
- }
191
+ }
192
+ .but-wrap{
193
+ text-align: center;
194
+ position: absolute;
195
+ bottom: 20px;
196
+ left: 0;
197
+ z-index: 1;
198
+ width: 100%;
199
+ }
200
+ .but-brown{
201
+ background-color: #c64c10;
202
+ padding: 0 20px;
203
+ font-size: 12px;
204
+ color: #fff;
205
+ height: 24px;
206
+ line-height: 24px;
207
+ border-radius: 5px;
208
+ border: 0;
209
+ cursor: pointer;
210
+ margin-left: 10px;
211
+ }
212
+ .but-act{
213
+ background-color: #bbbbbb;
214
+ color: #fff;
215
+ }
216
+ #htmlText :deep(.p),#htmlText :deep(.h1),#htmlText :deep(.h2),#htmlText :deep(.h3),#htmlText :deep(.h4){
217
+ text-align: justify;
218
+ }
219
+ .tagging-text :deep(.p),.tagging-text :deep(.h1),.tagging-text :deep(.h2),.tagging-text :deep(.h3),.tagging-text :deep(.h4){
220
+ text-align: justify;
221
+ }
@@ -17,6 +17,10 @@
17
17
  </div>
18
18
  <div class="tagging-html">
19
19
  <div class="tagging-text" ref="tagging" @click.right="rightMenu($event)"></div>
20
+ <div class="but-wrap">
21
+ <button class="but-brown" :disabled="page === 0" :class="{'but-act': page === 0}" @click="last">上一页</button>
22
+ <button class="but-brown" :disabled="page === htmlArr.length - 1" :class="{'but-act': page === htmlArr.length - 1}" @click="next">下一页</button>
23
+ </div>
20
24
  <div class="right-menu" :style="rightStyle" v-if="rightMenuShow">
21
25
  <span @click="annotations">批注</span>
22
26
  </div>
@@ -26,7 +30,7 @@
26
30
  <div class="tagging-right">
27
31
  <div class="tagging-title">批注指导</div>
28
32
  <div class="annotation">
29
- <div class="annotation-list" @click="guidance(item.id,index)" :id="item.id" v-for="(item, index) in annotationsData">
33
+ <div class="annotation-list" @click="guidance(item.id,index)" :id="item.id" v-for="(item, index) in annotationsArr">
30
34
  <div class="list-title">
31
35
  <div class="list-left">
32
36
  <span>刘秀芮老师</span>
@@ -57,7 +61,7 @@
57
61
  </template>
58
62
 
59
63
  <script>
60
- import { html2json, json2html } from 'html2json'
64
+ import {html2json, json2html} from 'html2json'
61
65
  import zydxTextarea from "../../textarea/src/textarea"
62
66
  import Range from "./range";
63
67
 
@@ -72,8 +76,12 @@ export default {
72
76
  left: '0px'
73
77
  },
74
78
  annotationsData: [],
79
+ annotationsArr: [],
75
80
  ranges: null,
76
- linkData: []
81
+ linkData: [],
82
+ htmlArr: [],
83
+ page: 0,
84
+ dataID: []
77
85
  }
78
86
  },
79
87
  props: {
@@ -89,29 +97,127 @@ export default {
89
97
  value: {
90
98
  handler(val) {
91
99
  this.$nextTick(() => {
92
- let h = json2html(JSON.parse(val.html))
93
- document.getElementById('htmlText').innerHTML = h
94
- this.$refs.tagging.innerHTML = h
100
+ document.getElementById('htmlText').innerHTML = json2html(JSON.parse(val.html))
101
+ document.getElementById('htmlText').style.width = this.$refs.tagging.offsetWidth + 'px'
95
102
  this.annotationsData = val.annotations
96
- this.linkFor()
103
+ setTimeout(() => {
104
+ this.readOnlyPage() // 分页
105
+ },100)
97
106
  })
98
107
  },
99
108
  immediate: true
100
109
  }
101
110
  },
102
111
  methods: {
112
+ last() {
113
+ if (this.page <= 0) return
114
+ this.page--
115
+ this.$refs.tagging.innerHTML = this.htmlArr[this.page]
116
+ this.annDataArrange() // 批注数据整理
117
+ this.linkFor() // 计算线的位置
118
+ },
119
+ next() {
120
+ if (this.page >= this.htmlArr.length - 1) return
121
+ this.page++
122
+ this.$refs.tagging.innerHTML = this.htmlArr[this.page]
123
+ this.annDataArrange() // 批注数据整理
124
+ this.linkFor() // 计算线的位置
125
+ },
126
+ readOnlyPage() { // 分页
127
+ this.htmlArr = []
128
+ const data = document.getElementById('htmlText').childNodes
129
+ const taggID = this.$refs.tagging
130
+ let max = taggID.offsetHeight
131
+ let pHeight = 0
132
+ let html = ''
133
+ for (let i = 0; i < data.length; i++) {
134
+ let text = data[i].offsetHeight
135
+ if ((pHeight + text) > max) {
136
+ const {start, end, size} = this.rows(data[i], max - pHeight)
137
+ html += `<p class="text"><span style="font-size: ${size}px">${start.data}</span></p>`
138
+ this.htmlArr.push(html)
139
+ pHeight = 0
140
+ html = ''
141
+ html += `<p class="text"><span style="font-size: ${size}px">${end.data}</span></p>`
142
+ pHeight = end.size
143
+ }else {
144
+ pHeight += text
145
+ html += data[i].outerHTML
146
+ }
147
+ if (i === data.length - 1) {
148
+ this.htmlArr.push(html)
149
+ pHeight = 0
150
+ html = ''
151
+ break
152
+ }
153
+ }
154
+ taggID.innerHTML = this.htmlArr[this.page]
155
+ this.annDataArrange() // 批注数据整理
156
+ this.linkFor() // 计算线的位置
157
+ },
158
+ // 批注数据整理
159
+ annDataArrange() {
160
+ this.annotationsArr = []
161
+ this.annotationsData.forEach(item => {
162
+ this.annDataID().forEach(item2 => {
163
+ if (item.id === item2) {
164
+ this.annotationsArr.push(item)
165
+ setTimeout(() => {
166
+ document.getElementById(item2).style.border = '1px solid #ccc'
167
+ },0)
168
+ }
169
+ })
170
+ })
171
+ },
172
+ // 当前页批注数据ID
173
+ annDataID() {
174
+ this.dataID = []
175
+ this.$refs.tagging.childNodes.forEach(item => {
176
+ this.childNode(item)
177
+ })
178
+ return this.dataID
179
+ },
180
+ childNode(data) {
181
+ data.childNodes.forEach(item => {
182
+ if(item.nodeName === 'I') {
183
+ this.childNode(item)
184
+ }else {
185
+ if(data.classList[1]) { // 判断是否有批注
186
+ this.dataID.push(data.classList[1].slice(0, data.classList[1].length - 1))
187
+ }
188
+ }
189
+ })
190
+ },
191
+ rows(data,num) {
192
+ let size = parseInt(window.getComputedStyle(data, null).fontSize)
193
+ let line = parseInt(window.getComputedStyle(data, null).lineHeight)
194
+ let width = data.offsetWidth
195
+ let height = data.offsetHeight
196
+ let rows = Math.round(num / line) // 行数
197
+ let text = data.innerText
198
+ let textLen = this.measureText(text,size,width * rows)
199
+ let start = text.slice(0, textLen)
200
+ let end = text.slice(textLen)
201
+ return {
202
+ start: {data: start, size: num},
203
+ end: {data: end, size: height - num},
204
+ size: size,
205
+ }
206
+ },
103
207
  getContent() {
208
+ let html = ''
209
+ this.htmlArr.forEach(item => html += item)
104
210
  return {
105
- html: html2json(this.$refs.tagging.innerHTML),
211
+ html: html2json(html),
106
212
  annotations: this.annotationsData
107
213
  }
108
214
  },
109
215
  // 保存批注
110
216
  preservation(id,index) {
111
217
  const text = this.$refs[`${id}ref`][0].getContent()
112
- this.annotationsData[index].readable = false
113
- this.annotationsData[index].more = true
114
- this.annotationsData[index].text = text
218
+ this.annotationsArr[index].readable = false
219
+ this.annotationsArr[index].more = true
220
+ this.annotationsArr[index].text = text
115
221
  this.linkFor()
116
222
  },
117
223
  // 取消批注
@@ -128,15 +234,20 @@ export default {
128
234
  del(id,index) {
129
235
  // 删除数组
130
236
  const className2 = document.getElementsByClassName(`${id}s`)
131
- this.annotationsData.splice(index,1) // 删除批注
237
+ this.annotationsArr.splice(index,1) // 删除批注
238
+ this.annotationsData.forEach((item,index2) => {
239
+ if (item.id === id) this.annotationsData.splice(index2,1) // 删除批注
240
+ })
132
241
  this.classBackDel(className2) // 删除批注对应的样式
133
242
  this.linkFor()
243
+ this.htmlArr[this.page] = this.$refs.tagging.innerHTML
134
244
  },
135
- linkFor() {
245
+ linkFor() { // 计算线的位置
136
246
  this.linkData = []
247
+ if(this.annotationsArr.length <= 0) return
137
248
  this.$nextTick(() => {
138
- for(let i=0; i<this.annotationsData.length; i++) {
139
- this.link(this.annotationsData[i].id)
249
+ for(let i=0; i<this.annotationsArr.length; i++) {
250
+ this.link(this.annotationsArr[i].id)
140
251
  }
141
252
  })
142
253
  },
@@ -275,26 +386,29 @@ export default {
275
386
  },
276
387
  // 修改
277
388
  modify(index) {
278
- this.annotationsData[index].readable = true
389
+ this.annotationsArr[index].readable = true
279
390
  this.linkFor()
280
391
  },
281
392
  // 更多
282
393
  moreTap(index) {
283
- this.annotationsData[index].more = false
394
+ this.annotationsArr[index].more = false
284
395
  this.linkFor()
285
396
  },
286
397
  annotations() {
287
398
  this.rightMenuShow = false
288
399
  let timestamp = 'wrap' + Math.random().toString(36).substr(2)
289
400
  this.replaceSelectedStrByEle('custom-underline',timestamp)
401
+ this.htmlArr[this.page] = this.$refs.tagging.innerHTML
290
402
  // 时间戳
291
- this.annotationsData.push({
403
+ let ann = {
292
404
  id: timestamp,
293
405
  time: this.timestampToTime(new Date().getTime()),
294
406
  more: true,
295
407
  readable: true,
296
408
  text: ''
297
- })
409
+ }
410
+ this.annotationsData.push(ann)
411
+ this.annotationsArr.push(ann)
298
412
  setTimeout(() => {
299
413
  this.link(timestamp)
300
414
  },0)
@@ -328,4 +442,4 @@ export default {
328
442
  }
329
443
  </script>
330
444
 
331
- <style scoped src="./tagging.css"></style>
445
+ <style scoped src="./tagging.css"></style>
@@ -13,7 +13,7 @@
13
13
  <button class="but" @click="del(item)">删除</button>
14
14
  </b>
15
15
  <b :style="{right: -item.right + 'px', top: item.top + 'px'}" v-if="replace" ref="b">
16
- <button class="but" @click="replaceTap(item,index)">替换题目</button>
16
+ <button class="but" @click="replaceTap(item,index)">{{ replaceText }}</button>
17
17
  </b>
18
18
  <b :style="{right: -item.right + 'px', top: item.top + 'px'}" v-if="choice" ref="b">
19
19
  <button class="but"
@@ -94,7 +94,11 @@ export default {
94
94
  scoreShow: {
95
95
  type: Boolean,
96
96
  default: false
97
- }
97
+ },
98
+ replaceText: {
99
+ type: String,
100
+ default: '替换题目'
101
+ },
98
102
  },
99
103
  watch: {
100
104
  data: {
@@ -211,4 +215,4 @@ export default {
211
215
  }
212
216
  </script>
213
217
 
214
- <style scoped src="./word.css"></style>
218
+ <style scoped src="./word.css"></style>
package/src/index.js CHANGED
@@ -77,7 +77,7 @@ function install(app) {
77
77
  }
78
78
 
79
79
  export default {
80
- version: '1.32.208',
80
+ version: '1.32.210',
81
81
  install,
82
82
  Calendar,
83
83
  Message,