xianniu-ui 0.1.8-beta → 0.1.10-beta

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.1.8-beta",
3
+ "version": "0.1.10-beta",
4
4
  "private": false,
5
5
  "main": "lib/xianniu-ui.umd.min.js",
6
6
  "scripts": {
@@ -24,7 +24,6 @@
24
24
  "axios": "^0.26.0",
25
25
  "core-js": "^3.6.5",
26
26
  "dayjs": "^1.10.7",
27
- "element-ui": "^2.15.10",
28
27
  "good-storage": "^1.1.1",
29
28
  "vue": "^2.6.11",
30
29
  "vue-lottie": "^0.2.1",
@@ -44,6 +43,7 @@
44
43
  "copy-webpack-plugin": "^5.1.2",
45
44
  "cp-cli": "^2.0.0",
46
45
  "cross-env": "^7.0.3",
46
+ "element-ui": "^2.15.10",
47
47
  "eslint": "^6.7.2",
48
48
  "eslint-plugin-vue": "^6.2.2",
49
49
  "highlight.js": "^9.3.0",
@@ -2,7 +2,7 @@
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}">
5
+ <div class="fz-12" :class="{ 'pb-10': selection }">
6
6
  <template v-if="selection">
7
7
  <span>已选择 {{ selectedData.length }} 项</span>
8
8
  <el-button
@@ -15,7 +15,10 @@
15
15
  >
16
16
  </template>
17
17
  </div>
18
- <div :class="{'pb-10': $slots.tools || tools.length}" class=" flex justify-content-between align-items-center">
18
+ <div
19
+ :class="{ 'pb-10': $slots.tools || tools.length }"
20
+ class="flex justify-content-between align-items-center"
21
+ >
19
22
  <slot name="tools">
20
23
  <!-- <el-button-group> -->
21
24
  <div>
@@ -117,11 +120,92 @@
117
120
 
118
121
  <slot name="column">
119
122
  <template v-for="(item, idx) in columns">
120
- <column
123
+ <el-table-column
124
+ v-bind="item"
125
+ v-on="$listeners"
126
+ :key="idx"
127
+ v-if="isShowColumn(item)"
128
+ >
129
+ <template v-if="item.labelMsg">
130
+ <template slot="header">
131
+ <el-tooltip
132
+ class="item"
133
+ effect="dark"
134
+ :content="item.labelMsg"
135
+ placement="right"
136
+ >
137
+ <span>{{ item.label }} <i class="el-icon-question"></i></span>
138
+ </el-tooltip>
139
+ </template>
140
+ </template>
141
+ <template slot-scope="{ row, $index }">
142
+ <expandDom
143
+ v-if="item.render"
144
+ :column="row"
145
+ :row="row"
146
+ :render="item.render"
147
+ :index="$index"
148
+ ></expandDom>
149
+ <template v-else>
150
+ {{ row[item.prop] }}
151
+ </template>
152
+ <!-- 更多操作 -->
153
+ <template v-if="item.more && item.more.options.length">
154
+ <template v-for="(itemBtn, idxBtn) in item.more.options">
155
+ <expand-dom
156
+ v-if="itemBtn.render && itemBtn.show && itemBtn.show(row)"
157
+ :key="idxBtn"
158
+ :column="itemBtn"
159
+ :row="row"
160
+ :render="itemBtn.render"
161
+ :index="idxBtn"
162
+ />
163
+ <template v-else>
164
+ <el-popconfirm
165
+ v-if="itemBtn.isPopConfirm"
166
+ :title="
167
+ itemBtn.options.title ||
168
+ `确定${label(itemBtn, row)}吗?`
169
+ "
170
+ :key="idxBtn"
171
+ :confirm-button-text="itemBtn.options.confirmButtonText"
172
+ class="ml-10"
173
+ @confirm="handleClick(itemBtn.method, row, $index)"
174
+ >
175
+ <el-button
176
+ :type="itemBtn.type || 'text'"
177
+ :size="itemBtn.size || 'mini'"
178
+ :icon="itemBtn.icon"
179
+ :plain="itemBtn.plain"
180
+ slot="reference"
181
+ >{{ label(itemBtn, row) }}</el-button
182
+ >
183
+ </el-popconfirm>
184
+ <template v-else>
185
+ <el-button
186
+ v-if="itemBtn.show ? itemBtn.show(row) : true"
187
+ :key="idxBtn"
188
+ :disabled="
189
+ itemBtn.disabled ? itemBtn.disabled(row) : false
190
+ "
191
+ :type="itemBtn.type || 'text'"
192
+ :size="itemBtn.size || 'mini'"
193
+ :icon="itemBtn.icon"
194
+ :plain="itemBtn.plain"
195
+ @click="handleClick(itemBtn.method, row, $index)"
196
+ >{{ label(itemBtn, row) }}</el-button
197
+ >
198
+ </template>
199
+ </template>
200
+ </template>
201
+ </template>
202
+ </template>
203
+ </el-table-column>
204
+ <!-- <column
121
205
  :key="idx"
122
206
  v-if="item.checked === true"
123
207
  v-bind="item"
124
- ></column>
208
+ ></column> -->
125
209
  </template>
126
210
  </slot>
127
211
  </el-table>
@@ -139,10 +223,30 @@
139
223
  </template>
140
224
 
141
225
  <script>
142
- import column from "./column.vue";
143
226
  export default {
144
227
  name: "XnTable",
145
- components: { column },
228
+ components: {
229
+ expandDom: {
230
+ functional: true,
231
+ props: {
232
+ row: Object,
233
+ render: Function,
234
+ index: Number,
235
+ column: {
236
+ type: Object,
237
+ default: null,
238
+ },
239
+ },
240
+ render: (h, ctx) => {
241
+ const params = {
242
+ row: ctx.props.row,
243
+ index: ctx.props.index,
244
+ };
245
+ if (ctx.props.column) params.column = ctx.props.column;
246
+ return ctx.props.render(h, params);
247
+ },
248
+ },
249
+ },
146
250
  props: {
147
251
  tools: {
148
252
  type: Array,
@@ -184,7 +288,23 @@ export default {
184
288
  selectedData: [],
185
289
  };
186
290
  },
187
- computed: {},
291
+ computed: {
292
+ label() {
293
+ return (itemBtn, row) => {
294
+ return typeof itemBtn.label === "function"
295
+ ? itemBtn.label(row)
296
+ : itemBtn.label;
297
+ };
298
+ },
299
+ isShowColumn() {
300
+ return (row) => {
301
+ if (row.show != undefined) {
302
+ return typeof row.show === "function" ? row.show() : row.show;
303
+ }
304
+ return true;
305
+ };
306
+ },
307
+ },
188
308
  created() {
189
309
  this.columns.length &&
190
310
  this.columns.forEach((item) => {
@@ -222,6 +342,15 @@ export default {
222
342
  doLayout() {
223
343
  this.$refs.table.doLayout();
224
344
  },
345
+ handleClick(method, row, index) {
346
+ if (this.$parent) {
347
+ this.$parent.$emit("handle-buttons", {
348
+ method,
349
+ row,
350
+ index,
351
+ });
352
+ }
353
+ },
225
354
  },
226
355
  };
227
356
  </script>