@tmagic/table 1.5.8 → 1.5.10
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 +32 -25
- package/dist/tmagic-table.umd.cjs +32 -25
- package/package.json +3 -3
- package/src/PopoverColumn.vue +3 -1
- package/src/TextColumn.vue +10 -5
- package/src/schema.ts +4 -2
- package/src/utils.ts +2 -2
- package/types/index.d.ts +9 -3
package/dist/tmagic-table.js
CHANGED
|
@@ -256,14 +256,14 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
256
256
|
}
|
|
257
257
|
});
|
|
258
258
|
|
|
259
|
-
const formatter = (item, row) => {
|
|
259
|
+
const formatter = (item, row, data) => {
|
|
260
260
|
if (!item.prop) return "";
|
|
261
261
|
if (item.formatter) {
|
|
262
262
|
if (item.formatter === "datetime") {
|
|
263
263
|
item.formatter = (value) => datetimeFormatter(value);
|
|
264
264
|
}
|
|
265
265
|
try {
|
|
266
|
-
return item.formatter(row[item.prop], row);
|
|
266
|
+
return item.formatter(row[item.prop], row, data);
|
|
267
267
|
} catch (e) {
|
|
268
268
|
return row[item.prop];
|
|
269
269
|
}
|
|
@@ -311,7 +311,7 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
311
311
|
{
|
|
312
312
|
default: withCtx(() => [
|
|
313
313
|
createTextVNode(
|
|
314
|
-
toDisplayString(_ctx.config.text || unref(formatter)(_ctx.config, scope.row)),
|
|
314
|
+
toDisplayString(_ctx.config.text || unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
315
315
|
1
|
|
316
316
|
/* TEXT */
|
|
317
317
|
)
|
|
@@ -346,11 +346,12 @@ const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
|
346
346
|
}
|
|
347
347
|
});
|
|
348
348
|
|
|
349
|
-
const _hoisted_1 =
|
|
350
|
-
const _hoisted_2 = ["
|
|
351
|
-
const _hoisted_3 = ["
|
|
352
|
-
const _hoisted_4 = ["
|
|
353
|
-
const _hoisted_5 = ["
|
|
349
|
+
const _hoisted_1 = { key: 0 };
|
|
350
|
+
const _hoisted_2 = ["innerHTML"];
|
|
351
|
+
const _hoisted_3 = ["href"];
|
|
352
|
+
const _hoisted_4 = ["src"];
|
|
353
|
+
const _hoisted_5 = ["href"];
|
|
354
|
+
const _hoisted_6 = ["innerHTML"];
|
|
354
355
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
355
356
|
...{
|
|
356
357
|
name: "MTableColumn"
|
|
@@ -373,8 +374,14 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
373
374
|
prop: _ctx.config.prop
|
|
374
375
|
}, {
|
|
375
376
|
default: withCtx((scope) => [
|
|
376
|
-
_ctx.config.type
|
|
377
|
-
|
|
377
|
+
_ctx.config.type === "index" ? (openBlock(), createElementBlock(
|
|
378
|
+
"div",
|
|
379
|
+
_hoisted_1,
|
|
380
|
+
toDisplayString(_ctx.config.pageIndex && _ctx.config.pageSize ? _ctx.config.pageIndex * _ctx.config.pageSize + scope.$index + 1 : scope.$index + 1),
|
|
381
|
+
1
|
|
382
|
+
/* TEXT */
|
|
383
|
+
)) : _ctx.config.type && _ctx.editState[scope.$index] ? (openBlock(), createBlock(unref(TMagicForm), {
|
|
384
|
+
key: 1,
|
|
378
385
|
"label-width": "0",
|
|
379
386
|
model: _ctx.editState[scope.$index]
|
|
380
387
|
}, {
|
|
@@ -390,36 +397,36 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
390
397
|
_: 2
|
|
391
398
|
/* DYNAMIC */
|
|
392
399
|
}, 1032, ["model"])) : _ctx.config.action === "actionLink" && _ctx.config.prop ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
393
|
-
key:
|
|
400
|
+
key: 2,
|
|
394
401
|
link: "",
|
|
395
402
|
type: "primary",
|
|
396
403
|
onClick: ($event) => _ctx.config.handler?.(scope.row)
|
|
397
404
|
}, {
|
|
398
405
|
default: withCtx(() => [
|
|
399
406
|
createElementVNode("span", {
|
|
400
|
-
innerHTML: unref(formatter)(_ctx.config, scope.row)
|
|
401
|
-
}, null, 8,
|
|
407
|
+
innerHTML: unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
408
|
+
}, null, 8, _hoisted_2)
|
|
402
409
|
]),
|
|
403
410
|
_: 2
|
|
404
411
|
/* DYNAMIC */
|
|
405
412
|
}, 1032, ["onClick"])) : _ctx.config.action === "img" && _ctx.config.prop ? (openBlock(), createElementBlock("a", {
|
|
406
|
-
key:
|
|
413
|
+
key: 3,
|
|
407
414
|
target: "_blank",
|
|
408
415
|
href: scope.row[_ctx.config.prop]
|
|
409
416
|
}, [
|
|
410
417
|
createElementVNode("img", {
|
|
411
418
|
src: scope.row[_ctx.config.prop],
|
|
412
419
|
height: "50"
|
|
413
|
-
}, null, 8,
|
|
414
|
-
], 8,
|
|
415
|
-
key:
|
|
420
|
+
}, null, 8, _hoisted_4)
|
|
421
|
+
], 8, _hoisted_3)) : _ctx.config.action === "link" && _ctx.config.prop ? (openBlock(), createElementBlock("a", {
|
|
422
|
+
key: 4,
|
|
416
423
|
target: "_blank",
|
|
417
424
|
href: scope.row[_ctx.config.prop],
|
|
418
425
|
class: "keep-all"
|
|
419
|
-
}, toDisplayString(scope.row[_ctx.config.prop]), 9,
|
|
426
|
+
}, toDisplayString(scope.row[_ctx.config.prop]), 9, _hoisted_5)) : _ctx.config.action === "tip" ? (openBlock(), createBlock(
|
|
420
427
|
_component_el_tooltip,
|
|
421
428
|
{
|
|
422
|
-
key:
|
|
429
|
+
key: 5,
|
|
423
430
|
placement: "left"
|
|
424
431
|
},
|
|
425
432
|
{
|
|
@@ -427,7 +434,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
427
434
|
createElementVNode(
|
|
428
435
|
"div",
|
|
429
436
|
null,
|
|
430
|
-
toDisplayString(unref(formatter)(_ctx.config, scope.row)),
|
|
437
|
+
toDisplayString(unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
431
438
|
1
|
|
432
439
|
/* TEXT */
|
|
433
440
|
)
|
|
@@ -454,13 +461,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
454
461
|
1024
|
|
455
462
|
/* DYNAMIC_SLOTS */
|
|
456
463
|
)) : _ctx.config.action === "tag" && _ctx.config.prop ? (openBlock(), createBlock(unref(TMagicTag), {
|
|
457
|
-
key:
|
|
464
|
+
key: 6,
|
|
458
465
|
type: typeof _ctx.config.type === "function" ? _ctx.config.type(scope.row[_ctx.config.prop], scope.row) : _ctx.config.type,
|
|
459
466
|
"close-transition": ""
|
|
460
467
|
}, {
|
|
461
468
|
default: withCtx(() => [
|
|
462
469
|
createTextVNode(
|
|
463
|
-
toDisplayString(unref(formatter)(_ctx.config, scope.row)),
|
|
470
|
+
toDisplayString(unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
464
471
|
1
|
|
465
472
|
/* TEXT */
|
|
466
473
|
)
|
|
@@ -468,9 +475,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
468
475
|
_: 2
|
|
469
476
|
/* DYNAMIC */
|
|
470
477
|
}, 1032, ["type"])) : (openBlock(), createElementBlock("div", {
|
|
471
|
-
key:
|
|
472
|
-
innerHTML: unref(formatter)(_ctx.config, scope.row)
|
|
473
|
-
}, null, 8,
|
|
478
|
+
key: 7,
|
|
479
|
+
innerHTML: unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
480
|
+
}, null, 8, _hoisted_6))
|
|
474
481
|
]),
|
|
475
482
|
_: 1
|
|
476
483
|
/* STABLE */
|
|
@@ -2511,14 +2511,14 @@
|
|
|
2511
2511
|
}
|
|
2512
2512
|
});
|
|
2513
2513
|
|
|
2514
|
-
const formatter = (item, row) => {
|
|
2514
|
+
const formatter = (item, row, data) => {
|
|
2515
2515
|
if (!item.prop) return "";
|
|
2516
2516
|
if (item.formatter) {
|
|
2517
2517
|
if (item.formatter === "datetime") {
|
|
2518
2518
|
item.formatter = (value) => form.datetimeFormatter(value);
|
|
2519
2519
|
}
|
|
2520
2520
|
try {
|
|
2521
|
-
return item.formatter(row[item.prop], row);
|
|
2521
|
+
return item.formatter(row[item.prop], row, data);
|
|
2522
2522
|
} catch (e) {
|
|
2523
2523
|
return row[item.prop];
|
|
2524
2524
|
}
|
|
@@ -2566,7 +2566,7 @@
|
|
|
2566
2566
|
{
|
|
2567
2567
|
default: vue.withCtx(() => [
|
|
2568
2568
|
vue.createTextVNode(
|
|
2569
|
-
vue.toDisplayString(_ctx.config.text || vue.unref(formatter)(_ctx.config, scope.row)),
|
|
2569
|
+
vue.toDisplayString(_ctx.config.text || vue.unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
2570
2570
|
1
|
|
2571
2571
|
/* TEXT */
|
|
2572
2572
|
)
|
|
@@ -2601,11 +2601,12 @@
|
|
|
2601
2601
|
}
|
|
2602
2602
|
});
|
|
2603
2603
|
|
|
2604
|
-
const _hoisted_1 =
|
|
2605
|
-
const _hoisted_2 = ["
|
|
2606
|
-
const _hoisted_3 = ["
|
|
2607
|
-
const _hoisted_4 = ["
|
|
2608
|
-
const _hoisted_5 = ["
|
|
2604
|
+
const _hoisted_1 = { key: 0 };
|
|
2605
|
+
const _hoisted_2 = ["innerHTML"];
|
|
2606
|
+
const _hoisted_3 = ["href"];
|
|
2607
|
+
const _hoisted_4 = ["src"];
|
|
2608
|
+
const _hoisted_5 = ["href"];
|
|
2609
|
+
const _hoisted_6 = ["innerHTML"];
|
|
2609
2610
|
const _sfc_main$1 = /* @__PURE__ */ vue.defineComponent({
|
|
2610
2611
|
...{
|
|
2611
2612
|
name: "MTableColumn"
|
|
@@ -2628,8 +2629,14 @@
|
|
|
2628
2629
|
prop: _ctx.config.prop
|
|
2629
2630
|
}, {
|
|
2630
2631
|
default: vue.withCtx((scope) => [
|
|
2631
|
-
_ctx.config.type
|
|
2632
|
-
|
|
2632
|
+
_ctx.config.type === "index" ? (vue.openBlock(), vue.createElementBlock(
|
|
2633
|
+
"div",
|
|
2634
|
+
_hoisted_1,
|
|
2635
|
+
vue.toDisplayString(_ctx.config.pageIndex && _ctx.config.pageSize ? _ctx.config.pageIndex * _ctx.config.pageSize + scope.$index + 1 : scope.$index + 1),
|
|
2636
|
+
1
|
|
2637
|
+
/* TEXT */
|
|
2638
|
+
)) : _ctx.config.type && _ctx.editState[scope.$index] ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicForm), {
|
|
2639
|
+
key: 1,
|
|
2633
2640
|
"label-width": "0",
|
|
2634
2641
|
model: _ctx.editState[scope.$index]
|
|
2635
2642
|
}, {
|
|
@@ -2645,36 +2652,36 @@
|
|
|
2645
2652
|
_: 2
|
|
2646
2653
|
/* DYNAMIC */
|
|
2647
2654
|
}, 1032, ["model"])) : _ctx.config.action === "actionLink" && _ctx.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
2648
|
-
key:
|
|
2655
|
+
key: 2,
|
|
2649
2656
|
link: "",
|
|
2650
2657
|
type: "primary",
|
|
2651
2658
|
onClick: ($event) => _ctx.config.handler?.(scope.row)
|
|
2652
2659
|
}, {
|
|
2653
2660
|
default: vue.withCtx(() => [
|
|
2654
2661
|
vue.createElementVNode("span", {
|
|
2655
|
-
innerHTML: vue.unref(formatter)(_ctx.config, scope.row)
|
|
2656
|
-
}, null, 8,
|
|
2662
|
+
innerHTML: vue.unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
2663
|
+
}, null, 8, _hoisted_2)
|
|
2657
2664
|
]),
|
|
2658
2665
|
_: 2
|
|
2659
2666
|
/* DYNAMIC */
|
|
2660
2667
|
}, 1032, ["onClick"])) : _ctx.config.action === "img" && _ctx.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
|
|
2661
|
-
key:
|
|
2668
|
+
key: 3,
|
|
2662
2669
|
target: "_blank",
|
|
2663
2670
|
href: scope.row[_ctx.config.prop]
|
|
2664
2671
|
}, [
|
|
2665
2672
|
vue.createElementVNode("img", {
|
|
2666
2673
|
src: scope.row[_ctx.config.prop],
|
|
2667
2674
|
height: "50"
|
|
2668
|
-
}, null, 8,
|
|
2669
|
-
], 8,
|
|
2670
|
-
key:
|
|
2675
|
+
}, null, 8, _hoisted_4)
|
|
2676
|
+
], 8, _hoisted_3)) : _ctx.config.action === "link" && _ctx.config.prop ? (vue.openBlock(), vue.createElementBlock("a", {
|
|
2677
|
+
key: 4,
|
|
2671
2678
|
target: "_blank",
|
|
2672
2679
|
href: scope.row[_ctx.config.prop],
|
|
2673
2680
|
class: "keep-all"
|
|
2674
|
-
}, vue.toDisplayString(scope.row[_ctx.config.prop]), 9,
|
|
2681
|
+
}, vue.toDisplayString(scope.row[_ctx.config.prop]), 9, _hoisted_5)) : _ctx.config.action === "tip" ? (vue.openBlock(), vue.createBlock(
|
|
2675
2682
|
_component_el_tooltip,
|
|
2676
2683
|
{
|
|
2677
|
-
key:
|
|
2684
|
+
key: 5,
|
|
2678
2685
|
placement: "left"
|
|
2679
2686
|
},
|
|
2680
2687
|
{
|
|
@@ -2682,7 +2689,7 @@
|
|
|
2682
2689
|
vue.createElementVNode(
|
|
2683
2690
|
"div",
|
|
2684
2691
|
null,
|
|
2685
|
-
vue.toDisplayString(vue.unref(formatter)(_ctx.config, scope.row)),
|
|
2692
|
+
vue.toDisplayString(vue.unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
2686
2693
|
1
|
|
2687
2694
|
/* TEXT */
|
|
2688
2695
|
)
|
|
@@ -2709,13 +2716,13 @@
|
|
|
2709
2716
|
1024
|
|
2710
2717
|
/* DYNAMIC_SLOTS */
|
|
2711
2718
|
)) : _ctx.config.action === "tag" && _ctx.config.prop ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicTag), {
|
|
2712
|
-
key:
|
|
2719
|
+
key: 6,
|
|
2713
2720
|
type: typeof _ctx.config.type === "function" ? _ctx.config.type(scope.row[_ctx.config.prop], scope.row) : _ctx.config.type,
|
|
2714
2721
|
"close-transition": ""
|
|
2715
2722
|
}, {
|
|
2716
2723
|
default: vue.withCtx(() => [
|
|
2717
2724
|
vue.createTextVNode(
|
|
2718
|
-
vue.toDisplayString(vue.unref(formatter)(_ctx.config, scope.row)),
|
|
2725
|
+
vue.toDisplayString(vue.unref(formatter)(_ctx.config, scope.row, { index: scope.$index })),
|
|
2719
2726
|
1
|
|
2720
2727
|
/* TEXT */
|
|
2721
2728
|
)
|
|
@@ -2723,9 +2730,9 @@
|
|
|
2723
2730
|
_: 2
|
|
2724
2731
|
/* DYNAMIC */
|
|
2725
2732
|
}, 1032, ["type"])) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
2726
|
-
key:
|
|
2727
|
-
innerHTML: vue.unref(formatter)(_ctx.config, scope.row)
|
|
2728
|
-
}, null, 8,
|
|
2733
|
+
key: 7,
|
|
2734
|
+
innerHTML: vue.unref(formatter)(_ctx.config, scope.row, { index: scope.$index })
|
|
2735
|
+
}, null, 8, _hoisted_6))
|
|
2729
2736
|
]),
|
|
2730
2737
|
_: 1
|
|
2731
2738
|
/* STABLE */
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.5.
|
|
2
|
+
"version": "1.5.10",
|
|
3
3
|
"name": "@tmagic/table",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vue": ">=3.5.0",
|
|
46
46
|
"typescript": "*",
|
|
47
|
-
"@tmagic/design": "1.5.
|
|
48
|
-
"@tmagic/form": "1.5.
|
|
47
|
+
"@tmagic/design": "1.5.10",
|
|
48
|
+
"@tmagic/form": "1.5.10"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"typescript": {
|
package/src/PopoverColumn.vue
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
:data="(config.prop && scope.row[config.prop]) || []"
|
|
17
17
|
></MTable>
|
|
18
18
|
<template #reference>
|
|
19
|
-
<TMagicButton link type="primary">
|
|
19
|
+
<TMagicButton link type="primary">
|
|
20
|
+
{{ config.text || formatter(config, scope.row, { index: scope.$index }) }}</TMagicButton
|
|
21
|
+
>
|
|
20
22
|
</template>
|
|
21
23
|
</TMagicPopover>
|
|
22
24
|
</template>
|
package/src/TextColumn.vue
CHANGED
|
@@ -8,7 +8,12 @@
|
|
|
8
8
|
:prop="config.prop"
|
|
9
9
|
>
|
|
10
10
|
<template v-slot="scope">
|
|
11
|
-
<
|
|
11
|
+
<div v-if="config.type === 'index'">
|
|
12
|
+
{{
|
|
13
|
+
config.pageIndex && config.pageSize ? config.pageIndex * config.pageSize + scope.$index + 1 : scope.$index + 1
|
|
14
|
+
}}
|
|
15
|
+
</div>
|
|
16
|
+
<TMagicForm v-else-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
|
|
12
17
|
<m-form-container
|
|
13
18
|
:prop="config.prop"
|
|
14
19
|
:rules="config.rules"
|
|
@@ -24,7 +29,7 @@
|
|
|
24
29
|
type="primary"
|
|
25
30
|
@click="config.handler?.(scope.row)"
|
|
26
31
|
>
|
|
27
|
-
<span v-html="formatter(config, scope.row)"></span>
|
|
32
|
+
<span v-html="formatter(config, scope.row, { index: scope.$index })"></span>
|
|
28
33
|
</TMagicButton>
|
|
29
34
|
|
|
30
35
|
<a v-else-if="config.action === 'img' && config.prop" target="_blank" :href="scope.row[config.prop]"
|
|
@@ -41,7 +46,7 @@
|
|
|
41
46
|
|
|
42
47
|
<el-tooltip v-else-if="config.action === 'tip'" placement="left">
|
|
43
48
|
<template #content>
|
|
44
|
-
<div>{{ formatter(config, scope.row) }}</div>
|
|
49
|
+
<div>{{ formatter(config, scope.row, { index: scope.$index }) }}</div>
|
|
45
50
|
</template>
|
|
46
51
|
<TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
|
|
47
52
|
</el-tooltip>
|
|
@@ -50,9 +55,9 @@
|
|
|
50
55
|
v-else-if="config.action === 'tag' && config.prop"
|
|
51
56
|
:type="typeof config.type === 'function' ? config.type(scope.row[config.prop], scope.row) : config.type"
|
|
52
57
|
close-transition
|
|
53
|
-
>{{ formatter(config, scope.row) }}</TMagicTag
|
|
58
|
+
>{{ formatter(config, scope.row, { index: scope.$index }) }}</TMagicTag
|
|
54
59
|
>
|
|
55
|
-
<div v-else v-html="formatter(config, scope.row)"></div>
|
|
60
|
+
<div v-else v-html="formatter(config, scope.row, { index: scope.$index })"></div>
|
|
56
61
|
</template>
|
|
57
62
|
</TMagicTableColumn>
|
|
58
63
|
</template>
|
package/src/schema.ts
CHANGED
|
@@ -34,6 +34,8 @@ export interface ColumnActionConfig {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export interface ColumnConfig<T = any> {
|
|
37
|
+
pageIndex?: number;
|
|
38
|
+
pageSize?: number;
|
|
37
39
|
form?: FormConfig;
|
|
38
40
|
rules?: any;
|
|
39
41
|
values?: FormValue;
|
|
@@ -43,13 +45,13 @@ export interface ColumnConfig<T = any> {
|
|
|
43
45
|
fixed?: 'left' | 'right' | boolean;
|
|
44
46
|
width?: number | string;
|
|
45
47
|
actions?: ColumnActionConfig[];
|
|
46
|
-
type?: 'popover' | 'expand' | 'component' | string | ((value: any, row: T) => string);
|
|
48
|
+
type?: 'popover' | 'expand' | 'component' | 'index' | string | ((value: any, row: T) => string);
|
|
47
49
|
text?: string;
|
|
48
50
|
prop?: string;
|
|
49
51
|
name?: string;
|
|
50
52
|
showHeader?: boolean;
|
|
51
53
|
table?: ColumnConfig[];
|
|
52
|
-
formatter?: 'datetime' | ((item: any, row: T) => any);
|
|
54
|
+
formatter?: 'datetime' | ((item: any, row: T, data: { index: number }) => any);
|
|
53
55
|
popover?: {
|
|
54
56
|
placement?:
|
|
55
57
|
| 'auto'
|
package/src/utils.ts
CHANGED
|
@@ -20,7 +20,7 @@ import { datetimeFormatter } from '@tmagic/form';
|
|
|
20
20
|
|
|
21
21
|
import type { ColumnConfig } from './schema';
|
|
22
22
|
|
|
23
|
-
export const formatter = (item: ColumnConfig, row: any) => {
|
|
23
|
+
export const formatter = (item: ColumnConfig, row: any, data: { index: number }) => {
|
|
24
24
|
if (!item.prop) return '';
|
|
25
25
|
|
|
26
26
|
if (item.formatter) {
|
|
@@ -29,7 +29,7 @@ export const formatter = (item: ColumnConfig, row: any) => {
|
|
|
29
29
|
item.formatter = (value: string) => datetimeFormatter(value);
|
|
30
30
|
}
|
|
31
31
|
try {
|
|
32
|
-
return item.formatter(row[item.prop], row);
|
|
32
|
+
return item.formatter(row[item.prop], row, data);
|
|
33
33
|
} catch (e) {
|
|
34
34
|
return row[item.prop];
|
|
35
35
|
}
|
package/types/index.d.ts
CHANGED
|
@@ -21,6 +21,8 @@ interface ColumnActionConfig {
|
|
|
21
21
|
}) => Promise<void> | void;
|
|
22
22
|
}
|
|
23
23
|
interface ColumnConfig<T = any> {
|
|
24
|
+
pageIndex?: number;
|
|
25
|
+
pageSize?: number;
|
|
24
26
|
form?: FormConfig;
|
|
25
27
|
rules?: any;
|
|
26
28
|
values?: FormValue;
|
|
@@ -30,13 +32,15 @@ interface ColumnConfig<T = any> {
|
|
|
30
32
|
fixed?: 'left' | 'right' | boolean;
|
|
31
33
|
width?: number | string;
|
|
32
34
|
actions?: ColumnActionConfig[];
|
|
33
|
-
type?: 'popover' | 'expand' | 'component' | string | ((value: any, row: T) => string);
|
|
35
|
+
type?: 'popover' | 'expand' | 'component' | 'index' | string | ((value: any, row: T) => string);
|
|
34
36
|
text?: string;
|
|
35
37
|
prop?: string;
|
|
36
38
|
name?: string;
|
|
37
39
|
showHeader?: boolean;
|
|
38
40
|
table?: ColumnConfig[];
|
|
39
|
-
formatter?: 'datetime' | ((item: any, row: T
|
|
41
|
+
formatter?: 'datetime' | ((item: any, row: T, data: {
|
|
42
|
+
index: number;
|
|
43
|
+
}) => any);
|
|
40
44
|
popover?: {
|
|
41
45
|
placement?: 'auto' | 'auto-start' | 'auto-end' | 'left' | 'right' | 'top' | 'bottom' | 'top-start' | 'top-end' | 'bottom-start' | 'bottom-end' | 'right-start' | 'right-end' | 'left-start' | 'left-end';
|
|
42
46
|
width?: string | number;
|
|
@@ -196,7 +200,9 @@ declare const _default$1: vue.DefineComponent<__VLS_Props, {
|
|
|
196
200
|
}) | null;
|
|
197
201
|
}, any>;
|
|
198
202
|
|
|
199
|
-
declare const formatter: (item: ColumnConfig, row: any
|
|
203
|
+
declare const formatter: (item: ColumnConfig, row: any, data: {
|
|
204
|
+
index: number;
|
|
205
|
+
}) => any;
|
|
200
206
|
declare const createColumns: (columns: ColumnConfig[]) => ColumnConfig<any>[];
|
|
201
207
|
|
|
202
208
|
declare const _default: {
|