@vue-ui-kit/ant 2.1.5 → 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 +2848 -2843
- package/package.json +1 -1
- package/src/packages/components/PCanvasGrid.vue +26 -20
- package/src/packages/components/PForm.vue +7 -12
- package/src/packages/components/PGrid.vue +14 -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>
|
|
@@ -490,6 +484,10 @@
|
|
|
490
484
|
:size="btn.size ?? 'middle'"
|
|
491
485
|
:disabled="toolbarConfig.disabled || btn.disabled"
|
|
492
486
|
:loading="loading.toolbar || (!!btn.code && codeLoadings[btn.code])"
|
|
487
|
+
:danger="btn.danger"
|
|
488
|
+
:shape="btn.shape"
|
|
489
|
+
:ghost="btn.ghost"
|
|
490
|
+
:block="btn.block"
|
|
493
491
|
>
|
|
494
492
|
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
495
493
|
{{ btn.content }}
|
|
@@ -502,6 +500,10 @@
|
|
|
502
500
|
:size="btn.size ?? 'middle'"
|
|
503
501
|
:disabled="toolbarConfig.disabled || btn.disabled"
|
|
504
502
|
:loading="loading.toolbar || (!!btn.code && codeLoadings[btn.code])"
|
|
503
|
+
:danger="btn.danger"
|
|
504
|
+
:shape="btn.shape"
|
|
505
|
+
:ghost="btn.ghost"
|
|
506
|
+
:block="btn.block"
|
|
505
507
|
@click="debounceToolBtnClick(btn.code)"
|
|
506
508
|
>
|
|
507
509
|
<Icon v-if="btn.icon" :icon="btn.icon" />
|
|
@@ -519,6 +521,10 @@
|
|
|
519
521
|
:type="tool.type"
|
|
520
522
|
:size="tool.size ?? 'middle'"
|
|
521
523
|
:disabled="toolbarConfig.disabled || tool.disabled"
|
|
524
|
+
:danger="tool.danger"
|
|
525
|
+
:shape="tool.shape"
|
|
526
|
+
:ghost="tool.ghost"
|
|
527
|
+
:block="tool.block"
|
|
522
528
|
@click="debounceToolToolClick(tool.code)"
|
|
523
529
|
:loading="loading.toolbar || (!!tool.code && codeLoadings[tool.code])"
|
|
524
530
|
>
|
|
@@ -539,7 +545,7 @@
|
|
|
539
545
|
ref="canvasTableRef"
|
|
540
546
|
:columns="finalColumns"
|
|
541
547
|
:config="{
|
|
542
|
-
...config,
|
|
548
|
+
...propsWithDefaults.config,
|
|
543
549
|
HEIGHT: renderHeight,
|
|
544
550
|
}"
|
|
545
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>
|
|
@@ -567,6 +562,10 @@
|
|
|
567
562
|
:size="btn.size ?? 'middle'"
|
|
568
563
|
:disabled="toolbarConfig.disabled || btn.disabled"
|
|
569
564
|
:loading="loading.toolbar || (!!btn.code && codeLoadings[btn.code])"
|
|
565
|
+
:danger="btn.danger"
|
|
566
|
+
:shape="btn.shape"
|
|
567
|
+
:ghost="btn.ghost"
|
|
568
|
+
:block="btn.block"
|
|
570
569
|
@click="debounceToolBtnClick(btn.code)"
|
|
571
570
|
>
|
|
572
571
|
<Icon v-if="btn.icon" :icon="btn.icon" />
|