@antdv-vue/pro-table 0.0.0-stage → 2.0.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/CHANGELOG.md +255 -0
- package/README.md +106 -2
- package/dist/InternalTable.d.ts +360 -0
- package/dist/InternalTable.js +444 -0
- package/dist/RenderTypings.d.ts +33 -0
- package/dist/RenderTypings.js +1 -0
- package/dist/ResizableTableTitle.d.ts +24 -0
- package/dist/ResizableTableTitle.js +89 -0
- package/dist/Store/Provide.d.ts +68 -0
- package/dist/Store/Provide.js +132 -0
- package/dist/Table.d.ts +363 -0
- package/dist/Table.js +151 -0
- package/dist/TableRender.d.ts +54 -0
- package/dist/TableRender.js +295 -0
- package/dist/components/Alert/index.d.ts +45 -0
- package/dist/components/Alert/index.js +94 -0
- package/dist/components/Alert/style/index.d.ts +8 -0
- package/dist/components/Alert/style/index.js +11 -0
- package/dist/components/ColumnSetting/CheckboxList.d.ts +24 -0
- package/dist/components/ColumnSetting/CheckboxList.js +138 -0
- package/dist/components/ColumnSetting/CheckboxListItem.d.ts +17 -0
- package/dist/components/ColumnSetting/CheckboxListItem.js +84 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.d.ts +22 -0
- package/dist/components/ColumnSetting/GroupCheckboxList.js +82 -0
- package/dist/components/ColumnSetting/ToolTipIcon.d.ts +12 -0
- package/dist/components/ColumnSetting/ToolTipIcon.js +47 -0
- package/dist/components/ColumnSetting/index.d.ts +26 -0
- package/dist/components/ColumnSetting/index.js +117 -0
- package/dist/components/ColumnSetting/style/index.d.ts +8 -0
- package/dist/components/ColumnSetting/style/index.js +73 -0
- package/dist/components/DragSortTable/index.d.ts +375 -0
- package/dist/components/DragSortTable/index.js +166 -0
- package/dist/components/DragSortTable/style/index.d.ts +8 -0
- package/dist/components/DragSortTable/style/index.js +25 -0
- package/dist/components/Dropdown/Button.d.ts +20 -0
- package/dist/components/Dropdown/Button.js +155 -0
- package/dist/components/Dropdown/index.d.ts +27 -0
- package/dist/components/Dropdown/index.js +149 -0
- package/dist/components/EditableTable/CellEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/CellEditorTable.js +167 -0
- package/dist/components/EditableTable/EditableTable.d.ts +67 -0
- package/dist/components/EditableTable/EditableTable.js +141 -0
- package/dist/components/EditableTable/InternalEditableTable.d.ts +189 -0
- package/dist/components/EditableTable/InternalEditableTable.js +508 -0
- package/dist/components/EditableTable/RowEditorTable.d.ts +63 -0
- package/dist/components/EditableTable/RowEditorTable.js +147 -0
- package/dist/components/EditableTable/context.d.ts +9 -0
- package/dist/components/EditableTable/context.js +11 -0
- package/dist/components/EditableTable/index.d.ts +5 -0
- package/dist/components/EditableTable/index.js +5 -0
- package/dist/components/Form/FormRender.d.ts +77 -0
- package/dist/components/Form/FormRender.js +198 -0
- package/dist/components/Form/index.d.ts +33 -0
- package/dist/components/Form/index.js +91 -0
- package/dist/components/ToolBar/DensityIcon.d.ts +22 -0
- package/dist/components/ToolBar/DensityIcon.js +71 -0
- package/dist/components/ToolBar/FullScreenIcon.d.ts +6 -0
- package/dist/components/ToolBar/FullScreenIcon.js +30 -0
- package/dist/components/ToolBar/HeaderMenu.d.ts +22 -0
- package/dist/components/ToolBar/HeaderMenu.js +84 -0
- package/dist/components/ToolBar/index.d.ts +102 -0
- package/dist/components/ToolBar/index.js +322 -0
- package/dist/components/ToolBar/style/index.d.ts +8 -0
- package/dist/components/ToolBar/style/index.js +116 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +10 -0
- package/dist/pro-table.esm.js +3274 -0
- package/dist/style/index.d.ts +11 -0
- package/dist/style/index.js +162 -0
- package/dist/typing.d.ts +409 -0
- package/dist/typing.js +1 -0
- package/dist/useFetchData.d.ts +10 -0
- package/dist/useFetchData.js +243 -0
- package/dist/utils/cellRenderToFromItem.d.ts +52 -0
- package/dist/utils/cellRenderToFromItem.js +163 -0
- package/dist/utils/columnRender.d.ts +54 -0
- package/dist/utils/columnRender.js +148 -0
- package/dist/utils/columnSort.d.ts +7 -0
- package/dist/utils/columnSort.js +17 -0
- package/dist/utils/genProColumnsToColumns.d.ts +69 -0
- package/dist/utils/genProColumnsToColumns.js +197 -0
- package/dist/utils/index.d.ts +122 -0
- package/dist/utils/index.js +227 -0
- package/dist/utils/useDragSort.d.ts +182 -0
- package/dist/utils/useDragSort.js +162 -0
- package/package.json +67 -3
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { useEditableProTableInstanceExpose } from "./InternalEditableTable.js";
|
|
2
|
+
import EditableProTable from "./EditableTable.js";
|
|
3
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
4
|
+
import { useMemo, useState } from "@antdv-vue/pro-utils";
|
|
5
|
+
//#region src/components/EditableTable/RowEditorTable.tsx
|
|
6
|
+
const RowEditorTable = /* @__PURE__ */ defineComponent((props, { slots, expose }) => {
|
|
7
|
+
const [editableKeys, setEditableRowKeys] = useState([]);
|
|
8
|
+
const rowKey = computed(() => props.rowKey || "id");
|
|
9
|
+
const editableTableRef = shallowRef(null);
|
|
10
|
+
const getRowKey = useMemo(() => {
|
|
11
|
+
if (typeof rowKey.value === "function") return rowKey.value;
|
|
12
|
+
return (record, index) => {
|
|
13
|
+
if (index === -1) return record?.[rowKey.value];
|
|
14
|
+
if (props.name) return index?.toString();
|
|
15
|
+
return record?.[rowKey.value] ?? index?.toString();
|
|
16
|
+
};
|
|
17
|
+
}, [() => props.name, rowKey]);
|
|
18
|
+
expose(useEditableProTableInstanceExpose(editableTableRef));
|
|
19
|
+
return () => createVNode(EditableProTable, mergeProps(props, {
|
|
20
|
+
"ref": editableTableRef,
|
|
21
|
+
"bordered": props.bordered || true,
|
|
22
|
+
"pagination": props.pagination || false,
|
|
23
|
+
"editable": {
|
|
24
|
+
editableKeys: editableKeys.value,
|
|
25
|
+
...props.editable
|
|
26
|
+
},
|
|
27
|
+
"columns": props?.columns?.map((item) => {
|
|
28
|
+
return {
|
|
29
|
+
...item,
|
|
30
|
+
onCell: (record, rowIndex) => ({
|
|
31
|
+
onDblclick: () => setEditableRowKeys([getRowKey.value(record, rowIndex)]),
|
|
32
|
+
onBlur: () => setEditableRowKeys([])
|
|
33
|
+
})
|
|
34
|
+
};
|
|
35
|
+
}) || []
|
|
36
|
+
}), slots);
|
|
37
|
+
}, {
|
|
38
|
+
name: "RowEditorTable",
|
|
39
|
+
inheritAttrs: false,
|
|
40
|
+
props: [
|
|
41
|
+
"beforeSearchSubmit",
|
|
42
|
+
"bodyCell",
|
|
43
|
+
"bordered",
|
|
44
|
+
"caption",
|
|
45
|
+
"cardBordered",
|
|
46
|
+
"cardProps",
|
|
47
|
+
"childrenColumnName",
|
|
48
|
+
"classes",
|
|
49
|
+
"columnEmptyText",
|
|
50
|
+
"columns",
|
|
51
|
+
"columnsState",
|
|
52
|
+
"components",
|
|
53
|
+
"controlled",
|
|
54
|
+
"dataSource",
|
|
55
|
+
"dateFormatter",
|
|
56
|
+
"debounceTime",
|
|
57
|
+
"defaultData",
|
|
58
|
+
"defaultExpandAllRows",
|
|
59
|
+
"defaultExpandedRowKeys",
|
|
60
|
+
"defaultSize",
|
|
61
|
+
"defaultValue",
|
|
62
|
+
"direction",
|
|
63
|
+
"dropdownPrefixCls",
|
|
64
|
+
"editable",
|
|
65
|
+
"errorBoundaryRender",
|
|
66
|
+
"expandIcon",
|
|
67
|
+
"expandIconColumnIndex",
|
|
68
|
+
"expandRowByClick",
|
|
69
|
+
"expandable",
|
|
70
|
+
"expandedRowClassName",
|
|
71
|
+
"expandedRowKeys",
|
|
72
|
+
"expandedRowRender",
|
|
73
|
+
"footer",
|
|
74
|
+
"form",
|
|
75
|
+
"formItemProps",
|
|
76
|
+
"getContainerWidth",
|
|
77
|
+
"getPopupContainer",
|
|
78
|
+
"ghost",
|
|
79
|
+
"headerCell",
|
|
80
|
+
"headerTitle",
|
|
81
|
+
"id",
|
|
82
|
+
"indentSize",
|
|
83
|
+
"loading",
|
|
84
|
+
"locale",
|
|
85
|
+
"manualRequest",
|
|
86
|
+
"maxLength",
|
|
87
|
+
"measureRowRender",
|
|
88
|
+
"name",
|
|
89
|
+
"onChange",
|
|
90
|
+
"onDataSourceChange",
|
|
91
|
+
"onExpand",
|
|
92
|
+
"onExpandedRowsChange",
|
|
93
|
+
"onHeaderRow",
|
|
94
|
+
"onLoad",
|
|
95
|
+
"onLoadingChange",
|
|
96
|
+
"onRequestError",
|
|
97
|
+
"onReset",
|
|
98
|
+
"onRow",
|
|
99
|
+
"onSizeChange",
|
|
100
|
+
"onSubmit",
|
|
101
|
+
"onTableChange",
|
|
102
|
+
"onValuesChange",
|
|
103
|
+
"options",
|
|
104
|
+
"optionsRender",
|
|
105
|
+
"pagination",
|
|
106
|
+
"params",
|
|
107
|
+
"polling",
|
|
108
|
+
"postData",
|
|
109
|
+
"prefixCls",
|
|
110
|
+
"recordCreatorProps",
|
|
111
|
+
"request",
|
|
112
|
+
"revalidateOnFocus",
|
|
113
|
+
"rootClass",
|
|
114
|
+
"rowClassName",
|
|
115
|
+
"rowHoverable",
|
|
116
|
+
"rowKey",
|
|
117
|
+
"rowSelection",
|
|
118
|
+
"scroll",
|
|
119
|
+
"search",
|
|
120
|
+
"searchFormRender",
|
|
121
|
+
"showHeader",
|
|
122
|
+
"showSorterTooltip",
|
|
123
|
+
"size",
|
|
124
|
+
"sortDirections",
|
|
125
|
+
"sticky",
|
|
126
|
+
"styles",
|
|
127
|
+
"summary",
|
|
128
|
+
"tableAlertOptionRender",
|
|
129
|
+
"tableAlertRender",
|
|
130
|
+
"tableClass",
|
|
131
|
+
"tableExtraRender",
|
|
132
|
+
"tableLayout",
|
|
133
|
+
"tableRender",
|
|
134
|
+
"tableStyle",
|
|
135
|
+
"tableViewRender",
|
|
136
|
+
"tailor",
|
|
137
|
+
"title",
|
|
138
|
+
"toolBarRender",
|
|
139
|
+
"toolbar",
|
|
140
|
+
"tooltip",
|
|
141
|
+
"type",
|
|
142
|
+
"value",
|
|
143
|
+
"virtual"
|
|
144
|
+
]
|
|
145
|
+
});
|
|
146
|
+
//#endregion
|
|
147
|
+
export { RowEditorTable as default };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ProTableInstance } from "../../typing.js";
|
|
2
|
+
import { ShallowRef } from "vue";
|
|
3
|
+
|
|
4
|
+
//#region src/components/EditableTable/context.d.ts
|
|
5
|
+
declare const editableTableActionContextKey: unique symbol;
|
|
6
|
+
declare function useEditableTableActionContextProvider<T extends Record<string, any> = Record<string, any>>(props: ShallowRef<ProTableInstance<T> | null>): void;
|
|
7
|
+
declare function useEditableTableActionContextInject<T extends Record<string, any> = Record<string, any>>(): ShallowRef<ProTableInstance<T> | null> | undefined;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { editableTableActionContextKey, useEditableTableActionContextInject, useEditableTableActionContextProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { inject, provide } from "vue";
|
|
2
|
+
//#region src/components/EditableTable/context.ts
|
|
3
|
+
const editableTableActionContextKey = Symbol("editableTableActionContext");
|
|
4
|
+
function useEditableTableActionContextProvider(props) {
|
|
5
|
+
return provide(editableTableActionContextKey, props);
|
|
6
|
+
}
|
|
7
|
+
function useEditableTableActionContextInject() {
|
|
8
|
+
return inject(editableTableActionContextKey);
|
|
9
|
+
}
|
|
10
|
+
//#endregion
|
|
11
|
+
export { editableTableActionContextKey, useEditableTableActionContextInject, useEditableTableActionContextProvider };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { EditableProTableInstance, EditableProTableProps, RecordCreator } from "./InternalEditableTable.js";
|
|
2
|
+
import EditableProTable from "./EditableTable.js";
|
|
3
|
+
import CellEditorProTable from "./CellEditorTable.js";
|
|
4
|
+
import RowEditorTable from "./RowEditorTable.js";
|
|
5
|
+
export { CellEditorProTable as CellEditorTable, EditableProTable, type EditableProTableInstance, type EditableProTableProps, RecordCreator as EditableProTableRecordCreator, RowEditorTable };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { RecordCreator } from "./InternalEditableTable.js";
|
|
2
|
+
import EditableProTable from "./EditableTable.js";
|
|
3
|
+
import CellEditorProTable from "./CellEditorTable.js";
|
|
4
|
+
import RowEditorTable from "./RowEditorTable.js";
|
|
5
|
+
export { CellEditorProTable as CellEditorTable, EditableProTable, RecordCreator as EditableProTableRecordCreator, RowEditorTable };
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { ActionType, ProColumns, ProTableProps } from "../../typing.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import { CSSProperties } from "vue";
|
|
4
|
+
import { BaseProQueryFilterProps, ProFormProps } from "@antdv-vue/pro-form";
|
|
5
|
+
import { FormItemProps, ProFieldValueObjectType, ProFieldValueType, ProSchemaComponentTypes } from "@antdv-vue/pro-utils";
|
|
6
|
+
import { ProCardProps } from "@antdv-vue/pro-card";
|
|
7
|
+
|
|
8
|
+
//#region src/components/Form/FormRender.d.ts
|
|
9
|
+
type SearchConfig = BaseProQueryFilterProps & {
|
|
10
|
+
filterType?: 'query' | 'light';
|
|
11
|
+
cardProps?: ProCardProps;
|
|
12
|
+
class?: string;
|
|
13
|
+
style?: CSSProperties;
|
|
14
|
+
};
|
|
15
|
+
type FormRenderProps<T, U, ValueType> = {
|
|
16
|
+
onSubmit?: (value: U, firstLoad: boolean) => void;
|
|
17
|
+
onReset?: (value: U) => void;
|
|
18
|
+
form?: Omit<ProFormProps<T, U>, 'form'>;
|
|
19
|
+
type?: ProSchemaComponentTypes;
|
|
20
|
+
dateFormatter?: ProTableProps<T, U, ValueType>['dateFormatter'];
|
|
21
|
+
search?: SearchConfig | false;
|
|
22
|
+
columns: ProColumns<T, ValueType>[];
|
|
23
|
+
submitButtonLoading?: boolean;
|
|
24
|
+
manualRequest?: boolean;
|
|
25
|
+
bordered?: boolean;
|
|
26
|
+
action?: ActionType<Record<string, any>, T>;
|
|
27
|
+
ghost?: boolean;
|
|
28
|
+
} & Omit<FormItemProps, 'onReset'>;
|
|
29
|
+
declare const FormRender: new <T extends Record<string, any>, U extends Record<string, any>, ValueType extends (ProFieldValueType | ProFieldValueObjectType)>(props: {
|
|
30
|
+
onSubmit?: ((value: U, firstLoad: boolean) => void) | undefined;
|
|
31
|
+
onReset?: ((value: U) => void) | undefined;
|
|
32
|
+
form?: Omit<ProFormProps<T, U>, "form"> | undefined;
|
|
33
|
+
type?: ProSchemaComponentTypes;
|
|
34
|
+
dateFormatter?: ProTableProps<T_1, U_1, ValueType_1>["dateFormatter"];
|
|
35
|
+
search?: SearchConfig | false;
|
|
36
|
+
columns: ProColumns<T, ValueType>[];
|
|
37
|
+
submitButtonLoading?: boolean;
|
|
38
|
+
manualRequest?: boolean;
|
|
39
|
+
bordered?: boolean;
|
|
40
|
+
action?: ActionType<Record<string, any>, T> | undefined;
|
|
41
|
+
ghost?: boolean;
|
|
42
|
+
} & Omit<FormItemProps, "onReset"> & {} & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps) => _$vue.CreateComponentPublicInstanceWithMixins<{
|
|
43
|
+
onSubmit?: ((value: U, firstLoad: boolean) => void) | undefined;
|
|
44
|
+
onReset?: ((value: U) => void) | undefined;
|
|
45
|
+
form?: Omit<ProFormProps<T, U>, "form"> | undefined;
|
|
46
|
+
type?: ProSchemaComponentTypes;
|
|
47
|
+
dateFormatter?: ProTableProps<T_1, U_1, ValueType_1>["dateFormatter"];
|
|
48
|
+
search?: SearchConfig | false;
|
|
49
|
+
columns: ProColumns<T, ValueType>[];
|
|
50
|
+
submitButtonLoading?: boolean;
|
|
51
|
+
manualRequest?: boolean;
|
|
52
|
+
bordered?: boolean;
|
|
53
|
+
action?: ActionType<Record<string, any>, T> | undefined;
|
|
54
|
+
ghost?: boolean;
|
|
55
|
+
} & Omit<FormItemProps, "onReset"> & {}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
56
|
+
P: {};
|
|
57
|
+
B: {};
|
|
58
|
+
D: {};
|
|
59
|
+
C: {};
|
|
60
|
+
M: {};
|
|
61
|
+
Defaults: {};
|
|
62
|
+
}, {
|
|
63
|
+
onSubmit?: ((value: U, firstLoad: boolean) => void) | undefined;
|
|
64
|
+
onReset?: ((value: U) => void) | undefined;
|
|
65
|
+
form?: Omit<ProFormProps<T, U>, "form"> | undefined;
|
|
66
|
+
type?: ProSchemaComponentTypes;
|
|
67
|
+
dateFormatter?: ProTableProps<T_1, U_1, ValueType_1>["dateFormatter"];
|
|
68
|
+
search?: SearchConfig | false;
|
|
69
|
+
columns: ProColumns<T, ValueType>[];
|
|
70
|
+
submitButtonLoading?: boolean;
|
|
71
|
+
manualRequest?: boolean;
|
|
72
|
+
bordered?: boolean;
|
|
73
|
+
action?: ActionType<Record<string, any>, T> | undefined;
|
|
74
|
+
ghost?: boolean;
|
|
75
|
+
} & Omit<FormItemProps, "onReset"> & {}, {}, {}, {}, {}, {}>;
|
|
76
|
+
//#endregion
|
|
77
|
+
export { FormRenderProps, SearchConfig, FormRender as default };
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import { computed, createVNode, defineComponent, mergeProps, shallowRef } from "vue";
|
|
2
|
+
import { SchemaForm, useProFormInstanceExpose } from "@antdv-vue/pro-form";
|
|
3
|
+
import { useProConfig } from "@antdv-vue/pro-provider";
|
|
4
|
+
import { classNames, omit } from "@v-c/util";
|
|
5
|
+
import { useConfig } from "antdv-next/config-provider/context";
|
|
6
|
+
import { Table } from "antdv-next";
|
|
7
|
+
import ProCard from "@antdv-vue/pro-card";
|
|
8
|
+
//#region src/components/Form/FormRender.tsx
|
|
9
|
+
function toLowerLine(str) {
|
|
10
|
+
let temp = str.replace(/[A-Z]/g, (match) => {
|
|
11
|
+
return `-${match.toLowerCase()}`;
|
|
12
|
+
});
|
|
13
|
+
if (temp.startsWith("-")) temp = temp.slice(1);
|
|
14
|
+
return temp;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 获取当前选择的 Form Layout 配置
|
|
18
|
+
*
|
|
19
|
+
* @param isForm
|
|
20
|
+
* @param searchConfig
|
|
21
|
+
* @returns LightFilter | QueryFilter | ProForm
|
|
22
|
+
*/
|
|
23
|
+
function getFormCompetent(isForm, searchConfig) {
|
|
24
|
+
if (!isForm && searchConfig !== false) {
|
|
25
|
+
if (searchConfig?.filterType === "light") return "LightFilter";
|
|
26
|
+
return "QueryFilter";
|
|
27
|
+
}
|
|
28
|
+
return "Form";
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 获取需要传给相应表单的props
|
|
32
|
+
*
|
|
33
|
+
* @param isForm
|
|
34
|
+
* @param searchConfig
|
|
35
|
+
* @param name
|
|
36
|
+
*/
|
|
37
|
+
function getFromProps(isForm, searchConfig, name) {
|
|
38
|
+
if (!isForm && name === "LightFilter") return omit({ ...searchConfig }, [
|
|
39
|
+
"labelWidth",
|
|
40
|
+
"defaultCollapsed",
|
|
41
|
+
"cardProps",
|
|
42
|
+
"filterType"
|
|
43
|
+
]);
|
|
44
|
+
if (!isForm) return omit({
|
|
45
|
+
labelWidth: searchConfig ? searchConfig?.labelWidth : void 0,
|
|
46
|
+
defaultCollapsed: true,
|
|
47
|
+
...searchConfig
|
|
48
|
+
}, ["filterType", "cardProps"]);
|
|
49
|
+
return {};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* 从formConfig中获取传给相应表单的配置
|
|
53
|
+
*
|
|
54
|
+
* @param isForm
|
|
55
|
+
* @param formConfig
|
|
56
|
+
*/
|
|
57
|
+
function getFormConfigs(isForm, formConfig) {
|
|
58
|
+
if (isForm) return omit(formConfig, ["ignoreRules"]);
|
|
59
|
+
return {
|
|
60
|
+
ignoreRules: true,
|
|
61
|
+
...formConfig
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
const FormRender = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
65
|
+
const config = useConfig();
|
|
66
|
+
const proProvide = useProConfig();
|
|
67
|
+
const formRef = shallowRef();
|
|
68
|
+
const prefixCls = computed(() => props.prefixCls || config.value.getPrefixCls("pro"));
|
|
69
|
+
const baseClassName = computed(() => `${prefixCls.value}-table-search`);
|
|
70
|
+
const isForm = computed(() => props.type === "form");
|
|
71
|
+
const competentName = computed(() => getFormCompetent(isForm.value, props.search));
|
|
72
|
+
/** 提交表单,根据两种模式不同,方法不相同 */
|
|
73
|
+
const submit = (values, firstLoad) => {
|
|
74
|
+
if (props.onSubmit) props.onSubmit(values, firstLoad);
|
|
75
|
+
};
|
|
76
|
+
const columnsList = computed(() => props.columns?.filter((item) => {
|
|
77
|
+
if (item === Table.EXPAND_COLUMN || item === Table.SELECTION_COLUMN) return false;
|
|
78
|
+
if (item.search === false && props.type !== "form") return false;
|
|
79
|
+
return !(props.type === "form" && item.hideInForm);
|
|
80
|
+
}).map((item) => {
|
|
81
|
+
const finalValueType = !item.valueType || [
|
|
82
|
+
"textarea",
|
|
83
|
+
"jsonCode",
|
|
84
|
+
"code"
|
|
85
|
+
].includes(item?.valueType) && props.type === "table" ? "text" : item?.valueType;
|
|
86
|
+
const columnKey = item?.key || item?.dataIndex?.toString();
|
|
87
|
+
return {
|
|
88
|
+
...item,
|
|
89
|
+
width: void 0,
|
|
90
|
+
...item.search && typeof item.search === "object" ? item.search : {},
|
|
91
|
+
valueType: finalValueType,
|
|
92
|
+
proFieldProps: {
|
|
93
|
+
...item.proFieldProps,
|
|
94
|
+
proFieldKey: columnKey ? `table-field-${columnKey}` : void 0
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}));
|
|
98
|
+
expose(useProFormInstanceExpose(formRef));
|
|
99
|
+
return () => {
|
|
100
|
+
const { type, dateFormatter = "string", submitButtonLoading, action, ghost, manualRequest, onReset, search: searchConfig, form: formConfig, bordered } = props;
|
|
101
|
+
const cardProps = typeof searchConfig !== "boolean" ? searchConfig?.cardProps || {} : {};
|
|
102
|
+
return createVNode(ProCard, mergeProps(cardProps, {
|
|
103
|
+
"ghost": ghost,
|
|
104
|
+
"class": classNames(baseClassName.value, proProvide.value.hashId, {
|
|
105
|
+
[`${baseClassName.value}-${toLowerLine(competentName.value)}`]: true,
|
|
106
|
+
[`${prefixCls.value}-table-form`]: isForm.value,
|
|
107
|
+
[searchConfig?.class]: searchConfig !== false && searchConfig?.class
|
|
108
|
+
}),
|
|
109
|
+
"style": searchConfig !== false && searchConfig?.style,
|
|
110
|
+
"variant": !bordered ? "borderless" : "outlined",
|
|
111
|
+
"styles": {
|
|
112
|
+
...cardProps?.styles,
|
|
113
|
+
body: {
|
|
114
|
+
...cardProps.styles ? "body" in cardProps?.styles ? cardProps?.styles?.body : {} : {},
|
|
115
|
+
padding: 0,
|
|
116
|
+
borderRadius: 0
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}), { default: () => [createVNode(SchemaForm, mergeProps({
|
|
120
|
+
"ref": formRef,
|
|
121
|
+
"layoutType": competentName.value,
|
|
122
|
+
"columns": columnsList.value,
|
|
123
|
+
"type": type,
|
|
124
|
+
"submitter": { submitButtonProps: { loading: submitButtonLoading } }
|
|
125
|
+
}, getFromProps(isForm.value, typeof searchConfig === "boolean" ? {} : searchConfig, competentName.value), getFormConfigs(isForm.value, formConfig || {}), {
|
|
126
|
+
"action": action,
|
|
127
|
+
"dateFormatter": dateFormatter,
|
|
128
|
+
"onInit": async (values, form) => {
|
|
129
|
+
formRef.value = form;
|
|
130
|
+
if (type !== "form") {
|
|
131
|
+
const pageInfo = action?.pageInfo;
|
|
132
|
+
const { current = pageInfo?.current, pageSize = pageInfo?.pageSize } = values;
|
|
133
|
+
await action?.setPageInfo?.({
|
|
134
|
+
...pageInfo,
|
|
135
|
+
current: Number.parseInt(current, 10),
|
|
136
|
+
pageSize: Number.parseInt(pageSize, 10)
|
|
137
|
+
});
|
|
138
|
+
if (manualRequest) return;
|
|
139
|
+
submit(values, true);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
"onReset": onReset,
|
|
143
|
+
"onFinish": (values) => submit(values, false),
|
|
144
|
+
"model": formConfig?.model
|
|
145
|
+
}), null)] });
|
|
146
|
+
};
|
|
147
|
+
}, {
|
|
148
|
+
name: "FormRender",
|
|
149
|
+
inheritAttrs: false,
|
|
150
|
+
props: [
|
|
151
|
+
"action",
|
|
152
|
+
"bordered",
|
|
153
|
+
"colon",
|
|
154
|
+
"columns",
|
|
155
|
+
"dateFormatter",
|
|
156
|
+
"dependencies",
|
|
157
|
+
"extra",
|
|
158
|
+
"fieldId",
|
|
159
|
+
"form",
|
|
160
|
+
"ghost",
|
|
161
|
+
"hasFeedback",
|
|
162
|
+
"help",
|
|
163
|
+
"hidden",
|
|
164
|
+
"htmlFor",
|
|
165
|
+
"id",
|
|
166
|
+
"initialValue",
|
|
167
|
+
"isListField",
|
|
168
|
+
"label",
|
|
169
|
+
"labelAlign",
|
|
170
|
+
"labelCol",
|
|
171
|
+
"layout",
|
|
172
|
+
"manualRequest",
|
|
173
|
+
"messageVariables",
|
|
174
|
+
"name",
|
|
175
|
+
"noStyle",
|
|
176
|
+
"onReset",
|
|
177
|
+
"onSubmit",
|
|
178
|
+
"prefixCls",
|
|
179
|
+
"required",
|
|
180
|
+
"rootClass",
|
|
181
|
+
"rules",
|
|
182
|
+
"search",
|
|
183
|
+
"status",
|
|
184
|
+
"submitButtonLoading",
|
|
185
|
+
"tooltip",
|
|
186
|
+
"trigger",
|
|
187
|
+
"type",
|
|
188
|
+
"validateDebounce",
|
|
189
|
+
"validateFirst",
|
|
190
|
+
"validateStatus",
|
|
191
|
+
"validateTrigger",
|
|
192
|
+
"valuePropName",
|
|
193
|
+
"vertical",
|
|
194
|
+
"wrapperCol"
|
|
195
|
+
]
|
|
196
|
+
});
|
|
197
|
+
//#endregion
|
|
198
|
+
export { FormRender as default };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ActionType, ProTableProps } from "../../typing.js";
|
|
2
|
+
import * as _$vue from "vue";
|
|
3
|
+
import { ProFieldValueObjectType, ProFieldValueType } from "@antdv-vue/pro-utils";
|
|
4
|
+
import { TablePaginationConfig } from "antdv-next";
|
|
5
|
+
|
|
6
|
+
//#region src/components/Form/index.d.ts
|
|
7
|
+
interface FormSearchProps<T, U, ValueType> {
|
|
8
|
+
pagination?: TablePaginationConfig | false;
|
|
9
|
+
beforeSearchSubmit?: (params: Partial<U>) => any;
|
|
10
|
+
action?: ActionType<Record<string, any>, T>;
|
|
11
|
+
onSubmit?: (params?: U) => void;
|
|
12
|
+
onReset?: (values?: U) => void;
|
|
13
|
+
loading?: boolean;
|
|
14
|
+
onFormSearchSubmit?: (params: U) => void;
|
|
15
|
+
columns?: ProTableProps<T, U, ValueType>['columns'];
|
|
16
|
+
dateFormatter?: ProTableProps<T, U, ValueType>['dateFormatter'];
|
|
17
|
+
ghost?: ProTableProps<T, U, ValueType>['ghost'];
|
|
18
|
+
type?: ProTableProps<T, U, ValueType>['type'];
|
|
19
|
+
cardBordered?: ProTableProps<T, U, ValueType>['cardBordered'];
|
|
20
|
+
form?: ProTableProps<T, U, ValueType>['form'];
|
|
21
|
+
search?: ProTableProps<T, U, ValueType>['search'];
|
|
22
|
+
manualRequest?: ProTableProps<T, U, ValueType>['manualRequest'];
|
|
23
|
+
}
|
|
24
|
+
declare const FormSearch: new <T extends Record<string, any>, U extends Record<string, any>, ValueType extends (ProFieldValueType | ProFieldValueObjectType)>(props: FormSearchProps<T, U, ValueType> & {} & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps) => _$vue.CreateComponentPublicInstanceWithMixins<FormSearchProps<T, U, ValueType> & {}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
25
|
+
P: {};
|
|
26
|
+
B: {};
|
|
27
|
+
D: {};
|
|
28
|
+
C: {};
|
|
29
|
+
M: {};
|
|
30
|
+
Defaults: {};
|
|
31
|
+
}, FormSearchProps<T, U, ValueType> & {}, {}, {}, {}, {}, {}>;
|
|
32
|
+
//#endregion
|
|
33
|
+
export { FormSearchProps, FormSearch as default };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { isBordered } from "../../utils/index.js";
|
|
2
|
+
import FormRender from "./FormRender.js";
|
|
3
|
+
import { computed, createVNode, defineComponent, shallowRef } from "vue";
|
|
4
|
+
import { useProFormInstanceExpose } from "@antdv-vue/pro-form";
|
|
5
|
+
import { omitUndefined } from "@antdv-vue/pro-utils";
|
|
6
|
+
import { omit } from "@v-c/util";
|
|
7
|
+
//#region src/components/Form/index.tsx
|
|
8
|
+
const FormSearch = /* @__PURE__ */ defineComponent((props, { expose }) => {
|
|
9
|
+
const formRef = shallowRef();
|
|
10
|
+
const pageInfo = computed(() => props.pagination ? omitUndefined({
|
|
11
|
+
current: props.pagination.current,
|
|
12
|
+
pageSize: props.pagination.pageSize
|
|
13
|
+
}) : {});
|
|
14
|
+
const onSubmit = async (value, firstLoad) => {
|
|
15
|
+
const { action, onFormSearchSubmit, onSubmit: propsOnSubmit, beforeSearchSubmit = (searchParams) => searchParams } = props;
|
|
16
|
+
if (props.form?.ignoreRules === false && firstLoad) await formRef?.value?.validateFields();
|
|
17
|
+
const omitParams = omit(beforeSearchSubmit({
|
|
18
|
+
...value,
|
|
19
|
+
_timestamp: Date.now(),
|
|
20
|
+
...pageInfo.value
|
|
21
|
+
}), Object.keys(pageInfo.value));
|
|
22
|
+
onFormSearchSubmit?.(omitParams);
|
|
23
|
+
if (!firstLoad) action?.setPageInfo?.({ current: 1 });
|
|
24
|
+
if (propsOnSubmit && !firstLoad) propsOnSubmit?.(value);
|
|
25
|
+
};
|
|
26
|
+
const onReset = async (value) => {
|
|
27
|
+
const { action, onReset: propsOnReset, onFormSearchSubmit, beforeSearchSubmit = (searchParams) => searchParams } = props;
|
|
28
|
+
const resetLogic = () => {
|
|
29
|
+
const omitParams = omit(beforeSearchSubmit({
|
|
30
|
+
...value,
|
|
31
|
+
...pageInfo.value
|
|
32
|
+
}), Object.keys(pageInfo.value));
|
|
33
|
+
onFormSearchSubmit?.(omitParams);
|
|
34
|
+
action?.setPageInfo?.({ current: 1 });
|
|
35
|
+
propsOnReset?.();
|
|
36
|
+
};
|
|
37
|
+
if (props.form?.ignoreRules === false) await formRef?.value?.validateFields();
|
|
38
|
+
resetLogic();
|
|
39
|
+
};
|
|
40
|
+
expose(useProFormInstanceExpose(formRef));
|
|
41
|
+
return () => {
|
|
42
|
+
const { action, columns, loading, type, ghost, pagination, form, manualRequest, search, cardBordered, dateFormatter } = props;
|
|
43
|
+
const pageInfo = pagination ? omitUndefined({
|
|
44
|
+
current: pagination.current,
|
|
45
|
+
pageSize: pagination.pageSize
|
|
46
|
+
}) : {};
|
|
47
|
+
return createVNode(FormRender, {
|
|
48
|
+
"ref": formRef,
|
|
49
|
+
"submitButtonLoading": loading,
|
|
50
|
+
"columns": columns,
|
|
51
|
+
"type": type,
|
|
52
|
+
"ghost": ghost,
|
|
53
|
+
"onSubmit": onSubmit,
|
|
54
|
+
"manualRequest": manualRequest,
|
|
55
|
+
"onReset": onReset,
|
|
56
|
+
"dateFormatter": dateFormatter,
|
|
57
|
+
"search": search,
|
|
58
|
+
"form": {
|
|
59
|
+
autoFocusFirstInput: false,
|
|
60
|
+
...form,
|
|
61
|
+
extraUrlParams: {
|
|
62
|
+
...pageInfo,
|
|
63
|
+
...form?.extraUrlParams
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
"action": action,
|
|
67
|
+
"bordered": isBordered("search", cardBordered)
|
|
68
|
+
}, null);
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
name: "FormSearch",
|
|
72
|
+
inheritAttrs: false,
|
|
73
|
+
props: [
|
|
74
|
+
"action",
|
|
75
|
+
"beforeSearchSubmit",
|
|
76
|
+
"cardBordered",
|
|
77
|
+
"columns",
|
|
78
|
+
"dateFormatter",
|
|
79
|
+
"form",
|
|
80
|
+
"loading",
|
|
81
|
+
"manualRequest",
|
|
82
|
+
"onFormSearchSubmit",
|
|
83
|
+
"onReset",
|
|
84
|
+
"onSubmit",
|
|
85
|
+
"pagination",
|
|
86
|
+
"search",
|
|
87
|
+
"type"
|
|
88
|
+
]
|
|
89
|
+
});
|
|
90
|
+
//#endregion
|
|
91
|
+
export { FormSearch as default };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
import { ProFieldValueObjectType, ProFieldValueType } from "@antdv-vue/pro-utils";
|
|
3
|
+
import { VueNode as VueNode$1 } from "@v-c/util";
|
|
4
|
+
|
|
5
|
+
//#region src/components/ToolBar/DensityIcon.d.ts
|
|
6
|
+
type DensitySize = 'medium' | 'small' | 'large' | undefined;
|
|
7
|
+
declare const DensityIcon: new <T extends Record<string, any>, P extends Record<string, any>, U extends (ProFieldValueType | ProFieldValueObjectType)>(props: {
|
|
8
|
+
icon?: VueNode$1;
|
|
9
|
+
} & {} & _$vue.VNodeProps & _$vue.AllowedComponentProps & _$vue.ComponentCustomProps) => _$vue.CreateComponentPublicInstanceWithMixins<{
|
|
10
|
+
icon?: VueNode$1;
|
|
11
|
+
} & {}, {}, {}, {}, {}, _$vue.ComponentOptionsMixin, _$vue.ComponentOptionsMixin, {}, _$vue.PublicProps, {}, false, {}, {}, {}, {}, string, {}, any, _$vue.ComponentProvideOptions, {
|
|
12
|
+
P: {};
|
|
13
|
+
B: {};
|
|
14
|
+
D: {};
|
|
15
|
+
C: {};
|
|
16
|
+
M: {};
|
|
17
|
+
Defaults: {};
|
|
18
|
+
}, {
|
|
19
|
+
icon?: VueNode$1;
|
|
20
|
+
} & {}, {}, {}, {}, {}, {}>;
|
|
21
|
+
//#endregion
|
|
22
|
+
export { DensitySize, DensityIcon as default };
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { useTableContextInject } from "../../Store/Provide.js";
|
|
2
|
+
import { createVNode, defineComponent, isVNode } from "vue";
|
|
3
|
+
import { useIntl } from "@antdv-vue/pro-provider";
|
|
4
|
+
import { Dropdown, Tooltip } from "antdv-next";
|
|
5
|
+
import { unit } from "@antdv-next/cssinjs";
|
|
6
|
+
import { ColumnHeightOutlined } from "@antdv-next/icons";
|
|
7
|
+
//#region src/components/ToolBar/DensityIcon.tsx
|
|
8
|
+
function _isSlot(s) {
|
|
9
|
+
return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
|
|
10
|
+
}
|
|
11
|
+
const DensityIcon = /* @__PURE__ */ defineComponent((props) => {
|
|
12
|
+
const intl = useIntl();
|
|
13
|
+
const { tableSize, setTableSize } = useTableContextInject();
|
|
14
|
+
return () => {
|
|
15
|
+
const { icon = createVNode(ColumnHeightOutlined, null, null) } = props;
|
|
16
|
+
return createVNode(Dropdown, {
|
|
17
|
+
"menu": {
|
|
18
|
+
style: { width: unit(80) },
|
|
19
|
+
selectedKeys: [tableSize?.value],
|
|
20
|
+
onClick: ({ key }) => {
|
|
21
|
+
setTableSize?.(key);
|
|
22
|
+
},
|
|
23
|
+
items: [
|
|
24
|
+
{
|
|
25
|
+
key: "large",
|
|
26
|
+
label: intl.value.getMessage({
|
|
27
|
+
id: "tableToolBar.densityLarger",
|
|
28
|
+
defaultMessage: "宽松"
|
|
29
|
+
})
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
key: "medium",
|
|
33
|
+
label: intl.value.getMessage({
|
|
34
|
+
id: "tableToolBar.densityMedium",
|
|
35
|
+
defaultMessage: "中等"
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
key: "small",
|
|
40
|
+
label: intl.value.getMessage({
|
|
41
|
+
id: "tableToolBar.densitySmall",
|
|
42
|
+
defaultMessage: "紧凑"
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
]
|
|
46
|
+
},
|
|
47
|
+
"trigger": ["click"]
|
|
48
|
+
}, { default: () => [createVNode(Tooltip, { "title": intl.value.getMessage({
|
|
49
|
+
id: "tableToolBar.density",
|
|
50
|
+
defaultMessage: "表格密度"
|
|
51
|
+
}) }, _isSlot(icon) ? icon : { default: () => [icon] })] });
|
|
52
|
+
};
|
|
53
|
+
}, {
|
|
54
|
+
props: { icon: {
|
|
55
|
+
type: [
|
|
56
|
+
Object,
|
|
57
|
+
Function,
|
|
58
|
+
String,
|
|
59
|
+
Number,
|
|
60
|
+
null,
|
|
61
|
+
Boolean,
|
|
62
|
+
Array
|
|
63
|
+
],
|
|
64
|
+
required: false,
|
|
65
|
+
default: void 0
|
|
66
|
+
} },
|
|
67
|
+
name: "DensityIcon",
|
|
68
|
+
inheritAttrs: false
|
|
69
|
+
});
|
|
70
|
+
//#endregion
|
|
71
|
+
export { DensityIcon as default };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import * as _$vue from "vue";
|
|
2
|
+
|
|
3
|
+
//#region src/components/ToolBar/FullScreenIcon.d.ts
|
|
4
|
+
declare const FullScreenIcon: _$vue.DefineSetupFnComponent<Record<string, any>, {}, {}, Record<string, any> & {}, _$vue.PublicProps>;
|
|
5
|
+
//#endregion
|
|
6
|
+
export { FullScreenIcon as default };
|