zydx-plus 1.20.117 → 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,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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
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
|
-
|
|
96
|
+
innerHTML: curr_name
|
|
102
97
|
}
|
|
103
|
-
|
|
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
|
}
|
|
@@ -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: {
|