@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.
- package/dist/tmagic-table.js +304 -326
- package/dist/tmagic-table.umd.cjs +302 -324
- package/package.json +3 -3
- 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 +3 -2
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.
|
|
2
|
+
"version": "1.7.0-beta.0",
|
|
3
3
|
"name": "@tmagic/table",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"peerDependencies": {
|
|
45
45
|
"vue": "^3.5.22",
|
|
46
46
|
"typescript": "^5.9.3",
|
|
47
|
-
"@tmagic/design": "1.
|
|
48
|
-
"@tmagic/form": "1.
|
|
47
|
+
"@tmagic/design": "1.7.0-beta.0",
|
|
48
|
+
"@tmagic/form": "1.7.0-beta.0"
|
|
49
49
|
},
|
|
50
50
|
"peerDependenciesMeta": {
|
|
51
51
|
"typescript": {
|
package/src/ActionsColumn.vue
CHANGED
|
@@ -1,48 +1,46 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
</template>
|
|
41
|
-
</TMagicTableColumn>
|
|
2
|
+
<TMagicTooltip
|
|
3
|
+
v-for="(action, actionIndex) in config.actions"
|
|
4
|
+
:placement="action.tooltipPlacement || 'top'"
|
|
5
|
+
:key="actionIndex"
|
|
6
|
+
:disabled="!Boolean(action.tooltip)"
|
|
7
|
+
:content="action.tooltip"
|
|
8
|
+
>
|
|
9
|
+
<TMagicButton
|
|
10
|
+
v-show="display(action.display, row) && !editState[index]"
|
|
11
|
+
class="action-btn"
|
|
12
|
+
link
|
|
13
|
+
size="small"
|
|
14
|
+
:type="action.buttonType || 'primary'"
|
|
15
|
+
:icon="action.icon"
|
|
16
|
+
:disabled="disabled(action.disabled, row)"
|
|
17
|
+
@click="actionHandler(action, row, index)"
|
|
18
|
+
><span v-html="formatter(action.text, row)"></span
|
|
19
|
+
></TMagicButton>
|
|
20
|
+
</TMagicTooltip>
|
|
21
|
+
|
|
22
|
+
<TMagicButton
|
|
23
|
+
class="action-btn"
|
|
24
|
+
v-show="editState[index]"
|
|
25
|
+
link
|
|
26
|
+
type="primary"
|
|
27
|
+
size="small"
|
|
28
|
+
@click="save(index, config)"
|
|
29
|
+
>保存</TMagicButton
|
|
30
|
+
>
|
|
31
|
+
<TMagicButton
|
|
32
|
+
class="action-btn"
|
|
33
|
+
v-show="editState[index]"
|
|
34
|
+
link
|
|
35
|
+
type="primary"
|
|
36
|
+
size="small"
|
|
37
|
+
@click="editState[index] = undefined"
|
|
38
|
+
>取消</TMagicButton
|
|
39
|
+
>
|
|
42
40
|
</template>
|
|
43
41
|
|
|
44
42
|
<script lang="ts" setup>
|
|
45
|
-
import { TMagicButton, tMagicMessage,
|
|
43
|
+
import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
|
|
46
44
|
|
|
47
45
|
import { ColumnActionConfig, ColumnConfig } from './schema';
|
|
48
46
|
|
|
@@ -52,10 +50,12 @@ defineOptions({
|
|
|
52
50
|
|
|
53
51
|
const props = withDefaults(
|
|
54
52
|
defineProps<{
|
|
55
|
-
columns:
|
|
53
|
+
columns: ColumnConfig[];
|
|
56
54
|
config: ColumnConfig;
|
|
57
55
|
rowkeyName?: string;
|
|
58
56
|
editState?: any;
|
|
57
|
+
row: any;
|
|
58
|
+
index: number;
|
|
59
59
|
}>(),
|
|
60
60
|
{
|
|
61
61
|
columns: () => [],
|
|
@@ -71,9 +71,22 @@ const display = (fuc: boolean | Function | undefined, row: any) => {
|
|
|
71
71
|
if (typeof fuc === 'function') {
|
|
72
72
|
return fuc(row);
|
|
73
73
|
}
|
|
74
|
+
if (typeof fuc === 'boolean') {
|
|
75
|
+
return fuc;
|
|
76
|
+
}
|
|
74
77
|
return true;
|
|
75
78
|
};
|
|
76
79
|
|
|
80
|
+
const disabled = (fuc: boolean | Function | undefined, row: any) => {
|
|
81
|
+
if (typeof fuc === 'function') {
|
|
82
|
+
return fuc(row);
|
|
83
|
+
}
|
|
84
|
+
if (typeof fuc === 'boolean') {
|
|
85
|
+
return fuc;
|
|
86
|
+
}
|
|
87
|
+
return false;
|
|
88
|
+
};
|
|
89
|
+
|
|
77
90
|
const formatter = (fuc: string | Function | undefined, row: any) => {
|
|
78
91
|
if (typeof fuc === 'function') {
|
|
79
92
|
return fuc(row);
|
|
@@ -100,7 +113,9 @@ const save = async (index: number, config: ColumnConfig) => {
|
|
|
100
113
|
props.columns
|
|
101
114
|
.filter((item) => item.type)
|
|
102
115
|
.forEach((column) => {
|
|
103
|
-
|
|
116
|
+
if (column.prop) {
|
|
117
|
+
data[column.prop] = row[column.prop];
|
|
118
|
+
}
|
|
104
119
|
});
|
|
105
120
|
|
|
106
121
|
const res: any = await action({
|
package/src/ComponentColumn.vue
CHANGED
|
@@ -1,25 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:sortable="config.sortable"
|
|
8
|
-
:prop="config.prop"
|
|
9
|
-
>
|
|
10
|
-
<template v-slot="scope">
|
|
11
|
-
<component
|
|
12
|
-
:is="config.component"
|
|
13
|
-
v-bind="componentProps(scope.row, scope.$index)"
|
|
14
|
-
v-on="componentListeners(scope.row, scope.$index)"
|
|
15
|
-
></component>
|
|
16
|
-
</template>
|
|
17
|
-
</TMagicTableColumn>
|
|
2
|
+
<component
|
|
3
|
+
:is="config.component"
|
|
4
|
+
v-bind="componentProps(row, index)"
|
|
5
|
+
v-on="componentListeners(row, index)"
|
|
6
|
+
></component>
|
|
18
7
|
</template>
|
|
19
8
|
|
|
20
9
|
<script lang="ts" setup>
|
|
21
|
-
import { TMagicTableColumn } from '@tmagic/design';
|
|
22
|
-
|
|
23
10
|
import { ColumnConfig } from './schema';
|
|
24
11
|
|
|
25
12
|
defineOptions({
|
|
@@ -29,6 +16,8 @@ defineOptions({
|
|
|
29
16
|
const props = withDefaults(
|
|
30
17
|
defineProps<{
|
|
31
18
|
config: ColumnConfig;
|
|
19
|
+
row: any;
|
|
20
|
+
index: number;
|
|
32
21
|
}>(),
|
|
33
22
|
{
|
|
34
23
|
config: () => ({}),
|
package/src/ExpandColumn.vue
CHANGED
|
@@ -1,26 +1,20 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
></MForm>
|
|
16
|
-
<div v-if="config.expandContent" v-html="config.expandContent(scope.row, config.prop)"></div>
|
|
17
|
-
<component v-if="config.component" :is="config.component" v-bind="componentProps(scope.row)"></component>
|
|
18
|
-
</template>
|
|
19
|
-
</TMagicTableColumn>
|
|
2
|
+
<MTable
|
|
3
|
+
v-if="config.table"
|
|
4
|
+
:show-header="false"
|
|
5
|
+
:columns="config.table"
|
|
6
|
+
:data="(config.prop && row[config.prop]) || []"
|
|
7
|
+
></MTable>
|
|
8
|
+
<MForm
|
|
9
|
+
v-if="config.form"
|
|
10
|
+
:config="config.form"
|
|
11
|
+
:init-values="config.values || (config.prop && row[config.prop]) || {}"
|
|
12
|
+
></MForm>
|
|
13
|
+
<div v-if="config.expandContent" v-html="config.expandContent(row, config.prop)"></div>
|
|
14
|
+
<component v-if="config.component" :is="config.component" v-bind="componentProps(row)"></component>
|
|
20
15
|
</template>
|
|
21
16
|
|
|
22
17
|
<script lang="ts" setup>
|
|
23
|
-
import { TMagicTableColumn } from '@tmagic/design';
|
|
24
18
|
import { MForm } from '@tmagic/form';
|
|
25
19
|
|
|
26
20
|
import { ColumnConfig } from './schema';
|
|
@@ -33,6 +27,7 @@ defineOptions({
|
|
|
33
27
|
const props = withDefaults(
|
|
34
28
|
defineProps<{
|
|
35
29
|
config: ColumnConfig;
|
|
30
|
+
row: any;
|
|
36
31
|
}>(),
|
|
37
32
|
{
|
|
38
33
|
config: () => ({}),
|
package/src/PopoverColumn.vue
CHANGED
|
@@ -1,32 +1,25 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
></MTable>
|
|
18
|
-
<template #reference>
|
|
19
|
-
<TMagicButton link type="primary">
|
|
20
|
-
{{ config.text || formatter(config, scope.row, { index: scope.$index }) }}</TMagicButton
|
|
21
|
-
>
|
|
22
|
-
</template>
|
|
23
|
-
</TMagicPopover>
|
|
2
|
+
<TMagicPopover
|
|
3
|
+
v-if="config.popover"
|
|
4
|
+
:placement="config.popover.placement"
|
|
5
|
+
:width="config.popover.width"
|
|
6
|
+
:trigger="config.popover.trigger"
|
|
7
|
+
:destroy-on-close="config.popover.destroyOnClose ?? true"
|
|
8
|
+
>
|
|
9
|
+
<MTable
|
|
10
|
+
v-if="config.popover.tableEmbed"
|
|
11
|
+
:show-header="config.showHeader"
|
|
12
|
+
:columns="config.table"
|
|
13
|
+
:data="(config.prop && row[config.prop]) || []"
|
|
14
|
+
></MTable>
|
|
15
|
+
<template #reference>
|
|
16
|
+
<TMagicButton link type="primary">{{ config.text || formatter(config, row, { index: index }) }}</TMagicButton>
|
|
24
17
|
</template>
|
|
25
|
-
</
|
|
18
|
+
</TMagicPopover>
|
|
26
19
|
</template>
|
|
27
20
|
|
|
28
21
|
<script lang="ts" setup>
|
|
29
|
-
import { TMagicButton, TMagicPopover
|
|
22
|
+
import { TMagicButton, TMagicPopover } from '@tmagic/design';
|
|
30
23
|
|
|
31
24
|
import { ColumnConfig } from './schema';
|
|
32
25
|
import MTable from './Table.vue';
|
|
@@ -39,6 +32,8 @@ defineOptions({
|
|
|
39
32
|
withDefaults(
|
|
40
33
|
defineProps<{
|
|
41
34
|
config: ColumnConfig;
|
|
35
|
+
row: any;
|
|
36
|
+
index: number;
|
|
42
37
|
}>(),
|
|
43
38
|
{
|
|
44
39
|
config: () => ({}),
|
package/src/Table.vue
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<TMagicTable
|
|
3
|
-
|
|
4
|
-
:tooltip-options="{ popperOptions: { strategy: 'absolute' } }"
|
|
3
|
+
v-loading="loading"
|
|
5
4
|
class="m-table"
|
|
6
5
|
ref="tMagicTable"
|
|
7
|
-
|
|
6
|
+
:show-overflow-tooltip="true"
|
|
7
|
+
tooltip-effect="dark"
|
|
8
|
+
:tooltip-options="{ popperOptions: { strategy: 'absolute' } }"
|
|
8
9
|
:data="tableData"
|
|
9
10
|
:show-header="showHeader"
|
|
10
11
|
:max-height="bodyHeight"
|
|
@@ -14,59 +15,21 @@
|
|
|
14
15
|
:tree-props="{ children: 'children' }"
|
|
15
16
|
:empty-text="emptyText || '暂无数据'"
|
|
16
17
|
:span-method="objectSpanMethod"
|
|
18
|
+
:columns="tableColumns"
|
|
17
19
|
@sort-change="sortChange"
|
|
18
20
|
@select="selectHandler"
|
|
19
21
|
@select-all="selectAllHandler"
|
|
20
22
|
@selection-change="selectionChangeHandler"
|
|
21
23
|
@cell-click="cellClickHandler"
|
|
22
24
|
@expand-change="expandChange"
|
|
23
|
-
>
|
|
24
|
-
<template v-for="(item, columnIndex) in columns">
|
|
25
|
-
<template v-if="item.type === 'expand'">
|
|
26
|
-
<ExpandColumn :config="item" :key="columnIndex"></ExpandColumn>
|
|
27
|
-
</template>
|
|
28
|
-
|
|
29
|
-
<template v-else-if="item.type === 'component'">
|
|
30
|
-
<ComponentColumn :config="item" :key="columnIndex"></ComponentColumn>
|
|
31
|
-
</template>
|
|
32
|
-
|
|
33
|
-
<template v-else-if="item.selection">
|
|
34
|
-
<component
|
|
35
|
-
width="40"
|
|
36
|
-
type="selection"
|
|
37
|
-
:is="tableColumnComponent?.component || 'el-table-column'"
|
|
38
|
-
:key="columnIndex"
|
|
39
|
-
:selectable="item.selectable"
|
|
40
|
-
></component>
|
|
41
|
-
</template>
|
|
42
|
-
|
|
43
|
-
<template v-else-if="item.actions">
|
|
44
|
-
<ActionsColumn
|
|
45
|
-
:columns="columns"
|
|
46
|
-
:config="item"
|
|
47
|
-
:rowkey-name="rowkeyName"
|
|
48
|
-
:edit-state="editState"
|
|
49
|
-
:key="columnIndex"
|
|
50
|
-
@after-action="$emit('after-action')"
|
|
51
|
-
></ActionsColumn>
|
|
52
|
-
</template>
|
|
53
|
-
|
|
54
|
-
<template v-else-if="item.type === 'popover'">
|
|
55
|
-
<PopoverColumn :key="columnIndex" :config="item"></PopoverColumn>
|
|
56
|
-
</template>
|
|
57
|
-
|
|
58
|
-
<template v-else>
|
|
59
|
-
<TextColumn :key="columnIndex" :config="item" :edit-state="editState"></TextColumn>
|
|
60
|
-
</template>
|
|
61
|
-
</template>
|
|
62
|
-
</TMagicTable>
|
|
25
|
+
></TMagicTable>
|
|
63
26
|
</template>
|
|
64
27
|
|
|
65
28
|
<script lang="ts" setup>
|
|
66
|
-
import { computed, ref } from 'vue';
|
|
29
|
+
import { computed, h, ref, useTemplateRef } from 'vue';
|
|
67
30
|
import { cloneDeep } from 'lodash-es';
|
|
68
31
|
|
|
69
|
-
import {
|
|
32
|
+
import { TMagicTable } from '@tmagic/design';
|
|
70
33
|
|
|
71
34
|
import ActionsColumn from './ActionsColumn.vue';
|
|
72
35
|
import ComponentColumn from './ComponentColumn.vue';
|
|
@@ -117,11 +80,72 @@ const emit = defineEmits([
|
|
|
117
80
|
'cell-click',
|
|
118
81
|
]);
|
|
119
82
|
|
|
120
|
-
const
|
|
83
|
+
const cellRender = (config: ColumnConfig, { row = {}, $index }: any) => {
|
|
84
|
+
if (config.type === 'expand') {
|
|
85
|
+
return h(ExpandColumn, {
|
|
86
|
+
config,
|
|
87
|
+
row,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
if (config.type === 'component') {
|
|
91
|
+
return h(ComponentColumn, {
|
|
92
|
+
config,
|
|
93
|
+
row,
|
|
94
|
+
index: $index,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
if (config.actions) {
|
|
98
|
+
return h(ActionsColumn, {
|
|
99
|
+
config,
|
|
100
|
+
row,
|
|
101
|
+
index: $index,
|
|
102
|
+
rowkeyName: props.rowkeyName,
|
|
103
|
+
editState: editState.value,
|
|
104
|
+
columns: props.columns,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
if (config.type === 'popover') {
|
|
108
|
+
return h(PopoverColumn, {
|
|
109
|
+
config,
|
|
110
|
+
row,
|
|
111
|
+
index: $index,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return h(TextColumn, {
|
|
115
|
+
config,
|
|
116
|
+
row,
|
|
117
|
+
index: $index,
|
|
118
|
+
editState: editState.value,
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
const tableColumns = computed(() =>
|
|
123
|
+
props.columns.map((item) => {
|
|
124
|
+
let type: 'default' | 'selection' | 'index' | 'expand' = 'default';
|
|
125
|
+
if (item.type === 'expand') {
|
|
126
|
+
type = 'expand';
|
|
127
|
+
} else if (item.selection) {
|
|
128
|
+
type = 'selection';
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
props: {
|
|
133
|
+
label: item.label,
|
|
134
|
+
fixed: item.fixed,
|
|
135
|
+
width: item.width ?? (item.selection ? 40 : undefined),
|
|
136
|
+
prop: item.prop,
|
|
137
|
+
type,
|
|
138
|
+
selectable: item.selectable,
|
|
139
|
+
},
|
|
140
|
+
cell: type === 'selection' ? undefined : ({ row, $index }: any) => cellRender(item, { row, $index }),
|
|
141
|
+
};
|
|
142
|
+
}),
|
|
143
|
+
);
|
|
144
|
+
|
|
145
|
+
const tMagicTableRef = useTemplateRef('tMagicTable');
|
|
121
146
|
|
|
122
147
|
const editState = ref([]);
|
|
123
148
|
|
|
124
|
-
const tableColumnComponent = getDesignConfig('components')?.tableColumn;
|
|
125
149
|
const selectionColumn = computed(() => {
|
|
126
150
|
const column = props.columns.filter((item) => item.selection);
|
|
127
151
|
return column.length ? column[0] : null;
|
|
@@ -171,15 +195,15 @@ const expandChange = (...args: any[]) => {
|
|
|
171
195
|
};
|
|
172
196
|
|
|
173
197
|
const toggleRowSelection = (row: any, selected: boolean) => {
|
|
174
|
-
|
|
198
|
+
tMagicTableRef.value?.toggleRowSelection(row, selected);
|
|
175
199
|
};
|
|
176
200
|
|
|
177
201
|
const toggleRowExpansion = (row: any, expanded: boolean) => {
|
|
178
|
-
|
|
202
|
+
tMagicTableRef.value?.toggleRowExpansion(row, expanded);
|
|
179
203
|
};
|
|
180
204
|
|
|
181
205
|
const clearSelection = () => {
|
|
182
|
-
|
|
206
|
+
tMagicTableRef.value?.clearSelection();
|
|
183
207
|
};
|
|
184
208
|
|
|
185
209
|
const objectSpanMethod = (data: any) => {
|
package/src/TextColumn.vue
CHANGED
|
@@ -1,69 +1,52 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}}
|
|
15
|
-
</div>
|
|
16
|
-
<TMagicForm v-else-if="config.type && editState[scope.$index]" label-width="0" :model="editState[scope.$index]">
|
|
17
|
-
<m-form-container
|
|
18
|
-
:prop="config.prop"
|
|
19
|
-
:rules="config.rules"
|
|
20
|
-
:config="config"
|
|
21
|
-
:name="config.prop"
|
|
22
|
-
:model="editState[scope.$index]"
|
|
23
|
-
></m-form-container>
|
|
24
|
-
</TMagicForm>
|
|
25
|
-
|
|
26
|
-
<TMagicButton
|
|
27
|
-
v-else-if="config.action === 'actionLink' && config.prop"
|
|
28
|
-
link
|
|
29
|
-
type="primary"
|
|
30
|
-
@click="config.handler?.(scope.row)"
|
|
31
|
-
>
|
|
32
|
-
<span v-html="formatter(config, scope.row, { index: scope.$index })"></span>
|
|
33
|
-
</TMagicButton>
|
|
2
|
+
<div v-if="config.type === 'index'">
|
|
3
|
+
{{ config.pageIndex && config.pageSize ? config.pageIndex * config.pageSize + index + 1 : index + 1 }}
|
|
4
|
+
</div>
|
|
5
|
+
<TMagicForm v-else-if="config.type && editState[index]" label-width="0" :model="editState[index]">
|
|
6
|
+
<m-form-container
|
|
7
|
+
:prop="config.prop"
|
|
8
|
+
:rules="config.rules"
|
|
9
|
+
:config="config"
|
|
10
|
+
:name="config.prop"
|
|
11
|
+
:model="editState[index]"
|
|
12
|
+
></m-form-container>
|
|
13
|
+
</TMagicForm>
|
|
34
14
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
15
|
+
<TMagicButton
|
|
16
|
+
v-else-if="config.action === 'actionLink' && config.prop"
|
|
17
|
+
link
|
|
18
|
+
type="primary"
|
|
19
|
+
@click="config.handler?.(row)"
|
|
20
|
+
>
|
|
21
|
+
<span v-html="formatter(config, row, { index: index })"></span>
|
|
22
|
+
</TMagicButton>
|
|
38
23
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
:href="scope.row[config.prop]"
|
|
43
|
-
class="keep-all"
|
|
44
|
-
>{{ scope.row[config.prop] }}</a
|
|
45
|
-
>
|
|
24
|
+
<a v-else-if="config.action === 'img' && config.prop" target="_blank" :href="row[config.prop]"
|
|
25
|
+
><img :src="row[config.prop]" height="50"
|
|
26
|
+
/></a>
|
|
46
27
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
</template>
|
|
51
|
-
<TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
|
|
52
|
-
</el-tooltip>
|
|
28
|
+
<a v-else-if="config.action === 'link' && config.prop" target="_blank" :href="row[config.prop]" class="keep-all">{{
|
|
29
|
+
row[config.prop]
|
|
30
|
+
}}</a>
|
|
53
31
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
close-transition
|
|
58
|
-
>{{ formatter(config, scope.row, { index: scope.$index }) }}</TMagicTag
|
|
59
|
-
>
|
|
60
|
-
<div v-else v-html="formatter(config, scope.row, { index: scope.$index })"></div>
|
|
32
|
+
<el-tooltip v-else-if="config.action === 'tip'" placement="left">
|
|
33
|
+
<template #content>
|
|
34
|
+
<div>{{ formatter(config, row, { index: index }) }}</div>
|
|
61
35
|
</template>
|
|
62
|
-
|
|
36
|
+
<TMagicButton link type="primary">{{ config.buttonText || '扩展配置' }}</TMagicButton>
|
|
37
|
+
</el-tooltip>
|
|
38
|
+
|
|
39
|
+
<TMagicTag
|
|
40
|
+
v-else-if="config.action === 'tag' && config.prop"
|
|
41
|
+
:type="typeof config.type === 'function' ? config.type(row[config.prop], row) : config.type"
|
|
42
|
+
close-transition
|
|
43
|
+
>{{ formatter(config, row, { index: index }) }}</TMagicTag
|
|
44
|
+
>
|
|
45
|
+
<div v-else v-html="formatter(config, row, { index: index })"></div>
|
|
63
46
|
</template>
|
|
64
47
|
|
|
65
48
|
<script lang="ts" setup>
|
|
66
|
-
import { TMagicButton, TMagicForm,
|
|
49
|
+
import { TMagicButton, TMagicForm, TMagicTag } from '@tmagic/design';
|
|
67
50
|
|
|
68
51
|
import { ColumnConfig } from './schema';
|
|
69
52
|
import { formatter } from './utils';
|
|
@@ -76,6 +59,8 @@ withDefaults(
|
|
|
76
59
|
defineProps<{
|
|
77
60
|
config: ColumnConfig;
|
|
78
61
|
editState?: any;
|
|
62
|
+
row: any;
|
|
63
|
+
index: number;
|
|
79
64
|
}>(),
|
|
80
65
|
{
|
|
81
66
|
config: () => ({}),
|
package/src/schema.ts
CHANGED
|
@@ -21,7 +21,8 @@ import { FormConfig, FormValue } from '@tmagic/form';
|
|
|
21
21
|
export interface ColumnActionConfig {
|
|
22
22
|
type?: 'delete' | 'copy' | 'edit' | string;
|
|
23
23
|
buttonType?: string;
|
|
24
|
-
display?: (row: any) => boolean;
|
|
24
|
+
display?: boolean | ((row: any) => boolean);
|
|
25
|
+
disabled?: boolean | ((row: any) => boolean);
|
|
25
26
|
text?: string | ((row: any) => string);
|
|
26
27
|
name?: string;
|
|
27
28
|
tooltip?: string;
|
package/types/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ import { FormConfig, FormValue } from '@tmagic/form';
|
|
|
5
5
|
interface ColumnActionConfig {
|
|
6
6
|
type?: 'delete' | 'copy' | 'edit' | string;
|
|
7
7
|
buttonType?: string;
|
|
8
|
-
display?: (row: any) => boolean;
|
|
8
|
+
display?: boolean | ((row: any) => boolean);
|
|
9
|
+
disabled?: boolean | ((row: any) => boolean);
|
|
9
10
|
text?: string | ((row: any) => string);
|
|
10
11
|
name?: string;
|
|
11
12
|
tooltip?: string;
|
|
@@ -106,9 +107,9 @@ declare const __VLS_export: _vue_runtime_core.DefineComponent<__VLS_Props, {
|
|
|
106
107
|
"onSelection-change"?: ((...args: any[]) => any) | undefined;
|
|
107
108
|
}>, {
|
|
108
109
|
loading: boolean;
|
|
110
|
+
columns: ColumnConfig[];
|
|
109
111
|
border: boolean;
|
|
110
112
|
defaultExpandAll: boolean;
|
|
111
|
-
columns: ColumnConfig[];
|
|
112
113
|
showHeader: boolean;
|
|
113
114
|
}, {}, {}, {}, string, _vue_runtime_core.ComponentProvideOptions, false, {}, any>;
|
|
114
115
|
declare const _default$1: typeof __VLS_export;
|