@10yun/cv-mobile-ui 0.5.20 → 0.5.22
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/plugins/jumps.js +57 -12
- package/plugins/lbs.js +17 -8
- package/ui-cv/components/cv-grid-item/cv-grid-item.vue +1 -1
- package/uni-ui/lib/uni-badge/uni-badge.vue +150 -1
- package/uni-ui/lib/uni-breadcrumb/uni-breadcrumb.vue +37 -1
- package/uni-ui/lib/uni-breadcrumb-item/uni-breadcrumb-item.vue +83 -1
- package/uni-ui/lib/uni-calendar/uni-calendar-item.vue +122 -1
- package/uni-ui/lib/uni-calendar/uni-calendar.vue +366 -1
- package/uni-ui/lib/uni-card/uni-card.vue +124 -1
- package/uni-ui/lib/uni-col/uni-col.vue +1 -1
- package/uni-ui/lib/uni-collapse/uni-collapse.vue +135 -1
- package/uni-ui/lib/uni-collapse-item/uni-collapse-item.vue +266 -1
- package/uni-ui/lib/uni-combox/uni-combox.vue +1 -1
- package/uni-ui/lib/uni-countdown/uni-countdown.vue +239 -1
- package/uni-ui/lib/uni-data-checkbox/uni-data-checkbox.vue +487 -1
- package/uni-ui/lib/uni-data-picker/uni-data-picker.vue +530 -1
- package/uni-ui/lib/uni-data-pickerview/uni-data-picker.js +157 -150
- package/uni-ui/lib/uni-data-pickerview/uni-data-pickerview.vue +166 -1
- package/uni-ui/lib/uni-data-select/uni-data-select.vue +289 -1
- package/uni-ui/lib/uni-datetime-picker/calendar-item.vue +70 -1
- package/uni-ui/lib/uni-datetime-picker/calendar.vue +629 -1
- package/uni-ui/lib/uni-datetime-picker/time-picker.vue +741 -1
- package/uni-ui/lib/uni-datetime-picker/uni-datetime-picker.vue +847 -1
- package/uni-ui/lib/uni-drawer/uni-drawer.vue +115 -1
- package/uni-ui/lib/uni-easyinput/uni-easyinput.vue +515 -1
- package/uni-ui/lib/uni-fab/uni-fab.vue +257 -1
- package/uni-ui/lib/uni-fav/uni-fav.vue +123 -1
- package/uni-ui/lib/uni-file-picker/uni-file-picker.vue +642 -1
- package/uni-ui/lib/uni-file-picker/upload-file.vue +177 -1
- package/uni-ui/lib/uni-file-picker/upload-image.vue +176 -1
- package/uni-ui/lib/uni-forms/uni-forms.vue +375 -1
- package/uni-ui/lib/uni-forms-item/uni-forms-item.vue +429 -1
- package/uni-ui/lib/uni-goods-nav/uni-goods-nav.vue +129 -1
- package/uni-ui/lib/uni-grid/uni-grid.vue +115 -1
- package/uni-ui/lib/uni-grid-item/uni-grid-item.vue +78 -1
- package/uni-ui/lib/uni-group/uni-group.vue +85 -1
- package/uni-ui/lib/uni-icons/uni-icons.vue +85 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list-item.vue +68 -1
- package/uni-ui/lib/uni-indexed-list/uni-indexed-list.vue +294 -1
- package/uni-ui/lib/uni-list/uni-list.vue +81 -1
- package/uni-ui/lib/uni-list-ad/uni-list-ad.vue +77 -1
- package/uni-ui/lib/uni-list-chat/uni-list-chat.vue +294 -1
- package/uni-ui/lib/uni-list-item/uni-list-item.vue +346 -1
- package/uni-ui/lib/uni-load-more/uni-load-more.vue +172 -1
- package/uni-ui/lib/uni-nav-bar/uni-nav-bar.vue +205 -1
- package/uni-ui/lib/uni-nav-bar/uni-status-bar.vue +18 -1
- package/uni-ui/lib/uni-notice-bar/uni-notice-bar.vue +331 -1
- package/uni-ui/lib/uni-number-box/uni-number-box.vue +166 -1
- package/uni-ui/lib/uni-pagination/uni-pagination.vue +323 -1
- package/uni-ui/lib/uni-popup/uni-popup.vue +1 -1
- package/uni-ui/lib/uni-popup-dialog/uni-popup-dialog.vue +173 -1
- package/uni-ui/lib/uni-popup-message/uni-popup-message.vue +74 -1
- package/uni-ui/lib/uni-popup-share/uni-popup-share.vue +106 -1
- package/uni-ui/lib/uni-rate/uni-rate.vue +322 -1
- package/uni-ui/lib/uni-row/uni-row.vue +1 -1
- package/uni-ui/lib/uni-search-bar/uni-search-bar.vue +236 -1
- package/uni-ui/lib/uni-section/uni-section.vue +109 -1
- package/uni-ui/lib/uni-segmented-control/uni-segmented-control.vue +103 -1
- package/uni-ui/lib/uni-status-bar/uni-status-bar.vue +1 -1
- package/uni-ui/lib/uni-steps/uni-steps.vue +120 -1
- package/uni-ui/lib/uni-swipe-action-item/uni-swipe-action-item.vue +226 -3
- package/uni-ui/lib/uni-swiper-dot/uni-swiper-dot.vue +167 -1
- package/uni-ui/lib/uni-table/uni-table.vue +297 -1
- package/uni-ui/lib/uni-tag/uni-tag.vue +100 -1
- package/uni-ui/lib/uni-td/uni-td.vue +78 -1
- package/uni-ui/lib/uni-th/filter-dropdown.vue +1 -1
- package/uni-ui/lib/uni-th/uni-th.vue +224 -1
- package/uni-ui/lib/uni-thead/uni-thead.vue +77 -1
- package/uni-ui/lib/uni-tr/table-checkbox.vue +79 -1
- package/uni-ui/lib/uni-tr/uni-tr.vue +135 -1
|
@@ -1 +1,297 @@
|
|
|
1
|
-
<template>
|
|
2
1
|
<view class="uni-table-scroll" :class="{ 'table--border': border, 'border-none': !noData }">
|
|
3
2
|
<!-- #ifdef H5 -->
|
|
4
3
|
<table
|
|
5
4
|
class="uni-table"
|
|
6
5
|
border="0"
|
|
7
6
|
cellpadding="0"
|
|
8
7
|
cellspacing="0"
|
|
9
8
|
:class="{ 'table--stripe': stripe }"
|
|
10
9
|
:style="{ 'min-width': minWidth + 'px' }"
|
|
11
10
|
>
|
|
12
11
|
<slot></slot>
|
|
13
12
|
<tr v-if="noData" class="uni-table-loading">
|
|
14
13
|
<td class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</td>
|
|
15
14
|
</tr>
|
|
16
15
|
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
|
|
17
16
|
</table>
|
|
18
17
|
<!-- #endif -->
|
|
19
18
|
<!-- #ifndef H5 -->
|
|
20
19
|
<view class="uni-table" :style="{ 'min-width': minWidth + 'px' }" :class="{ 'table--stripe': stripe }">
|
|
21
20
|
<slot></slot>
|
|
22
21
|
<view v-if="noData" class="uni-table-loading">
|
|
23
22
|
<view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view>
|
|
24
23
|
</view>
|
|
25
24
|
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
|
|
26
25
|
</view>
|
|
27
26
|
<!-- #endif -->
|
|
28
27
|
</view>
|
|
29
28
|
* Table 表格
|
|
30
29
|
* @description 用于展示多条结构类似的数据
|
|
31
30
|
* @tutorial https://ext.dcloud.net.cn/plugin?id=3270
|
|
32
31
|
* @property {Boolean} border 是否带有纵向边框
|
|
33
32
|
* @property {Boolean} stripe 是否显示斑马线
|
|
34
33
|
* @property {Boolean} type 是否开启多选
|
|
35
34
|
* @property {String} emptyText 空数据时显示的文本内容
|
|
36
35
|
* @property {Boolean} loading 显示加载中
|
|
37
36
|
* @event {Function} selection-change 开启多选时,当选择项发生变化时会触发该事件
|
|
38
37
|
*/
|
|
39
38
|
name: 'uniTable',
|
|
40
39
|
options: {
|
|
41
40
|
virtualHost: true
|
|
42
41
|
},
|
|
43
42
|
emits: ['selection-change'],
|
|
44
43
|
props: {
|
|
45
44
|
data: {
|
|
46
45
|
type: Array,
|
|
47
46
|
default() {
|
|
48
47
|
return [];
|
|
49
48
|
}
|
|
50
49
|
},
|
|
51
50
|
// 是否有竖线
|
|
52
51
|
border: {
|
|
53
52
|
type: Boolean,
|
|
54
53
|
default: false
|
|
55
54
|
},
|
|
56
55
|
// 是否显示斑马线
|
|
57
56
|
stripe: {
|
|
58
57
|
type: Boolean,
|
|
59
58
|
default: false
|
|
60
59
|
},
|
|
61
60
|
// 多选
|
|
62
61
|
type: {
|
|
63
62
|
type: String,
|
|
64
63
|
default: ''
|
|
65
64
|
},
|
|
66
65
|
// 没有更多数据
|
|
67
66
|
emptyText: {
|
|
68
67
|
type: String,
|
|
69
68
|
default: '没有更多数据'
|
|
70
69
|
},
|
|
71
70
|
loading: {
|
|
72
71
|
type: Boolean,
|
|
73
72
|
default: false
|
|
74
73
|
},
|
|
75
74
|
rowKey: {
|
|
76
75
|
type: String,
|
|
77
76
|
default: ''
|
|
78
77
|
}
|
|
79
78
|
},
|
|
80
79
|
data() {
|
|
81
80
|
return {
|
|
82
81
|
noData: true,
|
|
83
82
|
minWidth: 0,
|
|
84
83
|
multiTableHeads: []
|
|
85
84
|
};
|
|
86
85
|
},
|
|
87
86
|
watch: {
|
|
88
87
|
loading(val) {},
|
|
89
88
|
data(newVal) {
|
|
90
89
|
let theadChildren = this.theadChildren;
|
|
91
90
|
let rowspan = 1;
|
|
92
91
|
if (this.theadChildren) {
|
|
93
92
|
rowspan = this.theadChildren.rowspan;
|
|
94
93
|
}
|
|
95
94
|
// this.trChildren.length - rowspan
|
|
96
95
|
this.noData = false;
|
|
97
96
|
// this.noData = newVal.length === 0
|
|
98
97
|
}
|
|
99
98
|
},
|
|
100
99
|
created() {
|
|
101
100
|
// 定义tr的实例数组
|
|
102
101
|
this.trChildren = [];
|
|
103
102
|
this.thChildren = [];
|
|
104
103
|
this.theadChildren = null;
|
|
105
104
|
this.backData = [];
|
|
106
105
|
this.backIndexData = [];
|
|
107
106
|
},
|
|
108
107
|
methods: {
|
|
109
108
|
isNodata() {
|
|
110
109
|
let theadChildren = this.theadChildren;
|
|
111
110
|
let rowspan = 1;
|
|
112
111
|
if (this.theadChildren) {
|
|
113
112
|
rowspan = this.theadChildren.rowspan;
|
|
114
113
|
}
|
|
115
114
|
this.noData = this.trChildren.length - rowspan <= 0;
|
|
116
115
|
},
|
|
117
116
|
/**
|
|
118
117
|
* 选中所有
|
|
119
118
|
*/
|
|
120
119
|
selectionAll() {
|
|
121
120
|
let startIndex = 1;
|
|
122
121
|
let theadChildren = this.theadChildren;
|
|
123
122
|
if (!this.theadChildren) {
|
|
124
123
|
theadChildren = this.trChildren[0];
|
|
125
124
|
} else {
|
|
126
125
|
startIndex = theadChildren.rowspan - 1;
|
|
127
126
|
}
|
|
128
127
|
let isHaveData = this.data && this.data.length > 0;
|
|
129
128
|
theadChildren.checked = true;
|
|
130
129
|
theadChildren.indeterminate = false;
|
|
131
130
|
this.trChildren.forEach((item, index) => {
|
|
132
131
|
if (!item.disabled) {
|
|
133
132
|
item.checked = true;
|
|
134
133
|
if (isHaveData && item.keyValue) {
|
|
135
134
|
const row = this.data.find((v) => v[this.rowKey] === item.keyValue);
|
|
136
135
|
if (!this.backData.find((v) => v[this.rowKey] === row[this.rowKey])) {
|
|
137
136
|
this.backData.push(row);
|
|
138
137
|
}
|
|
139
138
|
}
|
|
140
139
|
if (index > startIndex - 1 && this.backIndexData.indexOf(index - startIndex) === -1) {
|
|
141
140
|
this.backIndexData.push(index - startIndex);
|
|
142
141
|
}
|
|
143
142
|
}
|
|
144
143
|
});
|
|
145
144
|
// this.backData = JSON.parse(JSON.stringify(this.data))
|
|
146
145
|
this.$emit('selection-change', {
|
|
147
146
|
detail: {
|
|
148
147
|
value: this.backData,
|
|
149
148
|
index: this.backIndexData
|
|
150
149
|
}
|
|
151
150
|
});
|
|
152
151
|
},
|
|
153
152
|
/**
|
|
154
153
|
* 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
|
|
155
154
|
*/
|
|
156
155
|
toggleRowSelection(row, selected) {
|
|
157
156
|
// if (!this.theadChildren) return
|
|
158
157
|
row = [].concat(row);
|
|
159
158
|
this.trChildren.forEach((item, index) => {
|
|
160
159
|
// if (item.keyValue) {
|
|
161
160
|
const select = row.findIndex((v) => {
|
|
162
161
|
//
|
|
163
162
|
if (typeof v === 'number') {
|
|
164
163
|
return v === index - 1;
|
|
165
164
|
} else {
|
|
166
165
|
return v[this.rowKey] === item.keyValue;
|
|
167
166
|
}
|
|
168
167
|
});
|
|
169
168
|
let ischeck = item.checked;
|
|
170
169
|
if (select !== -1) {
|
|
171
170
|
if (typeof selected === 'boolean') {
|
|
172
171
|
item.checked = selected;
|
|
173
172
|
} else {
|
|
174
173
|
item.checked = !item.checked;
|
|
175
174
|
}
|
|
176
175
|
if (ischeck !== item.checked) {
|
|
177
176
|
this.check(item.rowData || item, item.checked, item.rowData ? item.keyValue : null, true);
|
|
178
177
|
}
|
|
179
178
|
}
|
|
180
179
|
// }
|
|
181
180
|
});
|
|
182
181
|
this.$emit('selection-change', {
|
|
183
182
|
detail: {
|
|
184
183
|
value: this.backData,
|
|
185
184
|
index: this.backIndexData
|
|
186
185
|
}
|
|
187
186
|
});
|
|
188
187
|
},
|
|
189
188
|
/**
|
|
190
189
|
* 用于多选表格,清空用户的选择
|
|
191
190
|
*/
|
|
192
191
|
clearSelection() {
|
|
193
192
|
let theadChildren = this.theadChildren;
|
|
194
193
|
if (!this.theadChildren) {
|
|
195
194
|
theadChildren = this.trChildren[0];
|
|
196
195
|
}
|
|
197
196
|
// if (!this.theadChildren) return
|
|
198
197
|
theadChildren.checked = false;
|
|
199
198
|
theadChildren.indeterminate = false;
|
|
200
199
|
this.trChildren.forEach((item) => {
|
|
201
200
|
// if (item.keyValue) {
|
|
202
201
|
item.checked = false;
|
|
203
202
|
// }
|
|
204
203
|
});
|
|
205
204
|
this.backData = [];
|
|
206
205
|
this.backIndexData = [];
|
|
207
206
|
this.$emit('selection-change', {
|
|
208
207
|
detail: {
|
|
209
208
|
value: [],
|
|
210
209
|
index: []
|
|
211
210
|
}
|
|
212
211
|
});
|
|
213
212
|
},
|
|
214
213
|
/**
|
|
215
214
|
* 用于多选表格,切换所有行的选中状态
|
|
216
215
|
*/
|
|
217
216
|
toggleAllSelection() {
|
|
218
217
|
let list = [];
|
|
219
218
|
let startIndex = 1;
|
|
220
219
|
let theadChildren = this.theadChildren;
|
|
221
220
|
if (!this.theadChildren) {
|
|
222
221
|
theadChildren = this.trChildren[0];
|
|
223
222
|
} else {
|
|
224
223
|
startIndex = theadChildren.rowspan - 1;
|
|
225
224
|
}
|
|
226
225
|
this.trChildren.forEach((item, index) => {
|
|
227
226
|
if (!item.disabled) {
|
|
228
227
|
if (index > startIndex - 1) {
|
|
229
228
|
list.push(index - startIndex);
|
|
230
229
|
}
|
|
231
230
|
}
|
|
232
231
|
});
|
|
233
232
|
this.toggleRowSelection(list);
|
|
234
233
|
},
|
|
235
234
|
/**
|
|
236
235
|
* 选中\取消选中
|
|
237
236
|
* @param {Object} child
|
|
238
237
|
* @param {Object} check
|
|
239
238
|
* @param {Object} rowValue
|
|
240
239
|
*/
|
|
241
240
|
check(child, check, keyValue, emit) {
|
|
242
241
|
let theadChildren = this.theadChildren;
|
|
243
242
|
if (!this.theadChildren) {
|
|
244
243
|
theadChildren = this.trChildren[0];
|
|
245
244
|
}
|
|
246
245
|
let childDomIndex = this.trChildren.findIndex((item, index) => child === item);
|
|
247
246
|
if (childDomIndex < 0) {
|
|
248
247
|
childDomIndex = this.data.findIndex((v) => v[this.rowKey] === keyValue) + 1;
|
|
249
248
|
}
|
|
250
249
|
const dataLen = this.trChildren.filter((v) => !v.disabled && v.keyValue).length;
|
|
251
250
|
if (childDomIndex === 0) {
|
|
252
251
|
check ? this.selectionAll() : this.clearSelection();
|
|
253
252
|
return;
|
|
254
253
|
}
|
|
255
254
|
if (check) {
|
|
256
255
|
if (keyValue) {
|
|
257
256
|
this.backData.push(child);
|
|
258
257
|
}
|
|
259
258
|
this.backIndexData.push(childDomIndex - 1);
|
|
260
259
|
} else {
|
|
261
260
|
const index = this.backData.findIndex((v) => v[this.rowKey] === keyValue);
|
|
262
261
|
const idx = this.backIndexData.findIndex((item) => item === childDomIndex - 1);
|
|
263
262
|
if (keyValue) {
|
|
264
263
|
this.backData.splice(index, 1);
|
|
265
264
|
}
|
|
266
265
|
this.backIndexData.splice(idx, 1);
|
|
267
266
|
}
|
|
268
267
|
const domCheckAll = this.trChildren.find((item, index) => index > 0 && !item.checked && !item.disabled);
|
|
269
268
|
if (!domCheckAll) {
|
|
270
269
|
theadChildren.indeterminate = false;
|
|
271
270
|
theadChildren.checked = true;
|
|
272
271
|
} else {
|
|
273
272
|
theadChildren.indeterminate = true;
|
|
274
273
|
theadChildren.checked = false;
|
|
275
274
|
}
|
|
276
275
|
if (this.backIndexData.length === 0) {
|
|
277
276
|
theadChildren.indeterminate = false;
|
|
278
277
|
}
|
|
279
278
|
if (!emit) {
|
|
280
279
|
this.$emit('selection-change', {
|
|
281
280
|
detail: {
|
|
282
281
|
value: this.backData,
|
|
283
282
|
index: this.backIndexData
|
|
284
283
|
}
|
|
285
284
|
});
|
|
286
285
|
}
|
|
287
286
|
}
|
|
288
287
|
}
|
|
288
|
+
<template>
|
|
289
|
+
<view class="uni-table-scroll" :class="{ 'table--border': border, 'border-none': !noData }">
|
|
290
|
+
<!-- #ifdef H5 -->
|
|
291
|
+
<table
|
|
292
|
+
class="uni-table"
|
|
293
|
+
border="0"
|
|
294
|
+
cellpadding="0"
|
|
295
|
+
cellspacing="0"
|
|
296
|
+
:class="{ 'table--stripe': stripe }"
|
|
297
|
+
:style="{ 'min-width': minWidth + 'px' }"
|
|
298
|
+
>
|
|
299
|
+
<slot></slot>
|
|
300
|
+
<tr v-if="noData" class="uni-table-loading">
|
|
301
|
+
<td class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</td>
|
|
302
|
+
</tr>
|
|
303
|
+
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
|
|
304
|
+
</table>
|
|
305
|
+
<!-- #endif -->
|
|
306
|
+
<!-- #ifndef H5 -->
|
|
307
|
+
<view class="uni-table" :style="{ 'min-width': minWidth + 'px' }" :class="{ 'table--stripe': stripe }">
|
|
308
|
+
<slot></slot>
|
|
309
|
+
<view v-if="noData" class="uni-table-loading">
|
|
310
|
+
<view class="uni-table-text" :class="{ 'empty-border': border }">{{ emptyText }}</view>
|
|
311
|
+
</view>
|
|
312
|
+
<view v-if="loading" class="uni-table-mask" :class="{ 'empty-border': border }"><div class="uni-table--loader"></div></view>
|
|
313
|
+
</view>
|
|
314
|
+
<!-- #endif -->
|
|
315
|
+
</view>
|
|
316
|
+
</template>
|
|
317
|
+
<script>
|
|
318
|
+
/**
|
|
319
|
+
* Table 表格
|
|
320
|
+
* @description 用于展示多条结构类似的数据
|
|
321
|
+
* @tutorial https://ext.dcloud.net.cn/plugin?id=3270
|
|
322
|
+
* @property {Boolean} border 是否带有纵向边框
|
|
323
|
+
* @property {Boolean} stripe 是否显示斑马线
|
|
324
|
+
* @property {Boolean} type 是否开启多选
|
|
325
|
+
* @property {String} emptyText 空数据时显示的文本内容
|
|
326
|
+
* @property {Boolean} loading 显示加载中
|
|
327
|
+
* @event {Function} selection-change 开启多选时,当选择项发生变化时会触发该事件
|
|
328
|
+
*/
|
|
329
|
+
export default {
|
|
330
|
+
name: 'uniTable',
|
|
331
|
+
options: {
|
|
332
|
+
virtualHost: true
|
|
333
|
+
},
|
|
334
|
+
emits: ['selection-change'],
|
|
335
|
+
props: {
|
|
336
|
+
data: {
|
|
337
|
+
type: Array,
|
|
338
|
+
default() {
|
|
339
|
+
return [];
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
// 是否有竖线
|
|
343
|
+
border: {
|
|
344
|
+
type: Boolean,
|
|
345
|
+
default: false
|
|
346
|
+
},
|
|
347
|
+
// 是否显示斑马线
|
|
348
|
+
stripe: {
|
|
349
|
+
type: Boolean,
|
|
350
|
+
default: false
|
|
351
|
+
},
|
|
352
|
+
// 多选
|
|
353
|
+
type: {
|
|
354
|
+
type: String,
|
|
355
|
+
default: ''
|
|
356
|
+
},
|
|
357
|
+
// 没有更多数据
|
|
358
|
+
emptyText: {
|
|
359
|
+
type: String,
|
|
360
|
+
default: '没有更多数据'
|
|
361
|
+
},
|
|
362
|
+
loading: {
|
|
363
|
+
type: Boolean,
|
|
364
|
+
default: false
|
|
365
|
+
},
|
|
366
|
+
rowKey: {
|
|
367
|
+
type: String,
|
|
368
|
+
default: ''
|
|
369
|
+
}
|
|
370
|
+
},
|
|
371
|
+
data() {
|
|
372
|
+
return {
|
|
373
|
+
noData: true,
|
|
374
|
+
minWidth: 0,
|
|
375
|
+
multiTableHeads: []
|
|
376
|
+
};
|
|
377
|
+
},
|
|
378
|
+
watch: {
|
|
379
|
+
loading(val) {},
|
|
380
|
+
data(newVal) {
|
|
381
|
+
let theadChildren = this.theadChildren;
|
|
382
|
+
let rowspan = 1;
|
|
383
|
+
if (this.theadChildren) {
|
|
384
|
+
rowspan = this.theadChildren.rowspan;
|
|
385
|
+
}
|
|
386
|
+
// this.trChildren.length - rowspan
|
|
387
|
+
this.noData = false;
|
|
388
|
+
// this.noData = newVal.length === 0
|
|
389
|
+
}
|
|
390
|
+
},
|
|
391
|
+
created() {
|
|
392
|
+
// 定义tr的实例数组
|
|
393
|
+
this.trChildren = [];
|
|
394
|
+
this.thChildren = [];
|
|
395
|
+
this.theadChildren = null;
|
|
396
|
+
this.backData = [];
|
|
397
|
+
this.backIndexData = [];
|
|
398
|
+
},
|
|
399
|
+
methods: {
|
|
400
|
+
isNodata() {
|
|
401
|
+
let theadChildren = this.theadChildren;
|
|
402
|
+
let rowspan = 1;
|
|
403
|
+
if (this.theadChildren) {
|
|
404
|
+
rowspan = this.theadChildren.rowspan;
|
|
405
|
+
}
|
|
406
|
+
this.noData = this.trChildren.length - rowspan <= 0;
|
|
407
|
+
},
|
|
408
|
+
/**
|
|
409
|
+
* 选中所有
|
|
410
|
+
*/
|
|
411
|
+
selectionAll() {
|
|
412
|
+
let startIndex = 1;
|
|
413
|
+
let theadChildren = this.theadChildren;
|
|
414
|
+
if (!this.theadChildren) {
|
|
415
|
+
theadChildren = this.trChildren[0];
|
|
416
|
+
} else {
|
|
417
|
+
startIndex = theadChildren.rowspan - 1;
|
|
418
|
+
}
|
|
419
|
+
let isHaveData = this.data && this.data.length > 0;
|
|
420
|
+
theadChildren.checked = true;
|
|
421
|
+
theadChildren.indeterminate = false;
|
|
422
|
+
this.trChildren.forEach((item, index) => {
|
|
423
|
+
if (!item.disabled) {
|
|
424
|
+
item.checked = true;
|
|
425
|
+
if (isHaveData && item.keyValue) {
|
|
426
|
+
const row = this.data.find((v) => v[this.rowKey] === item.keyValue);
|
|
427
|
+
if (!this.backData.find((v) => v[this.rowKey] === row[this.rowKey])) {
|
|
428
|
+
this.backData.push(row);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
if (index > startIndex - 1 && this.backIndexData.indexOf(index - startIndex) === -1) {
|
|
432
|
+
this.backIndexData.push(index - startIndex);
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
});
|
|
436
|
+
// this.backData = JSON.parse(JSON.stringify(this.data))
|
|
437
|
+
this.$emit('selection-change', {
|
|
438
|
+
detail: {
|
|
439
|
+
value: this.backData,
|
|
440
|
+
index: this.backIndexData
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
},
|
|
444
|
+
/**
|
|
445
|
+
* 用于多选表格,切换某一行的选中状态,如果使用了第二个参数,则是设置这一行选中与否(selected 为 true 则选中)
|
|
446
|
+
*/
|
|
447
|
+
toggleRowSelection(row, selected) {
|
|
448
|
+
// if (!this.theadChildren) return
|
|
449
|
+
row = [].concat(row);
|
|
450
|
+
this.trChildren.forEach((item, index) => {
|
|
451
|
+
// if (item.keyValue) {
|
|
452
|
+
const select = row.findIndex((v) => {
|
|
453
|
+
//
|
|
454
|
+
if (typeof v === 'number') {
|
|
455
|
+
return v === index - 1;
|
|
456
|
+
} else {
|
|
457
|
+
return v[this.rowKey] === item.keyValue;
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
let ischeck = item.checked;
|
|
461
|
+
if (select !== -1) {
|
|
462
|
+
if (typeof selected === 'boolean') {
|
|
463
|
+
item.checked = selected;
|
|
464
|
+
} else {
|
|
465
|
+
item.checked = !item.checked;
|
|
466
|
+
}
|
|
467
|
+
if (ischeck !== item.checked) {
|
|
468
|
+
this.check(item.rowData || item, item.checked, item.rowData ? item.keyValue : null, true);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
// }
|
|
472
|
+
});
|
|
473
|
+
this.$emit('selection-change', {
|
|
474
|
+
detail: {
|
|
475
|
+
value: this.backData,
|
|
476
|
+
index: this.backIndexData
|
|
477
|
+
}
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
/**
|
|
481
|
+
* 用于多选表格,清空用户的选择
|
|
482
|
+
*/
|
|
483
|
+
clearSelection() {
|
|
484
|
+
let theadChildren = this.theadChildren;
|
|
485
|
+
if (!this.theadChildren) {
|
|
486
|
+
theadChildren = this.trChildren[0];
|
|
487
|
+
}
|
|
488
|
+
// if (!this.theadChildren) return
|
|
489
|
+
theadChildren.checked = false;
|
|
490
|
+
theadChildren.indeterminate = false;
|
|
491
|
+
this.trChildren.forEach((item) => {
|
|
492
|
+
// if (item.keyValue) {
|
|
493
|
+
item.checked = false;
|
|
494
|
+
// }
|
|
495
|
+
});
|
|
496
|
+
this.backData = [];
|
|
497
|
+
this.backIndexData = [];
|
|
498
|
+
this.$emit('selection-change', {
|
|
499
|
+
detail: {
|
|
500
|
+
value: [],
|
|
501
|
+
index: []
|
|
502
|
+
}
|
|
503
|
+
});
|
|
504
|
+
},
|
|
505
|
+
/**
|
|
506
|
+
* 用于多选表格,切换所有行的选中状态
|
|
507
|
+
*/
|
|
508
|
+
toggleAllSelection() {
|
|
509
|
+
let list = [];
|
|
510
|
+
let startIndex = 1;
|
|
511
|
+
let theadChildren = this.theadChildren;
|
|
512
|
+
if (!this.theadChildren) {
|
|
513
|
+
theadChildren = this.trChildren[0];
|
|
514
|
+
} else {
|
|
515
|
+
startIndex = theadChildren.rowspan - 1;
|
|
516
|
+
}
|
|
517
|
+
this.trChildren.forEach((item, index) => {
|
|
518
|
+
if (!item.disabled) {
|
|
519
|
+
if (index > startIndex - 1) {
|
|
520
|
+
list.push(index - startIndex);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
this.toggleRowSelection(list);
|
|
525
|
+
},
|
|
526
|
+
/**
|
|
527
|
+
* 选中\取消选中
|
|
528
|
+
* @param {Object} child
|
|
529
|
+
* @param {Object} check
|
|
530
|
+
* @param {Object} rowValue
|
|
531
|
+
*/
|
|
532
|
+
check(child, check, keyValue, emit) {
|
|
533
|
+
let theadChildren = this.theadChildren;
|
|
534
|
+
if (!this.theadChildren) {
|
|
535
|
+
theadChildren = this.trChildren[0];
|
|
536
|
+
}
|
|
537
|
+
let childDomIndex = this.trChildren.findIndex((item, index) => child === item);
|
|
538
|
+
if (childDomIndex < 0) {
|
|
539
|
+
childDomIndex = this.data.findIndex((v) => v[this.rowKey] === keyValue) + 1;
|
|
540
|
+
}
|
|
541
|
+
const dataLen = this.trChildren.filter((v) => !v.disabled && v.keyValue).length;
|
|
542
|
+
if (childDomIndex === 0) {
|
|
543
|
+
check ? this.selectionAll() : this.clearSelection();
|
|
544
|
+
return;
|
|
545
|
+
}
|
|
546
|
+
if (check) {
|
|
547
|
+
if (keyValue) {
|
|
548
|
+
this.backData.push(child);
|
|
549
|
+
}
|
|
550
|
+
this.backIndexData.push(childDomIndex - 1);
|
|
551
|
+
} else {
|
|
552
|
+
const index = this.backData.findIndex((v) => v[this.rowKey] === keyValue);
|
|
553
|
+
const idx = this.backIndexData.findIndex((item) => item === childDomIndex - 1);
|
|
554
|
+
if (keyValue) {
|
|
555
|
+
this.backData.splice(index, 1);
|
|
556
|
+
}
|
|
557
|
+
this.backIndexData.splice(idx, 1);
|
|
558
|
+
}
|
|
559
|
+
const domCheckAll = this.trChildren.find((item, index) => index > 0 && !item.checked && !item.disabled);
|
|
560
|
+
if (!domCheckAll) {
|
|
561
|
+
theadChildren.indeterminate = false;
|
|
562
|
+
theadChildren.checked = true;
|
|
563
|
+
} else {
|
|
564
|
+
theadChildren.indeterminate = true;
|
|
565
|
+
theadChildren.checked = false;
|
|
566
|
+
}
|
|
567
|
+
if (this.backIndexData.length === 0) {
|
|
568
|
+
theadChildren.indeterminate = false;
|
|
569
|
+
}
|
|
570
|
+
if (!emit) {
|
|
571
|
+
this.$emit('selection-change', {
|
|
572
|
+
detail: {
|
|
573
|
+
value: this.backData,
|
|
574
|
+
index: this.backIndexData
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
};
|
|
581
|
+
</script>
|
|
582
|
+
<style>
|
|
583
|
+
@import 'style.css';
|
|
584
|
+
</style>
|