@vue-ui-kit/ant 2.0.5 → 2.0.7
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 +1393 -1393
- package/dist/cjs/index.js +3 -3
- package/dist/declarations/antProxy.d.ts +5 -1
- package/dist/es/index.js +1342 -1304
- package/dist/packages/utils/core.d.ts +2 -0
- package/package.json +1 -1
- package/src/declarations/antProxy.ts +5 -1
- package/src/packages/components/PCanvasGrid.vue +34 -13
- package/src/packages/components/PCanvasTable.vue +2 -1
- package/src/packages/components/PFormCol.vue +61 -43
- package/src/packages/components/PFormGroup.vue +4 -1
- package/src/packages/utils/core.ts +22 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ColumnProps, Responsive } from '../../declarations/antProxy';
|
|
2
2
|
import { TableColumnGroupType, TableColumnType } from 'ant-design-vue';
|
|
3
|
+
import { WatchOptions, WatchSource } from 'vue';
|
|
3
4
|
export declare const cleanCol: (col: ColumnProps) => TableColumnType | TableColumnGroupType<Recordable>;
|
|
4
5
|
export declare const defaultItemResponsive: Responsive;
|
|
5
6
|
export declare const defaultLabelCol: Responsive;
|
|
6
7
|
export declare const labelColDict: Record<number, Responsive>;
|
|
7
8
|
export declare const get24rest: (exist: number[]) => number;
|
|
8
9
|
export declare const getButtonResponsive: (itemResponsive: number | Responsive[]) => any;
|
|
10
|
+
export declare function watchPreviousDeep<T extends object>(source: WatchSource<T>, cb: (value: T, oldValue: T, onCleanup: () => void) => void, options?: WatchOptions): import('vue').WatchHandle;
|
package/package.json
CHANGED
|
@@ -338,7 +338,11 @@ export interface PCanvasGridProps<
|
|
|
338
338
|
D extends Recordable = Recordable,
|
|
339
339
|
F extends Recordable = Recordable,
|
|
340
340
|
> {
|
|
341
|
-
|
|
341
|
+
staticConfig?: {
|
|
342
|
+
selectable?: boolean;
|
|
343
|
+
showCount?: boolean;
|
|
344
|
+
tree?: boolean;
|
|
345
|
+
};
|
|
342
346
|
manualFetch?: boolean;
|
|
343
347
|
formConfig?: PFormProps<F>;
|
|
344
348
|
columns: CanvasColumnProps<D>[];
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
(event: 'resetQuery'): void;
|
|
66
66
|
}>();
|
|
67
67
|
|
|
68
|
-
const { formConfig, pageConfig, columns, toolbarConfig, proxyConfig, config,
|
|
68
|
+
const { formConfig, pageConfig, columns, toolbarConfig, proxyConfig, config, staticConfig } =
|
|
69
69
|
toRefs(props);
|
|
70
70
|
const gridDefaults = getGridDefaults();
|
|
71
71
|
const canvasTableDefaults = getCanvasTableDefaults();
|
|
@@ -307,19 +307,40 @@
|
|
|
307
307
|
break;
|
|
308
308
|
}
|
|
309
309
|
};
|
|
310
|
-
const finalColumns = computed<CanvasColumnProps<D>[]>(() =>
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
310
|
+
const finalColumns = computed<CanvasColumnProps<D>[]>(() => {
|
|
311
|
+
if (!staticConfig.value || (!staticConfig.value.selectable && !staticConfig.value.tree)) {
|
|
312
|
+
return columns.value;
|
|
313
|
+
}
|
|
314
|
+
const firstColumn: CanvasColumnProps<D> =
|
|
315
|
+
staticConfig.value.selectable && staticConfig.value.tree
|
|
316
|
+
? {
|
|
317
|
+
type: 'tree-selection',
|
|
315
318
|
width: 40,
|
|
316
319
|
widthFillDisable: true,
|
|
317
320
|
title: '',
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
321
|
+
}
|
|
322
|
+
: staticConfig.value.selectable
|
|
323
|
+
? {
|
|
324
|
+
type: 'selection',
|
|
325
|
+
width: 40,
|
|
326
|
+
widthFillDisable: true,
|
|
327
|
+
title: '',
|
|
328
|
+
}
|
|
329
|
+
: staticConfig.value.tree
|
|
330
|
+
? {
|
|
331
|
+
type: 'tree',
|
|
332
|
+
width: 40,
|
|
333
|
+
widthFillDisable: true,
|
|
334
|
+
title: '',
|
|
335
|
+
}
|
|
336
|
+
: {
|
|
337
|
+
type: 'index',
|
|
338
|
+
width: 40,
|
|
339
|
+
widthFillDisable: true,
|
|
340
|
+
title: '',
|
|
341
|
+
};
|
|
342
|
+
return [firstColumn, ...columns.value];
|
|
343
|
+
});
|
|
323
344
|
const resetQueryFormData = (lazy?: boolean) => {
|
|
324
345
|
if (formConfig.value && formConfig.value.items.length > 0) {
|
|
325
346
|
if (formConfig.value.customReset) {
|
|
@@ -364,7 +385,7 @@
|
|
|
364
385
|
const formHeight = formOriginHeight.includes('px')
|
|
365
386
|
? toNumber(formOriginHeight.replace('px', ''))
|
|
366
387
|
: 0;
|
|
367
|
-
const showCountHeight =
|
|
388
|
+
const showCountHeight = staticConfig.value?.showCount ? 22 : 0;
|
|
368
389
|
renderHeight.value =
|
|
369
390
|
toNumber(ph.replace('px', '')) -
|
|
370
391
|
propsWithDefaults.value.fitCanvasHeight -
|
|
@@ -502,7 +523,7 @@
|
|
|
502
523
|
</div>
|
|
503
524
|
<div :class="`p-pane flex-1 h-0 p-inner-scroll`">
|
|
504
525
|
<div
|
|
505
|
-
v-if="
|
|
526
|
+
v-if="staticConfig?.selectable && staticConfig.showCount"
|
|
506
527
|
class="w-full text-slate-5 pl-4"
|
|
507
528
|
>
|
|
508
529
|
已选:{{ selectedRowKeys.length }}
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
import { v4 as uuidv4 } from 'uuid';
|
|
22
22
|
import { antFormatters } from '@/utils/AFormatters';
|
|
23
23
|
import { getCanvasTableDefaults } from '@/utils/config';
|
|
24
|
+
import { watchPreviousDeep } from '@/utils/core';
|
|
24
25
|
|
|
25
26
|
const emit = defineEmits<{
|
|
26
27
|
(e: 'change', value: any[]): void; // 需要默认实现change,不能动态绑定
|
|
@@ -197,7 +198,7 @@
|
|
|
197
198
|
},
|
|
198
199
|
{ deep: true },
|
|
199
200
|
);
|
|
200
|
-
|
|
201
|
+
watchPreviousDeep(
|
|
201
202
|
() => props.columns,
|
|
202
203
|
(newValue, oldValue) => {
|
|
203
204
|
if (!isEqual(newValue, oldValue)) {
|
|
@@ -1,46 +1,50 @@
|
|
|
1
1
|
<script setup lang="ts" generic="T extends Recordable = Recordable">
|
|
2
|
-
import type { PFormItemProps } from '#/antProxy'
|
|
3
|
-
import { defaultItemResponsive } from '@/utils/core';
|
|
4
|
-
import RenderAntItem from '@/components/RenderAntItem';
|
|
5
|
-
import RenderItemSlots from '@/components/RenderItemSlots';
|
|
6
|
-
import { InfoCircleOutlined } from '@ant-design/icons-vue'
|
|
7
|
-
import { v4 as uuid_v4 } from 'uuid'
|
|
8
|
-
import { ref
|
|
9
|
-
import { isEqual,debounce, isFunction, omit } from 'xe-utils'
|
|
2
|
+
import type { PFormItemProps } from '#/antProxy';
|
|
3
|
+
import { defaultItemResponsive, watchPreviousDeep } from '@/utils/core';
|
|
4
|
+
import RenderAntItem from '@/components/RenderAntItem';
|
|
5
|
+
import RenderItemSlots from '@/components/RenderItemSlots';
|
|
6
|
+
import { InfoCircleOutlined } from '@ant-design/icons-vue';
|
|
7
|
+
import { v4 as uuid_v4 } from 'uuid';
|
|
8
|
+
import { ref } from 'vue';
|
|
9
|
+
import { isEqual, debounce, isFunction, omit } from 'xe-utils';
|
|
10
10
|
|
|
11
|
-
const props = defineProps<{
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}>()
|
|
15
|
-
const emit = defineEmits<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}>()
|
|
19
|
-
const hangOut = ref(false)
|
|
20
|
-
const renderFormKey = ref(uuid_v4())
|
|
21
|
-
const handleDelayTrigger = (cusFields?: string | string[], time?: number) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const handleTrigger = (cusFields?: string | string[]) => {
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
const resetFormData = () => {
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
const refreshCol = () => {
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
const debounceRefreshCol = debounce(refreshCol, 100)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
11
|
+
const props = defineProps<{
|
|
12
|
+
item: PFormItemProps<T>;
|
|
13
|
+
formData: T;
|
|
14
|
+
}>();
|
|
15
|
+
const emit = defineEmits<{
|
|
16
|
+
(e: 'trigger', cusFields?: string | string[]): void;
|
|
17
|
+
(e: 'reset'): void;
|
|
18
|
+
}>();
|
|
19
|
+
const hangOut = ref(false);
|
|
20
|
+
const renderFormKey = ref(uuid_v4());
|
|
21
|
+
const handleDelayTrigger = (cusFields?: string | string[], time?: number) => {
|
|
22
|
+
const delayTime = time ?? 222;
|
|
23
|
+
hangOut.value = true;
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
hangOut.value = false;
|
|
26
|
+
emit('trigger', cusFields);
|
|
27
|
+
}, delayTime);
|
|
28
|
+
};
|
|
29
|
+
const handleTrigger = (cusFields?: string | string[]) => {
|
|
30
|
+
emit('trigger', cusFields);
|
|
31
|
+
};
|
|
32
|
+
const resetFormData = () => {
|
|
33
|
+
emit('reset');
|
|
34
|
+
};
|
|
35
|
+
const refreshCol = () => {
|
|
36
|
+
renderFormKey.value = uuid_v4();
|
|
37
|
+
};
|
|
38
|
+
const debounceRefreshCol = debounce(refreshCol, 100);
|
|
39
|
+
watchPreviousDeep(
|
|
40
|
+
() => props.item,
|
|
41
|
+
(cur, old) => {
|
|
42
|
+
if (!isEqual(cur, old)) {
|
|
43
|
+
debounceRefreshCol();
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{ deep: true },
|
|
47
|
+
);
|
|
44
48
|
</script>
|
|
45
49
|
|
|
46
50
|
<template>
|
|
@@ -58,7 +62,18 @@ watch(() => props.item, (cur, old) => {
|
|
|
58
62
|
:label="item.title"
|
|
59
63
|
:name="item.field"
|
|
60
64
|
:wrapper-col="item.wrapperCol ?? (item.title ? undefined : { span: 24 })"
|
|
61
|
-
v-bind="
|
|
65
|
+
v-bind="
|
|
66
|
+
omit(item, [
|
|
67
|
+
'field',
|
|
68
|
+
'title',
|
|
69
|
+
'span',
|
|
70
|
+
'col',
|
|
71
|
+
'wrapperCol',
|
|
72
|
+
'itemRender',
|
|
73
|
+
'forceRequired',
|
|
74
|
+
'tooltip',
|
|
75
|
+
])
|
|
76
|
+
"
|
|
62
77
|
>
|
|
63
78
|
<template v-if="item.slots?.title" #label>
|
|
64
79
|
<component :is="item.slots.title" />
|
|
@@ -82,7 +97,10 @@ watch(() => props.item, (cur, old) => {
|
|
|
82
97
|
/>
|
|
83
98
|
<span v-else />
|
|
84
99
|
<template v-if="item.tooltipConfig" #tooltip>
|
|
85
|
-
<a-tooltip
|
|
100
|
+
<a-tooltip
|
|
101
|
+
v-if="isFunction(item.tooltipConfig.title)"
|
|
102
|
+
v-bind="omit(item.tooltipConfig, ['title'])"
|
|
103
|
+
>
|
|
86
104
|
<info-circle-outlined class="cursor-pointer py-4 px-2" />
|
|
87
105
|
<template #title>
|
|
88
106
|
<div v-html="item.tooltipConfig.title()" />
|
|
@@ -52,7 +52,10 @@
|
|
|
52
52
|
{ content: '复制', code: 'copy' },
|
|
53
53
|
{ content: '删除', code: 'delete' },
|
|
54
54
|
];
|
|
55
|
-
const getPopupContainer = () =>
|
|
55
|
+
const getPopupContainer = (el: HTMLElement) =>
|
|
56
|
+
el?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement?.parentElement ??
|
|
57
|
+
rootRef.value?.$el ??
|
|
58
|
+
document.body;
|
|
56
59
|
// 实际是否强制渲染
|
|
57
60
|
const fr = computed(() => {
|
|
58
61
|
return props.forceRender || model.value.length <= 5;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ColumnProps, Responsive } from '#/antProxy';
|
|
2
2
|
import { TableColumnGroupType, TableColumnType } from 'ant-design-vue';
|
|
3
|
-
import { isArray, isNumber, omit, zipObject } from 'xe-utils';
|
|
3
|
+
import { clone, isArray, isNumber, omit, zipObject } from 'xe-utils';
|
|
4
4
|
import { valued } from '@/utils/is';
|
|
5
|
+
import { toValue, watch, WatchCallback, WatchOptions, WatchSource } from 'vue';
|
|
5
6
|
|
|
6
7
|
export const cleanCol = (col: ColumnProps): TableColumnType | TableColumnGroupType<Recordable> => {
|
|
7
8
|
return {
|
|
@@ -50,3 +51,23 @@ export const getButtonResponsive = (itemResponsive: number | Responsive[]) => {
|
|
|
50
51
|
),
|
|
51
52
|
);
|
|
52
53
|
};
|
|
54
|
+
|
|
55
|
+
export function watchPreviousDeep<T extends object>(
|
|
56
|
+
source: WatchSource<T>,
|
|
57
|
+
cb: (value: T, oldValue: T, onCleanup: () => void) => void,
|
|
58
|
+
options?: WatchOptions,
|
|
59
|
+
) {
|
|
60
|
+
const val = toValue(source);
|
|
61
|
+
if (typeof val !== 'object' || val === null) {
|
|
62
|
+
return watch(source, cb as WatchCallback<T>, options);
|
|
63
|
+
}
|
|
64
|
+
let previousValue = clone(val) as T;
|
|
65
|
+
return watch(
|
|
66
|
+
source,
|
|
67
|
+
(crtValue, _, onCleanup) => {
|
|
68
|
+
cb(crtValue as T, previousValue, onCleanup as () => void);
|
|
69
|
+
previousValue = clone(crtValue) as T;
|
|
70
|
+
},
|
|
71
|
+
options,
|
|
72
|
+
);
|
|
73
|
+
}
|