@vue-ui-kit/ant 1.7.4 → 1.8.2
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 +430 -233
- package/README.zh.md +446 -303
- package/dist/cjs/index.js +1 -1
- package/dist/declarations/antProxy.d.ts +7 -1
- package/dist/es/index.js +3038 -2244
- package/dist/index.d.ts +5 -1
- package/dist/packages/components/PFormCol.vue.d.ts +28 -0
- package/dist/packages/components/PFormGroup.vue.d.ts +2 -2
- package/dist/packages/components/PGrid.vue.d.ts +3 -2
- package/dist/packages/renders/TableInput.vue.d.ts +3 -3
- package/dist/packages/utils/config.d.ts +17 -0
- package/dist/packages/utils/core.d.ts +1 -1
- package/dist/style.css +1 -1
- package/package.json +3 -4
- package/src/declarations/antProxy.ts +8 -1
- package/src/index.ts +16 -0
- package/src/packages/components/PForm.vue +34 -85
- package/src/packages/components/PFormCol.vue +97 -0
- package/src/packages/components/PFormGroup.vue +90 -28
- package/src/packages/components/PGrid.vue +38 -81
- package/src/packages/renders/TableInput.vue +1 -1
- package/src/packages/store/renderStore.tsx +1 -1
- package/src/packages/styles/index.scss +80 -1
- package/src/packages/utils/AFormatters.ts +1 -1
- package/src/packages/utils/config.ts +72 -0
- package/src/packages/utils/core.ts +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { App } from 'vue';
|
|
2
|
+
import { setUIKitConfig, getUIKitConfig, resetUIKitConfig, UIKitConfig } from './packages/utils/config';
|
|
3
|
+
declare function setup(config?: Partial<UIKitConfig>): void;
|
|
2
4
|
declare const _default: {
|
|
3
5
|
install(app: App): void;
|
|
4
|
-
addFormatter: (formatter: Record<string, (a: import('./
|
|
6
|
+
addFormatter: (formatter: Record<string, (a: import('./Declarations/antProxy').CellFuncArg, ...args: any[]) => any>) => void;
|
|
5
7
|
addRender: (name: string, { renderItemContent, renderDefault, }: {
|
|
6
8
|
renderItemContent?: (options: import('./declarations/antProxy').RenderOptions, params: import('./declarations/antProxy').RenderFormParams, defaultHandler: Recordable) => any;
|
|
7
9
|
renderDefault?: (options: import('./declarations/antProxy').RenderOptions, params: import('./declarations/antProxy').RenderTableParams, defaultHandler: Recordable) => any;
|
|
8
10
|
}) => void;
|
|
11
|
+
setup: typeof setup;
|
|
9
12
|
};
|
|
10
13
|
export default _default;
|
|
11
14
|
export * from './declarations/antProxy';
|
|
12
15
|
export * from './packages/utils/core';
|
|
16
|
+
export { setup, setUIKitConfig, getUIKitConfig, resetUIKitConfig, type UIKitConfig };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { PFormItemProps } from '../../declarations/antProxy';
|
|
2
|
+
declare const _default: <T extends Recordable = Recordable<any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_Prettify<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
3
|
+
props: __VLS_Prettify<Pick<Partial<{}> & Omit<{
|
|
4
|
+
readonly onTrigger?: ((cusFields?: string | string[] | undefined) => any) | undefined;
|
|
5
|
+
readonly onReset?: (() => any) | undefined;
|
|
6
|
+
} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps & Readonly<{}> & Readonly<{
|
|
7
|
+
onTrigger?: ((cusFields?: string | string[] | undefined) => any) | undefined;
|
|
8
|
+
onReset?: (() => any) | undefined;
|
|
9
|
+
}>, never>, "onReset" | "onTrigger"> & {
|
|
10
|
+
item: PFormItemProps<T>;
|
|
11
|
+
formData: T;
|
|
12
|
+
}> & import('vue').PublicProps;
|
|
13
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
14
|
+
attrs: any;
|
|
15
|
+
slots: ReturnType<() => {}>;
|
|
16
|
+
emit: {
|
|
17
|
+
(e: "trigger", cusFields?: string | string[]): void;
|
|
18
|
+
(e: "reset"): void;
|
|
19
|
+
} & {};
|
|
20
|
+
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
21
|
+
[key: string]: any;
|
|
22
|
+
}> & {
|
|
23
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
24
|
+
};
|
|
25
|
+
export default _default;
|
|
26
|
+
type __VLS_Prettify<T> = {
|
|
27
|
+
[K in keyof T]: T[K];
|
|
28
|
+
} & {};
|
|
@@ -10,8 +10,8 @@ declare const _default: <F = Recordable<any>>(__VLS_props: NonNullable<Awaited<t
|
|
|
10
10
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
11
11
|
activeKey: import('vue').ComputedRef<number>;
|
|
12
12
|
setActiveKey: (key: number) => void;
|
|
13
|
-
validateAll: () => Promise<any[]>;
|
|
14
|
-
validate: (__index: number) =>
|
|
13
|
+
validateAll: () => Promise<PromiseSettledResult<any>[]>;
|
|
14
|
+
validate: (__index: number) => Promise<void>;
|
|
15
15
|
}>): void;
|
|
16
16
|
attrs: any;
|
|
17
17
|
slots: ReturnType<() => {
|
|
@@ -39,16 +39,17 @@ declare const _default: <D = Recordable<any>, F = Recordable<any>>(__VLS_props:
|
|
|
39
39
|
}>, never>, "onPick" | "onToolbarButtonClick" | "onToolbarToolClick" | "onResetQuery"> & PGridProps<D, F>> & import('vue').PublicProps;
|
|
40
40
|
expose(exposed: import('vue').ShallowUnwrapRef<{
|
|
41
41
|
commitProxy: {
|
|
42
|
-
query:
|
|
42
|
+
query: (this: any, ...args: any[]) => any;
|
|
43
43
|
reload: () => void;
|
|
44
44
|
reloadPage: () => Promise<D[]>;
|
|
45
|
-
passQuery: (params: Partial<F>, lazy?: boolean) =>
|
|
45
|
+
passQuery: (params: Partial<F>, lazy?: boolean) => any;
|
|
46
46
|
};
|
|
47
47
|
$table: import('vue').ComputedRef<any>;
|
|
48
48
|
selectedRowKeys: import('vue').ComputedRef<(string | number)[]>;
|
|
49
49
|
setBtnLoading: (code: string, value: boolean) => void;
|
|
50
50
|
selectedRecords: import('vue').ComputedRef<D[]>;
|
|
51
51
|
$form: import('vue').ComputedRef<any>;
|
|
52
|
+
getFormData: () => Partial<F>;
|
|
52
53
|
setLoadings: (value: boolean | Record<string, boolean>) => void;
|
|
53
54
|
resizeTable: () => void;
|
|
54
55
|
}>): void;
|
|
@@ -3,12 +3,12 @@ import { TableProps } from 'ant-design-vue';
|
|
|
3
3
|
import { ColumnProps } from '../../declarations/antProxy';
|
|
4
4
|
declare const _default: <D = Recordable<any>>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_Prettify<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
5
|
props: __VLS_Prettify<Pick<Partial<{
|
|
6
|
-
modelValue: D[];
|
|
7
6
|
tableConfig: TableProps<any>;
|
|
7
|
+
modelValue: D[];
|
|
8
8
|
editColumns: ColumnProps<Recordable<any>>[];
|
|
9
9
|
}> & Omit<{
|
|
10
|
-
readonly modelValue: D[];
|
|
11
10
|
readonly tableConfig: TableProps<any>;
|
|
11
|
+
readonly modelValue: D[];
|
|
12
12
|
readonly editColumns: ColumnProps<Recordable<any>>[];
|
|
13
13
|
readonly onTrigger?: ((...args: any[]) => any) | undefined;
|
|
14
14
|
readonly "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
@@ -28,7 +28,7 @@ declare const _default: <D = Recordable<any>>(__VLS_props: NonNullable<Awaited<t
|
|
|
28
28
|
}>> & Readonly<{
|
|
29
29
|
onTrigger?: ((...args: any[]) => any) | undefined;
|
|
30
30
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
31
|
-
}>, "
|
|
31
|
+
}>, "tableConfig" | "modelValue" | "editColumns">, "onTrigger" | "onUpdate:modelValue" | ("tableConfig" | "modelValue" | "editColumns")> & {}> & import('vue').PublicProps;
|
|
32
32
|
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
33
33
|
attrs: any;
|
|
34
34
|
slots: ReturnType<() => {}>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { PFormProps, PGridProps } from '../../declarations/antProxy';
|
|
2
|
+
export interface UIKitConfig {
|
|
3
|
+
form?: {
|
|
4
|
+
labelCol?: any;
|
|
5
|
+
wrapperCol?: any;
|
|
6
|
+
};
|
|
7
|
+
grid?: {
|
|
8
|
+
align?: 'left' | 'right' | 'center';
|
|
9
|
+
lazyReset?: boolean;
|
|
10
|
+
fitHeight?: number;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
export declare function setUIKitConfig(config: Partial<UIKitConfig>): void;
|
|
14
|
+
export declare function getUIKitConfig(): UIKitConfig;
|
|
15
|
+
export declare function getFormDefaults(): Partial<PFormProps>;
|
|
16
|
+
export declare function getGridDefaults(): Partial<PGridProps>;
|
|
17
|
+
export declare function resetUIKitConfig(): void;
|
|
@@ -5,4 +5,4 @@ export declare const defaultItemResponsive: Responsive;
|
|
|
5
5
|
export declare const defaultLabelCol: Responsive;
|
|
6
6
|
export declare const labelColDict: Record<number, Responsive>;
|
|
7
7
|
export declare const get24rest: (exist: number[]) => number;
|
|
8
|
-
export declare const getButtonResponsive: (itemResponsive: number | Responsive[]) =>
|
|
8
|
+
export declare const getButtonResponsive: (itemResponsive: number | Responsive[]) => any;
|
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
@charset "UTF-8";:root{--p-theme-bg: #fff}.p-pane{background-color:var(--p-theme-bg);padding:16px;border-radius:4px}.w-full{width:100%}.cursor-pointer{cursor:pointer}.py-4x{padding-top:4px;padding-bottom:4px}.px-2x{padding-left:2px;padding-right:2px}.pl-4x{padding-left:1em}.pl-8{padding-left:2em}.h-0{height:0}.h-full{height:100%}.flex{display:flex}.flex-col{flex-direction:column}.flex-1{flex:1}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-4px{gap:4px}.gap-8px{gap:8px}.pt-8px{padding-top:8px}.px-16px{padding-left:16px;padding-right:16px}.mt-4px{margin-top:4px}.text-right{text-align:right}.overflow-y-auto{overflow-y:auto}.p-theme-bg{background-color:var(--p-theme-bg)}.p-wrapper .p-form-wrapper{z-index:4}.p-wrapper .p-toolbar-wrapper{box-shadow:0 8px #fff;border-radius:.5em .5em 0 0;margin-bottom:-.5em}.p-wrapper .ant-form .ant-form-item{margin-bottom:0}.p-wrapper .ant-form .ant-form-item.p-required .ant-form-item-label>label:before{display:inline-block;margin-inline-end:4px;color:#ff4d4f;font-size:14px;font-family:SimSun,sans-serif;line-height:1;content:"*"}.p-wrapper .ant-form .ant-form-item .ant-form-item-label{display:flex;align-items:start;justify-content:flex-end}.p-wrapper .ant-form .ant-form-item .ant-form-item-label>label{white-space:break-spaces;align-items:flex-start;height:fit-content;padding-top:.36em}.p-wrapper .ant-form .ant-form-item .ant-form-item-label>label:after{padding-left:4px;margin-inline-start:unset}.p-wrapper .ant-form.ant-form-vertical .ant-form-item .ant-form-item-label{justify-content:flex-start;font-weight:600}.p-wrapper .ant-table-sticky-scroll{visibility:hidden}.p-wrapper .ant-table-header.ant-table-sticky-holder:before{content:"";width:100%;position:absolute;height:22px;display:block;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);top:-16px}.p-wrapper .ant-table-wrapper .ant-table-pagination.ant-pagination{margin:unset;padding:16px 0}.p-wrapper .p-inner-scroll>.ant-table-wrapper{height:100%}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading{height:100%}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading>.ant-spin-container{height:100%;display:flex;flex-direction:column}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading>.ant-spin-container>.ant-table{border-radius:unset}.p-wrapper .ant-pagination-options .ant-select{width:100px}.p-content-align-right.ant-form-item .ant-form-item-control-input-content{display:flex;justify-content:flex-end;align-items:center;text-align:right}.p-content-align-center.ant-form-item .ant-form-item-control-input-content{display:flex;justify-content:center;align-items:center;text-align:center}
|
|
1
|
+
@charset "UTF-8";:root{--p-theme-bg: #fff}.p-pane{background-color:var(--p-theme-bg);padding:16px;border-radius:4px}.w-full{width:100%}.cursor-pointer{cursor:pointer}.py-4x{padding-top:4px;padding-bottom:4px}.px-2x{padding-left:2px;padding-right:2px}.pl-4x{padding-left:1em}.pl-8{padding-left:2em}.h-0{height:0}.h-full{height:100%}.flex{display:flex}.flex-col{flex-direction:column}.flex-1{flex:1}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-4px{gap:4px}.gap-8px{gap:8px}.pt-8px{padding-top:8px}.px-16px{padding-left:16px;padding-right:16px}.mt-4px{margin-top:4px}.text-right{text-align:right}.overflow-y-auto{overflow-y:auto}.p-theme-bg{background-color:var(--p-theme-bg)}.p-wrapper .p-form-wrapper{z-index:4}.p-wrapper .p-error-hang-out .ant-input-affix-wrapper-status-error:not(.ant-input-affix-wrapper-disabled):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper{border-color:#d9d9d9!important}.p-wrapper .p-error-hang-out .ant-input-affix-wrapper-status-error:not(.ant-input-affix-wrapper-disabled):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper:focus{border-color:#4096ff!important}.p-wrapper .p-error-hang-out .ant-form-item-explain-error{opacity:0!important;transform:translateY(-10px)!important;max-height:0!important;overflow:hidden!important;transition:none!important}.p-wrapper .ant-form-item-explain-error{opacity:0;transform:translateY(-10px);max-height:0;overflow:hidden;transition:opacity .3s ease-out .3s,transform .3s ease-out .3s,max-height .3s ease-out .3s}.p-wrapper .ant-form-item-has-error .ant-form-item-explain-error{opacity:1;transform:translateY(0);max-height:100px}.p-wrapper .p-toolbar-wrapper{box-shadow:0 8px #fff;border-radius:.5em .5em 0 0;margin-bottom:-.5em}.p-wrapper .ant-form .ant-form-item{margin-bottom:0}.p-wrapper .ant-form .ant-form-item.p-required .ant-form-item-label>label:before{display:inline-block;margin-inline-end:4px;color:#ff4d4f;font-size:14px;font-family:SimSun,sans-serif;line-height:1;content:"*"}.p-wrapper .ant-form .ant-form-item .ant-form-item-label{display:flex;align-items:start;justify-content:flex-end}.p-wrapper .ant-form .ant-form-item .ant-form-item-label>label{white-space:break-spaces;align-items:flex-start;height:fit-content;padding-top:.36em}.p-wrapper .ant-form .ant-form-item .ant-form-item-label>label:after{padding-left:4px;margin-inline-start:unset}.p-wrapper .ant-form.ant-form-vertical .ant-form-item .ant-form-item-label{justify-content:flex-start;font-weight:600}.p-wrapper .ant-table-sticky-scroll{visibility:hidden}.p-wrapper .ant-table-header.ant-table-sticky-holder:before{content:"";width:100%;position:absolute;height:22px;display:block;-webkit-backdrop-filter:blur(2px);backdrop-filter:blur(2px);top:-16px}.p-wrapper .ant-table-wrapper .ant-table-pagination.ant-pagination{margin:unset;padding:16px 0}.p-wrapper .p-inner-scroll>.ant-table-wrapper{height:100%}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading{height:100%}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading>.ant-spin-container{height:100%;display:flex;flex-direction:column}.p-wrapper .p-inner-scroll>.ant-table-wrapper>.ant-spin-nested-loading>.ant-spin-container>.ant-table{border-radius:unset}.p-wrapper .ant-pagination-options .ant-select{width:100px}.p-error-group-tab{position:relative;overflow:visible;color:#f5222d!important}.p-error-group-tab:after{content:"🏷️";position:absolute;top:-1em;right:0;width:1em;height:1em;font-size:.8em;animation:heartbeat 2s infinite}.p-error-hang-out .ant-input-affix-wrapper-status-error:not(.ant-input-affix-wrapper-disabled):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper{border-color:#d9d9d9!important}.p-error-hang-out .ant-input-affix-wrapper-status-error:not(.ant-input-affix-wrapper-disabled):not(.ant-input-affix-wrapper-borderless).ant-input-affix-wrapper:focus{border-color:#4096ff!important}.p-error-hang-out .ant-form-item-explain-error{display:none}.no-error-border{border-color:#d9d9d9!important}.no-error-border:focus{border-color:#4096ff!important}.p-content-align-right.ant-form-item .ant-form-item-control-input-content{display:flex;justify-content:flex-end;align-items:center;text-align:right}.p-content-align-center.ant-form-item .ant-form-item-control-input-content{display:flex;justify-content:center;align-items:center;text-align:center}@keyframes heartbeat{0%{transform:scale(1)}6%{transform:scale(1.22)}12%{transform:scale(1)}18%{transform:scale(1.18)}24%{transform:scale(1)}48%{transform:scale(1)}54%{transform:scale(1.22)}60%{transform:scale(1)}66%{transform:scale(1.18)}72%{transform:scale(1)}to{transform:scale(1)}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vue-ui-kit/ant",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.2",
|
|
4
4
|
"description": "Vue3 UI Kit based on Ant Design",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"email": "adoin@qq.com"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"uuid": "^10.0.0",
|
|
43
|
+
"xe-utils": "^3.7.6"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {
|
|
46
46
|
"@ant-design/icons-vue": ">=7.0.0",
|
|
@@ -55,7 +55,6 @@
|
|
|
55
55
|
"@ant-design/icons-vue": ">=7.0.0",
|
|
56
56
|
"@commitlint/cli": "^19.4.1",
|
|
57
57
|
"@commitlint/config-conventional": "^19.4.1",
|
|
58
|
-
"@types/lodash-es": "^4.17.12",
|
|
59
58
|
"@types/uuid": "^10.0.0",
|
|
60
59
|
"@vitejs/plugin-vue": "^5.1.2",
|
|
61
60
|
"@vitejs/plugin-vue-jsx": "^4.0.1",
|
|
@@ -54,6 +54,8 @@ export interface PFormItemProps<F = Recordable> {
|
|
|
54
54
|
title?: string;
|
|
55
55
|
span?: number;
|
|
56
56
|
colon?: boolean;
|
|
57
|
+
labelCol?: ColProps
|
|
58
|
+
wrapperCol?: ColProps
|
|
57
59
|
forceRequired?: boolean; // 在页面需要必填标示,但field不需要必填校验时使用
|
|
58
60
|
align?: 'left' | 'right' | 'center';
|
|
59
61
|
col?: ColProps;
|
|
@@ -67,6 +69,7 @@ export interface PFormItemProps<F = Recordable> {
|
|
|
67
69
|
passTrigger?: (cusFields?: string | string[]) => void,
|
|
68
70
|
passDelayTrigger?: (cusFields?: string | string[], time?: number) => void
|
|
69
71
|
) => any;
|
|
72
|
+
defaultValue?: any
|
|
70
73
|
};
|
|
71
74
|
}
|
|
72
75
|
|
|
@@ -109,12 +112,13 @@ export interface PFormGroupProps<F = Recordable> {
|
|
|
109
112
|
tabLabel?: string;
|
|
110
113
|
editAble?: boolean;
|
|
111
114
|
showAdd?: boolean;
|
|
115
|
+
lazyErrorMark?: boolean;
|
|
112
116
|
forceRender?: boolean;
|
|
113
117
|
/* 是否保持连续编号 */
|
|
114
118
|
keepSerial?: boolean;
|
|
115
119
|
loading?: boolean;
|
|
116
120
|
itemMenus?: Array<GroupMenuItem<F>>;
|
|
117
|
-
|
|
121
|
+
createItem?: ({ list }: { list?: Partial<F>[] }) => Promise<Partial<F>>;
|
|
118
122
|
max?: number;
|
|
119
123
|
menuHandler?: GroupMenuItemHandler<F>;
|
|
120
124
|
}
|
|
@@ -199,6 +203,8 @@ export type PGridProps<D = Recordable, F = Recordable> = {
|
|
|
199
203
|
proxyConfig?: ProxyConfig<D, F>;
|
|
200
204
|
tableConfig?: TableProps<D>;
|
|
201
205
|
scrollMode?: 'outer' | 'inner';
|
|
206
|
+
// 重置后不自动提交
|
|
207
|
+
lazyReset?: boolean;
|
|
202
208
|
/**
|
|
203
209
|
* 适应展示区到页面顶部的高度,通常和容器最上的y值有关(正比)
|
|
204
210
|
*/
|
|
@@ -275,6 +281,7 @@ export interface PGridInstance<D = Recordable, F = Recordable> {
|
|
|
275
281
|
selectedRecords: D[];
|
|
276
282
|
$table: Recordable;
|
|
277
283
|
$form: Recordable;
|
|
284
|
+
getFormData: () => Partial<F>;
|
|
278
285
|
setLoadings: (value: boolean) => void;
|
|
279
286
|
setBtnLoading: (code: string, status: boolean) => void;
|
|
280
287
|
resizeTable: () => void;
|
package/src/index.ts
CHANGED
|
@@ -6,8 +6,16 @@ import PGroupBlock from '@/components/PGroupBlock.vue';
|
|
|
6
6
|
import PromisePicker from '@/components/PromisePicker.vue';
|
|
7
7
|
import { addFormatter } from '@/utils/AFormatters';
|
|
8
8
|
import { addRender } from '@/store/renderStore';
|
|
9
|
+
import { setUIKitConfig, getUIKitConfig, resetUIKitConfig, UIKitConfig } from '@/utils/config';
|
|
9
10
|
import * as utils from '@/utils/core';
|
|
10
11
|
|
|
12
|
+
// 创建setup方法
|
|
13
|
+
function setup(config?: Partial<UIKitConfig>) {
|
|
14
|
+
if (config) {
|
|
15
|
+
setUIKitConfig(config);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
11
19
|
export default {
|
|
12
20
|
install(app: App) {
|
|
13
21
|
app.component('PForm', PForm);
|
|
@@ -19,7 +27,15 @@ export default {
|
|
|
19
27
|
},
|
|
20
28
|
addFormatter,
|
|
21
29
|
addRender,
|
|
30
|
+
setup,
|
|
22
31
|
};
|
|
23
32
|
|
|
24
33
|
export * from '#/antProxy';
|
|
25
34
|
export * from '@/utils/core';
|
|
35
|
+
export {
|
|
36
|
+
setup,
|
|
37
|
+
setUIKitConfig,
|
|
38
|
+
getUIKitConfig,
|
|
39
|
+
resetUIKitConfig,
|
|
40
|
+
type UIKitConfig
|
|
41
|
+
};
|
|
@@ -1,24 +1,28 @@
|
|
|
1
1
|
<script generic="F = Recordable" lang="ts" name="PForm" setup>
|
|
2
2
|
import { PFormItemProps, PFormProps } from '#/antProxy';
|
|
3
|
-
import { computed,
|
|
4
|
-
import {
|
|
3
|
+
import { computed, ref, toRefs } from 'vue';
|
|
4
|
+
import { omit } from 'xe-utils';
|
|
5
5
|
import { v4 as uuid_v4 } from 'uuid';
|
|
6
|
-
import
|
|
7
|
-
import RenderItemSlots from '@/components/RenderItemSlots';
|
|
8
|
-
import { isGoodValue, valued } from '@/utils/is';
|
|
6
|
+
import { isGoodValue } from '@/utils/is';
|
|
9
7
|
import { eachTree } from '@/utils/treeHelper';
|
|
10
|
-
import {
|
|
8
|
+
import { getFormDefaults } from '@/utils/config';
|
|
9
|
+
import PFormCol from '@/components/PFormCol.vue';
|
|
11
10
|
import {
|
|
12
11
|
Form as AForm,
|
|
13
12
|
Row as ARow,
|
|
14
|
-
Col as ACol,
|
|
15
|
-
FormItem as AFormItem,
|
|
16
|
-
Tooltip as ATooltip,
|
|
17
13
|
} from 'ant-design-vue';
|
|
18
|
-
import { InfoCircleOutlined } from '@ant-design/icons-vue';
|
|
19
14
|
|
|
20
15
|
const props = defineProps<PFormProps<F> & { data: F }>();
|
|
21
16
|
const emit = defineEmits(['apply', 'reset']);
|
|
17
|
+
|
|
18
|
+
// 应用默认值
|
|
19
|
+
const formDefaults = getFormDefaults();
|
|
20
|
+
const propsWithDefaults = computed(() => ({
|
|
21
|
+
...props,
|
|
22
|
+
labelCol: props.labelCol ?? formDefaults.labelCol ?? { span: 6 },
|
|
23
|
+
wrapperCol: props.wrapperCol ?? formDefaults.wrapperCol ?? { span: 16 },
|
|
24
|
+
}));
|
|
25
|
+
|
|
22
26
|
const { items, data: formData } = toRefs(props);
|
|
23
27
|
|
|
24
28
|
function handleSubmit() {
|
|
@@ -30,8 +34,6 @@
|
|
|
30
34
|
const resetForm = () => {
|
|
31
35
|
renderFormKey.value = uuid_v4();
|
|
32
36
|
};
|
|
33
|
-
const debounceResetForm = debounce(resetForm, 100);
|
|
34
|
-
watch(() => items.value, debounceResetForm, { deep: true });
|
|
35
37
|
const resetFormData = () => {
|
|
36
38
|
if (props.customReset) {
|
|
37
39
|
props.customReset();
|
|
@@ -45,15 +47,24 @@
|
|
|
45
47
|
obj[item.field] = undefined;
|
|
46
48
|
}
|
|
47
49
|
}
|
|
50
|
+
else if (item.field && item.slots) {
|
|
51
|
+
if (isGoodValue(item.slots.defaultValue)) {
|
|
52
|
+
obj[item.field] = item.slots.defaultValue
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
obj[item.field] = undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
48
58
|
});
|
|
49
59
|
Object.assign(formData.value, obj);
|
|
50
60
|
}
|
|
61
|
+
emit('reset');
|
|
51
62
|
};
|
|
52
63
|
// omit({labelCol:defaultLabelCol,...props},['items','data','model'])
|
|
53
64
|
const fc = computed(() => ({
|
|
54
|
-
...omit(
|
|
55
|
-
labelCol:
|
|
56
|
-
wrapperCol:
|
|
65
|
+
...omit(propsWithDefaults.value, ['items', 'data', 'model', 'labelCol', 'wrapperCol']),
|
|
66
|
+
labelCol: propsWithDefaults.value.labelCol,
|
|
67
|
+
wrapperCol: propsWithDefaults.value.wrapperCol,
|
|
57
68
|
}));
|
|
58
69
|
const validateField = (fields?: string | string[]) => {
|
|
59
70
|
if (fields) {
|
|
@@ -63,19 +74,11 @@
|
|
|
63
74
|
const handleTrigger = (cusFields?: string | string[]) => {
|
|
64
75
|
validateField(cusFields);
|
|
65
76
|
};
|
|
66
|
-
|
|
67
|
-
const delayTime = time ?? 222;
|
|
68
|
-
setTimeout(() => {
|
|
69
|
-
validateField(cusFields);
|
|
70
|
-
}, delayTime);
|
|
71
|
-
};
|
|
77
|
+
|
|
72
78
|
defineExpose({
|
|
73
79
|
reset: resetForm,
|
|
74
80
|
$form: computed(() => formEl.value),
|
|
75
81
|
});
|
|
76
|
-
onMounted(() => {
|
|
77
|
-
resetForm();
|
|
78
|
-
});
|
|
79
82
|
</script>
|
|
80
83
|
<template>
|
|
81
84
|
<div
|
|
@@ -84,68 +87,14 @@
|
|
|
84
87
|
>
|
|
85
88
|
<a-form :key="renderFormKey" ref="formEl" :model="formData" v-bind="fc" @submit="handleSubmit">
|
|
86
89
|
<a-row :gutter="[6, 12]">
|
|
87
|
-
<
|
|
90
|
+
<p-form-col
|
|
88
91
|
v-for="(item, idx) in items"
|
|
89
|
-
:key="
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
:name="item.field"
|
|
96
|
-
:wrapper-col="item.wrapperCol ?? (item.title ? undefined : { span: 24 })"
|
|
97
|
-
colon
|
|
98
|
-
:class="`p-content-align-${item.align ?? 'left'} ${item.forceRequired ? 'p-required' : ''}`"
|
|
99
|
-
v-bind="
|
|
100
|
-
omit(item, [
|
|
101
|
-
'field',
|
|
102
|
-
'title',
|
|
103
|
-
'span',
|
|
104
|
-
'col',
|
|
105
|
-
'wrapperCol',
|
|
106
|
-
'itemRender',
|
|
107
|
-
'forceRequired',
|
|
108
|
-
'tooltip',
|
|
109
|
-
])
|
|
110
|
-
"
|
|
111
|
-
>
|
|
112
|
-
<template v-if="item.slots?.title" #label>
|
|
113
|
-
<component :is="item.slots.title" />
|
|
114
|
-
</template>
|
|
115
|
-
<render-item-slots
|
|
116
|
-
v-if="item.slots?.default"
|
|
117
|
-
:form-data="formData"
|
|
118
|
-
:item="item"
|
|
119
|
-
:key="'_sl_' + (item.field ?? '_') + '_' + idx"
|
|
120
|
-
:pass-trigger="handleTrigger"
|
|
121
|
-
:pass-delay-trigger="handleDelayTrigger"
|
|
122
|
-
/>
|
|
123
|
-
<render-ant-item
|
|
124
|
-
v-else-if="item.itemRender?.name"
|
|
125
|
-
:key="'_re_' + (item.field ?? '_') + '_' + idx"
|
|
126
|
-
:default-handler="{ reset: resetFormData }"
|
|
127
|
-
:item-render="item.itemRender"
|
|
128
|
-
@trigger="handleTrigger"
|
|
129
|
-
@delay-trigger="handleDelayTrigger"
|
|
130
|
-
:render-form-params="{ data: formData, field: item.field }"
|
|
131
|
-
/>
|
|
132
|
-
<span v-else></span>
|
|
133
|
-
<template #tooltip v-if="item.tooltipConfig">
|
|
134
|
-
<a-tooltip
|
|
135
|
-
v-if="isFunction(item.tooltipConfig.title)"
|
|
136
|
-
v-bind="omit(item.tooltipConfig, ['title'])"
|
|
137
|
-
>
|
|
138
|
-
<InfoCircleOutlined class="cursor-pointer py-4x px-2x" />
|
|
139
|
-
<template #title>
|
|
140
|
-
<div v-html="item.tooltipConfig.title()"></div>
|
|
141
|
-
</template>
|
|
142
|
-
</a-tooltip>
|
|
143
|
-
<a-tooltip v-else v-bind="item.tooltipConfig">
|
|
144
|
-
<InfoCircleOutlined class="cursor-pointer py-4x px-2x" />
|
|
145
|
-
</a-tooltip>
|
|
146
|
-
</template>
|
|
147
|
-
</a-form-item>
|
|
148
|
-
</a-col>
|
|
92
|
+
:key="`_col_${idx}`"
|
|
93
|
+
:form-data="formData"
|
|
94
|
+
:item="item"
|
|
95
|
+
@reset="resetFormData"
|
|
96
|
+
@trigger="handleTrigger"
|
|
97
|
+
/>
|
|
149
98
|
</a-row>
|
|
150
99
|
</a-form>
|
|
151
100
|
</div>
|
|
@@ -0,0 +1,97 @@
|
|
|
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, watch } from 'vue'
|
|
9
|
+
import { isEqual,debounce, isFunction, omit } from 'xe-utils'
|
|
10
|
+
|
|
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
|
+
watch(() => props.item, (cur, old) => {
|
|
40
|
+
if (!isEqual(cur, old)) {
|
|
41
|
+
debounceRefreshCol()
|
|
42
|
+
}
|
|
43
|
+
}, { deep: true })
|
|
44
|
+
</script>
|
|
45
|
+
|
|
46
|
+
<template>
|
|
47
|
+
<a-col
|
|
48
|
+
:key="`_col_${renderFormKey}`"
|
|
49
|
+
v-bind="item.col ?? (item.span ? { span: item.span } : defaultItemResponsive)"
|
|
50
|
+
>
|
|
51
|
+
<a-form-item
|
|
52
|
+
:key="`_item_${renderFormKey}`"
|
|
53
|
+
:class="[
|
|
54
|
+
`p-content-align-${item.align ?? 'left'} ${item.forceRequired ? 'p-required' : ''}`,
|
|
55
|
+
{ 'p-error-hang-out': hangOut },
|
|
56
|
+
]"
|
|
57
|
+
colon
|
|
58
|
+
:label="item.title"
|
|
59
|
+
:name="item.field"
|
|
60
|
+
:wrapper-col="item.wrapperCol ?? (item.title ? undefined : { span: 24 })"
|
|
61
|
+
v-bind="omit(item, ['field', 'title', 'span', 'col', 'wrapperCol', 'itemRender', 'forceRequired', 'tooltip'])"
|
|
62
|
+
>
|
|
63
|
+
<template v-if="item.slots?.title" #label>
|
|
64
|
+
<component :is="item.slots.title" />
|
|
65
|
+
</template>
|
|
66
|
+
<render-item-slots
|
|
67
|
+
v-if="item.slots?.default"
|
|
68
|
+
:key="`_sl_${item.field ?? '_'}_${renderFormKey}`"
|
|
69
|
+
:form-data="formData"
|
|
70
|
+
:item="item"
|
|
71
|
+
:pass-delay-trigger="handleDelayTrigger"
|
|
72
|
+
:pass-trigger="handleTrigger"
|
|
73
|
+
/>
|
|
74
|
+
<render-ant-item
|
|
75
|
+
v-else-if="item.itemRender?.name"
|
|
76
|
+
:key="`_re_${item.field ?? '_'}_${renderFormKey}`"
|
|
77
|
+
:default-handler="{ reset: resetFormData }"
|
|
78
|
+
:item-render="item.itemRender"
|
|
79
|
+
:render-form-params="{ data: formData as Recordable, field: item.field }"
|
|
80
|
+
@delay-trigger="handleDelayTrigger"
|
|
81
|
+
@trigger="handleTrigger"
|
|
82
|
+
/>
|
|
83
|
+
<span v-else />
|
|
84
|
+
<template v-if="item.tooltipConfig" #tooltip>
|
|
85
|
+
<a-tooltip v-if="isFunction(item.tooltipConfig.title)" v-bind="omit(item.tooltipConfig, ['title'])">
|
|
86
|
+
<info-circle-outlined class="cursor-pointer py-4 px-2" />
|
|
87
|
+
<template #title>
|
|
88
|
+
<div v-html="item.tooltipConfig.title()" />
|
|
89
|
+
</template>
|
|
90
|
+
</a-tooltip>
|
|
91
|
+
<a-tooltip v-else v-bind="item.tooltipConfig">
|
|
92
|
+
<info-circle-outlined class="cursor-pointer py-4 px-2" />
|
|
93
|
+
</a-tooltip>
|
|
94
|
+
</template>
|
|
95
|
+
</a-form-item>
|
|
96
|
+
</a-col>
|
|
97
|
+
</template>
|