xianniu-ui 0.8.6 → 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 +162 -45
- package/lib/xianniu-ui.umd.js +162 -45
- package/lib/xianniu-ui.umd.min.js +9 -9
- package/package.json +1 -1
- package/packages/table/main.vue +90 -22
- package/src/oss/index.js +0 -1
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,16 +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
|
+
:selectable="handleSelectable"
|
|
82
83
|
></el-table-column>
|
|
83
|
-
<el-table-column v-bind="$attrs" v-if="
|
|
84
|
+
<el-table-column v-bind="$attrs" v-if="isRadio" width="40px" align="center">
|
|
84
85
|
<template slot-scope="{ row }">
|
|
85
86
|
<el-radio v-model="radioSelected" :label="row[idKey]"
|
|
86
87
|
> </el-radio
|
|
@@ -94,15 +95,15 @@
|
|
|
94
95
|
type="index"
|
|
95
96
|
></el-table-column>
|
|
96
97
|
<slot>
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
<column
|
|
99
|
+
v-for="(item, idx) in columns"
|
|
100
|
+
:key="idx"
|
|
101
|
+
v-show="item.checked === true"
|
|
102
|
+
v-bind="item"
|
|
103
|
+
></column>
|
|
103
104
|
</slot>
|
|
104
105
|
<template #append v-if="$slots.append">
|
|
105
|
-
|
|
106
|
+
<slot name="append"></slot>
|
|
106
107
|
</template>
|
|
107
108
|
</el-table>
|
|
108
109
|
|
|
@@ -141,6 +142,13 @@ export default {
|
|
|
141
142
|
type: Array,
|
|
142
143
|
default: () => [],
|
|
143
144
|
},
|
|
145
|
+
type:{
|
|
146
|
+
type: String,
|
|
147
|
+
default:'',
|
|
148
|
+
validator: (val) => {
|
|
149
|
+
return ["selection", "radio"].indexOf(val) !== -1;
|
|
150
|
+
},
|
|
151
|
+
},
|
|
144
152
|
stripe: Boolean,
|
|
145
153
|
selection: Boolean,
|
|
146
154
|
radio: Boolean,
|
|
@@ -162,6 +170,26 @@ export default {
|
|
|
162
170
|
type: String,
|
|
163
171
|
default: "id",
|
|
164
172
|
},
|
|
173
|
+
disabledList: {
|
|
174
|
+
type: Array,
|
|
175
|
+
require: false,
|
|
176
|
+
default: () => {
|
|
177
|
+
return [];
|
|
178
|
+
},
|
|
179
|
+
},
|
|
180
|
+
disabledKey: {
|
|
181
|
+
type: String,
|
|
182
|
+
require: false,
|
|
183
|
+
default: "",
|
|
184
|
+
},
|
|
185
|
+
/* 筛选条件,正则 */
|
|
186
|
+
filterQuery: {
|
|
187
|
+
type: Object,
|
|
188
|
+
require: false,
|
|
189
|
+
default: () => {
|
|
190
|
+
return {};
|
|
191
|
+
},
|
|
192
|
+
},
|
|
165
193
|
},
|
|
166
194
|
data() {
|
|
167
195
|
return {
|
|
@@ -170,16 +198,19 @@ export default {
|
|
|
170
198
|
};
|
|
171
199
|
},
|
|
172
200
|
computed: {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
201
|
+
isSelection(){
|
|
202
|
+
return this.type === 'selection' || this.selection
|
|
203
|
+
},
|
|
204
|
+
isRadio(){
|
|
205
|
+
return this.type === 'radio' || this.radio
|
|
206
|
+
}
|
|
177
207
|
},
|
|
208
|
+
created() {},
|
|
178
209
|
updated() {
|
|
179
210
|
!this.$slots.default &&
|
|
180
211
|
this.columns.length &&
|
|
181
212
|
this.columns.forEach((item) => {
|
|
182
|
-
if(item.checked !== true) this.$set(item, "checked", true);
|
|
213
|
+
if (item.checked !== true) this.$set(item, "checked", true);
|
|
183
214
|
});
|
|
184
215
|
},
|
|
185
216
|
methods: {
|
|
@@ -187,7 +218,7 @@ export default {
|
|
|
187
218
|
this.$emit("on-page", val);
|
|
188
219
|
},
|
|
189
220
|
singleElection(val, column) {
|
|
190
|
-
if (!this.
|
|
221
|
+
if (!this.isRadio) return;
|
|
191
222
|
const { idKey } = this;
|
|
192
223
|
this.radioSelected = val[idKey];
|
|
193
224
|
const res = this.data.find(
|
|
@@ -210,7 +241,7 @@ export default {
|
|
|
210
241
|
this.$refs.table.toggleRowSelection(row, status);
|
|
211
242
|
},
|
|
212
243
|
clearSelection() {
|
|
213
|
-
if (this.
|
|
244
|
+
if (this.isRadio) {
|
|
214
245
|
this.radioSelected = "";
|
|
215
246
|
return;
|
|
216
247
|
}
|
|
@@ -222,9 +253,46 @@ export default {
|
|
|
222
253
|
tableRowClassName({ row, rowIndex }) {
|
|
223
254
|
row.rowIndex = rowIndex;
|
|
224
255
|
},
|
|
225
|
-
headerRowClassName(){
|
|
226
|
-
return
|
|
227
|
-
}
|
|
256
|
+
headerRowClassName() {
|
|
257
|
+
return "cus-table-header";
|
|
258
|
+
},
|
|
259
|
+
handleSelectable(row, idx) {
|
|
260
|
+
if (
|
|
261
|
+
this.isSelection &&
|
|
262
|
+
this.$attrs.selectable &&
|
|
263
|
+
typeof this.$attrs.selectable === "function"
|
|
264
|
+
) {
|
|
265
|
+
return this.$attrs.selectable(row, idx);
|
|
266
|
+
}
|
|
267
|
+
const list = this.disabledList;
|
|
268
|
+
const filter = this.filterQuery;
|
|
269
|
+
if (
|
|
270
|
+
list &&
|
|
271
|
+
list.length &&
|
|
272
|
+
this.disabledKey &&
|
|
273
|
+
list.includes(row[this.disabledKey])
|
|
274
|
+
) {
|
|
275
|
+
return 0;
|
|
276
|
+
} else if (Object.keys(filter).length) {
|
|
277
|
+
let step = 0;
|
|
278
|
+
Object.keys(filter).forEach((key) => {
|
|
279
|
+
if (filter[key].test(row[key])) {
|
|
280
|
+
step = step + 1;
|
|
281
|
+
}
|
|
282
|
+
});
|
|
283
|
+
|
|
284
|
+
if (step >= Object.keys(filter).length) {
|
|
285
|
+
/* if (isChange) {
|
|
286
|
+
this.key = Date.parse(new Date());
|
|
287
|
+
} */
|
|
288
|
+
return 1;
|
|
289
|
+
} else {
|
|
290
|
+
return 0;
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
return 1;
|
|
294
|
+
}
|
|
295
|
+
},
|
|
228
296
|
},
|
|
229
297
|
};
|
|
230
298
|
</script>
|