zydx-plus 1.19.88 → 1.19.90
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 +1 -1
- package/src/components/data_table/src/data_table.vue +72 -14
- package/src/components/data_table/src/table_head.vue +7 -4
- package/src/components/data_table/src/table_row.vue +30 -13
- package/src/components/editor2/src/editor.vue +10 -9
- package/src/components/read/src/read.vue +2 -2
- package/src/components/select/src/select.vue +33 -12
- package/src/index.js +1 -1
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@ import tableHead from './table_head.vue'
|
|
|
4
4
|
import tableRow from './table_row.vue'
|
|
5
5
|
import { defineComponent } from 'vue';
|
|
6
6
|
export function getColKey(col) {
|
|
7
|
-
if (col.type === 'checkbox') return '
|
|
7
|
+
if (col.type === 'checkbox') return 'checkbox'
|
|
8
8
|
return col.key
|
|
9
9
|
}
|
|
10
10
|
function getRowsAndCols(
|
|
@@ -135,18 +135,14 @@ export default defineComponent({
|
|
|
135
135
|
rows: [],
|
|
136
136
|
cols: [],
|
|
137
137
|
checkbox_state: [],
|
|
138
|
-
draggable_state: []
|
|
138
|
+
draggable_state: [],
|
|
139
|
+
matrix: []
|
|
139
140
|
}
|
|
140
141
|
},
|
|
141
|
-
emits: ['
|
|
142
|
+
emits: ['selected'],
|
|
142
143
|
mounted() {
|
|
143
|
-
const { rows, cols } = getRowsAndCols(this.columns)
|
|
144
|
-
this.rows = rows
|
|
145
|
-
this.cols = cols
|
|
146
144
|
this.draggable_state = [...this.data]
|
|
147
|
-
|
|
148
|
-
this.checkbox_state = Array.from({ length: this.data.length + 1 }, () => { return false })
|
|
149
|
-
}
|
|
145
|
+
this.checkbox_state = Array.from({ length: this.data.length + 1 }, () => { return false })
|
|
150
146
|
},
|
|
151
147
|
methods: {
|
|
152
148
|
onDragEnd: function (payload) {
|
|
@@ -167,16 +163,78 @@ export default defineComponent({
|
|
|
167
163
|
}
|
|
168
164
|
} else {
|
|
169
165
|
this.checkbox_state[idx] = !this.checkbox_state[idx]
|
|
166
|
+
if (this.checkbox_state.slice(1).some((v) => !v)) {
|
|
167
|
+
this.checkbox_state[0] = false
|
|
168
|
+
} else {
|
|
169
|
+
this.checkbox_state[0] = true
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
this.$emit('selected', this.checked_row)
|
|
173
|
+
},
|
|
174
|
+
draw_matrix: function ({ key, row, colSpan, rowSpan }) {
|
|
175
|
+
let column_index = this.matrix[row].findIndex(col => col.key === key)
|
|
176
|
+
this.matrix[row][column_index].rowSpan = rowSpan
|
|
177
|
+
this.matrix[row][column_index].colSpan = colSpan
|
|
178
|
+
},
|
|
179
|
+
traverse_matrix: function () {
|
|
180
|
+
// todo:优化traverse matrix 算法, 目前是O(n^3)
|
|
181
|
+
for (let i = 0; i < this.matrix.length; i++) {
|
|
182
|
+
for (let j = 0; j < this.matrix[i].length; j++) {
|
|
183
|
+
const { rowSpan, colSpan } = this.matrix[i][j]
|
|
184
|
+
if (rowSpan > 1) {
|
|
185
|
+
for (let r = 1; r < rowSpan; r++) {
|
|
186
|
+
this.matrix[i + r][j].rowSpan = 0
|
|
187
|
+
this.matrix[i + r][j].colSpan = 0
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
if (colSpan > 1) {
|
|
191
|
+
for (let r = 0; r < rowSpan; r++) {
|
|
192
|
+
for (let k = 1; k < colSpan; k++) {
|
|
193
|
+
this.matrix[i + r][j + k].colSpan = 0
|
|
194
|
+
this.matrix[i + r][j + k].rowSpan = 0
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
170
199
|
}
|
|
171
|
-
this.$emit('update:checkedRow', this.checked_row)
|
|
172
200
|
}
|
|
173
201
|
},
|
|
174
|
-
|
|
175
202
|
provide() {
|
|
176
203
|
return {
|
|
177
204
|
onCheckboxClick: this.onCheckboxClick,
|
|
178
205
|
}
|
|
179
206
|
},
|
|
207
|
+
watch: {
|
|
208
|
+
data: {
|
|
209
|
+
handler: function (v) {
|
|
210
|
+
if (!v) return
|
|
211
|
+
const { rows, cols } = getRowsAndCols(this.columns)
|
|
212
|
+
this.rows = rows
|
|
213
|
+
this.cols = cols
|
|
214
|
+
this.matrix = Array.from({ length: v.length }, () => {
|
|
215
|
+
return Array.from({ length: this.cols.length },
|
|
216
|
+
(_, idx) => {
|
|
217
|
+
return { key: this.cols[idx].key, row: 1, colSpan: 1, rowSpan: 1 }
|
|
218
|
+
})
|
|
219
|
+
})
|
|
220
|
+
v.forEach((row, row_idx) => {
|
|
221
|
+
this.cols.forEach((col) => {
|
|
222
|
+
const { column } = col
|
|
223
|
+
const { key, colSpan = () => 1, rowSpan = () => 1 } = column
|
|
224
|
+
this.draw_matrix({
|
|
225
|
+
key: key,
|
|
226
|
+
row: row_idx,
|
|
227
|
+
rowSpan: rowSpan(row, row_idx + 1),
|
|
228
|
+
colSpan: colSpan(row, row_idx + 1)
|
|
229
|
+
})
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
this.traverse_matrix()
|
|
233
|
+
},
|
|
234
|
+
immediate: true,
|
|
235
|
+
deep: true
|
|
236
|
+
}
|
|
237
|
+
},
|
|
180
238
|
computed: {
|
|
181
239
|
getHeight() {
|
|
182
240
|
if (this.maxHeight) {
|
|
@@ -206,7 +264,7 @@ export default defineComponent({
|
|
|
206
264
|
}
|
|
207
265
|
},
|
|
208
266
|
render() {
|
|
209
|
-
const { draggable, rows, cols, data, getHeight, getWidth, onDragEnd, checkbox_state } = this
|
|
267
|
+
const { draggable, rows, cols, data, getHeight, getWidth, onDragEnd, checkbox_state, matrix } = this
|
|
210
268
|
return (
|
|
211
269
|
<div class="table_wrapper" style={[getHeight, getWidth]}>
|
|
212
270
|
{
|
|
@@ -217,7 +275,7 @@ export default defineComponent({
|
|
|
217
275
|
<table-head rows={rows} checked={checkbox_state[0]}></table-head>
|
|
218
276
|
{
|
|
219
277
|
data.map((row, idx) => (
|
|
220
|
-
<table-row checked={checkbox_state[idx + 1]} cols={cols} row={row} draggable={draggable} data_row={idx + 1} />
|
|
278
|
+
<table-row rowInfo={matrix[idx]} checked={checkbox_state[idx + 1]} cols={cols} row={row} draggable={draggable} data_row={idx + 1} />
|
|
221
279
|
))
|
|
222
280
|
}
|
|
223
281
|
</VueDraggableNext>
|
|
@@ -229,7 +287,7 @@ export default defineComponent({
|
|
|
229
287
|
<tbody class="table_body">
|
|
230
288
|
{
|
|
231
289
|
data.map((row, idx) => (
|
|
232
|
-
<table-row checked={checkbox_state[idx + 1]} cols={cols} row={row} draggable={draggable} data_row={idx + 1} />
|
|
290
|
+
<table-row rowInfo={matrix[idx]} checked={checkbox_state[idx + 1]} cols={cols} row={row} draggable={draggable} data_row={idx + 1} />
|
|
233
291
|
))
|
|
234
292
|
}
|
|
235
293
|
</tbody>
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
<tr v-for=" (row, idx) in rows"
|
|
4
4
|
class="table_row"
|
|
5
5
|
:key="idx">
|
|
6
|
-
<th v-for="({ key, rowSpan, colSpan, column }) in row"
|
|
6
|
+
<th v-for="({ key, rowSpan, colSpan, column }, row_idx) in row"
|
|
7
7
|
:key="key"
|
|
8
8
|
class="table_cell"
|
|
9
9
|
:data-col-key="key"
|
|
10
10
|
:rowspan="rowSpan"
|
|
11
11
|
:colspan="colSpan"
|
|
12
|
-
:style="sticky({ level: idx, column: column })">
|
|
13
|
-
<template v-if="column.
|
|
12
|
+
:style="sticky({ level: idx, column: column, row: row, idx: row_idx })">
|
|
13
|
+
<template v-if="column.key === 'checkbox'">
|
|
14
14
|
<td class="checkbox_container table_cell">
|
|
15
15
|
<input type="checkbox"
|
|
16
16
|
@click="() => onCheckboxClick(0)"
|
|
@@ -47,12 +47,14 @@ export default defineComponent({
|
|
|
47
47
|
},
|
|
48
48
|
inject: ['onCheckboxClick'],
|
|
49
49
|
methods: {
|
|
50
|
-
sticky: function ({ level, column }) {
|
|
50
|
+
sticky: function ({ level, column, row, idx }) {
|
|
51
|
+
const left = row.slice(0, idx).reduce((acc, cur) => (cur.column.width + acc), 0)
|
|
51
52
|
return ` background: white;
|
|
52
53
|
position: sticky;
|
|
53
54
|
z-index: 5;
|
|
54
55
|
min-width: ${column.width}px;
|
|
55
56
|
max-width: ${column.width}px;
|
|
57
|
+
left: ${left}px;
|
|
56
58
|
top: ${level * 31}px;}`
|
|
57
59
|
}
|
|
58
60
|
}
|
|
@@ -101,6 +103,7 @@ td {
|
|
|
101
103
|
text-align: center;
|
|
102
104
|
text-align: center;
|
|
103
105
|
line-height: 30px;
|
|
106
|
+
font-size: 14px;
|
|
104
107
|
}
|
|
105
108
|
|
|
106
109
|
th {
|
|
@@ -7,6 +7,10 @@ export default defineComponent({
|
|
|
7
7
|
type: Object,
|
|
8
8
|
default: () => ({})
|
|
9
9
|
},
|
|
10
|
+
rowInfo: {
|
|
11
|
+
type: Array,
|
|
12
|
+
default: () => []
|
|
13
|
+
},
|
|
10
14
|
cols: {
|
|
11
15
|
type: Array,
|
|
12
16
|
default: () => []
|
|
@@ -26,31 +30,43 @@ export default defineComponent({
|
|
|
26
30
|
},
|
|
27
31
|
inject: ['onCheckboxClick'],
|
|
28
32
|
render() {
|
|
29
|
-
const { cols, row, data_row, draggable, checked, onCheckboxClick } = this
|
|
33
|
+
const { cols, row, data_row, draggable, checked, onCheckboxClick, rowInfo } = this
|
|
30
34
|
const { renderExpand, expandable } = row
|
|
31
35
|
const renderCell = () => {
|
|
32
|
-
return cols.map(({ column, key }) => {
|
|
33
|
-
const { width
|
|
36
|
+
return cols.map(({ column, key }, idx) => {
|
|
37
|
+
const { width } = column
|
|
38
|
+
const { colSpan, rowSpan } = rowInfo[idx]
|
|
39
|
+
const mergeCell = ({ rowSpan, colSpan, renderFn = false }) => {
|
|
40
|
+
return rowSpan >= 1 && colSpan >= 1
|
|
41
|
+
? renderFn
|
|
42
|
+
?
|
|
43
|
+
(
|
|
44
|
+
<td class="table_cell" style={`min-width:${width}px; max-width:${width}px; `} rowspan={rowSpan} colspan={colSpan} data-col-key={key}>
|
|
45
|
+
{row[key](row)}
|
|
46
|
+
</td>
|
|
47
|
+
)
|
|
48
|
+
: (
|
|
49
|
+
<td class="table_cell" style={`min-width:${width}px; max-width:${width}px;`} rowspan={rowSpan} colspan={colSpan} data-col-key={key}>
|
|
50
|
+
{row[key]}
|
|
51
|
+
</td>
|
|
52
|
+
)
|
|
53
|
+
: null
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
}
|
|
34
57
|
return typeof row[key] === 'function'
|
|
35
58
|
?
|
|
36
59
|
(
|
|
37
|
-
|
|
38
|
-
{row[key](row)}
|
|
39
|
-
</td>
|
|
60
|
+
mergeCell({ rowSpan, colSpan, renderFn: true })
|
|
40
61
|
)
|
|
41
62
|
:
|
|
42
|
-
|
|
43
|
-
|
|
63
|
+
key === 'checkbox'
|
|
44
64
|
? (
|
|
45
65
|
<td class="checkbox_container table_cell">
|
|
46
66
|
<input type="checkbox" checked={checked} onClick={() => onCheckboxClick(data_row)} />
|
|
47
67
|
</td>
|
|
48
68
|
)
|
|
49
|
-
: (
|
|
50
|
-
<td class="table_cell" style={`min-width:${width}px; max-width:${width}px;`} rowspan={1} colspan={1} data-col-key={key}>
|
|
51
|
-
{row[key]}
|
|
52
|
-
</td>
|
|
53
|
-
)
|
|
69
|
+
: mergeCell({ rowSpan, colSpan })
|
|
54
70
|
})
|
|
55
71
|
}
|
|
56
72
|
const renderExpandable = () => {
|
|
@@ -115,6 +131,7 @@ export default defineComponent({
|
|
|
115
131
|
text-align: center;
|
|
116
132
|
text-align: center;
|
|
117
133
|
line-height: 30px;
|
|
134
|
+
font-size: 14px;
|
|
118
135
|
}
|
|
119
136
|
|
|
120
137
|
th,
|
|
@@ -144,7 +144,7 @@ export default {
|
|
|
144
144
|
},
|
|
145
145
|
uploadType: {
|
|
146
146
|
type: Boolean,
|
|
147
|
-
default:
|
|
147
|
+
default: false
|
|
148
148
|
},
|
|
149
149
|
info: {
|
|
150
150
|
type: String,
|
|
@@ -201,19 +201,19 @@ export default {
|
|
|
201
201
|
see(index) {
|
|
202
202
|
this.$emit('see', this.uploadAttData[index])
|
|
203
203
|
},
|
|
204
|
-
uploadFile(file) {
|
|
204
|
+
uploadFile(file,data) {
|
|
205
205
|
return new Promise((rl,re) => {
|
|
206
|
-
const meta = Object.keys(
|
|
206
|
+
const meta = Object.keys(data.meta)
|
|
207
207
|
const param = new FormData()
|
|
208
208
|
param.append('file', file)
|
|
209
209
|
for(let i = 0; i < meta.length; i++) {
|
|
210
|
-
param.append(meta[i],
|
|
210
|
+
param.append(meta[i], data.meta[meta[i]])
|
|
211
211
|
}
|
|
212
212
|
const xhr = new XMLHttpRequest()
|
|
213
|
-
xhr.open('POST',
|
|
214
|
-
const headers = Object.keys(
|
|
213
|
+
xhr.open('POST', data.server)
|
|
214
|
+
const headers = Object.keys(data.headers)
|
|
215
215
|
for(let i = 0; i < headers.length; i++) {
|
|
216
|
-
xhr.setRequestHeader(headers[i],
|
|
216
|
+
xhr.setRequestHeader(headers[i], data.headers[headers[i]])
|
|
217
217
|
}
|
|
218
218
|
xhr.onreadystatechange = () => {
|
|
219
219
|
if(xhr.readyState === 4) {
|
|
@@ -229,9 +229,10 @@ export default {
|
|
|
229
229
|
const file = e.target.files[0]
|
|
230
230
|
if(this.uploadType) {
|
|
231
231
|
if(v === 'uploadAtt') {
|
|
232
|
+
file.active = true
|
|
232
233
|
this.uploadAttData.push(file)
|
|
233
234
|
}else {
|
|
234
|
-
this.uploadFile(file).then(r => {
|
|
235
|
+
this.uploadFile(file,this.uploadImage).then(r => {
|
|
235
236
|
const url = this.uploadImage.url + r.data
|
|
236
237
|
const html = [
|
|
237
238
|
{
|
|
@@ -251,7 +252,7 @@ export default {
|
|
|
251
252
|
})
|
|
252
253
|
}
|
|
253
254
|
}else {
|
|
254
|
-
this.uploadFile(file).then(r => {
|
|
255
|
+
this.uploadFile(file,(v === 'uploadAtt')? this.uploadAttachment: this.uploadImage).then(r => {
|
|
255
256
|
if(v === 'uploadAtt') {
|
|
256
257
|
r.data.active = true
|
|
257
258
|
this.uploadAttData.push(r.data)
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="wrapper">
|
|
3
|
-
<!-- <div id='custom-select-status'
|
|
4
|
-
class='hidden-visually'
|
|
5
|
-
aria-live="polite"></div> -->
|
|
6
3
|
<div class="custom-select">
|
|
7
4
|
<input stype="text"
|
|
8
5
|
:value="selected"
|
|
6
|
+
:placeholder="placeholder"
|
|
9
7
|
:readonly="true"
|
|
10
8
|
@click="toggleDropDown"
|
|
11
9
|
class="select-css" />
|
|
@@ -24,7 +22,7 @@
|
|
|
24
22
|
</span>
|
|
25
23
|
<transition>
|
|
26
24
|
<ul v-if="isOpen"
|
|
27
|
-
class="custom-select-options">
|
|
25
|
+
:class="{ 'custom-select-options': true, 'scroll': maxHeight > 0 }">
|
|
28
26
|
<li v-for="(option, idx) in options"
|
|
29
27
|
:key="idx"
|
|
30
28
|
@click="handleClick(option)">{{ option.label }}</li>
|
|
@@ -46,6 +44,14 @@ export default defineComponent({
|
|
|
46
44
|
value: {
|
|
47
45
|
type: String,
|
|
48
46
|
default: ''
|
|
47
|
+
},
|
|
48
|
+
placeholder: {
|
|
49
|
+
type: String,
|
|
50
|
+
default: ''
|
|
51
|
+
},
|
|
52
|
+
maxHeight: {
|
|
53
|
+
type: Number,
|
|
54
|
+
default: 0
|
|
49
55
|
}
|
|
50
56
|
},
|
|
51
57
|
data() {
|
|
@@ -72,12 +78,21 @@ export default defineComponent({
|
|
|
72
78
|
},
|
|
73
79
|
style: function () {
|
|
74
80
|
return 'transition: all 0.2s ease;'
|
|
81
|
+
},
|
|
82
|
+
_maxHeight: function () {
|
|
83
|
+
return this.maxHeight > 0
|
|
84
|
+
? `${this.maxHeight}px`
|
|
85
|
+
: ''
|
|
75
86
|
}
|
|
76
87
|
},
|
|
77
88
|
watch: {
|
|
78
89
|
value: {
|
|
79
90
|
handler: function (v) {
|
|
80
|
-
|
|
91
|
+
if (!v || !this.options.length) {
|
|
92
|
+
this.selected = ''
|
|
93
|
+
return
|
|
94
|
+
}
|
|
95
|
+
const { label } = this.options.find(option => option.value === v) || { label: '' }
|
|
81
96
|
this.selected = label
|
|
82
97
|
},
|
|
83
98
|
immediate: true
|
|
@@ -132,8 +147,6 @@ export default defineComponent({
|
|
|
132
147
|
-webkit-appearance: none;
|
|
133
148
|
appearance: none;
|
|
134
149
|
background-color: #fff;
|
|
135
|
-
position: relative;
|
|
136
|
-
z-index: 10;
|
|
137
150
|
outline: none;
|
|
138
151
|
}
|
|
139
152
|
|
|
@@ -152,10 +165,9 @@ export default defineComponent({
|
|
|
152
165
|
|
|
153
166
|
.custom-select-icons {
|
|
154
167
|
position: absolute;
|
|
155
|
-
top:
|
|
156
|
-
right:
|
|
157
|
-
|
|
158
|
-
border: 1px solid white;
|
|
168
|
+
top: 50%;
|
|
169
|
+
right: 5px;
|
|
170
|
+
transform: translateY(-30%);
|
|
159
171
|
background: transparent;
|
|
160
172
|
}
|
|
161
173
|
|
|
@@ -169,12 +181,21 @@ export default defineComponent({
|
|
|
169
181
|
list-style-type: none;
|
|
170
182
|
font-weight: normal;
|
|
171
183
|
cursor: pointer;
|
|
172
|
-
z-index:
|
|
184
|
+
z-index: 100;
|
|
173
185
|
position: absolute;
|
|
174
186
|
width: calc(100% - 1px);
|
|
175
187
|
background-color: #ffffff;
|
|
176
188
|
}
|
|
177
189
|
|
|
190
|
+
.custom-select-options.scroll {
|
|
191
|
+
max-height: v-bind(_maxHeight);
|
|
192
|
+
overflow-y: scroll;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.custom-select-options::-webkit-scrollbar {
|
|
196
|
+
display: none;
|
|
197
|
+
}
|
|
198
|
+
|
|
178
199
|
.custom-select-options li {
|
|
179
200
|
padding: 0 20px;
|
|
180
201
|
font-size: 14px;
|