@fe-free/core 3.0.34 → 3.0.35
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 +8 -0
- package/package.json +3 -3
- package/src/crud/crud.stories.tsx +7 -7
- package/src/crud/crud.tsx +0 -3
- package/src/crud/crud_detail.tsx +4 -22
- package/src/crud/table/style.scss +5 -2
- package/src/crud/types.tsx +0 -2
- package/src/crud_of_pure/index.tsx +3 -1
- package/src/value_type_map/index.tsx +6 -0
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fe-free/core",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.35",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"author": "",
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"antd": "^5.27.1",
|
|
47
47
|
"dayjs": "~1.11.10",
|
|
48
48
|
"react": "^19.2.0",
|
|
49
|
-
"@fe-free/icons": "3.0.
|
|
50
|
-
"@fe-free/tool": "3.0.
|
|
49
|
+
"@fe-free/icons": "3.0.35",
|
|
50
|
+
"@fe-free/tool": "3.0.35"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ProColumns } from '@ant-design/pro-components';
|
|
2
2
|
import { ProForm, ProFormSwitch, ProFormText } from '@ant-design/pro-components';
|
|
3
|
-
import type { CRUDRef } from '@fe-free/core';
|
|
4
|
-
import { CRUD, proFormSelectSearchProps } from '@fe-free/core';
|
|
3
|
+
import type { CRUDProps, CRUDRef } from '@fe-free/core';
|
|
4
|
+
import { CRUD, CustomValueTypeEnum, proFormSelectSearchProps } from '@fe-free/core';
|
|
5
5
|
|
|
6
6
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
7
7
|
import { Button } from 'antd';
|
|
@@ -31,6 +31,10 @@ type Story = StoryObj<typeof CRUD>;
|
|
|
31
31
|
export const Normal: Story = {
|
|
32
32
|
render: () => {
|
|
33
33
|
const columns = [
|
|
34
|
+
{
|
|
35
|
+
title: '序号',
|
|
36
|
+
valueType: CustomValueTypeEnum.CustomSerialNumber,
|
|
37
|
+
},
|
|
34
38
|
{
|
|
35
39
|
title: 'id',
|
|
36
40
|
dataIndex: 'id',
|
|
@@ -50,7 +54,7 @@ export const Normal: Story = {
|
|
|
50
54
|
title: 'area',
|
|
51
55
|
dataIndex: 'area',
|
|
52
56
|
},
|
|
53
|
-
];
|
|
57
|
+
] as CRUDProps['tableProps']['columns'];
|
|
54
58
|
|
|
55
59
|
return (
|
|
56
60
|
<CRUD
|
|
@@ -76,7 +80,6 @@ export const Normal: Story = {
|
|
|
76
80
|
)}
|
|
77
81
|
requestGetByRecord={fakeGetByRecord}
|
|
78
82
|
requestCreateByValues={fakeCreate}
|
|
79
|
-
requestUpdateById={fakeUpdateById}
|
|
80
83
|
/>
|
|
81
84
|
);
|
|
82
85
|
},
|
|
@@ -226,7 +229,6 @@ export const MoreCustom: Story = {
|
|
|
226
229
|
)}
|
|
227
230
|
requestGetByRecord={fakeGetByRecord}
|
|
228
231
|
requestCreateByValues={fakeCreate}
|
|
229
|
-
requestUpdateById={fakeUpdateById}
|
|
230
232
|
updateProps={{
|
|
231
233
|
operateIsDisabled: (record) => {
|
|
232
234
|
if (record.id % 3) {
|
|
@@ -577,7 +579,6 @@ export const ExpandedRowRender: Story = {
|
|
|
577
579
|
)}
|
|
578
580
|
requestGetByRecord={fakeGetByRecord}
|
|
579
581
|
requestCreateByValues={fakeCreate}
|
|
580
|
-
requestUpdateById={fakeUpdateById}
|
|
581
582
|
/>
|
|
582
583
|
);
|
|
583
584
|
},
|
|
@@ -633,7 +634,6 @@ export const FullPage: Story = {
|
|
|
633
634
|
)}
|
|
634
635
|
requestGetByRecord={fakeGetByRecord}
|
|
635
636
|
requestCreateByValues={fakeCreate}
|
|
636
|
-
requestUpdateById={fakeUpdateById}
|
|
637
637
|
/>
|
|
638
638
|
</div>
|
|
639
639
|
);
|
package/src/crud/crud.tsx
CHANGED
|
@@ -31,7 +31,6 @@ function CRUD<DataSource extends Record<string, any> = any, Key extends string |
|
|
|
31
31
|
createProps,
|
|
32
32
|
requestCreateByValues,
|
|
33
33
|
updateProps,
|
|
34
|
-
requestUpdateById,
|
|
35
34
|
requestUpdateByValues,
|
|
36
35
|
detailFormInstance,
|
|
37
36
|
requestDeleteByRecords,
|
|
@@ -56,7 +55,6 @@ function CRUD<DataSource extends Record<string, any> = any, Key extends string |
|
|
|
56
55
|
detailForm,
|
|
57
56
|
requestGetByRecord,
|
|
58
57
|
requestCreateByValues,
|
|
59
|
-
requestUpdateById,
|
|
60
58
|
requestUpdateByValues,
|
|
61
59
|
detailFormInstance,
|
|
62
60
|
createProps,
|
|
@@ -67,7 +65,6 @@ function CRUD<DataSource extends Record<string, any> = any, Key extends string |
|
|
|
67
65
|
detailForm,
|
|
68
66
|
requestGetByRecord,
|
|
69
67
|
requestCreateByValues,
|
|
70
|
-
requestUpdateById,
|
|
71
68
|
requestUpdateByValues,
|
|
72
69
|
detailFormInstance,
|
|
73
70
|
createProps,
|
package/src/crud/crud_detail.tsx
CHANGED
|
@@ -23,7 +23,6 @@ interface CRUDDetailProps
|
|
|
23
23
|
| 'readProps'
|
|
24
24
|
| 'requestCreateByValues'
|
|
25
25
|
| 'updateProps'
|
|
26
|
-
| 'requestUpdateById'
|
|
27
26
|
| 'requestUpdateByValues'
|
|
28
27
|
| 'detailForm'
|
|
29
28
|
| 'detailFormInstance'
|
|
@@ -49,7 +48,6 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
49
48
|
readProps,
|
|
50
49
|
requestCreateByValues,
|
|
51
50
|
updateProps,
|
|
52
|
-
requestUpdateById,
|
|
53
51
|
requestUpdateByValues,
|
|
54
52
|
detailFormInstance,
|
|
55
53
|
} = props;
|
|
@@ -76,15 +74,8 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
76
74
|
content,
|
|
77
75
|
});
|
|
78
76
|
}
|
|
79
|
-
if (action === 'update' &&
|
|
80
|
-
|
|
81
|
-
result = await requestUpdateByValues(values);
|
|
82
|
-
} else if (requestUpdateById) {
|
|
83
|
-
result = await requestUpdateById({
|
|
84
|
-
...values,
|
|
85
|
-
id,
|
|
86
|
-
});
|
|
87
|
-
}
|
|
77
|
+
if (action === 'update' && requestUpdateByValues) {
|
|
78
|
+
result = await requestUpdateByValues(values);
|
|
88
79
|
|
|
89
80
|
let content = '更新成功';
|
|
90
81
|
if (updateProps?.successText) {
|
|
@@ -114,16 +105,7 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
114
105
|
}, 10);
|
|
115
106
|
}
|
|
116
107
|
},
|
|
117
|
-
[
|
|
118
|
-
action,
|
|
119
|
-
requestCreateByValues,
|
|
120
|
-
requestUpdateById,
|
|
121
|
-
requestUpdateByValues,
|
|
122
|
-
onSuccess,
|
|
123
|
-
createProps,
|
|
124
|
-
id,
|
|
125
|
-
updateProps,
|
|
126
|
-
],
|
|
108
|
+
[action, requestCreateByValues, requestUpdateByValues, onSuccess, createProps, updateProps],
|
|
127
109
|
);
|
|
128
110
|
|
|
129
111
|
const handleOpenChange = useCallback(
|
|
@@ -164,7 +146,7 @@ function CRUDDetail(props: CRUDDetailProps) {
|
|
|
164
146
|
|
|
165
147
|
if (loading) {
|
|
166
148
|
return (
|
|
167
|
-
<div className="pt-[100px]
|
|
149
|
+
<div className="flex justify-center pt-[100px]">
|
|
168
150
|
<Spin />
|
|
169
151
|
</div>
|
|
170
152
|
);
|
package/src/crud/types.tsx
CHANGED
|
@@ -84,8 +84,6 @@ interface CRUDProps<DataSource = any, Key = string> {
|
|
|
84
84
|
|
|
85
85
|
/** 更新接口,返回 false 则不关闭弹窗 */
|
|
86
86
|
requestUpdateByValues?: (values: Partial<DataSource>) => Promise<false | void>;
|
|
87
|
-
/** @deprecated 请使用 requestUpdateByValues 替代 */
|
|
88
|
-
requestUpdateById?: (values: Partial<DataSource>) => Promise<false | void>;
|
|
89
87
|
updateProps?: {
|
|
90
88
|
/** 文本“编辑” */
|
|
91
89
|
operateText?: string;
|
|
@@ -29,7 +29,9 @@ function CRUDOfPure<
|
|
|
29
29
|
// 设置 placeholder
|
|
30
30
|
fieldProps: {
|
|
31
31
|
placeholder:
|
|
32
|
-
column.valueType === 'select'
|
|
32
|
+
column.valueType === 'select' || column.valueEnum
|
|
33
|
+
? `请选择${column.title}`
|
|
34
|
+
: `请输入${column.title}`,
|
|
33
35
|
...column.fieldProps,
|
|
34
36
|
},
|
|
35
37
|
};
|
|
@@ -16,6 +16,8 @@ enum CustomValueTypeEnum {
|
|
|
16
16
|
/** 渲染开关 */
|
|
17
17
|
CustomSwitchNumber = 'CustomSwitchNumber',
|
|
18
18
|
CustomSwitchOptions = 'CustomSwitchOptions',
|
|
19
|
+
/** CRUD 用,显示序号 */
|
|
20
|
+
CustomSerialNumber = 'CustomSerialNumber',
|
|
19
21
|
}
|
|
20
22
|
|
|
21
23
|
const customValueTypeMap: Record<string, ProRenderFieldPropsType> = {
|
|
@@ -43,6 +45,10 @@ const customValueTypeMap: Record<string, ProRenderFieldPropsType> = {
|
|
|
43
45
|
render: switchOptionsRender.render,
|
|
44
46
|
renderFormItem: switchOptionsRender.renderFormItem,
|
|
45
47
|
},
|
|
48
|
+
[CustomValueTypeEnum.CustomSerialNumber]: {
|
|
49
|
+
render: () => <></>,
|
|
50
|
+
renderFormItem: () => <></>,
|
|
51
|
+
},
|
|
46
52
|
};
|
|
47
53
|
|
|
48
54
|
export { CustomValueTypeEnum, customValueTypeMap };
|