@vue-ui-kit/ant 2.4.2 → 2.4.4
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/README.md +3 -3
- package/dist/cjs/index.js +5 -5
- package/dist/es/index.js +11094 -12211
- package/dist/index.d.ts +3080 -23
- package/dist/style.css +419 -1
- package/dist/style.scss +22 -1
- package/package.json +8 -8
- package/src/declarations/antProxy.ts +21 -6
- package/src/index.ts +1 -0
- package/src/packages/components/PGrid.vue +201 -98
- package/src/packages/components/RenderAntCell.tsx +29 -29
- package/src/packages/components/RenderDefaultSlots.tsx +6 -2
- package/src/packages/store/renderStore.tsx +1 -1
- package/src/packages/styles/index.scss +22 -1
- package/src/packages/utils/autoViewportBox.ts +156 -0
- package/src/packages/utils/config.ts +109 -105
- package/dist/declarations/antProxy.d.ts +0 -373
- package/dist/declarations/type.d.ts +0 -1
- package/dist/packages/components/RenderAntCell.d.ts +0 -28
- package/dist/packages/components/RenderAntItem.d.ts +0 -18
- package/dist/packages/components/RenderDefaultSlots.d.ts +0 -34
- package/dist/packages/components/RenderEditCell.d.ts +0 -25
- package/dist/packages/components/RenderItemSlots.d.ts +0 -25
- package/dist/packages/components/RenderTitleSlots.d.ts +0 -16
- package/dist/packages/hooks/useMessage.d.ts +0 -8
- package/dist/packages/renders/Icon.d.ts +0 -4
- package/dist/packages/store/renderStore.d.ts +0 -16
- package/dist/packages/utils/AFormatters.d.ts +0 -9
- package/dist/packages/utils/config.d.ts +0 -30
- package/dist/packages/utils/core.d.ts +0 -10
- package/dist/packages/utils/is.d.ts +0 -4
- package/dist/packages/utils/treeHelper.d.ts +0 -19
|
@@ -5,16 +5,42 @@
|
|
|
5
5
|
setup
|
|
6
6
|
>
|
|
7
7
|
import { ColumnProps, PFormItemProps, PGridProps, ResponsePathConfig } from '#/antProxy';
|
|
8
|
+
import PFormCol from '@/components/PFormCol.vue';
|
|
9
|
+
import RenderDefaultSlots from '@/components/RenderDefaultSlots';
|
|
10
|
+
import RenderTitleSlots from '@/components/RenderTitleSlots';
|
|
11
|
+
import { $confirm } from '@/hooks/useMessage';
|
|
12
|
+
import Icon from '@/renders/Icon';
|
|
13
|
+
import { getGridDefaults } from '@/utils/config';
|
|
14
|
+
import {
|
|
15
|
+
createAutoViewportBoxController,
|
|
16
|
+
parseAutoViewportBoxOffset,
|
|
17
|
+
type AutoViewportBoxController,
|
|
18
|
+
type AutoViewportBoxOffsetInput,
|
|
19
|
+
} from '@/utils/autoViewportBox';
|
|
20
|
+
import { cleanCol, defaultLabelCol } from '@/utils/core';
|
|
21
|
+
import { isGoodValue } from '@/utils/is';
|
|
22
|
+
import { eachTree } from '@/utils/treeHelper';
|
|
23
|
+
import { DownOutlined } from '@ant-design/icons-vue';
|
|
24
|
+
import {
|
|
25
|
+
message as $message,
|
|
26
|
+
Button as AButton,
|
|
27
|
+
Form as AForm,
|
|
28
|
+
Row as ARow,
|
|
29
|
+
Spin as ASpin,
|
|
30
|
+
Table as ATable,
|
|
31
|
+
} from 'ant-design-vue';
|
|
32
|
+
import { v4 as uuid_v4 } from 'uuid';
|
|
8
33
|
import {
|
|
9
|
-
computed,
|
|
10
|
-
useAttrs,
|
|
11
|
-
ref,
|
|
12
34
|
Ref,
|
|
13
|
-
|
|
35
|
+
computed,
|
|
36
|
+
nextTick,
|
|
37
|
+
onBeforeUnmount,
|
|
14
38
|
onMounted,
|
|
15
|
-
|
|
39
|
+
reactive,
|
|
40
|
+
ref,
|
|
16
41
|
toRefs,
|
|
17
|
-
|
|
42
|
+
useAttrs,
|
|
43
|
+
watch,
|
|
18
44
|
} from 'vue';
|
|
19
45
|
import {
|
|
20
46
|
debounce,
|
|
@@ -27,34 +53,15 @@
|
|
|
27
53
|
merge,
|
|
28
54
|
omit,
|
|
29
55
|
} from 'xe-utils';
|
|
30
|
-
import { eachTree } from '@/utils/treeHelper';
|
|
31
|
-
import { message as $message } from 'ant-design-vue';
|
|
32
|
-
import RenderTitleSlots from '@/components/RenderTitleSlots';
|
|
33
|
-
import RenderDefaultSlots from '@/components/RenderDefaultSlots';
|
|
34
|
-
import { v4 as uuid_v4 } from 'uuid';
|
|
35
|
-
import { isGoodValue } from '@/utils/is';
|
|
36
|
-
import PFormCol from '@/components/PFormCol.vue';
|
|
37
|
-
import { cleanCol, defaultLabelCol } from '@/utils/core';
|
|
38
|
-
import { getGridDefaults } from '@/utils/config';
|
|
39
|
-
import Icon from '@/renders/Icon';
|
|
40
|
-
import { $confirm } from '@/hooks/useMessage';
|
|
41
|
-
import {
|
|
42
|
-
Table as ATable,
|
|
43
|
-
Button as AButton,
|
|
44
|
-
Form as AForm,
|
|
45
|
-
Row as ARow,
|
|
46
|
-
Spin as ASpin,
|
|
47
|
-
} from 'ant-design-vue';
|
|
48
|
-
import { TablePaginationConfig } from 'ant-design-vue/es/table/interface';
|
|
49
|
-
import { DownOutlined } from '@ant-design/icons-vue';
|
|
50
56
|
|
|
51
57
|
const props = withDefaults(defineProps<PGridProps<D, F>>(), {
|
|
52
58
|
rowKey: 'id',
|
|
53
59
|
scrollMode: 'inner',
|
|
54
60
|
align: () => getGridDefaults().align ?? 'left',
|
|
55
61
|
lazyReset: () => getGridDefaults().lazyReset ?? false,
|
|
56
|
-
fitHeight: () => getGridDefaults().fitHeight ??
|
|
62
|
+
fitHeight: () => getGridDefaults().fitHeight ?? 30,
|
|
57
63
|
striped: () => getGridDefaults().striped ?? false,
|
|
64
|
+
autoBoxSize: false,
|
|
58
65
|
});
|
|
59
66
|
|
|
60
67
|
const {
|
|
@@ -67,6 +74,16 @@
|
|
|
67
74
|
selectConfig,
|
|
68
75
|
scrollMode,
|
|
69
76
|
} = toRefs(props);
|
|
77
|
+
|
|
78
|
+
/** 局部 `autoBoxSizeOffset` 优先,否则用 `getGridDefaults().autoBoxSizeOffset`(`setUIKitConfig`) */
|
|
79
|
+
const resolvedAutoBoxSizeOffset = computed<AutoViewportBoxOffsetInput>(() => {
|
|
80
|
+
const local = props.autoBoxSizeOffset;
|
|
81
|
+
if (local !== undefined && local !== null) {
|
|
82
|
+
return local;
|
|
83
|
+
}
|
|
84
|
+
return getGridDefaults().autoBoxSizeOffset as AutoViewportBoxOffsetInput;
|
|
85
|
+
});
|
|
86
|
+
|
|
70
87
|
const loading = reactive({
|
|
71
88
|
table: false,
|
|
72
89
|
toolbar: false,
|
|
@@ -86,6 +103,7 @@
|
|
|
86
103
|
const boxEl = ref<HTMLDivElement>();
|
|
87
104
|
const pFormWrapper = ref<HTMLDivElement>();
|
|
88
105
|
const tableWrapperEl = ref<HTMLDivElement>();
|
|
106
|
+
const tableFooterEl = ref<HTMLDivElement>();
|
|
89
107
|
const renderHeight = ref(500);
|
|
90
108
|
const selectedRowKeys = ref<Array<string | number>>([]);
|
|
91
109
|
const selectedCaches = ref<D[]>([]);
|
|
@@ -184,6 +202,8 @@
|
|
|
184
202
|
: 'list'
|
|
185
203
|
: 'bad',
|
|
186
204
|
);
|
|
205
|
+
/** 底部展示「已选」统计(与 multiple 无关,仅看 showCount) */
|
|
206
|
+
const showSelectionCount = computed(() => !!selectConfig.value?.showCount);
|
|
187
207
|
const attrs = useAttrs();
|
|
188
208
|
const emit = defineEmits<{
|
|
189
209
|
(
|
|
@@ -286,7 +306,6 @@
|
|
|
286
306
|
: {
|
|
287
307
|
list: response,
|
|
288
308
|
};
|
|
289
|
-
const enoughSpacing = ref(true);
|
|
290
309
|
const reload = () => {
|
|
291
310
|
selectedCaches.value = [];
|
|
292
311
|
selectedRowKeys.value = [];
|
|
@@ -298,15 +317,9 @@
|
|
|
298
317
|
selectedRowKeys.value = [];
|
|
299
318
|
return fetchData();
|
|
300
319
|
};
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
* @param _filters todo filters
|
|
305
|
-
* @param _sorter todo sorter
|
|
306
|
-
*/
|
|
307
|
-
const handleTableChange = (p: TablePaginationConfig, _filters, _sorter) => {
|
|
308
|
-
pagination.page = p.current!;
|
|
309
|
-
pagination.size = p.pageSize!;
|
|
320
|
+
const handlePaginationChange = (page: number, pageSize: number) => {
|
|
321
|
+
pagination.page = page;
|
|
322
|
+
pagination.size = pageSize;
|
|
310
323
|
return fetchData();
|
|
311
324
|
};
|
|
312
325
|
|
|
@@ -363,22 +376,10 @@
|
|
|
363
376
|
pagination.page = 1;
|
|
364
377
|
return lazy ? Promise.resolve() : debounceFetchData();
|
|
365
378
|
};
|
|
366
|
-
const pg = computed(() =>
|
|
367
|
-
mode.value === 'pagination'
|
|
368
|
-
? {
|
|
369
|
-
current: pagination.page,
|
|
370
|
-
total: totalCount.value,
|
|
371
|
-
pageSize: pagination.size,
|
|
372
|
-
responsive: false,
|
|
373
|
-
showSizeChanger: true,
|
|
374
|
-
showTotal: (total: number) => `共${total}条数据`,
|
|
375
|
-
}
|
|
376
|
-
: false,
|
|
377
|
-
);
|
|
378
379
|
const defaultTableConfig = {
|
|
379
|
-
size: 'small',
|
|
380
|
+
size: 'small' as const,
|
|
380
381
|
sticky: true,
|
|
381
|
-
transformCellText: ({ text }) => {
|
|
382
|
+
transformCellText: ({ text }: { text: any }) => {
|
|
382
383
|
return isArray(text) && text.length === 0 ? '-' : text;
|
|
383
384
|
},
|
|
384
385
|
};
|
|
@@ -423,16 +424,73 @@
|
|
|
423
424
|
},
|
|
424
425
|
{ deep: true },
|
|
425
426
|
);
|
|
427
|
+
watch(
|
|
428
|
+
() => [renderTableKey.value, dataSeed.value, mode.value, showSelectionCount.value],
|
|
429
|
+
() => nextTick(() => resizeTable()),
|
|
430
|
+
{ flush: 'post' },
|
|
431
|
+
);
|
|
432
|
+
|
|
433
|
+
let autoViewportBoxCtrl: AutoViewportBoxController | null = null;
|
|
434
|
+
const clearAutoViewportBox = () => {
|
|
435
|
+
autoViewportBoxCtrl?.destroy();
|
|
436
|
+
autoViewportBoxCtrl = null;
|
|
437
|
+
};
|
|
438
|
+
const syncAutoViewportBox = () => {
|
|
439
|
+
clearAutoViewportBox();
|
|
440
|
+
if (!props.autoBoxSize || !boxEl.value) return;
|
|
441
|
+
autoViewportBoxCtrl = createAutoViewportBoxController(
|
|
442
|
+
() => boxEl.value ?? undefined,
|
|
443
|
+
() => parseAutoViewportBoxOffset(resolvedAutoBoxSizeOffset.value),
|
|
444
|
+
{
|
|
445
|
+
onLayout: () => {
|
|
446
|
+
nextTick(() => resizeTable());
|
|
447
|
+
},
|
|
448
|
+
},
|
|
449
|
+
);
|
|
450
|
+
autoViewportBoxCtrl.attach();
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
watch(
|
|
454
|
+
() => props.autoBoxSize,
|
|
455
|
+
(on) => {
|
|
456
|
+
if (!on) clearAutoViewportBox();
|
|
457
|
+
else nextTick(() => syncAutoViewportBox());
|
|
458
|
+
},
|
|
459
|
+
);
|
|
460
|
+
watch(
|
|
461
|
+
resolvedAutoBoxSizeOffset,
|
|
462
|
+
() => {
|
|
463
|
+
if (props.autoBoxSize) autoViewportBoxCtrl?.update();
|
|
464
|
+
},
|
|
465
|
+
{ deep: true },
|
|
466
|
+
);
|
|
467
|
+
|
|
426
468
|
let resizeRaf: number | null = null;
|
|
469
|
+
|
|
470
|
+
const resolveTableHeaderEl = (wrapper: HTMLElement): HTMLElement | null => {
|
|
471
|
+
const root = wrapper.querySelector('.ant-table-wrapper');
|
|
472
|
+
if (!root) return null;
|
|
473
|
+
const byHeader = root.querySelector('.ant-table-header') as HTMLElement | null;
|
|
474
|
+
if (byHeader) return byHeader;
|
|
475
|
+
return root.querySelector('.ant-table-thead') as HTMLElement | null;
|
|
476
|
+
};
|
|
477
|
+
|
|
427
478
|
const resizeTable = () => {
|
|
428
479
|
if (resizeRaf) cancelAnimationFrame(resizeRaf);
|
|
429
480
|
resizeRaf = requestAnimationFrame(() => {
|
|
430
481
|
resizeRaf = null;
|
|
431
482
|
if (!tableWrapperEl.value) return;
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
483
|
+
if (isGoodValue(props.renderY)) {
|
|
484
|
+
renderHeight.value = props.renderY as number;
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const wrapperH = tableWrapperEl.value.clientHeight;
|
|
488
|
+
const footerH = tableFooterEl.value?.offsetHeight ?? 0;
|
|
489
|
+
const tableHeaderEl = resolveTableHeaderEl(tableWrapperEl.value);
|
|
490
|
+
const headerH = tableHeaderEl?.getBoundingClientRect().height ?? 0;
|
|
491
|
+
const reserve = props.fitHeight ?? 30;
|
|
492
|
+
const y = Math.max(wrapperH - footerH - headerH - reserve, 100);
|
|
493
|
+
renderHeight.value = y;
|
|
436
494
|
});
|
|
437
495
|
};
|
|
438
496
|
|
|
@@ -469,6 +527,8 @@
|
|
|
469
527
|
|
|
470
528
|
let observer: MutationObserver;
|
|
471
529
|
let boxElResizeObserver: ResizeObserver | null = null;
|
|
530
|
+
let tableWrapperResizeObserver: ResizeObserver | null = null;
|
|
531
|
+
let tableFooterResizeObserver: ResizeObserver | null = null;
|
|
472
532
|
onMounted(() => {
|
|
473
533
|
resizeTable();
|
|
474
534
|
window.addEventListener('resize', resizeTable);
|
|
@@ -495,7 +555,19 @@
|
|
|
495
555
|
ancestor = ancestor.parentElement;
|
|
496
556
|
}
|
|
497
557
|
}
|
|
558
|
+
tableWrapperResizeObserver = new ResizeObserver(() => resizeTable());
|
|
559
|
+
if (tableWrapperEl.value) {
|
|
560
|
+
tableWrapperResizeObserver.observe(tableWrapperEl.value);
|
|
561
|
+
}
|
|
562
|
+
tableFooterResizeObserver = new ResizeObserver(() => resizeTable());
|
|
563
|
+
if (tableFooterEl.value) {
|
|
564
|
+
tableFooterResizeObserver.observe(tableFooterEl.value);
|
|
565
|
+
}
|
|
498
566
|
resetQueryFormData(props.manualFetch);
|
|
567
|
+
nextTick(() => {
|
|
568
|
+
if (props.autoBoxSize) syncAutoViewportBox();
|
|
569
|
+
resizeTable();
|
|
570
|
+
});
|
|
499
571
|
});
|
|
500
572
|
const renderContent = (content: string | (() => any)) => {
|
|
501
573
|
if (isFunction(content)) {
|
|
@@ -519,15 +591,25 @@
|
|
|
519
591
|
...c,
|
|
520
592
|
}));
|
|
521
593
|
onBeforeUnmount(() => {
|
|
594
|
+
clearAutoViewportBox();
|
|
522
595
|
if (resizeRaf) cancelAnimationFrame(resizeRaf);
|
|
523
596
|
window.removeEventListener('resize', resizeTable);
|
|
524
597
|
observer.disconnect();
|
|
525
598
|
formWrapperResizeObserver?.disconnect();
|
|
526
599
|
boxElResizeObserver?.disconnect();
|
|
600
|
+
tableWrapperResizeObserver?.disconnect();
|
|
601
|
+
tableFooterResizeObserver?.disconnect();
|
|
527
602
|
});
|
|
528
603
|
</script>
|
|
529
604
|
<template>
|
|
530
|
-
<div
|
|
605
|
+
<div
|
|
606
|
+
ref="boxEl"
|
|
607
|
+
:class="[
|
|
608
|
+
'p-wrapper flex flex-col gap-8px overflow-y-auto',
|
|
609
|
+
autoBoxSize ? 'min-h-0 min-w-0 flex-1 w-full' : 'h-full',
|
|
610
|
+
]"
|
|
611
|
+
v-bind="attrs"
|
|
612
|
+
>
|
|
531
613
|
<div v-if="mode === 'bad'">请检查配置</div>
|
|
532
614
|
<template v-else>
|
|
533
615
|
<div
|
|
@@ -640,51 +722,72 @@
|
|
|
640
722
|
</div>
|
|
641
723
|
<div
|
|
642
724
|
ref="tableWrapperEl"
|
|
643
|
-
:class="`p-pane flex-1
|
|
725
|
+
:class="`p-pane flex-1 h-0 min-h-0 flex flex-col p-${scrollMode ?? 'inner'}-scroll`"
|
|
644
726
|
>
|
|
645
|
-
<div
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
727
|
+
<div class="p-grid-table-body flex-1 min-h-0 overflow-hidden">
|
|
728
|
+
<a-table
|
|
729
|
+
:key="renderTableKey + '_table'"
|
|
730
|
+
:row-key="rowKey ?? 'id'"
|
|
731
|
+
ref="tableEl"
|
|
732
|
+
:row-class-name="
|
|
733
|
+
striped ? (_record, index) => (index % 2 === 1 ? 'p-grid-row-striped' : '') : ''
|
|
734
|
+
"
|
|
735
|
+
:columns="passDefaultColumnProps(columns ?? []).map((c) => cleanCol(c as ColumnProps))"
|
|
736
|
+
:data-source="tableData"
|
|
737
|
+
:loading="loading.table"
|
|
738
|
+
:pagination="false"
|
|
739
|
+
v-bind="tc"
|
|
740
|
+
:scroll="{
|
|
741
|
+
x: 'max-content',
|
|
742
|
+
y: renderHeight,
|
|
743
|
+
}"
|
|
744
|
+
>
|
|
745
|
+
<template v-if="slotTitleColumns.length > 0" #headerCell="{ column }">
|
|
746
|
+
<render-title-slots
|
|
747
|
+
v-if="slotTitleColumns.some((s) => column.key && s.field === column.key)"
|
|
748
|
+
:key="renderTableKey + '_title_' + dataSeed + '_slot_' + column.key"
|
|
749
|
+
:column="slotTitleColumns.find((f) => column.key && f.field === column.key)!"
|
|
750
|
+
/>
|
|
751
|
+
</template>
|
|
752
|
+
<template v-if="slotDefaultColumns.length > 0" #bodyCell="{ column, record, index }">
|
|
753
|
+
<render-default-slots
|
|
754
|
+
v-if="slotDefaultColumns.some((s) => column.key && s.field === column.key)"
|
|
755
|
+
:key="renderTableKey + '_cell_' + dataSeed + '_slot_' + column.key"
|
|
756
|
+
:column="slotDefaultColumns.find((f) => column.key && f.field === column.key)!"
|
|
757
|
+
:default-handler="{ pick: pickRow, setLoadings }"
|
|
758
|
+
:row="record"
|
|
759
|
+
:row-index="index"
|
|
760
|
+
:table-data="tableData as Recordable[]"
|
|
761
|
+
/>
|
|
762
|
+
</template>
|
|
763
|
+
</a-table>
|
|
650
764
|
</div>
|
|
651
|
-
<
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
:
|
|
673
|
-
|
|
674
|
-
/>
|
|
675
|
-
</template>
|
|
676
|
-
<template v-if="slotDefaultColumns.length > 0" #bodyCell="{ column, record, index }">
|
|
677
|
-
<render-default-slots
|
|
678
|
-
v-if="slotDefaultColumns.some((s) => column.key && s.field === column.key)"
|
|
679
|
-
:key="renderTableKey + '_cell_' + dataSeed + '_slot_' + column.key"
|
|
680
|
-
:column="slotDefaultColumns.find((f) => column.key && f.field === column.key)!"
|
|
681
|
-
:default-handler="{ pick: pickRow, setLoadings }"
|
|
682
|
-
:row="record"
|
|
683
|
-
:row-index="index"
|
|
684
|
-
:table-data="tableData as Recordable[]"
|
|
765
|
+
<div ref="tableFooterEl" class="flex-shrink-0">
|
|
766
|
+
<div
|
|
767
|
+
v-if="mode !== 'pagination' && showSelectionCount"
|
|
768
|
+
class="w-full pt-8px px-16px text-slate-5"
|
|
769
|
+
>
|
|
770
|
+
已选:{{ selectedRowKeys.length }}
|
|
771
|
+
</div>
|
|
772
|
+
<div
|
|
773
|
+
v-else-if="mode === 'pagination'"
|
|
774
|
+
class="flex w-full items-center gap-12px pt-8px px-16px"
|
|
775
|
+
>
|
|
776
|
+
<div class="flex-1 min-w-0 text-slate-5 flex items-center">
|
|
777
|
+
<template v-if="showSelectionCount"> 已选:{{ selectedRowKeys.length }} </template>
|
|
778
|
+
</div>
|
|
779
|
+
<a-pagination
|
|
780
|
+
size="small"
|
|
781
|
+
:responsive="false"
|
|
782
|
+
:show-size-changer="true"
|
|
783
|
+
:show-total="(total: number) => `共${total}条数据`"
|
|
784
|
+
:current="pagination.page"
|
|
785
|
+
:page-size="pagination.size"
|
|
786
|
+
:total="totalCount"
|
|
787
|
+
@change="handlePaginationChange"
|
|
685
788
|
/>
|
|
686
|
-
</
|
|
687
|
-
</
|
|
789
|
+
</div>
|
|
790
|
+
</div>
|
|
688
791
|
</div>
|
|
689
792
|
</template>
|
|
690
793
|
</div>
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { defineComponent } from 'vue';
|
|
2
|
-
import { CellRender, RenderTableParams } from '#/antProxy';
|
|
3
|
-
import renderStore from '@/store/renderStore';
|
|
4
|
-
|
|
5
|
-
export default defineComponent(
|
|
6
|
-
<D extends Recordable = Recordable>(props: {
|
|
7
|
-
cellRender: CellRender;
|
|
8
|
-
renderTableParams: RenderTableParams<D>;
|
|
9
|
-
defaultHandler
|
|
10
|
-
[key: string]: (...args: any[]) => any;
|
|
11
|
-
};
|
|
12
|
-
}) => {
|
|
13
|
-
const { cellRender, renderTableParams } = props;
|
|
14
|
-
const { data, row, field, rowIndex } = renderTableParams!;
|
|
15
|
-
return () => {
|
|
16
|
-
return (
|
|
17
|
-
renderStore.renders[cellRender!.name]?.renderDefault?.(
|
|
18
|
-
cellRender!,
|
|
19
|
-
{ data, row, field, rowIndex },
|
|
20
|
-
props.defaultHandler,
|
|
21
|
-
) ?? null
|
|
22
|
-
);
|
|
23
|
-
};
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
name: 'RenderAntCell',
|
|
27
|
-
props: ['cellRender', 'renderTableParams', 'defaultHandler'],
|
|
28
|
-
},
|
|
29
|
-
);
|
|
1
|
+
import { defineComponent } from 'vue';
|
|
2
|
+
import { CellRender, RenderTableParams } from '#/antProxy';
|
|
3
|
+
import renderStore from '@/store/renderStore';
|
|
4
|
+
|
|
5
|
+
export default defineComponent(
|
|
6
|
+
<D extends Recordable = Recordable>(props: {
|
|
7
|
+
cellRender: CellRender;
|
|
8
|
+
renderTableParams: RenderTableParams<D>;
|
|
9
|
+
defaultHandler?: {
|
|
10
|
+
[key: string]: (...args: any[]) => any;
|
|
11
|
+
};
|
|
12
|
+
}) => {
|
|
13
|
+
const { cellRender, renderTableParams } = props;
|
|
14
|
+
const { data, row, field, rowIndex } = renderTableParams!;
|
|
15
|
+
return () => {
|
|
16
|
+
return (
|
|
17
|
+
renderStore.renders[cellRender!.name]?.renderDefault?.(
|
|
18
|
+
cellRender!,
|
|
19
|
+
{ data, row, field, rowIndex },
|
|
20
|
+
props.defaultHandler ?? {},
|
|
21
|
+
) ?? null
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'RenderAntCell',
|
|
27
|
+
props: ['cellRender', 'renderTableParams', 'defaultHandler'],
|
|
28
|
+
},
|
|
29
|
+
);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { defineComponent } from 'vue';
|
|
2
|
-
import { ColumnProps } from '#/antProxy';
|
|
2
|
+
import type { ColumnProps } from '#/antProxy';
|
|
3
3
|
import { renderAntFormat } from '@/utils/AFormatters';
|
|
4
4
|
import RenderAntCell from '@/components/RenderAntCell';
|
|
5
5
|
|
|
@@ -7,7 +7,11 @@ export default defineComponent(
|
|
|
7
7
|
<D extends Recordable = Recordable>(props: {
|
|
8
8
|
tableData: D[];
|
|
9
9
|
row: D;
|
|
10
|
-
|
|
10
|
+
/**
|
|
11
|
+
* `PGrid` / `columns` 仍为 `ColumnProps<D>[]`;此处不能写 `ColumnProps<D>`:
|
|
12
|
+
* 模板里 `a-table` 的 `record` 无泛型上下文,会被推断为 `Record<string, any>`,与 `formatter` 里 `row: D` 逆变冲突(TS2322)。
|
|
13
|
+
*/
|
|
14
|
+
column: ColumnProps<any>;
|
|
11
15
|
rowIndex: number;
|
|
12
16
|
defaultHandler?: {
|
|
13
17
|
[key: string]: (...args: any[]) => any;
|
|
@@ -30,7 +30,7 @@ import { computed, ref, Ref } from 'vue';
|
|
|
30
30
|
|
|
31
31
|
interface BtnOptions extends Omit<ButtonProps, 'type'> {
|
|
32
32
|
content?: string;
|
|
33
|
-
type?:
|
|
33
|
+
type?: ButtonProps['type'];
|
|
34
34
|
getContent?: (p: RenderTableParams) => string;
|
|
35
35
|
dynamicClassName?: (p: RenderTableParams) => string;
|
|
36
36
|
dropdowns?: BtnOptions[];
|
|
@@ -67,6 +67,22 @@
|
|
|
67
67
|
gap: 8px;
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
+
.gap-12px {
|
|
71
|
+
gap: 12px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.flex-shrink-0 {
|
|
75
|
+
flex-shrink: 0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
.min-w-0 {
|
|
79
|
+
min-width: 0;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.min-h-0 {
|
|
83
|
+
min-height: 0;
|
|
84
|
+
}
|
|
85
|
+
|
|
70
86
|
.pt-8px {
|
|
71
87
|
padding-top: 8px;
|
|
72
88
|
}
|
|
@@ -88,6 +104,10 @@
|
|
|
88
104
|
overflow-y: auto;
|
|
89
105
|
}
|
|
90
106
|
|
|
107
|
+
.overflow-hidden {
|
|
108
|
+
overflow: hidden;
|
|
109
|
+
}
|
|
110
|
+
|
|
91
111
|
/* #endregion */
|
|
92
112
|
|
|
93
113
|
/* #region P family styles */
|
|
@@ -273,7 +293,8 @@
|
|
|
273
293
|
}
|
|
274
294
|
}
|
|
275
295
|
.p-inner-scroll {
|
|
276
|
-
& > .ant-table-wrapper
|
|
296
|
+
& > .ant-table-wrapper,
|
|
297
|
+
& > .p-grid-table-body > .ant-table-wrapper {
|
|
277
298
|
height: 100%;
|
|
278
299
|
|
|
279
300
|
& > .ant-spin-nested-loading {
|