zydx-plus 1.20.116 → 1.20.118

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.20.116",
3
+ "version": "1.20.118",
4
4
  "description": "Vue.js",
5
5
  "main": "src/index.js",
6
6
  "files": [
@@ -1,6 +1,10 @@
1
1
 
2
2
  <script>
3
- import { defineComponent } from 'vue';
3
+ import { defineComponent, h } from 'vue';
4
+ export const FILE_ERROR = {
5
+ SIZE: 'SIZE_ERROR',
6
+ TYPE: 'TYPE_ERROR'
7
+ }
4
8
  export default defineComponent({
5
9
  name: 'zydx-button-group',
6
10
  props: {
@@ -41,23 +45,15 @@ export default defineComponent({
41
45
  }
42
46
 
43
47
  },
44
- onInputChange({ event, accept = [], file_size = 2, cb, disabled }) {
48
+ onInputChange({ event, accept = [], onError = () => null, file_size = 2, cb, disabled }) {
45
49
  if (disabled) return
46
50
  let file = event.target.files[0]
47
51
  if (file.size > file_size * 1024 * 1024) {
48
- this.$message({
49
- title: '提示',
50
- promptContent: `文件大小不能超过${file_size}M`,
51
- cancelShow: false,
52
- })
52
+ onError({ type: FILE_ERROR.SIZE })
53
53
  return
54
54
  }
55
55
  if (accept.length && !accept.includes(file.type)) {
56
- this.$message({
57
- title: '提示',
58
- promptContent: `请选择${accept.join('、')}格式的文件`,
59
- cancelShow: false,
60
- })
56
+ onError({ type: FILE_ERROR.TYPE })
61
57
  return
62
58
  }
63
59
  cb(file)
@@ -82,25 +78,43 @@ export default defineComponent({
82
78
  },
83
79
  render() {
84
80
  const { trackClick, onInputChange, showSearch, handleSearch, handleClose, is_show_search } = this
85
- const render = ({ type, name, accept = '', file_size, flip = null, ignore = false, onClick, disabled, idx }) => {
81
+ const render = ({ type, name, accept = '', file_size, flip = null, ignore = false, onClick, onError, disabled, idx, data_id }) => {
86
82
  let active_name = flip ? flip : name
87
83
  switch (type) {
88
- case 'button':
89
- return <button
90
- class={this.active_state[idx] ? 'z-button active' : 'z-button'}
91
- onClick={() => { onClick(); ignore ? () => null : trackClick(idx) }
92
- }
93
- disabled={disabled}
94
- >
95
- {this.active_state[idx] ? active_name : name}
96
- </button>
97
- case 'file':
98
- return <label class={disabled ? 'z-button disabled' : 'z-button'} >
99
- <span>{name}</span>
84
+ case 'button': {
85
+ let curr_name = this.active_state[idx] ? active_name : name
86
+ let btn = h(
87
+ <button
88
+ class={this.active_state[idx] ? 'z-button active' : 'z-button'}
89
+ data-id={data_id}
90
+ onClick={() => { onClick(); ignore ? () => null : trackClick(idx) }
91
+ }
92
+ disabled={disabled}
93
+ >
94
+ </button>,
100
95
  {
101
- disabled ? null : <input type="file" class="hidden" onClick={(e) => e.target.value = null} onChange={(e) => onInputChange({ event: e, accept, file_size, cb: onClick, disabled })}></input>
96
+ innerHTML: curr_name
102
97
  }
103
- </label>
98
+ )
99
+ return btn
100
+ }
101
+ case 'file': {
102
+ let btn = h('label', { class: disabled ? 'z-button disabled' : 'z-button' },
103
+ [
104
+ h('span', { innerHTML: name }),
105
+ disabled
106
+ ? null
107
+ : h('input', {
108
+ type: 'file',
109
+ class: 'hidden',
110
+ 'data-id': data_id,
111
+ onClick: (e) => e.target.value = null,
112
+ onChange: (e) => onInputChange({ event: e, accept, file_size, cb: onClick, onError, disabled })
113
+ })
114
+ ]
115
+ )
116
+ return btn
117
+ }
104
118
  case 'search':
105
119
  return is_show_search
106
120
  ?
@@ -118,6 +132,7 @@ export default defineComponent({
118
132
  </div>
119
133
  : <button
120
134
  class="z-button"
135
+ data-id={data_id}
121
136
  onClick={showSearch}
122
137
  >
123
138
  {name}
@@ -128,8 +143,8 @@ export default defineComponent({
128
143
  <div class="z-button-group">
129
144
  {
130
145
  this.buttons
131
- .map(({ onClick, disabled, file_size, accept, flip, ignore, type = "button", name }, idx) => {
132
- return render({ type, name, accept, file_size, flip, ignore, onClick, disabled, idx })
146
+ .map(({ onClick, onError, disabled, file_size, accept, flip, ignore, type = "button", name, data_id = '' }, idx) => {
147
+ return render({ type, name, accept, file_size, flip, ignore, onClick, onError, disabled, idx, data_id })
133
148
  }
134
149
  )
135
150
  }
@@ -5,15 +5,35 @@ let numberData = null
5
5
 
6
6
  const num = {1: '①', 2: '②', 3: '③', 4: '④', 5: '⑤', 6: '⑥', 7: '⑦', 8: '⑧', 9: '⑨', 10: '⑩', 11: '⑪', 12: '⑫', 13: '⑬', 14: '⑭', 15: '⑮', 16: '⑯', 17: '⑰', 18: '⑱', 19: '⑲', 20: '⑳',}
7
7
 
8
- function typeCode(node,value) {
8
+
9
+ function resumeSing() {
10
+ return {
11
+ type: 'attachment',
12
+ fileName: signData.text,
13
+ link: signData.ico,
14
+ sign: true,
15
+ children: [{text:''}]
16
+ }
17
+ }
18
+
19
+ function typeCode(node,value,num = false) {
9
20
  let hasAttachment = false
10
- for(let i = 0; i < node.length; i++){
11
- for(let j = 0; j < node[i].children.length; j++){
12
- if(node[i].children[j].type === value) {
21
+ if(num) {
22
+ for(let i = 0; i < node.length; i++){
23
+ if(node[i][value]) {
13
24
  hasAttachment = true
14
25
  break
15
26
  }
16
27
  }
28
+ }else {
29
+ for(let i = 0; i < node.length; i++){
30
+ for(let j = 0; j < node[i].children.length; j++){
31
+ if(node[i].children[j][value]) {
32
+ hasAttachment = true
33
+ break
34
+ }
35
+ }
36
+ }
17
37
  }
18
38
  return hasAttachment
19
39
  }
@@ -30,12 +50,31 @@ function hasValue(arr, value) {
30
50
  let num = 0
31
51
  arr.some(item => {
32
52
  item.children.some(items => {
33
- if(items.sup) num++
53
+ if(items[value]) num++
34
54
  })
35
55
  })
36
56
  return num
37
57
  }
38
58
 
59
+ //分割数组
60
+ function group(array, subNum) {
61
+ let index = 0;
62
+ let newArray = [];
63
+ let num = 0
64
+ while(index < array.length) {
65
+ newArray.push(array.slice(index, index += subNum));
66
+ }
67
+ for(let i=0; i<newArray[1].length; i++) {
68
+ if(newArray[1][i].children[0].state === undefined) {
69
+ num = (i === 0)? 1 : i
70
+ break;
71
+ }else {
72
+ num = (i === 0)? 1 : i
73
+ }
74
+ }
75
+ return num;
76
+ }
77
+
39
78
  //添加标志
40
79
  class signButtonMenu {
41
80
  constructor(v) {
@@ -61,14 +100,8 @@ class signButtonMenu {
61
100
  if (this.isDisabled(editor)) return
62
101
  let node = editor.children
63
102
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
64
- if(typeCode(node,'attachment')) return
65
- const resume = {
66
- type: 'attachment',
67
- fileName: signData.text,
68
- link: signData.ico,
69
- children: [{text:''}]
70
- }
71
- nodes.unshift(resume)
103
+ if(typeCode(nodes,'sign')) return
104
+ nodes.unshift(resumeSing())
72
105
  addNode(editor,nodes)
73
106
  }
74
107
  }
@@ -95,18 +128,10 @@ class redButtonMenu {
95
128
  if (this.isDisabled(editor)) return
96
129
  let node = editor.children
97
130
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
98
- if(nodes[0].children.length === 1) nodes.splice(0,1)
99
- let hasAttachment = false
100
- for(let i = 0; i < node.length; i++){
101
- if(node[i].state === 1) {
102
- hasAttachment = true
103
- break
104
- }
105
- }
106
- if(hasAttachment) return
131
+ if(typeCode(nodes,'tou', true)) return
107
132
  const resume = {
108
133
  type: 'paragraph',
109
- state: 1,
134
+ tou: true,
110
135
  children: [
111
136
  {
112
137
  text:'XXXXXXX(单位)文件',
@@ -131,7 +156,9 @@ class redButtonMenu {
131
156
  type: 'divider',
132
157
  children: [{text:''}]
133
158
  }
134
- if(typeCode(node,'attachment')) {
159
+ if(typeCode(node,'sign')) {
160
+ nodes.splice(0,1)
161
+ nodes.splice(0,0,resumeSing())
135
162
  nodes.splice(1,0,resume)
136
163
  nodes.splice(2,0,resume1)
137
164
  nodes.splice(3,0,resume2)
@@ -304,20 +331,15 @@ class taggingButtonMenu {
304
331
  if(anchor.offset === 0) return
305
332
  let node = editor.children
306
333
  let nodes = JSON.parse(JSON.stringify(node)) //拷贝一份
307
- const numSub = hasValue(nodes,'sup')
308
- // let one = nodes[0]
309
- // nodes.splice(0,1)
310
- // nodes.unshift({
311
- // type: 'attachment',
312
- // text: one.children[0].text
313
- // })
334
+ const numSub = hasValue(nodes,'subs')
314
335
  let textNode = nodes[anchor.path[0]].children[anchor.path[1]].text
315
336
  const left = textNode.substring(0, anchor.offset)
316
337
  const right = textNode.substring(anchor.offset)
317
338
  nodes[anchor.path[0]].children[anchor.path[1]].text = left
318
339
  nodes[anchor.path[0]].children.push({
319
340
  text: num[numSub+1],
320
- sup: true
341
+ sup: true,
342
+ subs: true
321
343
  },{text: right})
322
344
  const devider = {
323
345
  type: 'divider',
@@ -334,8 +356,12 @@ class taggingButtonMenu {
334
356
  }
335
357
  let nodeType = (nodes[anchor.path[0] + 1])? nodes[anchor.path[0] + 1].type : ''
336
358
  let deviderData = [devider,devider2]
337
- if(nodeType === 'divider') deviderData = [devider2]
338
- nodes.splice(anchor.path[0] + 1, 0, deviderData)
359
+ let numNode = -1
360
+ if(nodeType === 'divider') {
361
+ numNode = group(nodes,anchor.path[0] + 2)
362
+ deviderData = [devider2]
363
+ }
364
+ nodes.splice(anchor.path[0] + 2 + numNode, 0, deviderData)
339
365
  addNode(editor,nodes)
340
366
  }
341
367
  }
@@ -178,7 +178,7 @@ export default {
178
178
  default: true
179
179
  }
180
180
  },
181
- emits: ['see','del','complete','update:data','enclosureSuccess','download'],
181
+ emits: ['see','del','complete','update:data','enclosureSuccess','download','updateData'],
182
182
  watch:{
183
183
  // 强制监听data变化
184
184
  data: {
@@ -214,6 +214,12 @@ export default {
214
214
  }
215
215
  }),
216
216
  ],
217
+ onUpdate: ({ editor }) => {
218
+ this.$emit('updateData', {
219
+ html: html2json(editor.getHTML()).child,
220
+ enclosure: this.uploadAttData
221
+ })
222
+ },
217
223
  })
218
224
  },
219
225
  methods: {
package/src/index.js CHANGED
@@ -63,7 +63,7 @@ function install(app) {
63
63
  }
64
64
 
65
65
  export default {
66
- version: '1.20.116',
66
+ version: '1.20.118',
67
67
  install,
68
68
  Calendar,
69
69
  Message,