xianniu-ui 0.8.7 → 0.8.8
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/lib/xianniu-ui.common.js +46 -33
- package/lib/xianniu-ui.umd.js +46 -33
- package/lib/xianniu-ui.umd.min.js +2 -2
- package/package.json +1 -1
- package/packages/table/main.vue +23 -9
package/package.json
CHANGED
package/packages/table/main.vue
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
<div class="xn-table-box">
|
|
3
3
|
<div class="xn-table-box-tools" :class="{ 'is-border': !border }">
|
|
4
4
|
<div class="flex justify-content-between align-items-center">
|
|
5
|
-
<div class="fz-12" :class="{ 'pb-10':
|
|
6
|
-
<template v-if="
|
|
5
|
+
<div class="fz-12" :class="{ 'pb-10': isSelection }">
|
|
6
|
+
<template v-if="isSelection">
|
|
7
7
|
<span>已选择 {{ selectedData.length }} 项</span>
|
|
8
8
|
<el-button
|
|
9
9
|
type="text"
|
|
@@ -71,17 +71,17 @@
|
|
|
71
71
|
@row-click="singleElection"
|
|
72
72
|
@selection-change="selectionChange"
|
|
73
73
|
:row-class-name="tableRowClassName"
|
|
74
|
-
:class="{ 'disabled-all-selection':
|
|
74
|
+
:class="{ 'disabled-all-selection': isRadio }"
|
|
75
75
|
>
|
|
76
76
|
<el-table-column
|
|
77
|
-
v-if="
|
|
77
|
+
v-if="isSelection && data.length"
|
|
78
78
|
v-bind="$attrs"
|
|
79
79
|
type="selection"
|
|
80
80
|
width="50px"
|
|
81
81
|
align="center"
|
|
82
82
|
:selectable="handleSelectable"
|
|
83
83
|
></el-table-column>
|
|
84
|
-
<el-table-column v-bind="$attrs" v-if="
|
|
84
|
+
<el-table-column v-bind="$attrs" v-if="isRadio" width="40px" align="center">
|
|
85
85
|
<template slot-scope="{ row }">
|
|
86
86
|
<el-radio v-model="radioSelected" :label="row[idKey]"
|
|
87
87
|
> </el-radio
|
|
@@ -142,6 +142,13 @@ export default {
|
|
|
142
142
|
type: Array,
|
|
143
143
|
default: () => [],
|
|
144
144
|
},
|
|
145
|
+
type:{
|
|
146
|
+
type: String,
|
|
147
|
+
default:'',
|
|
148
|
+
validator: (val) => {
|
|
149
|
+
return ["selection", "radio"].indexOf(val) !== -1;
|
|
150
|
+
},
|
|
151
|
+
},
|
|
145
152
|
stripe: Boolean,
|
|
146
153
|
selection: Boolean,
|
|
147
154
|
radio: Boolean,
|
|
@@ -190,7 +197,14 @@ export default {
|
|
|
190
197
|
selectedData: [],
|
|
191
198
|
};
|
|
192
199
|
},
|
|
193
|
-
computed: {
|
|
200
|
+
computed: {
|
|
201
|
+
isSelection(){
|
|
202
|
+
return this.type === 'selection' || this.selection
|
|
203
|
+
},
|
|
204
|
+
isRadio(){
|
|
205
|
+
return this.type === 'radio' || this.radio
|
|
206
|
+
}
|
|
207
|
+
},
|
|
194
208
|
created() {},
|
|
195
209
|
updated() {
|
|
196
210
|
!this.$slots.default &&
|
|
@@ -204,7 +218,7 @@ export default {
|
|
|
204
218
|
this.$emit("on-page", val);
|
|
205
219
|
},
|
|
206
220
|
singleElection(val, column) {
|
|
207
|
-
if (!this.
|
|
221
|
+
if (!this.isRadio) return;
|
|
208
222
|
const { idKey } = this;
|
|
209
223
|
this.radioSelected = val[idKey];
|
|
210
224
|
const res = this.data.find(
|
|
@@ -227,7 +241,7 @@ export default {
|
|
|
227
241
|
this.$refs.table.toggleRowSelection(row, status);
|
|
228
242
|
},
|
|
229
243
|
clearSelection() {
|
|
230
|
-
if (this.
|
|
244
|
+
if (this.isRadio) {
|
|
231
245
|
this.radioSelected = "";
|
|
232
246
|
return;
|
|
233
247
|
}
|
|
@@ -244,7 +258,7 @@ export default {
|
|
|
244
258
|
},
|
|
245
259
|
handleSelectable(row, idx) {
|
|
246
260
|
if (
|
|
247
|
-
this.
|
|
261
|
+
this.isSelection &&
|
|
248
262
|
this.$attrs.selectable &&
|
|
249
263
|
typeof this.$attrs.selectable === "function"
|
|
250
264
|
) {
|