@tmagic/table 1.6.1 → 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.
@@ -1,6 +1,6 @@
1
- import { defineComponent, createBlock, openBlock, unref, withCtx, createElementBlock, withDirectives, Fragment, renderList, createVNode, createElementVNode, vShow, createTextVNode, resolveDynamicComponent, mergeProps, toHandlers, createCommentVNode, normalizeProps, toDisplayString, resolveComponent, ref, computed, resolveDirective } from 'vue';
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 { TMagicTableColumn, TMagicTooltip, TMagicButton, tMagicMessage, TMagicPopover, TMagicForm, TMagicTag, getDesignConfig, TMagicTable } from '@tmagic/design';
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
- data[column.prop] = row[column.prop];
63
+ if (column.prop) {
64
+ data[column.prop] = row[column.prop];
65
+ }
50
66
  });
51
67
  const res = await action({
52
68
  data
@@ -65,12 +81,10 @@ const _sfc_main$5 = /* @__PURE__ */ defineComponent({
65
81
  }
66
82
  };
67
83
  return (_ctx, _cache) => {
68
- return openBlock(), createBlock(unref(TMagicTableColumn), {
69
- label: __props.config.label,
70
- width: __props.config.width,
71
- fixed: __props.config.fixed
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,
@@ -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
- onClick: ($event) => actionHandler(action, scope.row, scope.$index)
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, scope.row)
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, scope.row) && !__props.editState[scope.$index]]
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(unref(TMagicButton), {
112
- class: "action-btn",
113
- link: "",
114
- type: "primary",
115
- size: "small",
116
- onClick: ($event) => save(scope.$index, __props.config)
117
- }, {
118
- default: withCtx(() => [..._cache[0] || (_cache[0] = [
119
- createTextVNode(
120
- "保存",
121
- -1
122
- /* CACHED */
123
- )
124
- ])]),
125
- _: 1
126
- /* STABLE */
127
- }, 8, ["onClick"]), [
128
- [vShow, __props.editState[scope.$index]]
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(unref(TMagicButton), {
131
- class: "action-btn",
132
- link: "",
133
- type: "primary",
134
- size: "small",
135
- onClick: ($event) => __props.editState[scope.$index] = void 0
136
- }, {
137
- default: withCtx(() => [..._cache[1] || (_cache[1] = [
138
- createTextVNode(
139
- "取消",
140
- -1
141
- /* CACHED */
142
- )
143
- ])]),
144
- _: 1
145
- /* STABLE */
146
- }, 8, ["onClick"]), [
147
- [vShow, __props.editState[scope.$index]]
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
- _: 1
151
- /* STABLE */
152
- }, 8, ["label", "width", "fixed"]);
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(unref(TMagicTableColumn), {
181
- "show-overflow-tooltip": "",
182
- label: __props.config.label,
183
- width: __props.config.width,
184
- fixed: __props.config.fixed,
185
- sortable: __props.config.sortable,
186
- prop: __props.config.prop
187
- }, {
188
- default: withCtx((scope) => [
189
- (openBlock(), createBlock(
190
- resolveDynamicComponent(__props.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
- createCommentVNode(" @ts-nocheck "),
227
- createVNode(unref(TMagicTableColumn), {
228
- type: "expand",
229
- width: __props.config.width,
230
- fixed: __props.config.fixed
231
- }, {
232
- default: withCtx((scope) => [
233
- __props.config.table ? (openBlock(), createBlock(_sfc_main, {
234
- key: 0,
235
- "show-header": false,
236
- columns: __props.config.table,
237
- data: __props.config.prop && scope.row[__props.config.prop] || []
238
- }, null, 8, ["columns", "data"])) : createCommentVNode("v-if", true),
239
- __props.config.form ? (openBlock(), createBlock(unref(MForm), {
240
- key: 1,
241
- config: __props.config.form,
242
- "init-values": __props.config.values || __props.config.prop && scope.row[__props.config.prop] || {}
243
- }, null, 8, ["config", "init-values"])) : createCommentVNode("v-if", true),
244
- __props.config.expandContent ? (openBlock(), createElementBlock("div", {
245
- key: 2,
246
- innerHTML: __props.config.expandContent(scope.row, __props.config.prop)
247
- }, null, 8, _hoisted_1$1)) : createCommentVNode("v-if", true),
248
- __props.config.component ? (openBlock(), createBlock(
249
- resolveDynamicComponent(__props.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
- 2112
261
- /* STABLE_FRAGMENT, DEV_ROOT_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(), createElementBlock(
296
- Fragment,
297
- null,
298
- [
299
- createCommentVNode(" @ts-nocheck "),
300
- createVNode(unref(TMagicTableColumn), {
301
- label: __props.config.label,
302
- width: __props.config.width,
303
- fixed: __props.config.fixed
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((scope) => [
306
- __props.config.popover ? (openBlock(), createBlock(unref(TMagicPopover), {
307
- key: 0,
308
- placement: __props.config.popover.placement,
309
- width: __props.config.popover.width,
310
- trigger: __props.config.popover.trigger,
311
- "destroy-on-close": __props.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(__props.config.text || unref(formatter)(__props.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
- __props.config.popover.tableEmbed ? (openBlock(), createBlock(_sfc_main, {
337
- key: 0,
338
- "show-header": __props.config.showHeader,
339
- columns: __props.config.table,
340
- data: __props.config.prop && scope.row[__props.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
- }, 8, ["label", "width", "fixed"])
350
- ],
351
- 2112
352
- /* STABLE_FRAGMENT, DEV_ROOT_FRAGMENT */
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(), createBlock(unref(TMagicTableColumn), {
378
- "show-overflow-tooltip": "",
379
- label: __props.config.label,
380
- width: __props.config.width,
381
- fixed: __props.config.fixed,
382
- sortable: __props.config.sortable,
383
- prop: __props.config.prop
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((scope) => [
386
- __props.config.type === "index" ? (openBlock(), createElementBlock(
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
- _hoisted_1,
389
- toDisplayString(__props.config.pageIndex && __props.config.pageSize ? __props.config.pageIndex * __props.config.pageSize + scope.$index + 1 : scope.$index + 1),
418
+ null,
419
+ toDisplayString(unref(formatter)(__props.config, __props.row, { index: __props.index })),
390
420
  1
391
421
  /* TEXT */
392
- )) : __props.config.type && __props.editState[scope.$index] ? (openBlock(), createBlock(unref(TMagicForm), {
393
- key: 1,
394
- "label-width": "0",
395
- model: __props.editState[scope.$index]
396
- }, {
397
- default: withCtx(() => [
398
- createVNode(_component_m_form_container, {
399
- prop: __props.config.prop,
400
- rules: __props.config.rules,
401
- config: __props.config,
402
- name: __props.config.prop,
403
- model: __props.editState[scope.$index]
404
- }, null, 8, ["prop", "rules", "config", "name", "model"])
405
- ]),
406
- _: 2
407
- /* DYNAMIC */
408
- }, 1032, ["model"])) : __props.config.action === "actionLink" && __props.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) => __props.config.handler?.(scope.row)
413
- }, {
414
- default: withCtx(() => [
415
- createElementVNode("span", {
416
- innerHTML: unref(formatter)(__props.config, scope.row, { index: scope.$index })
417
- }, null, 8, _hoisted_2)
418
- ]),
419
- _: 2
420
- /* DYNAMIC */
421
- }, 1032, ["onClick"])) : __props.config.action === "img" && __props.config.prop ? (openBlock(), createElementBlock("a", {
422
- key: 3,
423
- target: "_blank",
424
- href: scope.row[__props.config.prop]
425
- }, [
426
- createElementVNode("img", {
427
- src: scope.row[__props.config.prop],
428
- height: "50"
429
- }, null, 8, _hoisted_4)
430
- ], 8, _hoisted_3)) : __props.config.action === "link" && __props.config.prop ? (openBlock(), createElementBlock("a", {
431
- key: 4,
432
- target: "_blank",
433
- href: scope.row[__props.config.prop],
434
- class: "keep-all"
435
- }, toDisplayString(scope.row[__props.config.prop]), 9, _hoisted_5)) : __props.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)(__props.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(__props.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
- )) : __props.config.action === "tag" && __props.config.prop ? (openBlock(), createBlock(unref(TMagicTag), {
473
- key: 6,
474
- type: typeof __props.config.type === "function" ? __props.config.type(scope.row[__props.config.prop], scope.row) : __props.config.type,
475
- "close-transition": ""
427
+ type: "primary"
476
428
  }, {
477
429
  default: withCtx(() => [
478
430
  createTextVNode(
479
- toDisplayString(unref(formatter)(__props.config, scope.row, { index: scope.$index })),
431
+ toDisplayString(__props.config.buttonText || "扩展配置"),
480
432
  1
481
433
  /* TEXT */
482
434
  )
483
435
  ]),
484
- _: 2
485
- /* DYNAMIC */
486
- }, 1032, ["type"])) : (openBlock(), createElementBlock("div", {
487
- key: 7,
488
- innerHTML: unref(formatter)(__props.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
- }, 8, ["label", "width", "fixed", "sortable", "prop"]);
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 tMagicTable = ref();
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
- tMagicTable.value?.toggleRowSelection(row, selected);
589
+ tMagicTableRef.value?.toggleRowSelection(row, selected);
566
590
  };
567
591
  const toggleRowExpansion = (row, expanded) => {
568
- tMagicTable.value?.toggleRowExpansion(row, expanded);
592
+ tMagicTableRef.value?.toggleRowExpansion(row, expanded);
569
593
  };
570
594
  const clearSelection = () => {
571
- tMagicTable.value?.clearSelection();
595
+ tMagicTableRef.value?.clearSelection();
572
596
  };
573
597
  const objectSpanMethod = (data) => {
574
598
  if (typeof props.spanMethod === "function") {
@@ -587,11 +611,11 @@ 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
620
  "show-header": __props.showHeader,
597
621
  "max-height": __props.bodyHeight,
@@ -601,60 +625,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
601
625
  "tree-props": { children: "children" },
602
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
- default: withCtx(() => [
612
- (openBlock(true), createElementBlock(
613
- Fragment,
614
- null,
615
- renderList(__props.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: __props.columns,
633
- config: item,
634
- "rowkey-name": __props.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"])), [
635
+ }, null, 8, ["data", "show-header", "max-height", "default-expand-all", "border", "row-key", "empty-text", "columns"])), [
658
636
  [_directive_loading, __props.loading]
659
637
  ]);
660
638
  };