zydx-plus 1.28.139 → 1.29.140

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.28.139",
3
+ "version": "1.29.140",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -36,7 +36,8 @@
36
36
  "@tiptap/extension-text-style": "^2.0.3",
37
37
  "@tiptap/extension-color": "^2.0.3",
38
38
  "@vue-office/docx": "^1.1.3",
39
- "@vue-office/excel": "^1.1.3"
39
+ "@vue-office/excel": "^1.1.3",
40
+ "fabric": "^5.3.0"
40
41
  },
41
42
  "peerDependencies": {
42
43
  "vue": "^3.2.13"
@@ -40,7 +40,7 @@ export default {
40
40
  props: {
41
41
  value: {
42
42
  type: Array,
43
- default: true
43
+ default: []
44
44
  }
45
45
  },
46
46
  watch: {
@@ -48,7 +48,8 @@ export default {
48
48
  handler(val) {
49
49
  this.list = this.organize(val)
50
50
  },
51
- deep: true
51
+ deep: true,
52
+ immediate: true
52
53
  }
53
54
  },
54
55
  mounted() {
@@ -113,6 +114,7 @@ export default {
113
114
  border: none;
114
115
  outline: none;
115
116
  padding: 0 30px 0 10px;
117
+ box-sizing: border-box;
116
118
  }
117
119
  .list-cont-input img{
118
120
  width: 18px;
@@ -104,12 +104,6 @@ export default defineComponent({
104
104
  this.syncContent() //强制同步数据
105
105
  const data = this.formData.html
106
106
  for(let i=0; i<data.length; i++) {
107
- if(i === data.length - 1) {
108
- this.htmlArr.push(onePage)
109
- onePage = ''
110
- page = 0
111
- break
112
- }
113
107
  if(page >= 1162) {
114
108
  this.htmlArr.push(onePage)
115
109
  onePage = ''
@@ -160,6 +154,12 @@ export default defineComponent({
160
154
  onePage += `<p onclick="closeMaker('${data[i].link}')" style="height: 24px;line-height: 24px; margin: 5px 0;display: inline-block; position: relative;"><img style="width: 20px; height: 22px; position: absolute; top: 0; left: 0;" src="${pdf}" alt="" /><span style="display: inline-block; padding-left: 25px;font-size: 14px;">${data[i].fileName}</span></p>`
161
155
  page += 34
162
156
  }
157
+ if(i === data.length - 1) {
158
+ this.htmlArr.push(onePage)
159
+ onePage = ''
160
+ page = 0
161
+ break
162
+ }
163
163
  }
164
164
  },
165
165
  closeMaker(data) {
@@ -48,11 +48,12 @@ export default {
48
48
  handler: function (val, oldVal) {
49
49
  this.updateData(val)
50
50
  },
51
+ deep: true,
51
52
  immediate: true
52
53
  }
53
54
  },
54
55
  mounted() {
55
- this.updateData(this.value)
56
+ // this.updateData(this.value)
56
57
  },
57
58
  emits: ['change'],
58
59
  methods: {
File without changes
@@ -0,0 +1,434 @@
1
+ <template>
2
+ <div class="sketchpad">
3
+ <canvas id="canvas"></canvas>
4
+ <div class="tool">
5
+ <div class="tool-list" @click="set">
6
+ <img src="./img/shezi.png" alt="" />
7
+ <div v-if="setShow" class="set">
8
+ <div class="set-list">
9
+ <span>线条粗细</span>
10
+ <em v-for="(item,index) in strokeData" @click="strokeTap(item)">{{ item }}</em>
11
+ </div>
12
+ <div class="set-list">
13
+ <span>线条颜色</span>
14
+ <i v-for="(item,index) in strokeColor" @click="strokeColTap(item)" :style="{'background-color': item}"></i>
15
+ </div>
16
+ </div>
17
+ </div>
18
+ <div class="tool-list" @click="brush">
19
+ <img src="./img/huabi.png" alt="" />
20
+ </div>
21
+ <div class="tool-list" @click="rectangle">
22
+ <img src="./img/juxing.png" alt="" />
23
+ </div>
24
+ <div class="tool-list" @click="addTextBox">
25
+ <img src="./img/wenzi.png" alt="" />
26
+ <div v-if="textShow" class="set">
27
+ <div class="set-list">
28
+ <span>字号</span>
29
+ <em style="font-size: 13px;" v-for="(item,index) in textData" @click.stop="sizeTap(item)">{{ item }}</em>
30
+ </div>
31
+ <div class="set-list">
32
+ <span>内容</span>
33
+ <input type="text" v-model="text" @click.stop="false" />
34
+ </div>
35
+ <div class="set-list set-right">
36
+ <button class="but" @click="textBox">确认</button>
37
+ </div>
38
+ </div>
39
+ </div>
40
+ <div class="tool-list" @click="rotundity">
41
+ <img src="./img/yuan.png" alt="" />
42
+ </div>
43
+ <div class="tool-list" @click="addLine">
44
+ <img src="./img/jian.png" alt="" />
45
+ </div>
46
+ <div class="tool-list" @click="arrow">
47
+ <img src="./img/jiantou.png" alt="" />
48
+ </div>
49
+ <div class="tool-list" @click="save">
50
+ <img src="./img/baocun.png" alt="" />
51
+ </div>
52
+ <div class="tool-list" @click="clear">
53
+ <img src="./img/xiangpi.png" alt="" />
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </template>
58
+
59
+ <script>
60
+ import { fabric } from 'fabric'
61
+ export default {
62
+ name: "zydx-sketchpad",
63
+ data() {
64
+ return {
65
+ canvas: null,
66
+ strokeWidth: 2, // 线条粗细
67
+ color: '#000', // 线条颜色
68
+ line: null, // 线条
69
+ isDown: false, // 是否按下
70
+ state: null, // 状态
71
+ rect: null, // 矩形
72
+ circle: null, // 圆形
73
+ fontSize: 14, // 字体大小
74
+ setShow: false, // 设置
75
+ strokeData: ['1','2','3','4','5','6','7'], // 画笔数据
76
+ strokeColor: ['#000','#f00','#0f0','#00f','#f0f','#ff0','#0ff'], // 画笔颜色
77
+ textShow: false, // 文本
78
+ textData: ['14','16','18','20','22','24','28','30'], // 文本数据
79
+ text: ''
80
+ }
81
+ },
82
+ props: {
83
+ width: {
84
+ type: Number,
85
+ default: 800
86
+ },
87
+ height: {
88
+ type: Number,
89
+ default: 800
90
+ }
91
+ },
92
+ emits: ['save'],
93
+ mounted() {
94
+ this.init()
95
+ window.addEventListener('keydown', this.handleKeyEvent)
96
+ },
97
+ beforeDestroy() {
98
+ window.removeEventListener('keydown', this.handleKeyEvent)
99
+ },
100
+ methods: {
101
+ sizeTap(v) {
102
+ this.fontSize = Number(v)
103
+ },
104
+ addTextBox() {
105
+ this.state = 'text'
106
+ this.setShow = false
107
+ this.textShow = !this.textShow
108
+ },
109
+ strokeColTap(v) {
110
+ this.color = v
111
+ },
112
+ strokeTap(v) {
113
+ this.strokeWidth = Number(v)
114
+ },
115
+ set() {
116
+ this.textShow = false
117
+ this.setShow = !this.setShow
118
+ },
119
+ init() {
120
+ this.canvas = new fabric.Canvas("canvas", {
121
+ isDrawingMode: false,
122
+ width: this.width,
123
+ height: this.height,
124
+ });
125
+ this.canvas.selectionColor = "rgba(255,255,255,0)";
126
+ // this.canvas.loadFromJSON(v)
127
+ },
128
+ // 画笔
129
+ brush() {
130
+ this.state = 'brush'
131
+ this.canvas.isDrawingMode = !this.canvas.isDrawingMode
132
+ this.canvas.freeDrawingBrush.width = this.strokeWidth
133
+ this.canvas.freeDrawingBrush.color = this.color
134
+ },
135
+ // 直线
136
+ addLine() {
137
+ this.canvas.isDrawingMode = false
138
+ this.state = 'line'
139
+ const id = Date.now()
140
+ this.canvas.on('mouse:down', (o) => {
141
+ if(o.target !== null) return
142
+ if(this.state !== 'line') return
143
+ this.isDown = true
144
+ const pointer = this.canvas.getPointer(o.e)
145
+ const points = [pointer.x, pointer.y, pointer.x, pointer.y]
146
+ this.line = new fabric.Line(points, {
147
+ id: id,
148
+ strokeWidth: this.strokeWidth,
149
+ fill: this.color,
150
+ stroke: this.color,
151
+ originX: 'center',
152
+ originY: 'center'
153
+ })
154
+ this.canvas.add(this.line)
155
+ })
156
+ this.canvas.on('mouse:move', (o) => {
157
+ if(this.state !== 'line') return
158
+ if (!this.isDown) return
159
+ const pointer = this.canvas.getPointer(o.e)
160
+ this.line.set({ x2: pointer.x, y2: pointer.y })
161
+ this.canvas.renderAll()
162
+ })
163
+
164
+ this.canvas.on('mouse:up', (o) => {
165
+ this.isDown = false
166
+ this.line.setCoords()
167
+ })
168
+ },
169
+ // 矩形
170
+ rectangle() {
171
+ this.canvas.isDrawingMode = false
172
+ this.state = 'rectangle'
173
+ const id = Date.now()
174
+ let origX, origY
175
+ this.canvas.on('mouse:down', (o) => {
176
+ if(o.target !== null) return
177
+ if(this.state !== 'rectangle') return
178
+ this.isDown = true
179
+ let pointer = this.canvas.getPointer(o.e)
180
+ origX = pointer.x
181
+ origY = pointer.y
182
+ this.rect = new fabric.Rect({
183
+ id: id,
184
+ left: origX,
185
+ top: origY,
186
+ originX: 'left',
187
+ originY: 'top',
188
+ width: pointer.x - origX,
189
+ height: pointer.y - origY,
190
+ angle: 0,
191
+ fill: '',
192
+ stroke: this.color,
193
+ strokeWidth: this.strokeWidth
194
+ })
195
+ this.canvas.add(this.rect)
196
+ })
197
+ this.canvas.on('mouse:move', (o) => {
198
+ if(this.state !== 'rectangle') return
199
+ if (!this.isDown) return
200
+ let pointer = this.canvas.getPointer(o.e)
201
+
202
+ if (origX > pointer.x) {
203
+ this.rect.set({ left: Math.abs(pointer.x) })
204
+ }
205
+ if (origY > pointer.y) {
206
+ this.rect.set({ top: Math.abs(pointer.y) })
207
+ }
208
+ this.rect.set({ width: Math.abs(origX - pointer.x) })
209
+ this.rect.set({ height: Math.abs(origY - pointer.y) })
210
+ this.canvas.renderAll()
211
+ })
212
+ this.canvas.on('mouse:up', (o) => {
213
+ this.isDown = false
214
+ this.rect.setCoords()
215
+ })
216
+ },
217
+ // 圆形
218
+ rotundity() {
219
+ this.canvas.isDrawingMode = false
220
+ this.state = 'rotundity'
221
+ let origX, origY
222
+ this.canvas.on('mouse:down', (o) => {
223
+ if(o.target !== null) return
224
+ if(this.state !== 'rotundity') return
225
+ this.isDown = true
226
+ let pointer = this.canvas.getPointer(o.e)
227
+ origX = pointer.x
228
+ origY = pointer.y
229
+ this.circle = new fabric.Circle({
230
+ left: origX,
231
+ top: origY,
232
+ originX: 'left',
233
+ originY: 'top',
234
+ radius: pointer.x - origX,
235
+ angle: 0,
236
+ fill: '',
237
+ stroke: this.color,
238
+ strokeWidth: this.strokeWidth
239
+ })
240
+ this.canvas.add(this.circle)
241
+ })
242
+ this.canvas.on('mouse:move', (o) => {
243
+ if(this.state !== 'rotundity') return
244
+ if (!this.isDown) return
245
+ let pointer = this.canvas.getPointer(o.e)
246
+ let radius =
247
+ Math.max(
248
+ Math.abs(origY - pointer.y),
249
+ Math.abs(origX - pointer.x)
250
+ ) / 2
251
+ if (radius > this.circle.strokeWidth) {
252
+ radius -= this.circle.strokeWidth / 2
253
+ }
254
+ this.circle.set({ radius: radius })
255
+
256
+ if (origX > pointer.x) {
257
+ this.circle.set({ originX: 'right' })
258
+ } else {
259
+ this.circle.set({ originX: 'left' })
260
+ }
261
+ if (origY > pointer.y) {
262
+ this.circle.set({ originY: 'bottom' })
263
+ } else {
264
+ this.circle.set({ originY: 'top' })
265
+ }
266
+ this.canvas.renderAll()
267
+ })
268
+ this.canvas.on('mouse:up', () => {
269
+ this.isDown = false
270
+ this.circle.setCoords()
271
+ })
272
+ },
273
+ // 箭头
274
+ arrow() {
275
+ const id = Date.now()
276
+ const triangle = new fabric.Triangle({
277
+ width: 9,
278
+ height: 15,
279
+ fill: 'black',
280
+ left: 150,
281
+ top: 137,
282
+ angle: 90
283
+ })
284
+ const line = new fabric.Rect({
285
+ left: 100,
286
+ top: 140,
287
+ width: 40,
288
+ height: 3,
289
+ fill: 'black',
290
+ originX: 'left',
291
+ originY: 'top',
292
+ centeredRotation: true
293
+ })
294
+ const arrow = new fabric.Group([line, triangle], {
295
+ id: id,
296
+ left: this.canvas.width / 2,
297
+ top: this.canvas.height / 2,
298
+ angle: 0
299
+ })
300
+ this.canvas.add(arrow)
301
+ },
302
+ // 文本框
303
+ textBox() {
304
+ const id = Date.now()
305
+ this.textbox = new fabric.Textbox(this.text, {
306
+ id: id,
307
+ top: 200,
308
+ left: 200,
309
+ width: 10,
310
+ fill: this.color,
311
+ fontSize: this.fontSize,
312
+ color: this.color,
313
+ fontWeight: 400,
314
+ lineHeight: 1.5,
315
+ fontFamily: '微软雅黑',
316
+ textDecoration: 'none',
317
+ textAlign: 'left'
318
+ })
319
+ this.canvas.add(this.textbox)
320
+ },
321
+ save() {
322
+ this.$emit('save', this.canvas.toJSON())
323
+ },
324
+ clear() {
325
+ this.canvas.clear()
326
+ },
327
+ handleKeyEvent (e) {
328
+ const { key } = e
329
+ if (key === 'Backspace' || key === 'Delete') {
330
+ const el = this.canvas.getActiveObject()
331
+ if(el) this.canvas.remove(el)
332
+ }
333
+ }
334
+ }
335
+ }
336
+ </script>
337
+
338
+ <style scoped>
339
+ .sketchpad{
340
+ position: relative;
341
+ }
342
+ .tool{
343
+ position: absolute;
344
+ top: 50%;
345
+ left: -55px;
346
+ z-index: 1;
347
+ width: 50px;
348
+ padding: 15px;
349
+ border-radius: 10px;
350
+ box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
351
+ box-sizing: border-box;
352
+ background: #fff;
353
+ margin-top: -200px;
354
+ }
355
+ .tool-list{
356
+ width: 100%;
357
+ margin-bottom: 20px;
358
+ cursor: pointer;
359
+ position: relative;
360
+ }
361
+ .tool-list:last-child{
362
+ margin-bottom: 0;
363
+ }
364
+ .tool-list img{
365
+ width: 100%;
366
+ }
367
+ .set{
368
+ position: absolute;
369
+ top: 0;
370
+ left: 40px;
371
+ width: 280px;
372
+ background-color: #fff;
373
+ border-radius: 10px;
374
+ box-shadow: 0 0 5px 3px rgba(0,0,0,0.3);
375
+ padding: 10px;
376
+ z-index: 1;
377
+ }
378
+ .set-list{
379
+ padding: 5px 0;
380
+ font-size: 15px;
381
+ }
382
+ .set-list:after{
383
+ content: '';
384
+ display: block;
385
+ clear: both;
386
+ }
387
+ .set-list span{
388
+ margin-right: 10px;
389
+ float: left;
390
+ }
391
+ .set-list em{
392
+ font-style: normal;
393
+ font-size: 15px;
394
+ width: 16px;
395
+ display: inline-block;
396
+ margin-right: 10px;
397
+ text-align: center;
398
+ }
399
+ .set-list em:hover{
400
+ color: #5daf34;
401
+ }
402
+ .set-list i{
403
+ display: inline-block;
404
+ width: 16px;
405
+ height: 16px;
406
+ background-color: #000;
407
+ margin: 2px 10px 0 0;
408
+ float: left;
409
+ }
410
+ .set-list input{
411
+ width: calc(100% - 60px);
412
+ height: 22px;
413
+ border: 1px solid #ccc;
414
+ border-radius: 5px;
415
+ padding: 0 10px;
416
+ box-sizing: border-box;
417
+ float: left;
418
+ }
419
+ .but{
420
+ margin-left: 5px;
421
+ font-size: 12px;
422
+ background-color: transparent;
423
+ border: 1px solid #000;
424
+ border-radius: 3px;
425
+ padding: 2px 5px;
426
+ cursor: pointer;
427
+ min-width: 60px;
428
+ height: 21px;
429
+ margin-right: 20px;
430
+ }
431
+ .set-right{
432
+ text-align: right;
433
+ }
434
+ </style>
@@ -8,7 +8,7 @@ render(divNode, document.body)
8
8
  const container = divNode.el
9
9
 
10
10
  // 导出函数可通过调用 Confirm() 函数动态创建 XtxConfirm 组件
11
- const Confirm = ({ type, url ,title,radioArr, promptContent, middle, cancelShow, inputArr }) => {
11
+ const Confirm = ({ type, url ,title,radioArr,submitText, promptContent, middle, cancelShow, inputArr }) => {
12
12
  // 返回 Promise 对象
13
13
  return new Promise((resolve, reject) => {
14
14
  // 2. 点击确认按钮,触发resolve同时销毁组件
@@ -39,7 +39,7 @@ const Confirm = ({ type, url ,title,radioArr, promptContent, middle, cancelShow,
39
39
  reject('点击取消')
40
40
  }
41
41
  // 1. 创建 XtxConfirm 组件
42
- const VNode = createVNode(XtxConfirm, { type, url ,title, promptContent,radioArr, middle, cancelShow, inputArr, submit, cancel })
42
+ const VNode = createVNode(XtxConfirm, { type, url ,title, submitText, promptContent,radioArr, middle, cancelShow, inputArr, submit, cancel })
43
43
  render(VNode, container)
44
44
  })
45
45
  }
@@ -63,7 +63,7 @@
63
63
  </div>
64
64
  </div>
65
65
  <div class="tip-btnBox">
66
- <div @click="submit">确认</div>
66
+ <div @click="submit">{{ submitText }}</div>
67
67
  <div v-if="cancelShow" @click="cancel">取消</div>
68
68
  </div>
69
69
  </div>
@@ -117,6 +117,10 @@ export default {
117
117
  type: Array,
118
118
  default: []
119
119
  },
120
+ submitText: { // 确认按钮
121
+ type: String,
122
+ default: '确认'
123
+ },
120
124
  // 确认按钮
121
125
  submit: {
122
126
  type: Function,
@@ -6,7 +6,7 @@
6
6
  <div class="subject-title">
7
7
  <label>
8
8
  <input v-if="multipleShow" type="checkbox" @change="checkboxChange($event,index)" name="check" />
9
- <span>{{ index + 1 }}.<em v-html="item.title"></em></span>
9
+ <span>{{ item.order }}.<em v-html="item.title"></em></span>
10
10
  </label>
11
11
  </div>
12
12
  <div class="subject-but" v-if="butShow">
package/src/index.js CHANGED
@@ -27,6 +27,7 @@ import time from './components/time/index';
27
27
  import preface from './components/preface/index';
28
28
  import choice from './components/choice/index';
29
29
  import word from './components/word/index';
30
+ import sketchpad from './components/sketchpad/index';
30
31
 
31
32
  const components = [
32
33
  Calendar,
@@ -55,7 +56,8 @@ const components = [
55
56
  time,
56
57
  preface,
57
58
  choice,
58
- word
59
+ word,
60
+ sketchpad
59
61
  ];
60
62
 
61
63
  function install(app) {
@@ -67,7 +69,7 @@ function install(app) {
67
69
  }
68
70
 
69
71
  export default {
70
- version: '1.28.139',
72
+ version: '1.29.140',
71
73
  install,
72
74
  Calendar,
73
75
  Message,
@@ -97,6 +99,7 @@ export default {
97
99
  time,
98
100
  preface,
99
101
  choice,
100
- word
102
+ word,
103
+ sketchpad
101
104
  };
102
105