@gx-design-vue/pro-table 0.2.0-alpha.2 → 0.2.0-alpha.21
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/ProTable.d.ts +14 -493
- package/dist/ProTable.js +902 -511
- package/dist/components/Drag/Handle.d.ts +90 -0
- package/dist/components/Drag/Handle.js +64 -0
- package/dist/components/Drag/Tbody.d.ts +17 -0
- package/dist/components/Drag/Tbody.js +27 -0
- package/dist/components/EllipsisText/index.d.ts +50 -0
- package/dist/components/EllipsisText/index.js +65 -0
- package/dist/components/ScrollBar/Bar.d.ts +79 -0
- package/dist/components/ScrollBar/Bar.js +84 -0
- package/dist/components/ScrollBar/Thumb.d.ts +50 -0
- package/dist/components/ScrollBar/{Thumb/index.js → Thumb.js} +67 -58
- package/dist/components/ScrollBar/context.d.ts +3 -4
- package/dist/components/ScrollBar/context.js +3 -5
- package/dist/components/ScrollBar/util.d.ts +6 -5
- package/dist/components/ScrollBar/util.js +1 -14
- package/dist/components/SearchForm/CollapseToggle.d.ts +53 -0
- package/dist/components/SearchForm/CollapseToggle.js +47 -0
- package/dist/components/SearchForm/FormItemContainer.d.ts +73 -0
- package/dist/components/SearchForm/FormItemContainer.js +225 -0
- package/dist/components/SearchForm/FormItemWrapper.d.ts +80 -0
- package/dist/components/SearchForm/FormItemWrapper.js +62 -0
- package/dist/components/SearchForm/SearchForm.d.ts +128 -0
- package/dist/components/SearchForm/SearchForm.js +319 -0
- package/dist/components/SearchForm/index.d.ts +2 -0
- package/dist/components/SearchForm/index.js +2 -0
- package/dist/components/Toolbar/FullscreenIcon.d.ts +24 -0
- package/dist/components/Toolbar/FullscreenIcon.js +22 -0
- package/dist/components/Toolbar/ListToolBar.d.ts +109 -0
- package/dist/components/Toolbar/ListToolBar.js +101 -0
- package/dist/components/Toolbar/index.d.ts +101 -0
- package/dist/components/Toolbar/index.js +101 -0
- package/dist/components/Toolbar/style.d.ts +8 -0
- package/dist/components/{ListToolBar → Toolbar}/style.js +32 -27
- package/dist/context/TableContext.d.ts +15 -27
- package/dist/context/TableContext.js +3 -5
- package/dist/hooks/index.d.ts +19 -0
- package/dist/hooks/index.js +19 -0
- package/dist/hooks/useAutoScroll.d.ts +32 -0
- package/dist/hooks/useAutoScroll.js +127 -0
- package/dist/hooks/useBreakpoints.d.ts +13 -0
- package/dist/hooks/useBreakpoints.js +65 -0
- package/dist/hooks/useCellRender.d.ts +13 -0
- package/dist/hooks/useCellRender.js +40 -0
- package/dist/hooks/useColumnResize.d.ts +29 -0
- package/dist/hooks/useColumnResize.js +112 -0
- package/dist/hooks/useColumns.d.ts +35 -24
- package/dist/hooks/useColumns.js +89 -58
- package/dist/hooks/useDragHandleColumn.d.ts +26 -0
- package/dist/hooks/useDragHandleColumn.js +52 -0
- package/dist/hooks/useEllipsis.d.ts +20 -0
- package/dist/hooks/useEllipsis.js +51 -0
- package/dist/hooks/useFetchData.d.ts +42 -65
- package/dist/hooks/useFetchData.js +160 -176
- package/dist/hooks/useFitPage.d.ts +19 -0
- package/dist/hooks/useFitPage.js +90 -0
- package/dist/hooks/useKeepAliveReload.d.ts +21 -0
- package/dist/hooks/useKeepAliveReload.js +24 -0
- package/dist/hooks/useLoading.d.ts +18 -7
- package/dist/hooks/useLoading.js +27 -11
- package/dist/hooks/usePagination.d.ts +10 -7
- package/dist/hooks/usePagination.js +38 -29
- package/dist/hooks/useRequestOptions.d.ts +18 -0
- package/dist/hooks/useRequestOptions.js +39 -0
- package/dist/hooks/useRowDrag.d.ts +42 -0
- package/dist/hooks/useRowDrag.js +268 -0
- package/dist/hooks/useRowSelection.d.ts +27 -15
- package/dist/hooks/useRowSelection.js +93 -80
- package/dist/hooks/useTable.d.ts +35 -77
- package/dist/hooks/useTable.js +76 -49
- package/dist/hooks/useTableForm.d.ts +17 -82
- package/dist/hooks/useTableForm.js +137 -52
- package/dist/hooks/useTableScroll.d.ts +33 -31
- package/dist/hooks/useTableScroll.js +71 -28
- package/dist/hooks/useTableSize.d.ts +17 -7
- package/dist/hooks/useTableSize.js +21 -9
- package/dist/index.d.ts +11 -7
- package/dist/index.js +10 -4
- package/dist/interface.d.ts +537 -0
- package/dist/interface.js +1 -0
- package/dist/pro-table.esm.js +8897 -4012
- package/dist/pro-table.js +4 -1
- package/dist/style/ellipsis.d.ts +13 -0
- package/dist/style/ellipsis.js +16 -0
- package/dist/style/fit-page.d.ts +4 -2
- package/dist/style/fit-page.js +10 -5
- package/dist/style/index.d.ts +3 -7
- package/dist/style/index.js +38 -76
- package/dist/style/list.d.ts +4 -2
- package/dist/style/list.js +2 -12
- package/dist/style/resizable.d.ts +8 -0
- package/dist/style/resizable.js +18 -0
- package/dist/style/row-drag.d.ts +8 -0
- package/dist/style/row-drag.js +44 -0
- package/dist/style/scroll.d.ts +4 -2
- package/dist/style/scroll.js +9 -9
- package/dist/style/search.d.ts +8 -0
- package/dist/{components/Form/style.js → style/search.js} +22 -9
- package/dist/theme/augment.d.ts +8 -0
- package/dist/theme/augment.js +1 -0
- package/dist/theme/interface/components.d.ts +8 -0
- package/dist/theme/interface/components.js +1 -0
- package/dist/utils/arrayMove.d.ts +9 -0
- package/dist/utils/arrayMove.js +15 -0
- package/dist/utils/dateFormat.d.ts +9 -0
- package/dist/utils/dateFormat.js +29 -0
- package/dist/utils/ellipsis.d.ts +19 -0
- package/dist/utils/ellipsis.js +30 -0
- package/dist/utils/flipAnimate.d.ts +25 -0
- package/dist/utils/flipAnimate.js +40 -0
- package/dist/utils/formConstants.d.ts +9 -0
- package/dist/utils/formConstants.js +29 -0
- package/dist/utils/valueFormat.d.ts +9 -0
- package/dist/utils/valueFormat.js +27 -0
- package/package.json +23 -11
- package/dist/components/Form/components/RequestSelect.d.ts +0 -50
- package/dist/components/Form/components/RequestSelect.js +0 -58
- package/dist/components/Form/hooks/useForm.d.ts +0 -11
- package/dist/components/Form/hooks/useForm.js +0 -32
- package/dist/components/Form/index.d.ts +0 -33
- package/dist/components/Form/index.js +0 -479
- package/dist/components/Form/style.d.ts +0 -6
- package/dist/components/Form/utils/config.d.ts +0 -9
- package/dist/components/Form/utils/config.js +0 -30
- package/dist/components/Form/utils/dateFormat.d.ts +0 -22
- package/dist/components/Form/utils/dateFormat.js +0 -45
- package/dist/components/ListToolBar/index.d.ts +0 -60
- package/dist/components/ListToolBar/index.js +0 -123
- package/dist/components/ListToolBar/style.d.ts +0 -6
- package/dist/components/ScrollBar/Bar/index.d.ts +0 -49
- package/dist/components/ScrollBar/Bar/index.js +0 -71
- package/dist/components/ScrollBar/Bar/props.d.ts +0 -25
- package/dist/components/ScrollBar/Bar/props.js +0 -18
- package/dist/components/ScrollBar/Thumb/index.d.ts +0 -40
- package/dist/components/ScrollBar/Thumb/props.d.ts +0 -20
- package/dist/components/ScrollBar/Thumb/props.js +0 -18
- package/dist/components/TableCell/index.d.ts +0 -37
- package/dist/components/TableCell/index.js +0 -72
- package/dist/components/ToolBar/FullscreenIcon.d.ts +0 -7
- package/dist/components/ToolBar/FullscreenIcon.js +0 -14
- package/dist/components/ToolBar/index.d.ts +0 -34
- package/dist/components/ToolBar/index.js +0 -100
- package/dist/hooks/tryOnActivated.d.ts +0 -6
- package/dist/hooks/tryOnActivated.js +0 -14
- package/dist/hooks/useDebounceFn.d.ts +0 -8
- package/dist/hooks/useDebounceFn.js +0 -34
- package/dist/hooks/useScrollArea.d.ts +0 -24
- package/dist/hooks/useScrollArea.js +0 -104
- package/dist/props.d.ts +0 -340
- package/dist/props.js +0 -251
- package/dist/types/ColumnTypings.d.ts +0 -129
- package/dist/types/ColumnTypings.js +0 -1
- package/dist/types/SlotsTypings.d.ts +0 -63
- package/dist/types/SlotsTypings.js +0 -13
- package/dist/types/TableTypings.d.ts +0 -359
- package/dist/types/TableTypings.js +0 -1
- package/dist/types/index.d.ts +0 -9
- package/dist/types/index.js +0 -1
- package/dist/utils/utils.d.ts +0 -10
- package/dist/utils/utils.js +0 -91
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { CSSProperties, PropType } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/SearchForm/FormItemWrapper.d.ts
|
|
4
|
+
declare const FormItemWrapper: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
label: {
|
|
6
|
+
type: PropType<string | any>;
|
|
7
|
+
default: any;
|
|
8
|
+
};
|
|
9
|
+
labelWidth: {
|
|
10
|
+
type: PropType<number | string>;
|
|
11
|
+
default: any;
|
|
12
|
+
};
|
|
13
|
+
labelAlign: {
|
|
14
|
+
type: PropType<"left" | "center" | "right">;
|
|
15
|
+
default: any;
|
|
16
|
+
};
|
|
17
|
+
colon: {
|
|
18
|
+
type: BooleanConstructor;
|
|
19
|
+
default: any;
|
|
20
|
+
};
|
|
21
|
+
prefixCls: {
|
|
22
|
+
type: StringConstructor;
|
|
23
|
+
required: true;
|
|
24
|
+
};
|
|
25
|
+
hashId: {
|
|
26
|
+
type: StringConstructor;
|
|
27
|
+
default: string;
|
|
28
|
+
};
|
|
29
|
+
formItemStyle: {
|
|
30
|
+
type: PropType<CSSProperties>;
|
|
31
|
+
default: () => {};
|
|
32
|
+
};
|
|
33
|
+
globalLabelGap: {
|
|
34
|
+
type: NumberConstructor;
|
|
35
|
+
default: any;
|
|
36
|
+
};
|
|
37
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
38
|
+
label: {
|
|
39
|
+
type: PropType<string | any>;
|
|
40
|
+
default: any;
|
|
41
|
+
};
|
|
42
|
+
labelWidth: {
|
|
43
|
+
type: PropType<number | string>;
|
|
44
|
+
default: any;
|
|
45
|
+
};
|
|
46
|
+
labelAlign: {
|
|
47
|
+
type: PropType<"left" | "center" | "right">;
|
|
48
|
+
default: any;
|
|
49
|
+
};
|
|
50
|
+
colon: {
|
|
51
|
+
type: BooleanConstructor;
|
|
52
|
+
default: any;
|
|
53
|
+
};
|
|
54
|
+
prefixCls: {
|
|
55
|
+
type: StringConstructor;
|
|
56
|
+
required: true;
|
|
57
|
+
};
|
|
58
|
+
hashId: {
|
|
59
|
+
type: StringConstructor;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
formItemStyle: {
|
|
63
|
+
type: PropType<CSSProperties>;
|
|
64
|
+
default: () => {};
|
|
65
|
+
};
|
|
66
|
+
globalLabelGap: {
|
|
67
|
+
type: NumberConstructor;
|
|
68
|
+
default: any;
|
|
69
|
+
};
|
|
70
|
+
}>> & Readonly<{}>, {
|
|
71
|
+
label: any;
|
|
72
|
+
hashId: string;
|
|
73
|
+
labelWidth: string | number;
|
|
74
|
+
labelAlign: "left" | "right" | "center";
|
|
75
|
+
colon: boolean;
|
|
76
|
+
formItemStyle: CSSProperties;
|
|
77
|
+
globalLabelGap: number;
|
|
78
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
79
|
+
//#endregion
|
|
80
|
+
export { FormItemWrapper };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
//#region src/components/SearchForm/FormItemWrapper.tsx
|
|
3
|
+
const FormItemWrapper = /* @__PURE__ */ defineComponent({
|
|
4
|
+
name: "ProTableFormItemWrapper",
|
|
5
|
+
props: {
|
|
6
|
+
label: {
|
|
7
|
+
type: [String, Object],
|
|
8
|
+
default: void 0
|
|
9
|
+
},
|
|
10
|
+
labelWidth: {
|
|
11
|
+
type: [Number, String],
|
|
12
|
+
default: void 0
|
|
13
|
+
},
|
|
14
|
+
labelAlign: {
|
|
15
|
+
type: String,
|
|
16
|
+
default: void 0
|
|
17
|
+
},
|
|
18
|
+
colon: {
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: void 0
|
|
21
|
+
},
|
|
22
|
+
prefixCls: {
|
|
23
|
+
type: String,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
hashId: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: ""
|
|
29
|
+
},
|
|
30
|
+
formItemStyle: {
|
|
31
|
+
type: Object,
|
|
32
|
+
default: () => ({})
|
|
33
|
+
},
|
|
34
|
+
globalLabelGap: {
|
|
35
|
+
type: Number,
|
|
36
|
+
default: void 0
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
setup(props, { slots }) {
|
|
40
|
+
return () => {
|
|
41
|
+
const showLabel = !!props.label;
|
|
42
|
+
const labelAlignClass = props.labelAlign ? `${props.prefixCls}-search-item-label-${props.labelAlign}` : "";
|
|
43
|
+
const noColonClass = props.colon === false ? `${props.prefixCls}-search-item-label-no-colon` : "";
|
|
44
|
+
return createVNode("div", {
|
|
45
|
+
"class": [`${props.prefixCls}-search-item`, props.hashId],
|
|
46
|
+
"style": {
|
|
47
|
+
...props.formItemStyle,
|
|
48
|
+
...props.globalLabelGap != null ? { gap: `${props.globalLabelGap}px` } : {}
|
|
49
|
+
}
|
|
50
|
+
}, [showLabel && createVNode("div", {
|
|
51
|
+
"class": [
|
|
52
|
+
`${props.prefixCls}-search-item-label`,
|
|
53
|
+
labelAlignClass,
|
|
54
|
+
noColonClass
|
|
55
|
+
],
|
|
56
|
+
"style": props.labelWidth ? { width: typeof props.labelWidth === "number" ? `${props.labelWidth}px` : props.labelWidth } : void 0
|
|
57
|
+
}, [props.label]), createVNode("div", { "class": `${props.prefixCls}-search-item-children` }, [slots.default?.()])]);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
});
|
|
61
|
+
//#endregion
|
|
62
|
+
export { FormItemWrapper };
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { FormConfig, ProSearchMap } from "../../interface.js";
|
|
2
|
+
import { PropType } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/components/SearchForm/SearchForm.d.ts
|
|
5
|
+
declare const ProTableSearchForm: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
6
|
+
prefixCls: {
|
|
7
|
+
type: StringConstructor;
|
|
8
|
+
required: true;
|
|
9
|
+
};
|
|
10
|
+
formColumns: {
|
|
11
|
+
type: PropType<ProSearchMap[]>;
|
|
12
|
+
default: () => any[];
|
|
13
|
+
};
|
|
14
|
+
formState: {
|
|
15
|
+
type: PropType<Record<string, any>>;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
defaultFormSearch: {
|
|
19
|
+
type: PropType<Record<string, any>>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
formConfig: {
|
|
23
|
+
type: PropType<FormConfig | undefined>;
|
|
24
|
+
default: any;
|
|
25
|
+
};
|
|
26
|
+
formAutoRequest: {
|
|
27
|
+
type: BooleanConstructor;
|
|
28
|
+
default: boolean;
|
|
29
|
+
};
|
|
30
|
+
formActions: {
|
|
31
|
+
type: PropType<FormConfig["actions"] | undefined>;
|
|
32
|
+
default: any;
|
|
33
|
+
};
|
|
34
|
+
loading: {
|
|
35
|
+
type: PropType<boolean | any>;
|
|
36
|
+
default: boolean;
|
|
37
|
+
};
|
|
38
|
+
cardBordered: {
|
|
39
|
+
type: BooleanConstructor;
|
|
40
|
+
default: boolean;
|
|
41
|
+
};
|
|
42
|
+
proClasses: {
|
|
43
|
+
type: PropType<Record<string, string>>;
|
|
44
|
+
default: () => {};
|
|
45
|
+
};
|
|
46
|
+
proStyles: {
|
|
47
|
+
type: PropType<Record<string, any>>;
|
|
48
|
+
default: () => {};
|
|
49
|
+
};
|
|
50
|
+
onSearch: {
|
|
51
|
+
type: PropType<(params: Record<string, any>, action?: "reset" | "submit") => void>;
|
|
52
|
+
required: true;
|
|
53
|
+
};
|
|
54
|
+
onReset: {
|
|
55
|
+
type: PropType<(params: Record<string, any>) => void>;
|
|
56
|
+
default: any;
|
|
57
|
+
};
|
|
58
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
59
|
+
prefixCls: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
required: true;
|
|
62
|
+
};
|
|
63
|
+
formColumns: {
|
|
64
|
+
type: PropType<ProSearchMap[]>;
|
|
65
|
+
default: () => any[];
|
|
66
|
+
};
|
|
67
|
+
formState: {
|
|
68
|
+
type: PropType<Record<string, any>>;
|
|
69
|
+
required: true;
|
|
70
|
+
};
|
|
71
|
+
defaultFormSearch: {
|
|
72
|
+
type: PropType<Record<string, any>>;
|
|
73
|
+
required: true;
|
|
74
|
+
};
|
|
75
|
+
formConfig: {
|
|
76
|
+
type: PropType<FormConfig | undefined>;
|
|
77
|
+
default: any;
|
|
78
|
+
};
|
|
79
|
+
formAutoRequest: {
|
|
80
|
+
type: BooleanConstructor;
|
|
81
|
+
default: boolean;
|
|
82
|
+
};
|
|
83
|
+
formActions: {
|
|
84
|
+
type: PropType<FormConfig["actions"] | undefined>;
|
|
85
|
+
default: any;
|
|
86
|
+
};
|
|
87
|
+
loading: {
|
|
88
|
+
type: PropType<boolean | any>;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
91
|
+
cardBordered: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
proClasses: {
|
|
96
|
+
type: PropType<Record<string, string>>;
|
|
97
|
+
default: () => {};
|
|
98
|
+
};
|
|
99
|
+
proStyles: {
|
|
100
|
+
type: PropType<Record<string, any>>;
|
|
101
|
+
default: () => {};
|
|
102
|
+
};
|
|
103
|
+
onSearch: {
|
|
104
|
+
type: PropType<(params: Record<string, any>, action?: "reset" | "submit") => void>;
|
|
105
|
+
required: true;
|
|
106
|
+
};
|
|
107
|
+
onReset: {
|
|
108
|
+
type: PropType<(params: Record<string, any>) => void>;
|
|
109
|
+
default: any;
|
|
110
|
+
};
|
|
111
|
+
}>> & Readonly<{}>, {
|
|
112
|
+
onReset: (params: Record<string, any>) => void;
|
|
113
|
+
proClasses: Record<string, string>;
|
|
114
|
+
proStyles: Record<string, any>;
|
|
115
|
+
formColumns: ProSearchMap<"text", string>[];
|
|
116
|
+
formConfig: FormConfig;
|
|
117
|
+
formAutoRequest: boolean;
|
|
118
|
+
formActions: {
|
|
119
|
+
reset?: boolean;
|
|
120
|
+
resetReload?: boolean;
|
|
121
|
+
searchText?: string;
|
|
122
|
+
resetText?: string;
|
|
123
|
+
};
|
|
124
|
+
loading: any;
|
|
125
|
+
cardBordered: boolean;
|
|
126
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
127
|
+
//#endregion
|
|
128
|
+
export { ProTableSearchForm as default };
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import { useProBreakpoints } from "../../hooks/useBreakpoints.js";
|
|
2
|
+
import { formatDateRangeArray, formatStringValue, resolveValueFormat } from "../../utils/dateFormat.js";
|
|
3
|
+
import { CollapseToggle } from "./CollapseToggle.js";
|
|
4
|
+
import { FormItemContainer } from "./FormItemContainer.js";
|
|
5
|
+
import { FormItemWrapper } from "./FormItemWrapper.js";
|
|
6
|
+
import { computed, createVNode, defineComponent, isVNode, ref, watch } from "vue";
|
|
7
|
+
import { classNames, filterEmpty, isArray, isBoolean, isNumber, isObject } from "@gx-design-vue/pro-utils";
|
|
8
|
+
import { Button } from "antdv-next";
|
|
9
|
+
import { cloneDeep as cloneDeep$1 } from "es-toolkit";
|
|
10
|
+
//#region src/components/SearchForm/SearchForm.tsx
|
|
11
|
+
function _isSlot(s) {
|
|
12
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
13
|
+
}
|
|
14
|
+
const ProTableSearchForm = /* @__PURE__ */ defineComponent({
|
|
15
|
+
name: "ProTableSearchForm",
|
|
16
|
+
inheritAttrs: false,
|
|
17
|
+
props: {
|
|
18
|
+
prefixCls: {
|
|
19
|
+
type: String,
|
|
20
|
+
required: true
|
|
21
|
+
},
|
|
22
|
+
formColumns: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: () => []
|
|
25
|
+
},
|
|
26
|
+
formState: {
|
|
27
|
+
type: Object,
|
|
28
|
+
required: true
|
|
29
|
+
},
|
|
30
|
+
defaultFormSearch: {
|
|
31
|
+
type: Object,
|
|
32
|
+
required: true
|
|
33
|
+
},
|
|
34
|
+
formConfig: {
|
|
35
|
+
type: Object,
|
|
36
|
+
default: void 0
|
|
37
|
+
},
|
|
38
|
+
formAutoRequest: {
|
|
39
|
+
type: Boolean,
|
|
40
|
+
default: true
|
|
41
|
+
},
|
|
42
|
+
formActions: {
|
|
43
|
+
type: Object,
|
|
44
|
+
default: void 0
|
|
45
|
+
},
|
|
46
|
+
loading: {
|
|
47
|
+
type: [Boolean, Object],
|
|
48
|
+
default: false
|
|
49
|
+
},
|
|
50
|
+
cardBordered: {
|
|
51
|
+
type: Boolean,
|
|
52
|
+
default: false
|
|
53
|
+
},
|
|
54
|
+
proClasses: {
|
|
55
|
+
type: Object,
|
|
56
|
+
default: () => ({})
|
|
57
|
+
},
|
|
58
|
+
proStyles: {
|
|
59
|
+
type: Object,
|
|
60
|
+
default: () => ({})
|
|
61
|
+
},
|
|
62
|
+
onSearch: {
|
|
63
|
+
type: Function,
|
|
64
|
+
required: true
|
|
65
|
+
},
|
|
66
|
+
onReset: {
|
|
67
|
+
type: Function,
|
|
68
|
+
default: void 0
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
setup(props, { slots, expose }) {
|
|
72
|
+
const collapsed = ref(props.formConfig?.collapsed ?? props.formConfig?.defaultCollapsed);
|
|
73
|
+
watch(() => props.formConfig?.collapsed, (value) => {
|
|
74
|
+
collapsed.value = value;
|
|
75
|
+
});
|
|
76
|
+
const { getRowItemsPerBreakpoint } = useProBreakpoints();
|
|
77
|
+
const formConfig = computed(() => props.formConfig);
|
|
78
|
+
const formAutoRequest = computed(() => props.formAutoRequest);
|
|
79
|
+
const formActions = computed(() => props.formActions);
|
|
80
|
+
const breakpoint = computed(() => {
|
|
81
|
+
if (formConfig.value?.breakpoint && isObject(formConfig.value.breakpoint) && Object.keys(formConfig.value.breakpoint).length > 0) return formConfig.value.breakpoint;
|
|
82
|
+
});
|
|
83
|
+
const rowLength = computed(() => {
|
|
84
|
+
return getRowItemsPerBreakpoint(formConfig.value?.span, breakpoint.value);
|
|
85
|
+
});
|
|
86
|
+
const gap = computed(() => {
|
|
87
|
+
const gapValue = formConfig.value?.gap;
|
|
88
|
+
return typeof gapValue === "number" ? `${gapValue}px` : gapValue ?? "16px";
|
|
89
|
+
});
|
|
90
|
+
const formItemLabel = computed(() => formConfig.value?.label);
|
|
91
|
+
const showResetButton = computed(() => {
|
|
92
|
+
if (isBoolean(formActions.value?.reset)) return formActions.value.reset;
|
|
93
|
+
return !formAutoRequest.value;
|
|
94
|
+
});
|
|
95
|
+
function handleFormFieldChange(value, record, options) {
|
|
96
|
+
const name = record.name;
|
|
97
|
+
const valueType = record.valueType ?? "text";
|
|
98
|
+
let newValue = value;
|
|
99
|
+
switch (valueType) {
|
|
100
|
+
case "text": break;
|
|
101
|
+
case "number":
|
|
102
|
+
newValue = value ?? void 0;
|
|
103
|
+
break;
|
|
104
|
+
case "numberRange":
|
|
105
|
+
if ((options?.key === 0 || options?.key === 1) && props.formState[name]) {
|
|
106
|
+
const updated = [...Array.isArray(props.formState[name]) ? props.formState[name] : []];
|
|
107
|
+
if (options?.key !== void 0) updated[options.key] = value ?? "";
|
|
108
|
+
newValue = updated;
|
|
109
|
+
}
|
|
110
|
+
break;
|
|
111
|
+
case "select":
|
|
112
|
+
newValue = value ?? void 0;
|
|
113
|
+
break;
|
|
114
|
+
case "treeSelect":
|
|
115
|
+
newValue = value ?? (record.field?.treeCheckable || record.field?.multiple ? [] : null);
|
|
116
|
+
break;
|
|
117
|
+
case "cascader":
|
|
118
|
+
newValue = value ?? void 0;
|
|
119
|
+
break;
|
|
120
|
+
case "date": {
|
|
121
|
+
const format = resolveValueFormat(record.valueFormat, record.showTime);
|
|
122
|
+
newValue = value ? formatStringValue(value, format) : null;
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
case "dateWeek":
|
|
126
|
+
newValue = value ? formatStringValue(value, "YYYY-wo") : null;
|
|
127
|
+
break;
|
|
128
|
+
case "dateMonth":
|
|
129
|
+
newValue = value ? formatStringValue(value, "YYYY-MM") : null;
|
|
130
|
+
break;
|
|
131
|
+
case "dateQuarter":
|
|
132
|
+
newValue = value ? formatStringValue(value, "YYYY-QQ") : null;
|
|
133
|
+
break;
|
|
134
|
+
case "dateYear":
|
|
135
|
+
newValue = value ? formatStringValue(value, "YYYY") : null;
|
|
136
|
+
break;
|
|
137
|
+
case "dateRange": {
|
|
138
|
+
const format = resolveValueFormat(record.valueFormat, record.showTime);
|
|
139
|
+
newValue = value && isArray(value) && value.length === 2 ? formatDateRangeArray(value, format, "string") : null;
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
case "time":
|
|
143
|
+
newValue = value ? formatStringValue(value, record.valueFormat || "HH:mm:ss") : null;
|
|
144
|
+
break;
|
|
145
|
+
}
|
|
146
|
+
props.formState[name] = newValue;
|
|
147
|
+
handleAutoSubmit();
|
|
148
|
+
}
|
|
149
|
+
function handleAutoSubmit() {
|
|
150
|
+
if (formAutoRequest.value) handleSubmit();
|
|
151
|
+
}
|
|
152
|
+
function handleSubmit() {
|
|
153
|
+
const searchParams = buildFormSearchParams();
|
|
154
|
+
props.onSearch(searchParams);
|
|
155
|
+
}
|
|
156
|
+
function handleManualSubmit() {
|
|
157
|
+
const searchParams = buildFormSearchParams();
|
|
158
|
+
props.onSearch(searchParams, "submit");
|
|
159
|
+
}
|
|
160
|
+
function buildFormSearchParams() {
|
|
161
|
+
const searchParams = cloneDeep$1(props.formState);
|
|
162
|
+
for (const record of props.formColumns) {
|
|
163
|
+
const valueType = record.valueType ?? "text";
|
|
164
|
+
const name = record.name;
|
|
165
|
+
if (valueType === "text") searchParams[name] = props.formState[name] ?? record.initialValue;
|
|
166
|
+
if (valueType === "dateRange" && (record.rangeStartName || record.rangeEndName)) {
|
|
167
|
+
const rangeValue = searchParams[name];
|
|
168
|
+
searchParams[record.rangeStartName || "start"] = Array.isArray(rangeValue) ? rangeValue[0] : void 0;
|
|
169
|
+
searchParams[record.rangeEndName || "end"] = Array.isArray(rangeValue) ? rangeValue[1] : void 0;
|
|
170
|
+
delete searchParams[name];
|
|
171
|
+
}
|
|
172
|
+
if (valueType === "cascader" && record.valueKey === "single") {
|
|
173
|
+
const value = searchParams[name];
|
|
174
|
+
searchParams[name] = Array.isArray(value) ? value[value.length - 1] : void 0;
|
|
175
|
+
}
|
|
176
|
+
if (valueType === "numberRange") {
|
|
177
|
+
const value = searchParams[name];
|
|
178
|
+
searchParams[name] = Array.isArray(value) && value.some((val) => isNumber(val)) ? value : void 0;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
return searchParams;
|
|
182
|
+
}
|
|
183
|
+
function resetForm() {
|
|
184
|
+
const defaults = cloneDeep$1(props.defaultFormSearch);
|
|
185
|
+
Object.keys(props.formState).forEach((key) => {
|
|
186
|
+
props.formState[key] = key in defaults ? defaults[key] : void 0;
|
|
187
|
+
});
|
|
188
|
+
for (const record of props.formColumns) if (record.valueType === "dateRange" && (record.rangeStartName || record.rangeEndName)) {
|
|
189
|
+
const startKey = record.rangeStartName || "start";
|
|
190
|
+
const endKey = record.rangeEndName || "end";
|
|
191
|
+
if (defaults[startKey] !== void 0 || defaults[endKey] !== void 0) props.formState[record.name] = [defaults[startKey], defaults[endKey]];
|
|
192
|
+
}
|
|
193
|
+
const searchParams = buildFormSearchParams();
|
|
194
|
+
props.onSearch(searchParams, "reset");
|
|
195
|
+
props.onReset?.(searchParams);
|
|
196
|
+
}
|
|
197
|
+
function handleCollapseToggle(status) {
|
|
198
|
+
collapsed.value = status;
|
|
199
|
+
}
|
|
200
|
+
expose({
|
|
201
|
+
handleSubmit,
|
|
202
|
+
resetForm
|
|
203
|
+
});
|
|
204
|
+
function getFormItemStyle(index, itemsPerRow, containerGap) {
|
|
205
|
+
const rowWidth = { width: `calc((100% - (${itemsPerRow - 1} * ${containerGap})) / ${itemsPerRow})` };
|
|
206
|
+
return (index + 1) % itemsPerRow === 0 ? {
|
|
207
|
+
...rowWidth,
|
|
208
|
+
marginRight: 0
|
|
209
|
+
} : {
|
|
210
|
+
...rowWidth,
|
|
211
|
+
marginRight: containerGap
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
return () => {
|
|
215
|
+
const formNode = [...props.formColumns];
|
|
216
|
+
const normalizedSlots = filterEmpty(slots.default?.() || []);
|
|
217
|
+
const mergedFormItems = sortFormItemsByOrder([...formNode, ...normalizedSlots.map((item) => ({
|
|
218
|
+
...item,
|
|
219
|
+
order: item.props?.order ?? void 0
|
|
220
|
+
}))]);
|
|
221
|
+
const itemsPerRow = rowLength.value;
|
|
222
|
+
const containerGap = gap.value;
|
|
223
|
+
const totalItems = mergedFormItems.length;
|
|
224
|
+
const isCollapsed = collapsed.value !== false;
|
|
225
|
+
const showCollapse = totalItems > itemsPerRow;
|
|
226
|
+
const renderFormItem = (item, index) => {
|
|
227
|
+
const formItemStyle = getFormItemStyle(index, itemsPerRow, containerGap);
|
|
228
|
+
const label = isVNode(item) ? item.props?.label : item.label;
|
|
229
|
+
const labelWidth = (isVNode(item) ? item.props?.labelWidth : item.labelWidth) ?? formItemLabel.value?.width;
|
|
230
|
+
const labelAlign = (isVNode(item) ? item.props?.labelAlign : item.labelAlign) ?? formItemLabel.value?.align;
|
|
231
|
+
if (isVNode(item)) return createVNode(FormItemWrapper, {
|
|
232
|
+
"label": label,
|
|
233
|
+
"labelWidth": labelWidth,
|
|
234
|
+
"labelAlign": labelAlign,
|
|
235
|
+
"colon": formItemLabel.value?.colon,
|
|
236
|
+
"globalLabelGap": formItemLabel.value?.gap,
|
|
237
|
+
"prefixCls": props.prefixCls,
|
|
238
|
+
"formItemStyle": formItemStyle
|
|
239
|
+
}, _isSlot(item) ? item : { default: () => [item] });
|
|
240
|
+
return createVNode(FormItemWrapper, {
|
|
241
|
+
"key": String(item.name ?? item.key ?? index),
|
|
242
|
+
"label": item.label,
|
|
243
|
+
"labelWidth": labelWidth,
|
|
244
|
+
"labelAlign": labelAlign,
|
|
245
|
+
"colon": formItemLabel.value?.colon,
|
|
246
|
+
"globalLabelGap": formItemLabel.value?.gap,
|
|
247
|
+
"prefixCls": props.prefixCls,
|
|
248
|
+
"formItemStyle": formItemStyle
|
|
249
|
+
}, { default: () => [createVNode(FormItemContainer, {
|
|
250
|
+
"prefixCls": props.prefixCls,
|
|
251
|
+
"record": item,
|
|
252
|
+
"formState": props.formState,
|
|
253
|
+
"autoRequest": formAutoRequest.value,
|
|
254
|
+
"loading": typeof props.loading === "boolean" ? props.loading : false,
|
|
255
|
+
"onChange": handleFormFieldChange,
|
|
256
|
+
"onSubmit": handleAutoSubmit
|
|
257
|
+
}, null)] });
|
|
258
|
+
};
|
|
259
|
+
const renderActionButtons = () => {
|
|
260
|
+
if (!showResetButton.value && formAutoRequest.value) return null;
|
|
261
|
+
return createVNode("div", {
|
|
262
|
+
"class": [`${props.prefixCls}-search-buttons`, props.proClasses.searchButtons],
|
|
263
|
+
"style": props.proStyles.searchButtons
|
|
264
|
+
}, [showResetButton.value && createVNode(Button, {
|
|
265
|
+
"key": "reset",
|
|
266
|
+
"onClick": resetForm
|
|
267
|
+
}, { default: () => [formActions.value?.resetText || "重置"] }), !formAutoRequest.value && createVNode(Button, {
|
|
268
|
+
"key": "submit",
|
|
269
|
+
"type": "primary",
|
|
270
|
+
"loading": typeof props.loading === "boolean" ? props.loading : false,
|
|
271
|
+
"onClick": handleManualSubmit
|
|
272
|
+
}, { default: () => [formActions.value?.searchText || "查询"] })]);
|
|
273
|
+
};
|
|
274
|
+
const renderCollapseToggle = (show, isCollapsedState) => {
|
|
275
|
+
if (formConfig.value?.collapseRender === false && !renderActionButtons()) return null;
|
|
276
|
+
const actionBtns = renderActionButtons();
|
|
277
|
+
if (!show && !actionBtns) return null;
|
|
278
|
+
return createVNode("div", {
|
|
279
|
+
"class": [`${props.prefixCls}-search-control`, props.proClasses.searchControl],
|
|
280
|
+
"style": {
|
|
281
|
+
flex: 1,
|
|
282
|
+
justifyContent: "flex-end",
|
|
283
|
+
...props.proStyles.searchControl
|
|
284
|
+
}
|
|
285
|
+
}, [createVNode("div", { "class": [`${props.prefixCls}-search-control-content`, props.proClasses.searchContent] }, [actionBtns, show && createVNode(CollapseToggle, {
|
|
286
|
+
"collapsed": isCollapsedState,
|
|
287
|
+
"collapseRender": formConfig.value?.collapseRender,
|
|
288
|
+
"prefixCls": props.prefixCls,
|
|
289
|
+
"onToggle": handleCollapseToggle
|
|
290
|
+
}, null)])]);
|
|
291
|
+
};
|
|
292
|
+
const borderedCls = props.cardBordered ? `${props.prefixCls}-search-border` : "";
|
|
293
|
+
const visibleItemCount = totalItems <= itemsPerRow || !isCollapsed ? totalItems : Math.max(itemsPerRow - 1, 0);
|
|
294
|
+
return createVNode("div", {
|
|
295
|
+
"class": classNames(props.proClasses.search, `${props.prefixCls}-search`, borderedCls, formConfig.value?.className),
|
|
296
|
+
"style": props.proStyles.search
|
|
297
|
+
}, [mergedFormItems.slice(0, visibleItemCount).map((item, index) => renderFormItem(item, index)), renderCollapseToggle(showCollapse, isCollapsed)]);
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
});
|
|
301
|
+
function sortFormItemsByOrder(items) {
|
|
302
|
+
let maxOrder = items.reduce((max, item) => {
|
|
303
|
+
return item.order !== void 0 ? Math.max(max, item.order) : max;
|
|
304
|
+
}, 0);
|
|
305
|
+
const sorted = items.map((item) => {
|
|
306
|
+
if (item.order === void 0) {
|
|
307
|
+
maxOrder += 1;
|
|
308
|
+
return {
|
|
309
|
+
...item,
|
|
310
|
+
order: maxOrder
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
return item;
|
|
314
|
+
});
|
|
315
|
+
sorted.sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
|
|
316
|
+
return sorted;
|
|
317
|
+
}
|
|
318
|
+
//#endregion
|
|
319
|
+
export { ProTableSearchForm as default };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { PropType } from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/Toolbar/FullscreenIcon.d.ts
|
|
4
|
+
declare const FullscreenIcon: import("vue").DefineComponent<import("vue").ExtractPropTypes<{
|
|
5
|
+
isFullscreen: {
|
|
6
|
+
type: BooleanConstructor;
|
|
7
|
+
required: true;
|
|
8
|
+
};
|
|
9
|
+
onToggle: {
|
|
10
|
+
type: PropType<() => void>;
|
|
11
|
+
required: true;
|
|
12
|
+
};
|
|
13
|
+
}>, () => import("vue/jsx-runtime").JSX.Element, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
|
|
14
|
+
isFullscreen: {
|
|
15
|
+
type: BooleanConstructor;
|
|
16
|
+
required: true;
|
|
17
|
+
};
|
|
18
|
+
onToggle: {
|
|
19
|
+
type: PropType<() => void>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
}>> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
23
|
+
//#endregion
|
|
24
|
+
export { FullscreenIcon };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { createVNode, defineComponent } from "vue";
|
|
2
|
+
import { Tooltip } from "antdv-next";
|
|
3
|
+
import { GIcon } from "@gx-design-vue/icon";
|
|
4
|
+
//#region src/components/Toolbar/FullscreenIcon.tsx
|
|
5
|
+
const FullscreenIcon = /* @__PURE__ */ defineComponent({
|
|
6
|
+
name: "ProTableFullscreenIcon",
|
|
7
|
+
props: {
|
|
8
|
+
isFullscreen: {
|
|
9
|
+
type: Boolean,
|
|
10
|
+
required: true
|
|
11
|
+
},
|
|
12
|
+
onToggle: {
|
|
13
|
+
type: Function,
|
|
14
|
+
required: true
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
setup(props) {
|
|
18
|
+
return () => createVNode(Tooltip, { "title": props.isFullscreen ? "退出全屏" : "全屏" }, { default: () => [createVNode("span", { "onClick": props.onToggle }, [props.isFullscreen ? createVNode(GIcon, { "type": "FullscreenExitOutlined" }, null) : createVNode(GIcon, { "type": "FullscreenOutlined" }, null)])] });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
//#endregion
|
|
22
|
+
export { FullscreenIcon };
|