@vue-ui-kit/ant 2.1.6 → 2.1.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/dist/cjs/index.js +4 -4
- package/dist/es/index.js +2519 -2530
- package/package.json +1 -1
- package/src/packages/components/PCanvasGrid.vue +14 -20
- package/src/packages/components/PForm.vue +7 -12
- package/src/packages/components/PGrid.vue +10 -15
package/package.json
CHANGED
|
@@ -5,17 +5,7 @@
|
|
|
5
5
|
name="PCanvasGrid"
|
|
6
6
|
>
|
|
7
7
|
import PCanvasTable from './PCanvasTable.vue';
|
|
8
|
-
import {
|
|
9
|
-
computed,
|
|
10
|
-
useAttrs,
|
|
11
|
-
ref,
|
|
12
|
-
Ref,
|
|
13
|
-
reactive,
|
|
14
|
-
onMounted,
|
|
15
|
-
watch,
|
|
16
|
-
toRefs,
|
|
17
|
-
onBeforeUnmount,
|
|
18
|
-
} from 'vue';
|
|
8
|
+
import { computed, useAttrs, ref, Ref, reactive, onMounted, toRefs, onBeforeUnmount } from 'vue';
|
|
19
9
|
import {
|
|
20
10
|
debounce,
|
|
21
11
|
get,
|
|
@@ -50,7 +40,10 @@
|
|
|
50
40
|
import { DownOutlined } from '@ant-design/icons-vue';
|
|
51
41
|
import { getCanvasTableDefaults, getGridDefaults } from '@/utils/config';
|
|
52
42
|
import { eachTree } from '@/utils/treeHelper';
|
|
53
|
-
const props = defineProps<PCanvasGridProps<D, F>>()
|
|
43
|
+
const props = withDefaults(defineProps<PCanvasGridProps<D, F>>(), {
|
|
44
|
+
lazyReset: () => getGridDefaults().lazyReset ?? false,
|
|
45
|
+
fitHeight: () => getGridDefaults().fitCanvasHeight ?? 100,
|
|
46
|
+
});
|
|
54
47
|
const attrs = useAttrs();
|
|
55
48
|
const emit = defineEmits<{
|
|
56
49
|
(
|
|
@@ -67,18 +60,17 @@
|
|
|
67
60
|
|
|
68
61
|
const { formConfig, pageConfig, columns, toolbarConfig, proxyConfig, config, staticConfig } =
|
|
69
62
|
toRefs(props);
|
|
70
|
-
const gridDefaults = getGridDefaults();
|
|
71
63
|
const canvasTableDefaults = getCanvasTableDefaults();
|
|
72
64
|
const renderFormKey = ref(uuid_v4());
|
|
73
65
|
const queryFormData = ref<Partial<F>>({}) as Ref<Partial<F>>;
|
|
66
|
+
|
|
67
|
+
// 只处理 config 的合并,其他属性通过 withDefaults 处理
|
|
74
68
|
const propsWithDefaults = computed(() => ({
|
|
75
69
|
...props,
|
|
76
70
|
config: {
|
|
77
71
|
...canvasTableDefaults,
|
|
78
72
|
...props.config,
|
|
79
73
|
},
|
|
80
|
-
lazyReset: props.lazyReset ?? gridDefaults.lazyReset ?? false,
|
|
81
|
-
fitCanvasHeight: props.fitHeight ?? gridDefaults.fitCanvasHeight ?? 100,
|
|
82
74
|
}));
|
|
83
75
|
const mode = computed<'list' | 'pagination' | 'bad'>(() =>
|
|
84
76
|
proxyConfig.value && proxyConfig.value.ajax
|
|
@@ -162,14 +154,16 @@
|
|
|
162
154
|
const selectedRecords = computed<D[]>(() =>
|
|
163
155
|
uniq(
|
|
164
156
|
Object.values(pageSelections.value).flat(),
|
|
165
|
-
(f) => f[
|
|
157
|
+
(f) => f[propsWithDefaults.value.config?.ROW_KEY ?? 'id'] as string | number,
|
|
166
158
|
),
|
|
167
159
|
);
|
|
168
160
|
const handleFormSubmit = () => {
|
|
169
161
|
resetPage();
|
|
170
162
|
};
|
|
171
163
|
const selectedRowKeys = computed<Array<string | number>>(() =>
|
|
172
|
-
selectedRecords.value.map(
|
|
164
|
+
selectedRecords.value.map(
|
|
165
|
+
(f) => f[propsWithDefaults.value.config?.ROW_KEY ?? 'id'] as string | number,
|
|
166
|
+
),
|
|
173
167
|
);
|
|
174
168
|
const handleResponse = (response: Recordable, pathConfig?: ResponsePathConfig<D>) =>
|
|
175
169
|
pathConfig
|
|
@@ -393,7 +387,7 @@
|
|
|
393
387
|
const showCountHeight = staticConfig.value?.showCount ? 22 : 0;
|
|
394
388
|
renderHeight.value =
|
|
395
389
|
toNumber(ph.replace('px', '')) -
|
|
396
|
-
|
|
390
|
+
props.fitHeight -
|
|
397
391
|
(props.toolbarConfig ? 30 : 0) -
|
|
398
392
|
formHeight -
|
|
399
393
|
showCountHeight;
|
|
@@ -464,7 +458,7 @@
|
|
|
464
458
|
:key="`_col_${item.field || idx}`"
|
|
465
459
|
:form-data="queryFormData"
|
|
466
460
|
:item="item as PFormItemProps<Partial<F>>"
|
|
467
|
-
@reset="resetQueryFormData(
|
|
461
|
+
@reset="resetQueryFormData(props.lazyReset)"
|
|
468
462
|
/>
|
|
469
463
|
</a-row>
|
|
470
464
|
</a-form>
|
|
@@ -551,7 +545,7 @@
|
|
|
551
545
|
ref="canvasTableRef"
|
|
552
546
|
:columns="finalColumns"
|
|
553
547
|
:config="{
|
|
554
|
-
...config,
|
|
548
|
+
...propsWithDefaults.config,
|
|
555
549
|
HEIGHT: renderHeight,
|
|
556
550
|
}"
|
|
557
551
|
@selection-change="handleSelectionChange"
|
|
@@ -9,17 +9,12 @@
|
|
|
9
9
|
import PFormCol from '@/components/PFormCol.vue';
|
|
10
10
|
import { Form as AForm, Row as ARow } from 'ant-design-vue';
|
|
11
11
|
|
|
12
|
-
const props = defineProps<PFormProps<F> & { data: F }>()
|
|
12
|
+
const props = withDefaults(defineProps<PFormProps<F> & { data: F }>(), {
|
|
13
|
+
labelCol: () => getFormDefaults().labelCol ?? { span: 6 },
|
|
14
|
+
wrapperCol: () => getFormDefaults().wrapperCol ?? { span: 16 },
|
|
15
|
+
});
|
|
13
16
|
const emit = defineEmits(['apply', 'reset']);
|
|
14
17
|
|
|
15
|
-
// 应用默认值
|
|
16
|
-
const formDefaults = getFormDefaults();
|
|
17
|
-
const propsWithDefaults = computed(() => ({
|
|
18
|
-
...props,
|
|
19
|
-
labelCol: props.labelCol ?? formDefaults.labelCol ?? { span: 6 },
|
|
20
|
-
wrapperCol: props.wrapperCol ?? formDefaults.wrapperCol ?? { span: 16 },
|
|
21
|
-
}));
|
|
22
|
-
|
|
23
18
|
const { items, data: formData } = toRefs(props);
|
|
24
19
|
|
|
25
20
|
function handleSubmit() {
|
|
@@ -57,9 +52,9 @@
|
|
|
57
52
|
};
|
|
58
53
|
// omit({labelCol:defaultLabelCol,...props},['items','data','model'])
|
|
59
54
|
const fc = computed(() => ({
|
|
60
|
-
...omit(
|
|
61
|
-
labelCol:
|
|
62
|
-
wrapperCol:
|
|
55
|
+
...omit(props, ['items', 'data', 'model', 'labelCol', 'wrapperCol']),
|
|
56
|
+
labelCol: props.labelCol,
|
|
57
|
+
wrapperCol: props.wrapperCol,
|
|
63
58
|
}));
|
|
64
59
|
const validateField = (fields?: string | string[]) => {
|
|
65
60
|
if (fields) {
|
|
@@ -49,18 +49,13 @@
|
|
|
49
49
|
import { TablePaginationConfig } from 'ant-design-vue/es/table/interface';
|
|
50
50
|
import { DownOutlined } from '@ant-design/icons-vue';
|
|
51
51
|
|
|
52
|
-
const props = defineProps<PGridProps<D, F>>()
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
scrollMode: props.scrollMode ?? 'inner',
|
|
60
|
-
align: props.align ?? gridDefaults.align ?? 'left',
|
|
61
|
-
lazyReset: props.lazyReset ?? gridDefaults.lazyReset ?? false,
|
|
62
|
-
fitHeight: props.fitHeight ?? gridDefaults.fitHeight ?? 170,
|
|
63
|
-
}));
|
|
52
|
+
const props = withDefaults(defineProps<PGridProps<D, F>>(), {
|
|
53
|
+
rowKey: 'id',
|
|
54
|
+
scrollMode: 'inner',
|
|
55
|
+
align: () => getGridDefaults().align ?? 'left',
|
|
56
|
+
lazyReset: () => getGridDefaults().lazyReset ?? false,
|
|
57
|
+
fitHeight: () => getGridDefaults().fitHeight ?? 170,
|
|
58
|
+
});
|
|
64
59
|
|
|
65
60
|
const {
|
|
66
61
|
formConfig,
|
|
@@ -440,7 +435,7 @@
|
|
|
440
435
|
renderHeight.value =
|
|
441
436
|
props.renderY ??
|
|
442
437
|
toNumber(ph.replace('px', '')) -
|
|
443
|
-
|
|
438
|
+
props.fitHeight -
|
|
444
439
|
(props.toolbarConfig ? 30 : 0) -
|
|
445
440
|
formHeight -
|
|
446
441
|
showCountHeight;
|
|
@@ -491,7 +486,7 @@
|
|
|
491
486
|
columns.map((c) => ({
|
|
492
487
|
...passFields.reduce(
|
|
493
488
|
(prev, cur) => ({
|
|
494
|
-
[cur]:
|
|
489
|
+
[cur]: props[cur],
|
|
495
490
|
}),
|
|
496
491
|
{} as ColumnProps<D>,
|
|
497
492
|
),
|
|
@@ -525,7 +520,7 @@
|
|
|
525
520
|
:key="`_col_${item.field || idx}`"
|
|
526
521
|
:form-data="queryFormData"
|
|
527
522
|
:item="item as PFormItemProps<Partial<F>>"
|
|
528
|
-
@reset="resetQueryFormData(
|
|
523
|
+
@reset="resetQueryFormData(props.lazyReset)"
|
|
529
524
|
/>
|
|
530
525
|
</a-row>
|
|
531
526
|
</a-form>
|