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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "xianniu-ui",
3
- "version": "0.8.7",
3
+ "version": "0.8.8",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -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': selection }">
6
- <template v-if="selection">
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': radio }"
74
+ :class="{ 'disabled-all-selection': isRadio }"
75
75
  >
76
76
  <el-table-column
77
- v-if="selection && data.length"
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="radio" width="40px" align="center">
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
  >&nbsp;</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.radio) return;
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.radio) {
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.selection &&
261
+ this.isSelection &&
248
262
  this.$attrs.selectable &&
249
263
  typeof this.$attrs.selectable === "function"
250
264
  ) {