@vue-ui-kit/ant 1.8.0 → 1.8.3
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 +1 -1
- package/dist/declarations/antProxy.d.ts +1 -0
- package/dist/es/index.js +1751 -1766
- package/dist/index.d.ts +5 -1
- package/dist/packages/components/PFormCol.vue.d.ts +1 -4
- package/dist/packages/renders/TableInput.vue.d.ts +3 -3
- package/dist/packages/utils/config.d.ts +17 -0
- package/dist/style.css +1 -1
- package/dist/style.scss +301 -0
- package/dist/variables.scss +3 -0
- package/package.json +3 -2
- package/src/declarations/antProxy.ts +2 -0
- package/src/index.ts +16 -0
- package/src/packages/components/PForm.vue +14 -10
- package/src/packages/components/PFormCol.vue +11 -3
- package/src/packages/components/PGrid.vue +26 -80
- package/src/packages/styles/index.scss +52 -1
- package/src/packages/utils/config.ts +72 -0
|
@@ -14,29 +14,38 @@
|
|
|
14
14
|
import { debounce, get, isArray, isBoolean, isFunction, isObject, isString, merge, omit, toNumber } from 'xe-utils';
|
|
15
15
|
import { eachTree } from '@/utils/treeHelper';
|
|
16
16
|
import { message as $message } from 'ant-design-vue';
|
|
17
|
-
import RenderAntItem from '@/components/RenderAntItem';
|
|
18
17
|
import RenderTitleSlots from '@/components/RenderTitleSlots';
|
|
19
18
|
import RenderDefaultSlots from '@/components/RenderDefaultSlots';
|
|
20
19
|
import { v4 as uuid_v4 } from 'uuid';
|
|
21
|
-
import { isGoodValue
|
|
22
|
-
import
|
|
23
|
-
import { cleanCol,
|
|
20
|
+
import { isGoodValue } from '@/utils/is';
|
|
21
|
+
import PFormCol from '@/components/PFormCol.vue';
|
|
22
|
+
import { cleanCol, defaultLabelCol } from '@/utils/core';
|
|
23
|
+
import { getGridDefaults } from '@/utils/config';
|
|
24
24
|
import Icon from '@/renders/Icon';
|
|
25
25
|
import { $confirm } from '@/hooks/useMessage';
|
|
26
26
|
import {
|
|
27
27
|
Table as ATable,
|
|
28
28
|
Button as AButton,
|
|
29
29
|
Form as AForm,
|
|
30
|
-
FormItem as AFormItem,
|
|
31
30
|
Row as ARow,
|
|
32
|
-
Col as ACol,
|
|
33
31
|
Spin as ASpin,
|
|
34
|
-
Tooltip as ATooltip,
|
|
35
32
|
} from 'ant-design-vue';
|
|
36
33
|
import { TablePaginationConfig } from 'ant-design-vue/es/table/interface';
|
|
37
|
-
import {
|
|
34
|
+
import { DownOutlined } from '@ant-design/icons-vue';
|
|
38
35
|
|
|
39
36
|
const props = defineProps<PGridProps<D, F>>();
|
|
37
|
+
|
|
38
|
+
// 应用默认值
|
|
39
|
+
const gridDefaults = getGridDefaults();
|
|
40
|
+
const propsWithDefaults = computed(() => ({
|
|
41
|
+
...props,
|
|
42
|
+
rowKey: props.rowKey ?? 'id',
|
|
43
|
+
scrollMode: props.scrollMode ?? 'inner',
|
|
44
|
+
align: props.align ?? gridDefaults.align ?? 'left',
|
|
45
|
+
lazyReset: props.lazyReset ?? gridDefaults.lazyReset ?? false,
|
|
46
|
+
fitHeight: props.fitHeight ?? gridDefaults.fitHeight ?? 170,
|
|
47
|
+
}));
|
|
48
|
+
|
|
40
49
|
const {
|
|
41
50
|
formConfig,
|
|
42
51
|
pageConfig,
|
|
@@ -63,7 +72,6 @@
|
|
|
63
72
|
loading.toolbar = value;
|
|
64
73
|
}
|
|
65
74
|
};
|
|
66
|
-
const submitOnReset = true;
|
|
67
75
|
const boxEl = ref<HTMLDivElement>();
|
|
68
76
|
const pFormWrapper = ref<HTMLDivElement>();
|
|
69
77
|
const renderHeight = ref(500);
|
|
@@ -118,9 +126,7 @@
|
|
|
118
126
|
const tableEl = ref();
|
|
119
127
|
const renderFormKey = ref(uuid_v4());
|
|
120
128
|
const renderTableKey = ref(uuid_v4());
|
|
121
|
-
|
|
122
|
-
renderFormKey.value = uuid_v4();
|
|
123
|
-
};
|
|
129
|
+
|
|
124
130
|
const codeLoadings = reactive<Record<string, boolean>>(
|
|
125
131
|
[
|
|
126
132
|
...(props.toolbarConfig?.buttons?.map((m) => m.code) ?? []).filter((f) => f),
|
|
@@ -139,7 +145,6 @@
|
|
|
139
145
|
const refreshTable = () => {
|
|
140
146
|
renderTableKey.value = uuid_v4();
|
|
141
147
|
};
|
|
142
|
-
const debounceRefreshForm = debounce(refreshForm, 100);
|
|
143
148
|
const debounceRefreshTable = debounce(refreshTable, 100);
|
|
144
149
|
const slotDefaultColumns = computed(() => {
|
|
145
150
|
const cols: ColumnProps<D>[] = [];
|
|
@@ -237,7 +242,6 @@
|
|
|
237
242
|
queryFormData.value = obj;
|
|
238
243
|
}
|
|
239
244
|
emit('resetQuery');
|
|
240
|
-
refreshForm();
|
|
241
245
|
}
|
|
242
246
|
|
|
243
247
|
pagination.page = 1;
|
|
@@ -397,13 +401,6 @@
|
|
|
397
401
|
resetPage();
|
|
398
402
|
};
|
|
399
403
|
|
|
400
|
-
watch(
|
|
401
|
-
() => formConfig.value,
|
|
402
|
-
() => {
|
|
403
|
-
debounceRefreshForm();
|
|
404
|
-
},
|
|
405
|
-
{ deep: true },
|
|
406
|
-
);
|
|
407
404
|
watch(
|
|
408
405
|
() => [columns.value, proxyConfig.value, toolbarConfig.value],
|
|
409
406
|
() => {
|
|
@@ -423,7 +420,7 @@
|
|
|
423
420
|
const showCountHeight = selectConfig.value?.showCount ? 22 : 0
|
|
424
421
|
renderHeight.value =
|
|
425
422
|
props.renderY ??
|
|
426
|
-
toNumber(ph.replace('px', '')) -
|
|
423
|
+
toNumber(ph.replace('px', '')) -propsWithDefaults.value.fitHeight -(props.toolbarConfig ? 30 : 0) -formHeight- showCountHeight;
|
|
427
424
|
enoughSpacing.value = toNumber(ph.replace('px', '')) > 600;
|
|
428
425
|
};
|
|
429
426
|
defineExpose({
|
|
@@ -468,7 +465,7 @@
|
|
|
468
465
|
const passFields = ['align']
|
|
469
466
|
const passDefaultColumnProps = (columns: ColumnProps<D>[]) => columns.map(c => ({
|
|
470
467
|
...passFields.reduce((prev, cur) => ({
|
|
471
|
-
[cur]:
|
|
468
|
+
[cur]: propsWithDefaults.value[cur],
|
|
472
469
|
}), {} as ColumnProps<D>),
|
|
473
470
|
...c,
|
|
474
471
|
}))
|
|
@@ -495,64 +492,13 @@
|
|
|
495
492
|
@submit="handleFormSubmit"
|
|
496
493
|
>
|
|
497
494
|
<a-row :gutter="[6, 12]">
|
|
498
|
-
<
|
|
495
|
+
<p-form-col
|
|
499
496
|
v-for="(item, idx) in formConfig!.items"
|
|
500
|
-
:key="
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
:class="`p-content-align-${item.align ?? 'left'} ${item.forceRequired ? 'p-required' : ''}`"
|
|
506
|
-
:label="item.title"
|
|
507
|
-
:name="item.field"
|
|
508
|
-
v-bind="
|
|
509
|
-
omit(item, [
|
|
510
|
-
'field',
|
|
511
|
-
'title',
|
|
512
|
-
'span',
|
|
513
|
-
'col',
|
|
514
|
-
'itemRender',
|
|
515
|
-
'forceRequired',
|
|
516
|
-
'tooltip',
|
|
517
|
-
])
|
|
518
|
-
"
|
|
519
|
-
>
|
|
520
|
-
<render-item-slots
|
|
521
|
-
v-if="item.slots?.default"
|
|
522
|
-
:key="'_sl_' + (item.field ?? '_') + '_' + idx"
|
|
523
|
-
:form-data="queryFormData"
|
|
524
|
-
:item="item"
|
|
525
|
-
:pass-trigger="() => {}"
|
|
526
|
-
:pass-delay-trigger="() => {}"
|
|
527
|
-
/>
|
|
528
|
-
<render-ant-item
|
|
529
|
-
v-else-if="item.itemRender?.name"
|
|
530
|
-
:key="'_re_' + (item.field ?? '_') + '_' + idx"
|
|
531
|
-
:default-handler="{
|
|
532
|
-
reset: () => {
|
|
533
|
-
resetQueryFormData(!submitOnReset);
|
|
534
|
-
},
|
|
535
|
-
}"
|
|
536
|
-
:item-render="item.itemRender"
|
|
537
|
-
:render-form-params="{ data: queryFormData, field: item.field }"
|
|
538
|
-
/>
|
|
539
|
-
<span v-else></span>
|
|
540
|
-
<template #tooltip v-if="item.tooltipConfig">
|
|
541
|
-
<a-tooltip
|
|
542
|
-
v-if="isFunction(item.tooltipConfig.title)"
|
|
543
|
-
v-bind="omit(item.tooltipConfig, ['title'])"
|
|
544
|
-
>
|
|
545
|
-
<InfoCircleOutlined class="cursor-pointer py-4x px-2x" />
|
|
546
|
-
<template #title>
|
|
547
|
-
<div v-html="item.tooltipConfig.title()"></div>
|
|
548
|
-
</template>
|
|
549
|
-
</a-tooltip>
|
|
550
|
-
<a-tooltip v-else v-bind="item.tooltipConfig">
|
|
551
|
-
<InfoCircleOutlined class="cursor-pointer py-4x px-2x" />
|
|
552
|
-
</a-tooltip>
|
|
553
|
-
</template>
|
|
554
|
-
</a-form-item>
|
|
555
|
-
</a-col>
|
|
497
|
+
:key="`_col_${idx}`"
|
|
498
|
+
:form-data="queryFormData"
|
|
499
|
+
:item="item as PFormItemProps<Partial<F>>"
|
|
500
|
+
@reset="resetQueryFormData(propsWithDefaults.lazyReset)"
|
|
501
|
+
/>
|
|
556
502
|
</a-row>
|
|
557
503
|
</a-form>
|
|
558
504
|
</a-spin>
|
|
@@ -99,7 +99,37 @@
|
|
|
99
99
|
.p-form-wrapper {
|
|
100
100
|
z-index: 4;
|
|
101
101
|
}
|
|
102
|
-
|
|
102
|
+
.p-error-hang-out {
|
|
103
|
+
.ant-input-affix-wrapper-status-error:not(
|
|
104
|
+
.ant-input-affix-wrapper-disabled
|
|
105
|
+
):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper {
|
|
106
|
+
border-color: #d9d9d9 !important;
|
|
107
|
+
|
|
108
|
+
&:focus {
|
|
109
|
+
border-color: #4096ff !important;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
.ant-form-item-explain-error {
|
|
113
|
+
opacity: 0 !important;
|
|
114
|
+
transform: translateY(-10px) !important;
|
|
115
|
+
max-height: 0 !important;
|
|
116
|
+
overflow: hidden !important;
|
|
117
|
+
transition: none !important;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
.ant-form-item-explain-error {
|
|
121
|
+
opacity: 0;
|
|
122
|
+
transform: translateY(-10px);
|
|
123
|
+
max-height: 0;
|
|
124
|
+
overflow: hidden;
|
|
125
|
+
transition: opacity 0.3s ease-out 0.3s, transform 0.3s ease-out 0.3s,
|
|
126
|
+
max-height 0.3s ease-out 0.3s;
|
|
127
|
+
}
|
|
128
|
+
.ant-form-item-has-error .ant-form-item-explain-error {
|
|
129
|
+
opacity: 1;
|
|
130
|
+
transform: translateY(0);
|
|
131
|
+
max-height: 100px;
|
|
132
|
+
}
|
|
103
133
|
.p-toolbar-wrapper {
|
|
104
134
|
box-shadow: 0 8px #fff;
|
|
105
135
|
border-radius: 0.5em 0.5em 0 0;
|
|
@@ -219,6 +249,27 @@
|
|
|
219
249
|
animation: heartbeat 2s infinite;
|
|
220
250
|
}
|
|
221
251
|
}
|
|
252
|
+
.p-error-hang-out {
|
|
253
|
+
.ant-input-affix-wrapper-status-error:not(
|
|
254
|
+
.ant-input-affix-wrapper-disabled
|
|
255
|
+
):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper {
|
|
256
|
+
border-color: #d9d9d9 !important;
|
|
257
|
+
|
|
258
|
+
&:focus {
|
|
259
|
+
border-color: #4096ff !important;
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
.ant-form-item-explain-error {
|
|
263
|
+
display: none;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
.no-error-border {
|
|
267
|
+
border-color: #d9d9d9 !important;
|
|
268
|
+
|
|
269
|
+
&:focus {
|
|
270
|
+
border-color: #4096ff !important;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
222
273
|
//endregion
|
|
223
274
|
|
|
224
275
|
@each $align in right center {
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { PFormProps, PGridProps } from '#/antProxy';
|
|
2
|
+
import { clone } from 'xe-utils';
|
|
3
|
+
|
|
4
|
+
// 全局配置接口
|
|
5
|
+
export interface UIKitConfig {
|
|
6
|
+
form?: {
|
|
7
|
+
labelCol?: any;
|
|
8
|
+
wrapperCol?: any;
|
|
9
|
+
};
|
|
10
|
+
grid?: {
|
|
11
|
+
align?: 'left' | 'right' | 'center';
|
|
12
|
+
lazyReset?: boolean;
|
|
13
|
+
fitHeight?: number;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 默认配置
|
|
18
|
+
const defaultConfig: UIKitConfig = {
|
|
19
|
+
form: {
|
|
20
|
+
labelCol: { span: 6 },
|
|
21
|
+
wrapperCol: { span: 16 },
|
|
22
|
+
},
|
|
23
|
+
grid: {
|
|
24
|
+
align: 'left',
|
|
25
|
+
lazyReset: false,
|
|
26
|
+
fitHeight: 170,
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
// 当前配置(可被修改)
|
|
31
|
+
let currentConfig: UIKitConfig = clone(defaultConfig);
|
|
32
|
+
|
|
33
|
+
// 设置配置
|
|
34
|
+
export function setUIKitConfig(config: Partial<UIKitConfig>): void {
|
|
35
|
+
currentConfig = {
|
|
36
|
+
form: {
|
|
37
|
+
...currentConfig.form,
|
|
38
|
+
...config.form,
|
|
39
|
+
},
|
|
40
|
+
grid: {
|
|
41
|
+
...currentConfig.grid,
|
|
42
|
+
...config.grid,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 获取配置
|
|
48
|
+
export function getUIKitConfig(): UIKitConfig {
|
|
49
|
+
return currentConfig;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// 获取表单默认配置
|
|
53
|
+
export function getFormDefaults(): Partial<PFormProps> {
|
|
54
|
+
return {
|
|
55
|
+
labelCol: currentConfig.form?.labelCol,
|
|
56
|
+
wrapperCol: currentConfig.form?.wrapperCol,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// 获取Grid默认配置
|
|
61
|
+
export function getGridDefaults(): Partial<PGridProps> {
|
|
62
|
+
return {
|
|
63
|
+
align: currentConfig.grid?.align,
|
|
64
|
+
lazyReset: currentConfig.grid?.lazyReset,
|
|
65
|
+
fitHeight: currentConfig.grid?.fitHeight,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// 重置为默认配置
|
|
70
|
+
export function resetUIKitConfig(): void {
|
|
71
|
+
currentConfig = JSON.parse(JSON.stringify(defaultConfig));
|
|
72
|
+
}
|