@tmagic/table 1.6.0 → 1.7.0-beta.0
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/dist/tmagic-table.js +311 -333
- package/dist/tmagic-table.umd.cjs +309 -331
- package/package.json +5 -5
- package/src/ActionsColumn.vue +58 -43
- package/src/ComponentColumn.vue +7 -18
- package/src/ExpandColumn.vue +14 -19
- package/src/PopoverColumn.vue +19 -24
- package/src/Table.vue +74 -50
- package/src/TextColumn.vue +42 -57
- package/src/schema.ts +2 -1
- package/types/index.d.ts +5 -3
package/dist/tmagic-table.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { defineComponent,
|
|
1
|
+
import { defineComponent, createElementBlock, openBlock, Fragment, withDirectives, renderList, createBlock, unref, withCtx, createVNode, createElementVNode, vShow, createTextVNode, resolveDynamicComponent, mergeProps, toHandlers, createCommentVNode, normalizeProps, toDisplayString, resolveComponent, computed, useTemplateRef, ref, resolveDirective, h } from 'vue';
|
|
2
2
|
import { cloneDeep } from 'lodash-es';
|
|
3
|
-
import {
|
|
3
|
+
import { TMagicTooltip, TMagicButton, tMagicMessage, TMagicPopover, TMagicForm, TMagicTag, TMagicTable } from '@tmagic/design';
|
|
4
4
|
import { MForm, datetimeFormatter } from '@tmagic/form';
|
|
5
5
|
|
|
6
6
|
const _hoisted_1$2 = ["innerHTML"];
|
|
@@ -13,7 +13,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
13
13
|
columns: { default: () => [] },
|
|
14
14
|
config: { default: () => ({}) },
|
|
15
15
|
rowkeyName: { default: "c_id" },
|
|
16
|
-
editState: { default: () => [] }
|
|
16
|
+
editState: { default: () => [] },
|
|
17
|
+
row: {},
|
|
18
|
+
index: {}
|
|
17
19
|
},
|
|
18
20
|
emits: ["after-action"],
|
|
19
21
|
setup(__props, { emit: __emit }) {
|
|
@@ -23,8 +25,20 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
23
25
|
if (typeof fuc === "function") {
|
|
24
26
|
return fuc(row);
|
|
25
27
|
}
|
|
28
|
+
if (typeof fuc === "boolean") {
|
|
29
|
+
return fuc;
|
|
30
|
+
}
|
|
26
31
|
return true;
|
|
27
32
|
};
|
|
33
|
+
const disabled = (fuc, row) => {
|
|
34
|
+
if (typeof fuc === "function") {
|
|
35
|
+
return fuc(row);
|
|
36
|
+
}
|
|
37
|
+
if (typeof fuc === "boolean") {
|
|
38
|
+
return fuc;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
};
|
|
28
42
|
const formatter = (fuc, row) => {
|
|
29
43
|
if (typeof fuc === "function") {
|
|
30
44
|
return fuc(row);
|
|
@@ -46,7 +60,9 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
46
60
|
const data = {};
|
|
47
61
|
const row = props.editState[index];
|
|
48
62
|
props.columns.filter((item) => item.type).forEach((column) => {
|
|
49
|
-
|
|
63
|
+
if (column.prop) {
|
|
64
|
+
data[column.prop] = row[column.prop];
|
|
65
|
+
}
|
|
50
66
|
});
|
|
51
67
|
const res = await action({
|
|
52
68
|
data
|
|
@@ -65,16 +81,14 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
65
81
|
}
|
|
66
82
|
};
|
|
67
83
|
return (_ctx, _cache) => {
|
|
68
|
-
return openBlock(),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}, {
|
|
73
|
-
default: withCtx((scope) => [
|
|
84
|
+
return openBlock(), createElementBlock(
|
|
85
|
+
Fragment,
|
|
86
|
+
null,
|
|
87
|
+
[
|
|
74
88
|
(openBlock(true), createElementBlock(
|
|
75
89
|
Fragment,
|
|
76
90
|
null,
|
|
77
|
-
renderList(
|
|
91
|
+
renderList(__props.config.actions, (action, actionIndex) => {
|
|
78
92
|
return openBlock(), createBlock(unref(TMagicTooltip), {
|
|
79
93
|
placement: action.tooltipPlacement || "top",
|
|
80
94
|
key: actionIndex,
|
|
@@ -88,17 +102,18 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
88
102
|
size: "small",
|
|
89
103
|
type: action.buttonType || "primary",
|
|
90
104
|
icon: action.icon,
|
|
91
|
-
|
|
105
|
+
disabled: disabled(action.disabled, __props.row),
|
|
106
|
+
onClick: ($event) => actionHandler(action, __props.row, __props.index)
|
|
92
107
|
}, {
|
|
93
108
|
default: withCtx(() => [
|
|
94
109
|
createElementVNode("span", {
|
|
95
|
-
innerHTML: formatter(action.text,
|
|
110
|
+
innerHTML: formatter(action.text, __props.row)
|
|
96
111
|
}, null, 8, _hoisted_1$2)
|
|
97
112
|
]),
|
|
98
113
|
_: 2
|
|
99
114
|
/* DYNAMIC */
|
|
100
|
-
}, 1032, ["type", "icon", "onClick"]), [
|
|
101
|
-
[vShow, display(action.display,
|
|
115
|
+
}, 1032, ["type", "icon", "disabled", "onClick"]), [
|
|
116
|
+
[vShow, display(action.display, __props.row) && !__props.editState[__props.index]]
|
|
102
117
|
])
|
|
103
118
|
]),
|
|
104
119
|
_: 2
|
|
@@ -108,48 +123,60 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
|
108
123
|
128
|
|
109
124
|
/* KEYED_FRAGMENT */
|
|
110
125
|
)),
|
|
111
|
-
withDirectives(createVNode(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
withDirectives(createVNode(
|
|
127
|
+
unref(TMagicButton),
|
|
128
|
+
{
|
|
129
|
+
class: "action-btn",
|
|
130
|
+
link: "",
|
|
131
|
+
type: "primary",
|
|
132
|
+
size: "small",
|
|
133
|
+
onClick: _cache[0] || (_cache[0] = ($event) => save(__props.index, __props.config))
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
default: withCtx(() => [..._cache[2] || (_cache[2] = [
|
|
137
|
+
createTextVNode(
|
|
138
|
+
"保存",
|
|
139
|
+
-1
|
|
140
|
+
/* CACHED */
|
|
141
|
+
)
|
|
142
|
+
])]),
|
|
143
|
+
_: 1
|
|
144
|
+
/* STABLE */
|
|
145
|
+
},
|
|
146
|
+
512
|
|
147
|
+
/* NEED_PATCH */
|
|
148
|
+
), [
|
|
149
|
+
[vShow, __props.editState[__props.index]]
|
|
129
150
|
]),
|
|
130
|
-
withDirectives(createVNode(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
withDirectives(createVNode(
|
|
152
|
+
unref(TMagicButton),
|
|
153
|
+
{
|
|
154
|
+
class: "action-btn",
|
|
155
|
+
link: "",
|
|
156
|
+
type: "primary",
|
|
157
|
+
size: "small",
|
|
158
|
+
onClick: _cache[1] || (_cache[1] = ($event) => __props.editState[__props.index] = void 0)
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
default: withCtx(() => [..._cache[3] || (_cache[3] = [
|
|
162
|
+
createTextVNode(
|
|
163
|
+
"取消",
|
|
164
|
+
-1
|
|
165
|
+
/* CACHED */
|
|
166
|
+
)
|
|
167
|
+
])]),
|
|
168
|
+
_: 1
|
|
169
|
+
/* STABLE */
|
|
170
|
+
},
|
|
171
|
+
512
|
|
172
|
+
/* NEED_PATCH */
|
|
173
|
+
), [
|
|
174
|
+
[vShow, __props.editState[__props.index]]
|
|
148
175
|
])
|
|
149
|
-
]
|
|
150
|
-
|
|
151
|
-
/*
|
|
152
|
-
|
|
176
|
+
],
|
|
177
|
+
64
|
|
178
|
+
/* STABLE_FRAGMENT */
|
|
179
|
+
);
|
|
153
180
|
};
|
|
154
181
|
}
|
|
155
182
|
});
|
|
@@ -160,7 +187,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
160
187
|
},
|
|
161
188
|
__name: "ComponentColumn",
|
|
162
189
|
props: {
|
|
163
|
-
config: { default: () => ({}) }
|
|
190
|
+
config: { default: () => ({}) },
|
|
191
|
+
row: {},
|
|
192
|
+
index: {}
|
|
164
193
|
},
|
|
165
194
|
setup(__props) {
|
|
166
195
|
const props = __props;
|
|
@@ -177,26 +206,13 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
|
177
206
|
return props.config.listeners || {};
|
|
178
207
|
};
|
|
179
208
|
return (_ctx, _cache) => {
|
|
180
|
-
return openBlock(), createBlock(
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}, {
|
|
188
|
-
default: withCtx((scope) => [
|
|
189
|
-
(openBlock(), createBlock(
|
|
190
|
-
resolveDynamicComponent(_ctx.config.component),
|
|
191
|
-
mergeProps(componentProps(scope.row, scope.$index), toHandlers(componentListeners(scope.row, scope.$index))),
|
|
192
|
-
null,
|
|
193
|
-
16
|
|
194
|
-
/* FULL_PROPS */
|
|
195
|
-
))
|
|
196
|
-
]),
|
|
197
|
-
_: 1
|
|
198
|
-
/* STABLE */
|
|
199
|
-
}, 8, ["label", "width", "fixed", "sortable", "prop"]);
|
|
209
|
+
return openBlock(), createBlock(
|
|
210
|
+
resolveDynamicComponent(__props.config.component),
|
|
211
|
+
mergeProps(componentProps(__props.row, __props.index), toHandlers(componentListeners(__props.row, __props.index))),
|
|
212
|
+
null,
|
|
213
|
+
16
|
|
214
|
+
/* FULL_PROPS */
|
|
215
|
+
);
|
|
200
216
|
};
|
|
201
217
|
}
|
|
202
218
|
});
|
|
@@ -208,7 +224,8 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
208
224
|
},
|
|
209
225
|
__name: "ExpandColumn",
|
|
210
226
|
props: {
|
|
211
|
-
config: { default: () => ({}) }
|
|
227
|
+
config: { default: () => ({}) },
|
|
228
|
+
row: {}
|
|
212
229
|
},
|
|
213
230
|
setup(__props) {
|
|
214
231
|
const props = __props;
|
|
@@ -223,42 +240,31 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
223
240
|
Fragment,
|
|
224
241
|
null,
|
|
225
242
|
[
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
_ctx.config.component ? (openBlock(), createBlock(
|
|
249
|
-
resolveDynamicComponent(_ctx.config.component),
|
|
250
|
-
normalizeProps(mergeProps({ key: 3 }, componentProps(scope.row))),
|
|
251
|
-
null,
|
|
252
|
-
16
|
|
253
|
-
/* FULL_PROPS */
|
|
254
|
-
)) : createCommentVNode("v-if", true)
|
|
255
|
-
]),
|
|
256
|
-
_: 1
|
|
257
|
-
/* STABLE */
|
|
258
|
-
}, 8, ["width", "fixed"])
|
|
243
|
+
__props.config.table ? (openBlock(), createBlock(_sfc_main, {
|
|
244
|
+
key: 0,
|
|
245
|
+
"show-header": false,
|
|
246
|
+
columns: __props.config.table,
|
|
247
|
+
data: __props.config.prop && __props.row[__props.config.prop] || []
|
|
248
|
+
}, null, 8, ["columns", "data"])) : createCommentVNode("v-if", true),
|
|
249
|
+
__props.config.form ? (openBlock(), createBlock(unref(MForm), {
|
|
250
|
+
key: 1,
|
|
251
|
+
config: __props.config.form,
|
|
252
|
+
"init-values": __props.config.values || __props.config.prop && __props.row[__props.config.prop] || {}
|
|
253
|
+
}, null, 8, ["config", "init-values"])) : createCommentVNode("v-if", true),
|
|
254
|
+
__props.config.expandContent ? (openBlock(), createElementBlock("div", {
|
|
255
|
+
key: 2,
|
|
256
|
+
innerHTML: __props.config.expandContent(__props.row, __props.config.prop)
|
|
257
|
+
}, null, 8, _hoisted_1$1)) : createCommentVNode("v-if", true),
|
|
258
|
+
__props.config.component ? (openBlock(), createBlock(
|
|
259
|
+
resolveDynamicComponent(__props.config.component),
|
|
260
|
+
normalizeProps(mergeProps({ key: 3 }, componentProps(__props.row))),
|
|
261
|
+
null,
|
|
262
|
+
16
|
|
263
|
+
/* FULL_PROPS */
|
|
264
|
+
)) : createCommentVNode("v-if", true)
|
|
259
265
|
],
|
|
260
|
-
|
|
261
|
-
/* STABLE_FRAGMENT
|
|
266
|
+
64
|
|
267
|
+
/* STABLE_FRAGMENT */
|
|
262
268
|
);
|
|
263
269
|
};
|
|
264
270
|
}
|
|
@@ -288,69 +294,46 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
288
294
|
},
|
|
289
295
|
__name: "PopoverColumn",
|
|
290
296
|
props: {
|
|
291
|
-
config: { default: () => ({}) }
|
|
297
|
+
config: { default: () => ({}) },
|
|
298
|
+
row: {},
|
|
299
|
+
index: {}
|
|
292
300
|
},
|
|
293
301
|
setup(__props) {
|
|
294
302
|
return (_ctx, _cache) => {
|
|
295
|
-
return openBlock(),
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
303
|
+
return __props.config.popover ? (openBlock(), createBlock(unref(TMagicPopover), {
|
|
304
|
+
key: 0,
|
|
305
|
+
placement: __props.config.popover.placement,
|
|
306
|
+
width: __props.config.popover.width,
|
|
307
|
+
trigger: __props.config.popover.trigger,
|
|
308
|
+
"destroy-on-close": __props.config.popover.destroyOnClose ?? true
|
|
309
|
+
}, {
|
|
310
|
+
reference: withCtx(() => [
|
|
311
|
+
createVNode(unref(TMagicButton), {
|
|
312
|
+
link: "",
|
|
313
|
+
type: "primary"
|
|
304
314
|
}, {
|
|
305
|
-
default: withCtx((
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
"destroy-on-close": _ctx.config.popover.destroyOnClose ?? true
|
|
312
|
-
}, {
|
|
313
|
-
reference: withCtx(() => [
|
|
314
|
-
createVNode(
|
|
315
|
-
unref(TMagicButton),
|
|
316
|
-
{
|
|
317
|
-
link: "",
|
|
318
|
-
type: "primary"
|
|
319
|
-
},
|
|
320
|
-
{
|
|
321
|
-
default: withCtx(() => [
|
|
322
|
-
createTextVNode(
|
|
323
|
-
toDisplayString(_ctx.config.text || unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
324
|
-
1
|
|
325
|
-
/* TEXT */
|
|
326
|
-
)
|
|
327
|
-
]),
|
|
328
|
-
_: 2
|
|
329
|
-
/* DYNAMIC */
|
|
330
|
-
},
|
|
331
|
-
1024
|
|
332
|
-
/* DYNAMIC_SLOTS */
|
|
333
|
-
)
|
|
334
|
-
]),
|
|
335
|
-
default: withCtx(() => [
|
|
336
|
-
_ctx.config.popover.tableEmbed ? (openBlock(), createBlock(_sfc_main, {
|
|
337
|
-
key: 0,
|
|
338
|
-
"show-header": _ctx.config.showHeader,
|
|
339
|
-
columns: _ctx.config.table,
|
|
340
|
-
data: _ctx.config.prop && scope.row[_ctx.config.prop] || []
|
|
341
|
-
}, null, 8, ["show-header", "columns", "data"])) : createCommentVNode("v-if", true)
|
|
342
|
-
]),
|
|
343
|
-
_: 2
|
|
344
|
-
/* DYNAMIC */
|
|
345
|
-
}, 1032, ["placement", "width", "trigger", "destroy-on-close"])) : createCommentVNode("v-if", true)
|
|
315
|
+
default: withCtx(() => [
|
|
316
|
+
createTextVNode(
|
|
317
|
+
toDisplayString(__props.config.text || unref(formatter)(__props.config, __props.row, { index: __props.index })),
|
|
318
|
+
1
|
|
319
|
+
/* TEXT */
|
|
320
|
+
)
|
|
346
321
|
]),
|
|
347
322
|
_: 1
|
|
348
323
|
/* STABLE */
|
|
349
|
-
}
|
|
350
|
-
],
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
324
|
+
})
|
|
325
|
+
]),
|
|
326
|
+
default: withCtx(() => [
|
|
327
|
+
__props.config.popover.tableEmbed ? (openBlock(), createBlock(_sfc_main, {
|
|
328
|
+
key: 0,
|
|
329
|
+
"show-header": __props.config.showHeader,
|
|
330
|
+
columns: __props.config.table,
|
|
331
|
+
data: __props.config.prop && __props.row[__props.config.prop] || []
|
|
332
|
+
}, null, 8, ["show-header", "columns", "data"])) : createCommentVNode("v-if", true)
|
|
333
|
+
]),
|
|
334
|
+
_: 1
|
|
335
|
+
/* STABLE */
|
|
336
|
+
}, 8, ["placement", "width", "trigger", "destroy-on-close"])) : createCommentVNode("v-if", true);
|
|
354
337
|
};
|
|
355
338
|
}
|
|
356
339
|
});
|
|
@@ -368,129 +351,112 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
368
351
|
__name: "TextColumn",
|
|
369
352
|
props: {
|
|
370
353
|
config: { default: () => ({}) },
|
|
371
|
-
editState: { default: () => ({}) }
|
|
354
|
+
editState: { default: () => ({}) },
|
|
355
|
+
row: {},
|
|
356
|
+
index: {}
|
|
372
357
|
},
|
|
373
358
|
setup(__props) {
|
|
374
359
|
return (_ctx, _cache) => {
|
|
375
360
|
const _component_m_form_container = resolveComponent("m-form-container");
|
|
376
361
|
const _component_el_tooltip = resolveComponent("el-tooltip");
|
|
377
|
-
return openBlock(),
|
|
378
|
-
"
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
362
|
+
return __props.config.type === "index" ? (openBlock(), createElementBlock(
|
|
363
|
+
"div",
|
|
364
|
+
_hoisted_1,
|
|
365
|
+
toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + __props.index + 1 : __props.index + 1),
|
|
366
|
+
1
|
|
367
|
+
/* TEXT */
|
|
368
|
+
)) : __props.config.type && __props.editState[__props.index] ? (openBlock(), createBlock(unref(TMagicForm), {
|
|
369
|
+
key: 1,
|
|
370
|
+
"label-width": "0",
|
|
371
|
+
model: __props.editState[__props.index]
|
|
384
372
|
}, {
|
|
385
|
-
default: withCtx((
|
|
386
|
-
|
|
373
|
+
default: withCtx(() => [
|
|
374
|
+
createVNode(_component_m_form_container, {
|
|
375
|
+
prop: __props.config.prop,
|
|
376
|
+
rules: __props.config.rules,
|
|
377
|
+
config: __props.config,
|
|
378
|
+
name: __props.config.prop,
|
|
379
|
+
model: __props.editState[__props.index]
|
|
380
|
+
}, null, 8, ["prop", "rules", "config", "name", "model"])
|
|
381
|
+
]),
|
|
382
|
+
_: 1
|
|
383
|
+
/* STABLE */
|
|
384
|
+
}, 8, ["model"])) : __props.config.action === "actionLink" && __props.config.prop ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
385
|
+
key: 2,
|
|
386
|
+
link: "",
|
|
387
|
+
type: "primary",
|
|
388
|
+
onClick: _cache[0] || (_cache[0] = ($event) => __props.config.handler?.(__props.row))
|
|
389
|
+
}, {
|
|
390
|
+
default: withCtx(() => [
|
|
391
|
+
createElementVNode("span", {
|
|
392
|
+
innerHTML: unref(formatter)(__props.config, __props.row, { index: __props.index })
|
|
393
|
+
}, null, 8, _hoisted_2)
|
|
394
|
+
]),
|
|
395
|
+
_: 1
|
|
396
|
+
/* STABLE */
|
|
397
|
+
})) : __props.config.action === "img" && __props.config.prop ? (openBlock(), createElementBlock("a", {
|
|
398
|
+
key: 3,
|
|
399
|
+
target: "_blank",
|
|
400
|
+
href: __props.row[__props.config.prop]
|
|
401
|
+
}, [
|
|
402
|
+
createElementVNode("img", {
|
|
403
|
+
src: __props.row[__props.config.prop],
|
|
404
|
+
height: "50"
|
|
405
|
+
}, null, 8, _hoisted_4)
|
|
406
|
+
], 8, _hoisted_3)) : __props.config.action === "link" && __props.config.prop ? (openBlock(), createElementBlock("a", {
|
|
407
|
+
key: 4,
|
|
408
|
+
target: "_blank",
|
|
409
|
+
href: __props.row[__props.config.prop],
|
|
410
|
+
class: "keep-all"
|
|
411
|
+
}, toDisplayString(__props.row[__props.config.prop]), 9, _hoisted_5)) : __props.config.action === "tip" ? (openBlock(), createBlock(_component_el_tooltip, {
|
|
412
|
+
key: 5,
|
|
413
|
+
placement: "left"
|
|
414
|
+
}, {
|
|
415
|
+
content: withCtx(() => [
|
|
416
|
+
createElementVNode(
|
|
387
417
|
"div",
|
|
388
|
-
|
|
389
|
-
toDisplayString(
|
|
418
|
+
null,
|
|
419
|
+
toDisplayString(unref(formatter)(__props.config, __props.row, { index: __props.index })),
|
|
390
420
|
1
|
|
391
421
|
/* TEXT */
|
|
392
|
-
)
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
}, {
|
|
397
|
-
default: withCtx(() => [
|
|
398
|
-
createVNode(_component_m_form_container, {
|
|
399
|
-
prop: _ctx.config.prop,
|
|
400
|
-
rules: _ctx.config.rules,
|
|
401
|
-
config: _ctx.config,
|
|
402
|
-
name: _ctx.config.prop,
|
|
403
|
-
model: _ctx.editState[scope.$index]
|
|
404
|
-
}, null, 8, ["prop", "rules", "config", "name", "model"])
|
|
405
|
-
]),
|
|
406
|
-
_: 2
|
|
407
|
-
/* DYNAMIC */
|
|
408
|
-
}, 1032, ["model"])) : _ctx.config.action === "actionLink" && _ctx.config.prop ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
409
|
-
key: 2,
|
|
422
|
+
)
|
|
423
|
+
]),
|
|
424
|
+
default: withCtx(() => [
|
|
425
|
+
createVNode(unref(TMagicButton), {
|
|
410
426
|
link: "",
|
|
411
|
-
type: "primary"
|
|
412
|
-
onClick: ($event) => _ctx.config.handler?.(scope.row)
|
|
413
|
-
}, {
|
|
414
|
-
default: withCtx(() => [
|
|
415
|
-
createElementVNode("span", {
|
|
416
|
-
innerHTML: unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
417
|
-
}, null, 8, _hoisted_2)
|
|
418
|
-
]),
|
|
419
|
-
_: 2
|
|
420
|
-
/* DYNAMIC */
|
|
421
|
-
}, 1032, ["onClick"])) : _ctx.config.action === "img" && _ctx.config.prop ? (openBlock(), createElementBlock("a", {
|
|
422
|
-
key: 3,
|
|
423
|
-
target: "_blank",
|
|
424
|
-
href: scope.row[_ctx.config.prop]
|
|
425
|
-
}, [
|
|
426
|
-
createElementVNode("img", {
|
|
427
|
-
src: scope.row[_ctx.config.prop],
|
|
428
|
-
height: "50"
|
|
429
|
-
}, null, 8, _hoisted_4)
|
|
430
|
-
], 8, _hoisted_3)) : _ctx.config.action === "link" && _ctx.config.prop ? (openBlock(), createElementBlock("a", {
|
|
431
|
-
key: 4,
|
|
432
|
-
target: "_blank",
|
|
433
|
-
href: scope.row[_ctx.config.prop],
|
|
434
|
-
class: "keep-all"
|
|
435
|
-
}, toDisplayString(scope.row[_ctx.config.prop]), 9, _hoisted_5)) : _ctx.config.action === "tip" ? (openBlock(), createBlock(
|
|
436
|
-
_component_el_tooltip,
|
|
437
|
-
{
|
|
438
|
-
key: 5,
|
|
439
|
-
placement: "left"
|
|
440
|
-
},
|
|
441
|
-
{
|
|
442
|
-
content: withCtx(() => [
|
|
443
|
-
createElementVNode(
|
|
444
|
-
"div",
|
|
445
|
-
null,
|
|
446
|
-
toDisplayString(unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
447
|
-
1
|
|
448
|
-
/* TEXT */
|
|
449
|
-
)
|
|
450
|
-
]),
|
|
451
|
-
default: withCtx(() => [
|
|
452
|
-
createVNode(unref(TMagicButton), {
|
|
453
|
-
link: "",
|
|
454
|
-
type: "primary"
|
|
455
|
-
}, {
|
|
456
|
-
default: withCtx(() => [
|
|
457
|
-
createTextVNode(
|
|
458
|
-
toDisplayString(_ctx.config.buttonText || "扩展配置"),
|
|
459
|
-
1
|
|
460
|
-
/* TEXT */
|
|
461
|
-
)
|
|
462
|
-
]),
|
|
463
|
-
_: 1
|
|
464
|
-
/* STABLE */
|
|
465
|
-
})
|
|
466
|
-
]),
|
|
467
|
-
_: 2
|
|
468
|
-
/* DYNAMIC */
|
|
469
|
-
},
|
|
470
|
-
1024
|
|
471
|
-
/* DYNAMIC_SLOTS */
|
|
472
|
-
)) : _ctx.config.action === "tag" && _ctx.config.prop ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
473
|
-
key: 6,
|
|
474
|
-
type: typeof _ctx.config.type === "function" ? _ctx.config.type(scope.row[_ctx.config.prop], scope.row) : _ctx.config.type,
|
|
475
|
-
"close-transition": ""
|
|
427
|
+
type: "primary"
|
|
476
428
|
}, {
|
|
477
429
|
default: withCtx(() => [
|
|
478
430
|
createTextVNode(
|
|
479
|
-
toDisplayString(
|
|
431
|
+
toDisplayString(__props.config.buttonText || "扩展配置"),
|
|
480
432
|
1
|
|
481
433
|
/* TEXT */
|
|
482
434
|
)
|
|
483
435
|
]),
|
|
484
|
-
_:
|
|
485
|
-
/*
|
|
486
|
-
}
|
|
487
|
-
key: 7,
|
|
488
|
-
innerHTML: unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
489
|
-
}, null, 8, _hoisted_6))
|
|
436
|
+
_: 1
|
|
437
|
+
/* STABLE */
|
|
438
|
+
})
|
|
490
439
|
]),
|
|
491
440
|
_: 1
|
|
492
441
|
/* STABLE */
|
|
493
|
-
}
|
|
442
|
+
})) : __props.config.action === "tag" && __props.config.prop ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
443
|
+
key: 6,
|
|
444
|
+
type: typeof __props.config.type === "function" ? __props.config.type(__props.row[__props.config.prop], __props.row) : __props.config.type,
|
|
445
|
+
"close-transition": ""
|
|
446
|
+
}, {
|
|
447
|
+
default: withCtx(() => [
|
|
448
|
+
createTextVNode(
|
|
449
|
+
toDisplayString(unref(formatter)(__props.config, __props.row, { index: __props.index })),
|
|
450
|
+
1
|
|
451
|
+
/* TEXT */
|
|
452
|
+
)
|
|
453
|
+
]),
|
|
454
|
+
_: 1
|
|
455
|
+
/* STABLE */
|
|
456
|
+
}, 8, ["type"])) : (openBlock(), createElementBlock("div", {
|
|
457
|
+
key: 7,
|
|
458
|
+
innerHTML: unref(formatter)(__props.config, __props.row, { index: __props.index })
|
|
459
|
+
}, null, 8, _hoisted_6));
|
|
494
460
|
};
|
|
495
461
|
}
|
|
496
462
|
});
|
|
@@ -524,9 +490,67 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
524
490
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
525
491
|
const props = __props;
|
|
526
492
|
const emit = __emit;
|
|
527
|
-
const
|
|
493
|
+
const cellRender = (config, { row = {}, $index }) => {
|
|
494
|
+
if (config.type === "expand") {
|
|
495
|
+
return h(_sfc_main$3, {
|
|
496
|
+
config,
|
|
497
|
+
row
|
|
498
|
+
});
|
|
499
|
+
}
|
|
500
|
+
if (config.type === "component") {
|
|
501
|
+
return h(_sfc_main$4, {
|
|
502
|
+
config,
|
|
503
|
+
row,
|
|
504
|
+
index: $index
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
if (config.actions) {
|
|
508
|
+
return h(_sfc_main$5, {
|
|
509
|
+
config,
|
|
510
|
+
row,
|
|
511
|
+
index: $index,
|
|
512
|
+
rowkeyName: props.rowkeyName,
|
|
513
|
+
editState: editState.value,
|
|
514
|
+
columns: props.columns
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
if (config.type === "popover") {
|
|
518
|
+
return h(_sfc_main$2, {
|
|
519
|
+
config,
|
|
520
|
+
row,
|
|
521
|
+
index: $index
|
|
522
|
+
});
|
|
523
|
+
}
|
|
524
|
+
return h(_sfc_main$1, {
|
|
525
|
+
config,
|
|
526
|
+
row,
|
|
527
|
+
index: $index,
|
|
528
|
+
editState: editState.value
|
|
529
|
+
});
|
|
530
|
+
};
|
|
531
|
+
const tableColumns = computed(
|
|
532
|
+
() => props.columns.map((item) => {
|
|
533
|
+
let type = "default";
|
|
534
|
+
if (item.type === "expand") {
|
|
535
|
+
type = "expand";
|
|
536
|
+
} else if (item.selection) {
|
|
537
|
+
type = "selection";
|
|
538
|
+
}
|
|
539
|
+
return {
|
|
540
|
+
props: {
|
|
541
|
+
label: item.label,
|
|
542
|
+
fixed: item.fixed,
|
|
543
|
+
width: item.width ?? (item.selection ? 40 : void 0),
|
|
544
|
+
prop: item.prop,
|
|
545
|
+
type,
|
|
546
|
+
selectable: item.selectable
|
|
547
|
+
},
|
|
548
|
+
cell: type === "selection" ? void 0 : ({ row, $index }) => cellRender(item, { row, $index })
|
|
549
|
+
};
|
|
550
|
+
})
|
|
551
|
+
);
|
|
552
|
+
const tMagicTableRef = useTemplateRef("tMagicTable");
|
|
528
553
|
const editState = ref([]);
|
|
529
|
-
const tableColumnComponent = getDesignConfig("components")?.tableColumn;
|
|
530
554
|
const selectionColumn = computed(() => {
|
|
531
555
|
const column = props.columns.filter((item) => item.selection);
|
|
532
556
|
return column.length ? column[0] : null;
|
|
@@ -562,13 +586,13 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
562
586
|
emit("expand-change", ...args);
|
|
563
587
|
};
|
|
564
588
|
const toggleRowSelection = (row, selected) => {
|
|
565
|
-
|
|
589
|
+
tMagicTableRef.value?.toggleRowSelection(row, selected);
|
|
566
590
|
};
|
|
567
591
|
const toggleRowExpansion = (row, expanded) => {
|
|
568
|
-
|
|
592
|
+
tMagicTableRef.value?.toggleRowExpansion(row, expanded);
|
|
569
593
|
};
|
|
570
594
|
const clearSelection = () => {
|
|
571
|
-
|
|
595
|
+
tMagicTableRef.value?.clearSelection();
|
|
572
596
|
};
|
|
573
597
|
const objectSpanMethod = (data) => {
|
|
574
598
|
if (typeof props.spanMethod === "function") {
|
|
@@ -587,75 +611,29 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
587
611
|
return (_ctx, _cache) => {
|
|
588
612
|
const _directive_loading = resolveDirective("loading");
|
|
589
613
|
return withDirectives((openBlock(), createBlock(unref(TMagicTable), {
|
|
614
|
+
class: "m-table",
|
|
615
|
+
ref: "tMagicTable",
|
|
616
|
+
"show-overflow-tooltip": true,
|
|
590
617
|
"tooltip-effect": "dark",
|
|
591
618
|
"tooltip-options": { popperOptions: { strategy: "absolute" } },
|
|
592
|
-
class: "m-table",
|
|
593
|
-
ref_key: "tMagicTable",
|
|
594
|
-
ref: tMagicTable,
|
|
595
619
|
data: tableData.value,
|
|
596
|
-
"show-header":
|
|
597
|
-
"max-height":
|
|
598
|
-
"default-expand-all":
|
|
620
|
+
"show-header": __props.showHeader,
|
|
621
|
+
"max-height": __props.bodyHeight,
|
|
622
|
+
"default-expand-all": __props.defaultExpandAll,
|
|
599
623
|
border: hasBorder.value,
|
|
600
|
-
"row-key":
|
|
624
|
+
"row-key": __props.rowkeyName || "id",
|
|
601
625
|
"tree-props": { children: "children" },
|
|
602
|
-
"empty-text":
|
|
626
|
+
"empty-text": __props.emptyText || "暂无数据",
|
|
603
627
|
"span-method": objectSpanMethod,
|
|
628
|
+
columns: tableColumns.value,
|
|
604
629
|
onSortChange: sortChange,
|
|
605
630
|
onSelect: selectHandler,
|
|
606
631
|
onSelectAll: selectAllHandler,
|
|
607
632
|
onSelectionChange: selectionChangeHandler,
|
|
608
633
|
onCellClick: cellClickHandler,
|
|
609
634
|
onExpandChange: expandChange
|
|
610
|
-
},
|
|
611
|
-
|
|
612
|
-
(openBlock(true), createElementBlock(
|
|
613
|
-
Fragment,
|
|
614
|
-
null,
|
|
615
|
-
renderList(_ctx.columns, (item, columnIndex) => {
|
|
616
|
-
return openBlock(), createElementBlock(
|
|
617
|
-
Fragment,
|
|
618
|
-
null,
|
|
619
|
-
[
|
|
620
|
-
item.type === "expand" ? (openBlock(), createBlock(_sfc_main$3, {
|
|
621
|
-
config: item,
|
|
622
|
-
key: columnIndex
|
|
623
|
-
}, null, 8, ["config"])) : item.type === "component" ? (openBlock(), createBlock(_sfc_main$4, {
|
|
624
|
-
config: item,
|
|
625
|
-
key: columnIndex
|
|
626
|
-
}, null, 8, ["config"])) : item.selection ? (openBlock(), createBlock(resolveDynamicComponent(unref(tableColumnComponent)?.component || "el-table-column"), {
|
|
627
|
-
width: "40",
|
|
628
|
-
type: "selection",
|
|
629
|
-
key: columnIndex,
|
|
630
|
-
selectable: item.selectable
|
|
631
|
-
}, null, 8, ["selectable"])) : item.actions ? (openBlock(), createBlock(_sfc_main$5, {
|
|
632
|
-
columns: _ctx.columns,
|
|
633
|
-
config: item,
|
|
634
|
-
"rowkey-name": _ctx.rowkeyName,
|
|
635
|
-
"edit-state": editState.value,
|
|
636
|
-
key: columnIndex,
|
|
637
|
-
onAfterAction: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("after-action"))
|
|
638
|
-
}, null, 8, ["columns", "config", "rowkey-name", "edit-state"])) : item.type === "popover" ? (openBlock(), createBlock(_sfc_main$2, {
|
|
639
|
-
key: columnIndex,
|
|
640
|
-
config: item
|
|
641
|
-
}, null, 8, ["config"])) : (openBlock(), createBlock(_sfc_main$1, {
|
|
642
|
-
key: columnIndex,
|
|
643
|
-
config: item,
|
|
644
|
-
"edit-state": editState.value
|
|
645
|
-
}, null, 8, ["config", "edit-state"]))
|
|
646
|
-
],
|
|
647
|
-
64
|
|
648
|
-
/* STABLE_FRAGMENT */
|
|
649
|
-
);
|
|
650
|
-
}),
|
|
651
|
-
256
|
|
652
|
-
/* UNKEYED_FRAGMENT */
|
|
653
|
-
))
|
|
654
|
-
]),
|
|
655
|
-
_: 1
|
|
656
|
-
/* STABLE */
|
|
657
|
-
}, 8, ["data", "show-header", "max-height", "default-expand-all", "border", "row-key", "empty-text"])), [
|
|
658
|
-
[_directive_loading, _ctx.loading]
|
|
635
|
+
}, null, 8, ["data", "show-header", "max-height", "default-expand-all", "border", "row-key", "empty-text", "columns"])), [
|
|
636
|
+
[_directive_loading, __props.loading]
|
|
659
637
|
]);
|
|
660
638
|
};
|
|
661
639
|
}
|