Skip to content

Commit c7fe37d

Browse files
committedApr 18, 2023
fix(ProForm): 导出ts类型
1 parent 44481dc commit c7fe37d

File tree

7 files changed

+199
-11
lines changed

7 files changed

+199
-11
lines changed
 

‎examples/base/config/routes.json

+14-8
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,23 @@
1111
"index": true,
1212
"redirect": "/tableList"
1313
},
14+
{
15+
"path": "/home",
16+
"name": "首页",
17+
"element": "@/pages/TableList",
18+
"icon": "home"
19+
},
1420
{
1521
"path": "/tableList",
1622
"name": "查询表格",
1723
"element": "@/pages/TableList",
1824
"icon": "search"
1925
},
2026
{
21-
"path": "/home",
22-
"name": "首页",
23-
"element": "@/pages/TableList",
24-
"icon": "home"
27+
"path": "/form",
28+
"name": "数据录入",
29+
"element": "@/pages/Form",
30+
"icon": "search"
2531
},
2632
{
2733
"path": "/:group/*",
@@ -58,7 +64,7 @@
5864
},
5965
{
6066
"path": "/dom/exceptions",
61-
"name": "异常12",
67+
"name": "异常",
6268
"icon": "warning-o",
6369
"side": false,
6470
"children": [
@@ -68,17 +74,17 @@
6874
},
6975
{
7076
"path": "/dom/exceptions/403",
71-
"name": "403-1",
77+
"name": "403",
7278
"element": "@uiw-admin/exceptions/esm/Exceptions/403"
7379
},
7480
{
7581
"path": "/dom/exceptions/500",
76-
"name": "500-1",
82+
"name": "500",
7783
"element": "@uiw-admin/exceptions/esm/Exceptions/500"
7884
},
7985
{
8086
"path": "/dom/exceptions/404",
81-
"name": "404-1",
87+
"name": "404",
8288
"element": "@uiw-admin/exceptions/esm/Exceptions/404"
8389
}
8490
]
+162
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,162 @@
1+
import { ProForm } from '@uiw-admin/components'
2+
import { Slider } from 'uiw'
3+
4+
const option = [
5+
{ value: 1, label: '苹果' },
6+
{ value: 2, label: '西瓜' },
7+
{ value: 3, label: '香蕉' },
8+
{ value: 4, label: '东北大冻梨' },
9+
{ value: 5, label: '香蕉' },
10+
{ value: 6, label: '葡萄' },
11+
{ value: 6, label: '哈密瓜' },
12+
]
13+
14+
const Page = () => {
15+
return (
16+
<ProForm
17+
// 表单类型
18+
formType="card"
19+
title="基本使用(与uiw/form使用保持一致)"
20+
// 自定义组件
21+
customWidgetsList={{
22+
slider: Slider,
23+
}}
24+
cardProps={{
25+
noHover: true,
26+
}}
27+
// 是否展示uiw/form提交按钮
28+
showSaveButton
29+
// 是否展示uiw/form重置按钮
30+
showResetButton
31+
// 提交后验证
32+
onSubmit={(initial, current) => {
33+
console.log(111, initial, current)
34+
}}
35+
formDatas={[
36+
{
37+
label: 'input',
38+
key: 'input',
39+
widget: 'input',
40+
initialValue: '',
41+
widgetProps: {},
42+
help: 'input不能为空',
43+
rules: [{ required: true, message: 'input不能为空' }],
44+
},
45+
{
46+
label: 'textarea',
47+
key: 'textarea',
48+
widget: 'textarea',
49+
span: '24',
50+
colstyle: { maxWidth: 800 },
51+
},
52+
{
53+
label: 'select',
54+
key: 'select',
55+
widget: 'select',
56+
option: [
57+
{ value: 1, label: '苹果' },
58+
{ value: 2, label: '西瓜' },
59+
{ value: 3, label: '香蕉' },
60+
{ value: 4, label: '东北大冻梨' },
61+
],
62+
},
63+
{
64+
label: 'switch',
65+
key: 'switch',
66+
widget: 'switch',
67+
},
68+
{
69+
label: 'radio',
70+
widget: 'radio',
71+
key: 'radio',
72+
option: [
73+
{ label: '男', value: 'man' },
74+
{ label: '女', value: 'girl' },
75+
],
76+
},
77+
{
78+
label: '多选框',
79+
widget: 'checkbox',
80+
key: 'checkbox',
81+
option: [
82+
{ label: '四川菜', value: 'sichuan' },
83+
{ label: '湖北菜', value: 'hubei' },
84+
],
85+
},
86+
{
87+
label: '年月日时分秒',
88+
key: 'dateInputsecond',
89+
widget: 'dateInput',
90+
widgetProps: {
91+
format: 'YYYY-MM-DD HH:mm:ss',
92+
},
93+
},
94+
{
95+
label: '年月日',
96+
key: 'dateInput',
97+
widget: 'dateInput',
98+
widgetProps: {
99+
format: 'YYYY-MM-DD',
100+
},
101+
},
102+
{
103+
label: '年月',
104+
key: 'monthPicker',
105+
widget: 'monthPicker',
106+
widgetProps: {
107+
format: 'YYYY-MM',
108+
},
109+
},
110+
{
111+
label: '时分秒',
112+
key: 'timePicker',
113+
widget: 'timePicker',
114+
},
115+
{
116+
label: 'searchSelect',
117+
key: 'searchSelect',
118+
widget: 'searchSelect',
119+
option: option,
120+
widgetProps: {
121+
mode: 'multiple',
122+
allowClear: true,
123+
showSearch: true,
124+
style: { width: '100%' },
125+
},
126+
},
127+
{
128+
label: '评分',
129+
key: 'rate',
130+
widget: 'rate',
131+
span: '8',
132+
},
133+
// 只读模式下支持读取React.ReactNode
134+
{
135+
label: '自定义组件',
136+
key: 'slider',
137+
widget: 'slider',
138+
readSpan: 2,
139+
span: '16',
140+
},
141+
{
142+
label: '上传组件',
143+
key: 'upload',
144+
widget: 'upload',
145+
span: '24',
146+
readSpan: 3,
147+
widgetProps: {
148+
uploadType: 'card',
149+
multiple: true,
150+
maxNumber: 2,
151+
showFileIcon: {
152+
showPreviewIcon: true,
153+
showRemoveIcon: true,
154+
},
155+
},
156+
},
157+
]}
158+
/>
159+
)
160+
}
161+
162+
export default Page

