@visactor/vue-vtable 1.25.0 → 1.25.1-alpha.1
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/cjs/components/component/menu.js +3 -3
- package/cjs/components/component/tooltip.js +3 -3
- package/cjs/components/custom/checkBox.js +3 -3
- package/cjs/components/custom/group.js +3 -3
- package/cjs/components/custom/image.js +3 -3
- package/cjs/components/custom/radio.js +3 -3
- package/cjs/components/custom/tag.js +3 -3
- package/cjs/components/custom/text.js +3 -3
- package/cjs/components/custom/vtable-vue-attribute-plugin.js +622 -408
- package/cjs/components/list/list-column.js +3 -3
- package/cjs/components/pivot/pivot-column-dimension.js +3 -3
- package/cjs/components/pivot/pivot-column-header-title.js +3 -3
- package/cjs/components/pivot/pivot-corner.js +3 -3
- package/cjs/components/pivot/pivot-indicator.js +3 -3
- package/cjs/components/pivot/pivot-row-dimension.js +3 -3
- package/cjs/components/pivot/pivot-row-header-title.js +3 -3
- package/cjs/constants.js +1 -0
- package/cjs/edit/editor.js +209 -194
- package/cjs/edit/util.js +51 -31
- package/cjs/eventsUtils.js +97 -60
- package/cjs/hooks/useCellRender.js +27 -20
- package/cjs/hooks/useEditorRender.js +75 -52
- package/cjs/index.js +5 -5
- package/cjs/tables/base-table.vue.js +266 -237
- package/cjs/tables/chartModule.js +2 -2
- package/cjs/tables/list-table.vue.js +41 -39
- package/cjs/tables/pivot-chart.vue.js +35 -37
- package/cjs/tables/pivot-table.vue.js +36 -38
- package/cjs/utils/customLayoutUtils.js +109 -96
- package/cjs/utils/slotUtils.js +85 -88
- package/cjs/utils/stringUtils.js +14 -12
- package/cjs/utils/vnodeUtils.js +3 -2
- package/dist/vue-vtable.js +1715 -1358
- package/dist/vue-vtable.min.js +1 -1
- package/es/components/component/menu.js +3 -3
- package/es/components/component/tooltip.js +3 -3
- package/es/components/custom/checkBox.js +3 -3
- package/es/components/custom/group.js +3 -3
- package/es/components/custom/image.js +3 -3
- package/es/components/custom/radio.js +3 -3
- package/es/components/custom/tag.js +3 -3
- package/es/components/custom/text.js +3 -3
- package/es/components/custom/vtable-vue-attribute-plugin.js +622 -408
- package/es/components/list/list-column.js +3 -3
- package/es/components/pivot/pivot-column-dimension.js +3 -3
- package/es/components/pivot/pivot-column-header-title.js +3 -3
- package/es/components/pivot/pivot-corner.js +3 -3
- package/es/components/pivot/pivot-indicator.js +3 -3
- package/es/components/pivot/pivot-row-dimension.js +3 -3
- package/es/components/pivot/pivot-row-header-title.js +3 -3
- package/es/constants.js +1 -0
- package/es/edit/editor.js +209 -194
- package/es/edit/util.js +51 -31
- package/es/eventsUtils.js +97 -60
- package/es/hooks/useCellRender.js +27 -20
- package/es/hooks/useEditorRender.js +75 -52
- package/es/index.js +3 -3
- package/es/tables/base-table.vue.js +266 -237
- package/es/tables/chartModule.js +2 -2
- package/es/tables/list-table.vue.js +41 -39
- package/es/tables/pivot-chart.vue.js +35 -37
- package/es/tables/pivot-table.vue.js +36 -38
- package/es/utils/customLayoutUtils.js +109 -96
- package/es/utils/slotUtils.js +85 -88
- package/es/utils/stringUtils.js +14 -12
- package/es/utils/vnodeUtils.js +3 -2
- package/package.json +5 -5
- package/cjs/components/component/menu.d.ts +0 -14
- package/cjs/components/component/tooltip.d.ts +0 -11
- package/cjs/components/custom/checkBox.d.ts +0 -20
- package/cjs/components/custom/custom-layout.d.ts +0 -20
- package/cjs/components/custom/group.d.ts +0 -6
- package/cjs/components/custom/image.d.ts +0 -6
- package/cjs/components/custom/radio.d.ts +0 -17
- package/cjs/components/custom/tag.d.ts +0 -16
- package/cjs/components/custom/text.d.ts +0 -6
- package/cjs/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
- package/cjs/components/index.d.ts +0 -15
- package/cjs/components/list/list-column.d.ts +0 -7
- package/cjs/components/pivot/pivot-column-dimension.d.ts +0 -11
- package/cjs/components/pivot/pivot-column-header-title.d.ts +0 -7
- package/cjs/components/pivot/pivot-corner.d.ts +0 -7
- package/cjs/components/pivot/pivot-indicator.d.ts +0 -7
- package/cjs/components/pivot/pivot-row-dimension.d.ts +0 -11
- package/cjs/components/pivot/pivot-row-header-title.d.ts +0 -7
- package/cjs/constants.d.ts +0 -1
- package/cjs/edit/editor.d.ts +0 -50
- package/cjs/edit/index.d.ts +0 -2
- package/cjs/edit/util.d.ts +0 -4
- package/cjs/eventsUtils.d.ts +0 -120
- package/cjs/hooks/index.d.ts +0 -2
- package/cjs/hooks/useCellRender.d.ts +0 -2
- package/cjs/hooks/useEditorRender.d.ts +0 -2
- package/cjs/index.d.ts +0 -6
- package/cjs/tables/base-table.vue.d.ts +0 -543
- package/cjs/tables/chartModule.d.ts +0 -1
- package/cjs/tables/index.d.ts +0 -5
- package/cjs/tables/list-table.vue.d.ts +0 -38
- package/cjs/tables/pivot-chart.vue.d.ts +0 -38
- package/cjs/tables/pivot-table.vue.d.ts +0 -38
- package/cjs/utils/customLayoutUtils.d.ts +0 -5
- package/cjs/utils/slotUtils.d.ts +0 -28
- package/cjs/utils/stringUtils.d.ts +0 -2
- package/cjs/utils/vnodeUtils.d.ts +0 -1
- package/cjs/utils.d.ts +0 -4
- package/es/components/component/menu.d.ts +0 -14
- package/es/components/component/tooltip.d.ts +0 -11
- package/es/components/custom/checkBox.d.ts +0 -20
- package/es/components/custom/custom-layout.d.ts +0 -20
- package/es/components/custom/group.d.ts +0 -6
- package/es/components/custom/image.d.ts +0 -6
- package/es/components/custom/radio.d.ts +0 -17
- package/es/components/custom/tag.d.ts +0 -16
- package/es/components/custom/text.d.ts +0 -6
- package/es/components/custom/vtable-vue-attribute-plugin.d.ts +0 -62
- package/es/components/index.d.ts +0 -15
- package/es/components/list/list-column.d.ts +0 -7
- package/es/components/pivot/pivot-column-dimension.d.ts +0 -11
- package/es/components/pivot/pivot-column-header-title.d.ts +0 -7
- package/es/components/pivot/pivot-corner.d.ts +0 -7
- package/es/components/pivot/pivot-indicator.d.ts +0 -7
- package/es/components/pivot/pivot-row-dimension.d.ts +0 -11
- package/es/components/pivot/pivot-row-header-title.d.ts +0 -7
- package/es/constants.d.ts +0 -1
- package/es/edit/editor.d.ts +0 -50
- package/es/edit/index.d.ts +0 -2
- package/es/edit/util.d.ts +0 -4
- package/es/eventsUtils.d.ts +0 -120
- package/es/hooks/index.d.ts +0 -2
- package/es/hooks/useCellRender.d.ts +0 -2
- package/es/hooks/useEditorRender.d.ts +0 -2
- package/es/index.d.ts +0 -6
- package/es/tables/base-table.vue.d.ts +0 -543
- package/es/tables/chartModule.d.ts +0 -1
- package/es/tables/index.d.ts +0 -5
- package/es/tables/list-table.vue.d.ts +0 -38
- package/es/tables/pivot-chart.vue.d.ts +0 -38
- package/es/tables/pivot-table.vue.d.ts +0 -38
- package/es/utils/customLayoutUtils.d.ts +0 -5
- package/es/utils/slotUtils.d.ts +0 -28
- package/es/utils/stringUtils.d.ts +0 -2
- package/es/utils/vnodeUtils.d.ts +0 -1
- package/es/utils.d.ts +0 -4
|
@@ -4,243 +4,272 @@ import { TABLE_EVENTS_KEYS, TABLE_EVENTS } from '../eventsUtils.js';
|
|
|
4
4
|
import { useEditorRender } from '../hooks/useEditorRender.js';
|
|
5
5
|
import { useCellRender } from '../hooks/useCellRender.js';
|
|
6
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
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
7
|
+
// 创建表格实例
|
|
8
|
+
// use Constructor<T> will cause error in rollup-plugin-typescript2, use any temporarily
|
|
9
|
+
var _sfc_main = /*@__PURE__*/ defineComponent({
|
|
10
|
+
__name: 'base-table',
|
|
11
|
+
props: {
|
|
12
|
+
type: { type: String, required: false },
|
|
13
|
+
options: { type: null, required: false },
|
|
14
|
+
records: { type: Array, required: false },
|
|
15
|
+
width: { type: [Number, String], required: false, default: '100%' },
|
|
16
|
+
height: { type: [Number, String], required: false, default: '100%' },
|
|
17
|
+
onReady: { type: Function, required: false },
|
|
18
|
+
onError: { type: Function, required: false },
|
|
19
|
+
keepColumnWidthChange: { type: Boolean, required: false },
|
|
20
|
+
onClickCell: { type: Function, required: false },
|
|
21
|
+
onDblClickCell: { type: Function, required: false },
|
|
22
|
+
onMouseDownCell: { type: Function, required: false },
|
|
23
|
+
onMouseUpCell: { type: Function, required: false },
|
|
24
|
+
onSelectedCell: { type: Function, required: false },
|
|
25
|
+
onKeyDown: { type: Function, required: false },
|
|
26
|
+
onMouseEnterTable: { type: Function, required: false },
|
|
27
|
+
onMouseLeaveTable: { type: Function, required: false },
|
|
28
|
+
onMouseDownTable: { type: Function, required: false },
|
|
29
|
+
onMouseMoveCell: { type: Function, required: false },
|
|
30
|
+
onMouseEnterCell: { type: Function, required: false },
|
|
31
|
+
onMouseLeaveCell: { type: Function, required: false },
|
|
32
|
+
onContextMenuCell: { type: Function, required: false },
|
|
33
|
+
onContextMenuCanvas: { type: Function, required: false },
|
|
34
|
+
onResizeColumn: { type: Function, required: false },
|
|
35
|
+
onResizeColumnEnd: { type: Function, required: false },
|
|
36
|
+
onChangeHeaderPosition: { type: Function, required: false },
|
|
37
|
+
onChangeHeaderPositionStart: { type: Function, required: false },
|
|
38
|
+
onChangeHeaderPositionFail: { type: Function, required: false },
|
|
39
|
+
onSortClick: { type: Function, required: false },
|
|
40
|
+
onFreezeClick: { type: Function, required: false },
|
|
41
|
+
onScroll: { type: Function, required: false },
|
|
42
|
+
onDropdownMenuClick: { type: Function, required: false },
|
|
43
|
+
onMouseOverChartSymbol: { type: Function, required: false },
|
|
44
|
+
onDragSelectEnd: { type: Function, required: false },
|
|
45
|
+
onDropdownIconClick: { type: Function, required: false },
|
|
46
|
+
onDropdownMenuClear: { type: Function, required: false },
|
|
47
|
+
onTreeHierarchyStateChange: { type: Function, required: false },
|
|
48
|
+
onShowMenu: { type: Function, required: false },
|
|
49
|
+
onHideMenu: { type: Function, required: false },
|
|
50
|
+
onIconClick: { type: Function, required: false },
|
|
51
|
+
onLegendItemClick: { type: Function, required: false },
|
|
52
|
+
onLegendItemHover: { type: Function, required: false },
|
|
53
|
+
onLegendItemUnHover: { type: Function, required: false },
|
|
54
|
+
onLegendChange: { type: Function, required: false },
|
|
55
|
+
onMouseEnterAxis: { type: Function, required: false },
|
|
56
|
+
onMouseLeaveAxis: { type: Function, required: false },
|
|
57
|
+
onCheckboxStateChange: { type: Function, required: false },
|
|
58
|
+
onRadioStateChange: { type: Function, required: false },
|
|
59
|
+
onAfterRender: { type: Function, required: false },
|
|
60
|
+
onInitialized: { type: Function, required: false },
|
|
61
|
+
onPivotSortClick: { type: Function, required: false },
|
|
62
|
+
onDrillMenuClick: { type: Function, required: false },
|
|
63
|
+
onVChartEventType: { type: Function, required: false },
|
|
64
|
+
onChangeCellValue: { type: Function, required: false },
|
|
65
|
+
onMousedownFillHandle: { type: Function, required: false },
|
|
66
|
+
onDragFillHandleEnd: { type: Function, required: false },
|
|
67
|
+
onDblclickFillHandle: { type: Function, required: false },
|
|
68
|
+
onScrollVerticalEnd: { type: Function, required: false },
|
|
69
|
+
onScrollHorizontalEnd: { type: Function, required: false },
|
|
70
|
+
onChangCellValue: { type: Function, required: false },
|
|
71
|
+
onEmptyTipClick: { type: Function, required: false },
|
|
72
|
+
onEmptyTipDblClick: { type: Function, required: false },
|
|
73
|
+
onButtonClick: { type: Function, required: false },
|
|
74
|
+
onBeforeCacheChartImage: { type: Function, required: false },
|
|
75
|
+
onPastedData: { type: Function, required: false }
|
|
76
|
+
},
|
|
77
|
+
emits: TABLE_EVENTS_KEYS,
|
|
78
|
+
setup(__props, { expose: __expose, emit: __emit }) {
|
|
79
|
+
const props = __props;
|
|
80
|
+
// 创建用于引用 DOM 元素和表格实例的 ref
|
|
81
|
+
const vTableContainer = ref(null);
|
|
82
|
+
const vTableInstance = shallowRef(null);
|
|
83
|
+
// for keepColumnWidthChange
|
|
84
|
+
const columnWidths = ref(new Map());
|
|
85
|
+
const pivotColumnWidths = ref([]);
|
|
86
|
+
const pivotHeaderColumnWidths = ref([]);
|
|
87
|
+
// 自定义编辑渲染器
|
|
88
|
+
useEditorRender(props, vTableInstance);
|
|
89
|
+
// 自定义单元格渲染器
|
|
90
|
+
useCellRender(props, vTableInstance);
|
|
91
|
+
// 公开 vTableInstance,以便外部组件可以访问
|
|
92
|
+
__expose({ vTableInstance });
|
|
93
|
+
// 计算容器的宽度和高度
|
|
94
|
+
const containerWidth = computed(() => (typeof props.width === 'number' ? `${props.width}px` : props.width));
|
|
95
|
+
const containerHeight = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height));
|
|
96
|
+
// 绑定事件到表格实例
|
|
97
|
+
const emit = __emit;
|
|
98
|
+
const bindEvents = (instance) => {
|
|
99
|
+
TABLE_EVENTS_KEYS.forEach(eventKey => {
|
|
100
|
+
const vueEventHandler = (event) => {
|
|
101
|
+
emit(eventKey, event);
|
|
102
|
+
};
|
|
103
|
+
instance.on(TABLE_EVENTS[eventKey], vueEventHandler);
|
|
104
|
+
});
|
|
105
|
+
};
|
|
106
|
+
const createTableInstance = (Type, options) => {
|
|
107
|
+
const vtable = new Type(vTableContainer.value, options);
|
|
108
|
+
vTableInstance.value = vtable;
|
|
109
|
+
// for keepColumnWidthChange
|
|
110
|
+
columnWidths.value.clear();
|
|
111
|
+
pivotColumnWidths.value = [];
|
|
112
|
+
pivotHeaderColumnWidths.value = [];
|
|
113
|
+
vtable.on('resize_column_end', (args) => {
|
|
114
|
+
// const table = vTableInstance.value;
|
|
115
|
+
if (!props.keepColumnWidthChange) {
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const { col, colWidths } = args;
|
|
119
|
+
const width = colWidths[col];
|
|
120
|
+
if (vtable.isPivotTable()) {
|
|
121
|
+
const path = vtable.getCellHeaderPaths(col, vtable.columnHeaderLevelCount);
|
|
122
|
+
let dimensions = null;
|
|
123
|
+
if (path.cellLocation === 'rowHeader') {
|
|
124
|
+
dimensions = path.rowHeaderPaths;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
dimensions = path.colHeaderPaths;
|
|
128
|
+
}
|
|
129
|
+
let found = false;
|
|
130
|
+
// pivotColumnWidths.value.forEach(item => {
|
|
131
|
+
// if (JSON.stringify(item.dimensions) === JSON.stringify(dimensions)) {
|
|
132
|
+
// item.width = width;
|
|
133
|
+
// found = true;
|
|
134
|
+
// }
|
|
135
|
+
// });
|
|
136
|
+
for (let i = 0; i < pivotColumnWidths.value.length; i++) {
|
|
137
|
+
const item = pivotColumnWidths.value[i];
|
|
138
|
+
if (JSON.stringify(item.dimensions) === JSON.stringify(dimensions)) {
|
|
139
|
+
item.width = width;
|
|
140
|
+
found = true;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!found) {
|
|
144
|
+
pivotColumnWidths.value.push({ dimensions, width });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
else {
|
|
148
|
+
const define = vtable.getBodyColumnDefine(col, 0);
|
|
149
|
+
if (define === null || define === void 0 ? void 0 : define.key) {
|
|
150
|
+
columnWidths.value.set(define.key, width);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
const createVTable = () => {
|
|
156
|
+
var _a, _b;
|
|
157
|
+
if (!vTableContainer.value) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
if (vTableInstance.value) {
|
|
161
|
+
vTableInstance.value.release();
|
|
162
|
+
}
|
|
163
|
+
const getRecords = () => {
|
|
164
|
+
return props.records !== undefined && props.records !== null && props.records.length > 0
|
|
165
|
+
? props.records
|
|
166
|
+
: props.options.records;
|
|
167
|
+
};
|
|
168
|
+
try {
|
|
169
|
+
switch (props.type) {
|
|
170
|
+
case 'list':
|
|
171
|
+
createTableInstance(ListTable, Object.assign(Object.assign({}, props.options), { records: getRecords() }));
|
|
172
|
+
break;
|
|
173
|
+
case 'pivot':
|
|
174
|
+
createTableInstance(PivotTable, Object.assign(Object.assign({}, props.options), { records: getRecords() }));
|
|
175
|
+
break;
|
|
176
|
+
case 'chart':
|
|
177
|
+
createTableInstance(PivotChart, Object.assign(Object.assign({}, props.options), { records: getRecords() }));
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
bindEvents(vTableInstance.value);
|
|
181
|
+
(_a = props.onReady) === null || _a === void 0 ? void 0 : _a.call(props, vTableInstance.value, true);
|
|
182
|
+
}
|
|
183
|
+
catch (err) {
|
|
184
|
+
(_b = props.onError) === null || _b === void 0 ? void 0 : _b.call(props, err);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
// 更新表格实例
|
|
188
|
+
const updateVTable = (newOptions) => {
|
|
189
|
+
var _a;
|
|
190
|
+
if (!vTableInstance.value) {
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
try {
|
|
194
|
+
// for keepColumnWidthChange, update column width
|
|
195
|
+
if (props.keepColumnWidthChange) {
|
|
196
|
+
const columnWidthConfig = updateWidthCache(columnWidths.value, pivotColumnWidths.value, vTableInstance.value);
|
|
197
|
+
newOptions = Object.assign(Object.assign({}, newOptions), { columnWidthConfig: columnWidthConfig, columnWidthConfigForRowHeader: columnWidthConfig });
|
|
198
|
+
}
|
|
199
|
+
switch (props.type) {
|
|
200
|
+
case 'list':
|
|
201
|
+
if (vTableInstance.value instanceof ListTable) {
|
|
202
|
+
vTableInstance.value.updateOption(newOptions);
|
|
203
|
+
}
|
|
204
|
+
break;
|
|
205
|
+
case 'pivot':
|
|
206
|
+
if (vTableInstance.value instanceof PivotTable) {
|
|
207
|
+
vTableInstance.value.updateOption(newOptions);
|
|
208
|
+
}
|
|
209
|
+
break;
|
|
210
|
+
case 'chart':
|
|
211
|
+
if (vTableInstance.value instanceof PivotChart) {
|
|
212
|
+
vTableInstance.value.updateOption(newOptions);
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
catch (err) {
|
|
218
|
+
(_a = props.onError) === null || _a === void 0 ? void 0 : _a.call(props, err);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
// 组件挂载时创建表格
|
|
222
|
+
onMounted(createVTable);
|
|
223
|
+
onBeforeUnmount(() => {
|
|
224
|
+
var _a;
|
|
225
|
+
(_a = vTableInstance.value) === null || _a === void 0 ? void 0 : _a.release();
|
|
226
|
+
});
|
|
227
|
+
// 监听 options 属性的变化
|
|
228
|
+
// 需要去做细颗粒度的比较
|
|
229
|
+
// deep 选中会导致tree失效
|
|
230
|
+
watch(() => props.options, (newOptions, oldOptions) => {
|
|
231
|
+
if (vTableInstance.value) {
|
|
232
|
+
updateVTable(newOptions);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
createVTable();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
// { deep: true },
|
|
239
|
+
);
|
|
240
|
+
// 监听 records 属性的变化并更新表格
|
|
241
|
+
// 需要去做细颗粒度的比较
|
|
242
|
+
watch(() => props.records, (newRecords, oldRecords) => {
|
|
243
|
+
// if (!isEqual(newRecords, oldRecords)) {
|
|
244
|
+
if (vTableInstance.value) {
|
|
245
|
+
updateVTable(Object.assign(Object.assign({}, props.options), { records: newRecords }));
|
|
246
|
+
}
|
|
247
|
+
else {
|
|
248
|
+
createVTable();
|
|
249
|
+
}
|
|
250
|
+
// }
|
|
251
|
+
}, { deep: true });
|
|
252
|
+
function updateWidthCache(columnWidths, pivotColumnWidths, table) {
|
|
253
|
+
if (table.isPivotTable()) {
|
|
254
|
+
return pivotColumnWidths;
|
|
255
|
+
}
|
|
256
|
+
const columnWidthConfig = [];
|
|
257
|
+
columnWidths.forEach((width, key) => {
|
|
258
|
+
columnWidthConfig.push({
|
|
259
|
+
key,
|
|
260
|
+
width
|
|
261
|
+
});
|
|
262
|
+
});
|
|
263
|
+
return columnWidthConfig;
|
|
264
|
+
}
|
|
265
|
+
return (_ctx, _cache) => {
|
|
266
|
+
return (openBlock(), createElementBlock("div", {
|
|
267
|
+
ref_key: "vTableContainer",
|
|
268
|
+
ref: vTableContainer,
|
|
269
|
+
style: normalizeStyle([{ width: containerWidth.value, height: containerHeight.value }, { "position": "relative" }])
|
|
270
|
+
}, null, 4 /* STYLE */));
|
|
271
|
+
};
|
|
272
|
+
}
|
|
244
273
|
});
|
|
245
274
|
|
|
246
275
|
export { _sfc_main as default };
|
package/es/tables/chartModule.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as VTable from '@visactor/vtable';
|
|
2
2
|
|
|
3
|
-
const registerChartModule = (name, chart) => {
|
|
4
|
-
VTable.register.chartModule(name, chart);
|
|
3
|
+
const registerChartModule = (name, chart) => {
|
|
4
|
+
VTable.register.chartModule(name, chart);
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
export { registerChartModule };
|
|
@@ -1,46 +1,48 @@
|
|
|
1
1
|
import { defineComponent, ref, useSlots, computed, openBlock, createElementBlock, Fragment, createVNode, mergeProps, renderSlot } from 'vue';
|
|
2
|
+
import _sfc_main$1 from './base-table.vue.js';
|
|
2
3
|
import { flattenVNodes } from '../utils/vnodeUtils.js';
|
|
3
|
-
import '@visactor/vtable';
|
|
4
|
-
import '@visactor/vutils';
|
|
5
4
|
import { extractListSlotOptions, mergeSlotOptions } from '../utils/slotUtils.js';
|
|
6
|
-
import _sfc_main$1 from './base-table.vue.js';
|
|
7
5
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
6
|
+
// 定义属性
|
|
7
|
+
var _sfc_main = /*@__PURE__*/ defineComponent({
|
|
8
|
+
__name: 'list-table',
|
|
9
|
+
props: {
|
|
10
|
+
options: { type: Object, required: true },
|
|
11
|
+
records: { type: Array, required: false },
|
|
12
|
+
width: { type: [String, Number], required: false },
|
|
13
|
+
height: { type: [String, Number], required: false }
|
|
14
|
+
},
|
|
15
|
+
setup(__props, { expose: __expose }) {
|
|
16
|
+
const props = __props;
|
|
17
|
+
// 引用BaseTable实例
|
|
18
|
+
const baseTableRef = ref(null);
|
|
19
|
+
const slots = useSlots();
|
|
20
|
+
// 合并插槽配置
|
|
21
|
+
const computedOptions = computed(() => {
|
|
22
|
+
var _a;
|
|
23
|
+
const flattenedSlots = flattenVNodes(((_a = slots.default) === null || _a === void 0 ? void 0 : _a.call(slots)) || []);
|
|
24
|
+
const slotOptions = extractListSlotOptions(flattenedSlots);
|
|
25
|
+
return mergeSlotOptions(props.options, slotOptions);
|
|
26
|
+
});
|
|
27
|
+
// 暴露实例
|
|
28
|
+
__expose({
|
|
29
|
+
vTableInstance: computed(() => { var _a; return ((_a = baseTableRef.value) === null || _a === void 0 ? void 0 : _a.vTableInstance) || null; }),
|
|
30
|
+
});
|
|
31
|
+
return (_ctx, _cache) => {
|
|
32
|
+
return (openBlock(), createElementBlock(Fragment, null, [
|
|
33
|
+
createVNode(_sfc_main$1, mergeProps({
|
|
34
|
+
type: "list",
|
|
35
|
+
options: computedOptions.value,
|
|
36
|
+
records: __props.records,
|
|
37
|
+
width: __props.width,
|
|
38
|
+
height: __props.height,
|
|
39
|
+
ref_key: "baseTableRef",
|
|
40
|
+
ref: baseTableRef
|
|
41
|
+
}, _ctx.$attrs), null, 16 /* FULL_PROPS */, ["options", "records", "width", "height"]),
|
|
42
|
+
renderSlot(_ctx.$slots, "default")
|
|
43
|
+
], 64 /* STABLE_FRAGMENT */));
|
|
44
|
+
};
|
|
45
|
+
}
|
|
44
46
|
});
|
|
45
47
|
|
|
46
48
|
export { _sfc_main as default };
|