‎packages/components/src/ProForm/formdom.tsx

-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ function FormDom({
4646
const styles: React.CSSProperties = {
4747
background: '#fff',
4848
paddingBottom: 10,
49-
marginBottom: 14,
5049
...style,
5150
};
5251

‎packages/components/src/ProForm/index.tsx

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { StoreCtx, ColPropsContext } from './hooks/store';
88
import { isObjectEmpty } from './utils';
99
import './style/form-item.css';
1010

11+
export * from './type';
12+
1113
function ProForm(
1214
props: ProFormProps,
1315
ref: React.ForwardedRef<
@@ -103,7 +105,7 @@ function ProForm(
103105
return (
104106
<StoreCtx.Provider value={store}>
105107
<ColPropsContext.Provider value={colProps || {}}>
106-
{children}
108+
<div className="uiw-admin-proform">{children}</div>
107109
</ColPropsContext.Provider>
108110
</StoreCtx.Provider>
109111
);

‎packages/components/src/ProForm/style/form-item.css

+13
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,17 @@
2626
top: 3px;
2727
transform: translateX(-50%);
2828
color: red;
29+
}
30+
31+
.uiw-admin-proform .w-form-label {
32+
font-weight: normal;
33+
color: rgba(0, 0, 0, .7);
34+
}
35+
.uiw-admin-proform .w-select {
36+
background-color: transparent;
37+
}
38+
39+
.uiw-admin-proform .w-card-head {
40+
height: 50px;
41+
line-height: 50px;
2942
}

‎packages/components/src/ProTable/index.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@
1919
}
2020

2121
.uiw-protable-form .w-select {
22-
background-color: #fff;
22+
background-color: transparent;
2323
}

‎packages/components/src/index.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
export { default as ProTable } from './ProTable';
2+
export * from './ProTable';
23
export { default as useTable } from './ProTable/useTable';
4+
export * from './ProTable/useTable';
35
export { default as Skeleton } from './Skeleton';
6+
export * from './Skeleton';
47
export { default as ProDrawer } from './ProDrawer';
8+
export * from './ProDrawer';
59
export { default as ProForm } from './ProForm';
10+
export * from './ProForm';
611
export { default as useForm } from './ProForm/hooks/useForm';
12+
export * from './ProForm';
713

814
export * from './form';
915
export { default as Form } from './form';

0 commit comments

Comments
 (0)