正在显示
17 个修改的文件
包含
1056 行增加
和
0 行删除
ant-design-pro/BasicForm/.gitignore
0 → 100644
ant-design-pro/BasicForm/.umirc.js
0 → 100644
1 | +import React, { PureComponent } from 'react'; | ||
2 | +import { connect } from 'dva'; | ||
3 | +import styles from './GridContent.less'; | ||
4 | + | ||
5 | +class GridContent extends PureComponent { | ||
6 | + render() { | ||
7 | + const { contentWidth, children } = this.props; | ||
8 | + let className = `${styles.main}`; | ||
9 | + if (contentWidth === 'Fixed') { | ||
10 | + className = `${styles.main} ${styles.wide}`; | ||
11 | + } | ||
12 | + return <div className={className}>{children}</div>; | ||
13 | + } | ||
14 | +} | ||
15 | + | ||
16 | +export default connect(({ setting }) => ({ | ||
17 | + contentWidth: setting.contentWidth, | ||
18 | +}))(GridContent); |
1 | +import React from 'react'; | ||
2 | +import { FormattedMessage } from 'umi/locale'; | ||
3 | +import Link from 'umi/link'; | ||
4 | +import PageHeader from 'ant-design-pro/lib/PageHeader'; | ||
5 | +import { connect } from 'dva'; | ||
6 | +import GridContent from './GridContent'; | ||
7 | +import styles from './index.less'; | ||
8 | +import MenuContext from '@/layouts/MenuContext'; | ||
9 | + | ||
10 | +const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => ( | ||
11 | + <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}> | ||
12 | + {top} | ||
13 | + <MenuContext.Consumer> | ||
14 | + {value => ( | ||
15 | + <PageHeader | ||
16 | + wide={contentWidth === 'Fixed'} | ||
17 | + home={<FormattedMessage id="menu.home" defaultMessage="Home" />} | ||
18 | + {...value} | ||
19 | + key="pageheader" | ||
20 | + {...restProps} | ||
21 | + linkElement={Link} | ||
22 | + itemRender={item => { | ||
23 | + if (item.locale) { | ||
24 | + return <FormattedMessage id={item.locale} defaultMessage={item.title} />; | ||
25 | + } | ||
26 | + return item.title; | ||
27 | + }} | ||
28 | + /> | ||
29 | + )} | ||
30 | + </MenuContext.Consumer> | ||
31 | + {children ? ( | ||
32 | + <div className={styles.content}> | ||
33 | + <GridContent>{children}</GridContent> | ||
34 | + </div> | ||
35 | + ) : null} | ||
36 | + </div> | ||
37 | +); | ||
38 | + | ||
39 | +export default connect(({ setting }) => ({ | ||
40 | + contentWidth: setting.contentWidth, | ||
41 | +}))(PageHeaderWrapper); |
ant-design-pro/BasicForm/README.md
0 → 100644
ant-design-pro/BasicForm/package.json
0 → 100644
1 | +{ | ||
2 | + "name": "@umi-block/basicform", | ||
3 | + "version": "0.0.1", | ||
4 | + "description": "BasicForm", | ||
5 | + "main": "src/index.js", | ||
6 | + "scripts": { | ||
7 | + "dev": "umi dev" | ||
8 | + }, | ||
9 | + "repository": { | ||
10 | + "type": "git", | ||
11 | + "url": "https://github.com/umijs/umi-blocks/basicform" | ||
12 | + }, | ||
13 | + "dependencies": { | ||
14 | + "react": "^16.6.3", | ||
15 | + "dva": "^2.4.0", | ||
16 | + "ant-design-pro": "^2.1.1", | ||
17 | + "antd": "^3.10.9", | ||
18 | + "mockjs": "*" | ||
19 | + }, | ||
20 | + "devDependencies": { | ||
21 | + "umi": "^2.3.0-beta.1", | ||
22 | + "umi-plugin-react": "^1.3.0-beta.1", | ||
23 | + "umi-plugin-block-dev": "^1.0.0" | ||
24 | + }, | ||
25 | + "license": "ISC" | ||
26 | +} |
ant-design-pro/BasicForm/src/_mock.js
0 → 100644
1 | +import mockjs from 'mockjs'; | ||
2 | + | ||
3 | +const titles = [ | ||
4 | + 'Alipay', | ||
5 | + 'Angular', | ||
6 | + 'Ant Design', | ||
7 | + 'Ant Design Pro', | ||
8 | + 'Bootstrap', | ||
9 | + 'React', | ||
10 | + 'Vue', | ||
11 | + 'Webpack', | ||
12 | +]; | ||
13 | +const avatars = [ | ||
14 | + 'https://gw.alipayobjects.com/zos/rmsportal/WdGqmHpayyMjiEhcKoVE.png', // Alipay | ||
15 | + 'https://gw.alipayobjects.com/zos/rmsportal/zOsKZmFRdUtvpqCImOVY.png', // Angular | ||
16 | + 'https://gw.alipayobjects.com/zos/rmsportal/dURIMkkrRFpPgTuzkwnB.png', // Ant Design | ||
17 | + 'https://gw.alipayobjects.com/zos/rmsportal/sfjbOqnsXXJgNCjCzDBL.png', // Ant Design Pro | ||
18 | + 'https://gw.alipayobjects.com/zos/rmsportal/siCrBXXhmvTQGWPNLBow.png', // Bootstrap | ||
19 | + 'https://gw.alipayobjects.com/zos/rmsportal/kZzEzemZyKLKFsojXItE.png', // React | ||
20 | + 'https://gw.alipayobjects.com/zos/rmsportal/ComBAopevLwENQdKWiIn.png', // Vue | ||
21 | + 'https://gw.alipayobjects.com/zos/rmsportal/nxkuOJlFJuAUhzlMTCEe.png', // Webpack | ||
22 | +]; | ||
23 | + | ||
24 | +const avatars2 = [ | ||
25 | + 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png', | ||
26 | + 'https://gw.alipayobjects.com/zos/rmsportal/cnrhVkzwxjPwAaCfPbdc.png', | ||
27 | + 'https://gw.alipayobjects.com/zos/rmsportal/gaOngJwsRYRaVAuXXcmB.png', | ||
28 | + 'https://gw.alipayobjects.com/zos/rmsportal/ubnKSIfAJTxIgXOKlciN.png', | ||
29 | + 'https://gw.alipayobjects.com/zos/rmsportal/WhxKECPNujWoWEFNdnJE.png', | ||
30 | + 'https://gw.alipayobjects.com/zos/rmsportal/jZUIxmJycoymBprLOUbT.png', | ||
31 | + 'https://gw.alipayobjects.com/zos/rmsportal/psOgztMplJMGpVEqfcgF.png', | ||
32 | + 'https://gw.alipayobjects.com/zos/rmsportal/ZpBqSxLxVEXfcUNoPKrz.png', | ||
33 | + 'https://gw.alipayobjects.com/zos/rmsportal/laiEnJdGHVOhJrUShBaJ.png', | ||
34 | + 'https://gw.alipayobjects.com/zos/rmsportal/UrQsqscbKEpNuJcvBZBu.png', | ||
35 | +]; | ||
36 | + | ||
37 | +const covers = [ | ||
38 | + 'https://gw.alipayobjects.com/zos/rmsportal/uMfMFlvUuceEyPpotzlq.png', | ||
39 | + 'https://gw.alipayobjects.com/zos/rmsportal/iZBVOIhGJiAnhplqjvZW.png', | ||
40 | + 'https://gw.alipayobjects.com/zos/rmsportal/iXjVmWVHbCJAyqvDxdtx.png', | ||
41 | + 'https://gw.alipayobjects.com/zos/rmsportal/gLaIAoVWTtLbBWZNYEMg.png', | ||
42 | +]; | ||
43 | +const desc = [ | ||
44 | + '那是一种内在的东西, 他们到达不了,也无法触及的', | ||
45 | + '希望是一个好东西,也许是最好的,好东西是不会消亡的', | ||
46 | + '生命就像一盒巧克力,结果往往出人意料', | ||
47 | + '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', | ||
48 | + '那时候我只会想自己想要什么,从不想自己拥有什么', | ||
49 | +]; | ||
50 | + | ||
51 | +const user = [ | ||
52 | + '付小小', | ||
53 | + '曲丽丽', | ||
54 | + '林东东', | ||
55 | + '周星星', | ||
56 | + '吴加好', | ||
57 | + '朱偏右', | ||
58 | + '鱼酱', | ||
59 | + '乐哥', | ||
60 | + '谭小仪', | ||
61 | + '仲尼', | ||
62 | +]; | ||
63 | + | ||
64 | +function fakeList(count) { | ||
65 | + const list = []; | ||
66 | + for (let i = 0; i < count; i += 1) { | ||
67 | + list.push({ | ||
68 | + id: `fake-list-${i}`, | ||
69 | + owner: user[i % 10], | ||
70 | + title: titles[i % 8], | ||
71 | + avatar: avatars[i % 8], | ||
72 | + cover: parseInt(i / 4, 10) % 2 === 0 ? covers[i % 4] : covers[3 - (i % 4)], | ||
73 | + status: ['active', 'exception', 'normal'][i % 3], | ||
74 | + percent: Math.ceil(Math.random() * 50) + 50, | ||
75 | + logo: avatars[i % 8], | ||
76 | + href: 'https://ant.design', | ||
77 | + updatedAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), | ||
78 | + createdAt: new Date(new Date().getTime() - 1000 * 60 * 60 * 2 * i), | ||
79 | + subDescription: desc[i % 5], | ||
80 | + description: | ||
81 | + '在中台产品的研发过程中,会出现不同的设计规范和实现方式,但其中往往存在很多类似的页面和组件,这些类似的组件会被抽离成一套标准规范。', | ||
82 | + activeUser: Math.ceil(Math.random() * 100000) + 100000, | ||
83 | + newUser: Math.ceil(Math.random() * 1000) + 1000, | ||
84 | + star: Math.ceil(Math.random() * 100) + 100, | ||
85 | + like: Math.ceil(Math.random() * 100) + 100, | ||
86 | + message: Math.ceil(Math.random() * 10) + 10, | ||
87 | + content: | ||
88 | + '段落示意:蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。蚂蚁金服设计平台 ant.design,用最小的工作量,无缝接入蚂蚁金服生态,提供跨越设计与开发的体验解决方案。', | ||
89 | + members: [ | ||
90 | + { | ||
91 | + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/ZiESqWwCXBRQoaPONSJe.png', | ||
92 | + name: '曲丽丽', | ||
93 | + id: 'member1', | ||
94 | + }, | ||
95 | + { | ||
96 | + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/tBOxZPlITHqwlGjsJWaF.png', | ||
97 | + name: '王昭君', | ||
98 | + id: 'member2', | ||
99 | + }, | ||
100 | + { | ||
101 | + avatar: 'https://gw.alipayobjects.com/zos/rmsportal/sBxjgqiuHMGRkIjqlQCd.png', | ||
102 | + name: '董娜娜', | ||
103 | + id: 'member3', | ||
104 | + }, | ||
105 | + ], | ||
106 | + }); | ||
107 | + } | ||
108 | + | ||
109 | + return list; | ||
110 | +} | ||
111 | + | ||
112 | +let sourceData; | ||
113 | + | ||
114 | +function getFakeList(req, res) { | ||
115 | + const params = req.query; | ||
116 | + | ||
117 | + const count = params.count * 1 || 20; | ||
118 | + | ||
119 | + const result = fakeList(count); | ||
120 | + sourceData = result; | ||
121 | + return res.json(result); | ||
122 | +} | ||
123 | + | ||
124 | +function postFakeList(req, res) { | ||
125 | + const { /* url = '', */ body } = req; | ||
126 | + // const params = getUrlParams(url); | ||
127 | + const { method, id } = body; | ||
128 | + // const count = (params.count * 1) || 20; | ||
129 | + let result = sourceData; | ||
130 | + | ||
131 | + switch (method) { | ||
132 | + case 'delete': | ||
133 | + result = result.filter(item => item.id !== id); | ||
134 | + break; | ||
135 | + case 'update': | ||
136 | + result.forEach((item, i) => { | ||
137 | + if (item.id === id) { | ||
138 | + result[i] = Object.assign(item, body); | ||
139 | + } | ||
140 | + }); | ||
141 | + break; | ||
142 | + case 'post': | ||
143 | + result.unshift({ | ||
144 | + body, | ||
145 | + id: `fake-list-${result.length}`, | ||
146 | + createdAt: new Date().getTime(), | ||
147 | + }); | ||
148 | + break; | ||
149 | + default: | ||
150 | + break; | ||
151 | + } | ||
152 | + | ||
153 | + return res.json(result); | ||
154 | +} | ||
155 | + | ||
156 | +const getNotice = [ | ||
157 | + { | ||
158 | + id: 'xxx1', | ||
159 | + title: titles[0], | ||
160 | + logo: avatars[0], | ||
161 | + description: '那是一种内在的东西,他们到达不了,也无法触及的', | ||
162 | + updatedAt: new Date(), | ||
163 | + member: '科学搬砖组', | ||
164 | + href: '', | ||
165 | + memberLink: '', | ||
166 | + }, | ||
167 | + { | ||
168 | + id: 'xxx2', | ||
169 | + title: titles[1], | ||
170 | + logo: avatars[1], | ||
171 | + description: '希望是一个好东西,也许是最好的,好东西是不会消亡的', | ||
172 | + updatedAt: new Date('2017-07-24'), | ||
173 | + member: '全组都是吴彦祖', | ||
174 | + href: '', | ||
175 | + memberLink: '', | ||
176 | + }, | ||
177 | + { | ||
178 | + id: 'xxx3', | ||
179 | + title: titles[2], | ||
180 | + logo: avatars[2], | ||
181 | + description: '城镇中有那么多的酒馆,她却偏偏走进了我的酒馆', | ||
182 | + updatedAt: new Date(), | ||
183 | + member: '中二少女团', | ||
184 | + href: '', | ||
185 | + memberLink: '', | ||
186 | + }, | ||
187 | + { | ||
188 | + id: 'xxx4', | ||
189 | + title: titles[3], | ||
190 | + logo: avatars[3], | ||
191 | + description: '那时候我只会想自己想要什么,从不想自己拥有什么', | ||
192 | + updatedAt: new Date('2017-07-23'), | ||
193 | + member: '程序员日常', | ||
194 | + href: '', | ||
195 | + memberLink: '', | ||
196 | + }, | ||
197 | + { | ||
198 | + id: 'xxx5', | ||
199 | + title: titles[4], | ||
200 | + logo: avatars[4], | ||
201 | + description: '凛冬将至', | ||
202 | + updatedAt: new Date('2017-07-23'), | ||
203 | + member: '高逼格设计天团', | ||
204 | + href: '', | ||
205 | + memberLink: '', | ||
206 | + }, | ||
207 | + { | ||
208 | + id: 'xxx6', | ||
209 | + title: titles[5], | ||
210 | + logo: avatars[5], | ||
211 | + description: '生命就像一盒巧克力,结果往往出人意料', | ||
212 | + updatedAt: new Date('2017-07-23'), | ||
213 | + member: '骗你来学计算机', | ||
214 | + href: '', | ||
215 | + memberLink: '', | ||
216 | + }, | ||
217 | +]; | ||
218 | + | ||
219 | +const getActivities = [ | ||
220 | + { | ||
221 | + id: 'trend-1', | ||
222 | + updatedAt: new Date(), | ||
223 | + user: { | ||
224 | + name: '曲丽丽', | ||
225 | + avatar: avatars2[0], | ||
226 | + }, | ||
227 | + group: { | ||
228 | + name: '高逼格设计天团', | ||
229 | + link: 'http://github.com/', | ||
230 | + }, | ||
231 | + project: { | ||
232 | + name: '六月迭代', | ||
233 | + link: 'http://github.com/', | ||
234 | + }, | ||
235 | + template: '在 @{group} 新建项目 @{project}', | ||
236 | + }, | ||
237 | + { | ||
238 | + id: 'trend-2', | ||
239 | + updatedAt: new Date(), | ||
240 | + user: { | ||
241 | + name: '付小小', | ||
242 | + avatar: avatars2[1], | ||
243 | + }, | ||
244 | + group: { | ||
245 | + name: '高逼格设计天团', | ||
246 | + link: 'http://github.com/', | ||
247 | + }, | ||
248 | + project: { | ||
249 | + name: '六月迭代', | ||
250 | + link: 'http://github.com/', | ||
251 | + }, | ||
252 | + template: '在 @{group} 新建项目 @{project}', | ||
253 | + }, | ||
254 | + { | ||
255 | + id: 'trend-3', | ||
256 | + updatedAt: new Date(), | ||
257 | + user: { | ||
258 | + name: '林东东', | ||
259 | + avatar: avatars2[2], | ||
260 | + }, | ||
261 | + group: { | ||
262 | + name: '中二少女团', | ||
263 | + link: 'http://github.com/', | ||
264 | + }, | ||
265 | + project: { | ||
266 | + name: '六月迭代', | ||
267 | + link: 'http://github.com/', | ||
268 | + }, | ||
269 | + template: '在 @{group} 新建项目 @{project}', | ||
270 | + }, | ||
271 | + { | ||
272 | + id: 'trend-4', | ||
273 | + updatedAt: new Date(), | ||
274 | + user: { | ||
275 | + name: '周星星', | ||
276 | + avatar: avatars2[4], | ||
277 | + }, | ||
278 | + project: { | ||
279 | + name: '5 月日常迭代', | ||
280 | + link: 'http://github.com/', | ||
281 | + }, | ||
282 | + template: '将 @{project} 更新至已发布状态', | ||
283 | + }, | ||
284 | + { | ||
285 | + id: 'trend-5', | ||
286 | + updatedAt: new Date(), | ||
287 | + user: { | ||
288 | + name: '朱偏右', | ||
289 | + avatar: avatars2[3], | ||
290 | + }, | ||
291 | + project: { | ||
292 | + name: '工程效能', | ||
293 | + link: 'http://github.com/', | ||
294 | + }, | ||
295 | + comment: { | ||
296 | + name: '留言', | ||
297 | + link: 'http://github.com/', | ||
298 | + }, | ||
299 | + template: '在 @{project} 发布了 @{comment}', | ||
300 | + }, | ||
301 | + { | ||
302 | + id: 'trend-6', | ||
303 | + updatedAt: new Date(), | ||
304 | + user: { | ||
305 | + name: '乐哥', | ||
306 | + avatar: avatars2[5], | ||
307 | + }, | ||
308 | + group: { | ||
309 | + name: '程序员日常', | ||
310 | + link: 'http://github.com/', | ||
311 | + }, | ||
312 | + project: { | ||
313 | + name: '品牌迭代', | ||
314 | + link: 'http://github.com/', | ||
315 | + }, | ||
316 | + template: '在 @{group} 新建项目 @{project}', | ||
317 | + }, | ||
318 | +]; | ||
319 | + | ||
320 | +function getFakeCaptcha(req, res) { | ||
321 | + return res.json('captcha-xxx'); | ||
322 | +} | ||
323 | + | ||
324 | +export default { | ||
325 | + 'GET /api/project/notice': getNotice, | ||
326 | + 'GET /api/activities': getActivities, | ||
327 | + 'POST /api/forms': (req, res) => { | ||
328 | + res.send({ message: 'Ok' }); | ||
329 | + }, | ||
330 | + 'GET /api/tags': mockjs.mock({ | ||
331 | + 'list|100': [{ name: '@city', 'value|1-100': 150, 'type|0-2': 1 }], | ||
332 | + }), | ||
333 | + 'GET /api/fake_list': getFakeList, | ||
334 | + 'POST /api/fake_list': postFakeList, | ||
335 | + 'GET /api/captcha': getFakeCaptcha, | ||
336 | +}; |
1 | +module.exports = { | ||
2 | + navTheme: 'dark', // theme for nav menu | ||
3 | + primaryColor: '#1890FF', // primary color of ant design | ||
4 | + layout: 'sidemenu', // nav menu position: sidemenu or topmenu | ||
5 | + contentWidth: 'Fluid', // layout of content: Fluid or Fixed, only works when layout is topmenu | ||
6 | + fixedHeader: false, // sticky header | ||
7 | + autoHideHeader: false, // auto hide header | ||
8 | + fixSiderbar: false, // sticky siderbar | ||
9 | +}; |
ant-design-pro/BasicForm/src/index.js
0 → 100644
1 | +import React, { PureComponent } from 'react'; | ||
2 | +import { connect } from 'dva'; | ||
3 | +import { formatMessage, FormattedMessage } from 'umi/locale'; | ||
4 | +import { | ||
5 | + Form, | ||
6 | + Input, | ||
7 | + DatePicker, | ||
8 | + Select, | ||
9 | + Button, | ||
10 | + Card, | ||
11 | + InputNumber, | ||
12 | + Radio, | ||
13 | + Icon, | ||
14 | + Tooltip, | ||
15 | +} from 'antd'; | ||
16 | +import PageHeaderWrapper from '@/components/PageHeaderWrapper'; | ||
17 | +import styles from './style.less'; | ||
18 | + | ||
19 | +const FormItem = Form.Item; | ||
20 | +const { Option } = Select; | ||
21 | +const { RangePicker } = DatePicker; | ||
22 | +const { TextArea } = Input; | ||
23 | + | ||
24 | +@connect(({ loading }) => ({ | ||
25 | + submitting: loading.effects['form/submitRegularForm'], | ||
26 | +})) | ||
27 | +@Form.create() | ||
28 | +class BasicForms extends PureComponent { | ||
29 | + handleSubmit = e => { | ||
30 | + const { dispatch, form } = this.props; | ||
31 | + e.preventDefault(); | ||
32 | + form.validateFieldsAndScroll((err, values) => { | ||
33 | + if (!err) { | ||
34 | + dispatch({ | ||
35 | + type: 'form/submitRegularForm', | ||
36 | + payload: values, | ||
37 | + }); | ||
38 | + } | ||
39 | + }); | ||
40 | + }; | ||
41 | + | ||
42 | + render() { | ||
43 | + const { submitting } = this.props; | ||
44 | + const { | ||
45 | + form: { getFieldDecorator, getFieldValue }, | ||
46 | + } = this.props; | ||
47 | + | ||
48 | + const formItemLayout = { | ||
49 | + labelCol: { | ||
50 | + xs: { span: 24 }, | ||
51 | + sm: { span: 7 }, | ||
52 | + }, | ||
53 | + wrapperCol: { | ||
54 | + xs: { span: 24 }, | ||
55 | + sm: { span: 12 }, | ||
56 | + md: { span: 10 }, | ||
57 | + }, | ||
58 | + }; | ||
59 | + | ||
60 | + const submitFormLayout = { | ||
61 | + wrapperCol: { | ||
62 | + xs: { span: 24, offset: 0 }, | ||
63 | + sm: { span: 10, offset: 7 }, | ||
64 | + }, | ||
65 | + }; | ||
66 | + | ||
67 | + return ( | ||
68 | + <PageHeaderWrapper | ||
69 | + title={<FormattedMessage id="app.forms.basic.title" />} | ||
70 | + content={<FormattedMessage id="app.forms.basic.description" />} | ||
71 | + > | ||
72 | + <Card bordered={false}> | ||
73 | + <Form onSubmit={this.handleSubmit} hideRequiredMark style={{ marginTop: 8 }}> | ||
74 | + <FormItem {...formItemLayout} label={<FormattedMessage id="form.title.label" />}> | ||
75 | + {getFieldDecorator('title', { | ||
76 | + rules: [ | ||
77 | + { | ||
78 | + required: true, | ||
79 | + message: formatMessage({ id: 'validation.title.required' }), | ||
80 | + }, | ||
81 | + ], | ||
82 | + })(<Input placeholder={formatMessage({ id: 'form.title.placeholder' })} />)} | ||
83 | + </FormItem> | ||
84 | + <FormItem {...formItemLayout} label={<FormattedMessage id="form.date.label" />}> | ||
85 | + {getFieldDecorator('date', { | ||
86 | + rules: [ | ||
87 | + { | ||
88 | + required: true, | ||
89 | + message: formatMessage({ id: 'validation.date.required' }), | ||
90 | + }, | ||
91 | + ], | ||
92 | + })( | ||
93 | + <RangePicker | ||
94 | + style={{ width: '100%' }} | ||
95 | + placeholder={[ | ||
96 | + formatMessage({ id: 'form.date.placeholder.start' }), | ||
97 | + formatMessage({ id: 'form.date.placeholder.end' }), | ||
98 | + ]} | ||
99 | + /> | ||
100 | + )} | ||
101 | + </FormItem> | ||
102 | + <FormItem {...formItemLayout} label={<FormattedMessage id="form.goal.label" />}> | ||
103 | + {getFieldDecorator('goal', { | ||
104 | + rules: [ | ||
105 | + { | ||
106 | + required: true, | ||
107 | + message: formatMessage({ id: 'validation.goal.required' }), | ||
108 | + }, | ||
109 | + ], | ||
110 | + })( | ||
111 | + <TextArea | ||
112 | + style={{ minHeight: 32 }} | ||
113 | + placeholder={formatMessage({ id: 'form.goal.placeholder' })} | ||
114 | + rows={4} | ||
115 | + /> | ||
116 | + )} | ||
117 | + </FormItem> | ||
118 | + <FormItem {...formItemLayout} label={<FormattedMessage id="form.standard.label" />}> | ||
119 | + {getFieldDecorator('standard', { | ||
120 | + rules: [ | ||
121 | + { | ||
122 | + required: true, | ||
123 | + message: formatMessage({ id: 'validation.standard.required' }), | ||
124 | + }, | ||
125 | + ], | ||
126 | + })( | ||
127 | + <TextArea | ||
128 | + style={{ minHeight: 32 }} | ||
129 | + placeholder={formatMessage({ id: 'form.standard.placeholder' })} | ||
130 | + rows={4} | ||
131 | + /> | ||
132 | + )} | ||
133 | + </FormItem> | ||
134 | + <FormItem | ||
135 | + {...formItemLayout} | ||
136 | + label={ | ||
137 | + <span> | ||
138 | + <FormattedMessage id="form.client.label" /> | ||
139 | + <em className={styles.optional}> | ||
140 | + <FormattedMessage id="form.optional" /> | ||
141 | + <Tooltip title={<FormattedMessage id="form.client.label.tooltip" />}> | ||
142 | + <Icon type="info-circle-o" style={{ marginRight: 4 }} /> | ||
143 | + </Tooltip> | ||
144 | + </em> | ||
145 | + </span> | ||
146 | + } | ||
147 | + > | ||
148 | + {getFieldDecorator('client')( | ||
149 | + <Input placeholder={formatMessage({ id: 'form.client.placeholder' })} /> | ||
150 | + )} | ||
151 | + </FormItem> | ||
152 | + <FormItem | ||
153 | + {...formItemLayout} | ||
154 | + label={ | ||
155 | + <span> | ||
156 | + <FormattedMessage id="form.invites.label" /> | ||
157 | + <em className={styles.optional}> | ||
158 | + <FormattedMessage id="form.optional" /> | ||
159 | + </em> | ||
160 | + </span> | ||
161 | + } | ||
162 | + > | ||
163 | + {getFieldDecorator('invites')( | ||
164 | + <Input placeholder={formatMessage({ id: 'form.invites.placeholder' })} /> | ||
165 | + )} | ||
166 | + </FormItem> | ||
167 | + <FormItem | ||
168 | + {...formItemLayout} | ||
169 | + label={ | ||
170 | + <span> | ||
171 | + <FormattedMessage id="form.weight.label" /> | ||
172 | + <em className={styles.optional}> | ||
173 | + <FormattedMessage id="form.optional" /> | ||
174 | + </em> | ||
175 | + </span> | ||
176 | + } | ||
177 | + > | ||
178 | + {getFieldDecorator('weight')( | ||
179 | + <InputNumber | ||
180 | + placeholder={formatMessage({ id: 'form.weight.placeholder' })} | ||
181 | + min={0} | ||
182 | + max={100} | ||
183 | + /> | ||
184 | + )} | ||
185 | + <span className="ant-form-text">%</span> | ||
186 | + </FormItem> | ||
187 | + <FormItem | ||
188 | + {...formItemLayout} | ||
189 | + label={<FormattedMessage id="form.public.label" />} | ||
190 | + help={<FormattedMessage id="form.public.label.help" />} | ||
191 | + > | ||
192 | + <div> | ||
193 | + {getFieldDecorator('public', { | ||
194 | + initialValue: '1', | ||
195 | + })( | ||
196 | + <Radio.Group> | ||
197 | + <Radio value="1"> | ||
198 | + <FormattedMessage id="form.public.radio.public" /> | ||
199 | + </Radio> | ||
200 | + <Radio value="2"> | ||
201 | + <FormattedMessage id="form.public.radio.partially-public" /> | ||
202 | + </Radio> | ||
203 | + <Radio value="3"> | ||
204 | + <FormattedMessage id="form.public.radio.private" /> | ||
205 | + </Radio> | ||
206 | + </Radio.Group> | ||
207 | + )} | ||
208 | + <FormItem style={{ marginBottom: 0 }}> | ||
209 | + {getFieldDecorator('publicUsers')( | ||
210 | + <Select | ||
211 | + mode="multiple" | ||
212 | + placeholder={formatMessage({ id: 'form.publicUsers.placeholder' })} | ||
213 | + style={{ | ||
214 | + margin: '8px 0', | ||
215 | + display: getFieldValue('public') === '2' ? 'block' : 'none', | ||
216 | + }} | ||
217 | + > | ||
218 | + <Option value="1"> | ||
219 | + <FormattedMessage id="form.publicUsers.option.A" /> | ||
220 | + </Option> | ||
221 | + <Option value="2"> | ||
222 | + <FormattedMessage id="form.publicUsers.option.B" /> | ||
223 | + </Option> | ||
224 | + <Option value="3"> | ||
225 | + <FormattedMessage id="form.publicUsers.option.C" /> | ||
226 | + </Option> | ||
227 | + </Select> | ||
228 | + )} | ||
229 | + </FormItem> | ||
230 | + </div> | ||
231 | + </FormItem> | ||
232 | + <FormItem {...submitFormLayout} style={{ marginTop: 32 }}> | ||
233 | + <Button type="primary" htmlType="submit" loading={submitting}> | ||
234 | + <FormattedMessage id="form.submit" /> | ||
235 | + </Button> | ||
236 | + <Button style={{ marginLeft: 8 }}> | ||
237 | + <FormattedMessage id="form.save" /> | ||
238 | + </Button> | ||
239 | + </FormItem> | ||
240 | + </Form> | ||
241 | + </Card> | ||
242 | + </PageHeaderWrapper> | ||
243 | + ); | ||
244 | + } | ||
245 | +} | ||
246 | + | ||
247 | +export default BasicForms; |
1 | +export default { | ||
2 | + 'form.get-captcha': 'Get Captcha', | ||
3 | + 'form.captcha.second': 'sec', | ||
4 | + 'form.optional': ' (optional) ', | ||
5 | + 'form.submit': 'Submit', | ||
6 | + 'form.save': 'Save', | ||
7 | + 'form.email.placeholder': 'Email', | ||
8 | + 'form.password.placeholder': 'Password', | ||
9 | + 'form.confirm-password.placeholder': 'Confirm password', | ||
10 | + 'form.phone-number.placeholder': 'Phone number', | ||
11 | + 'form.verification-code.placeholder': 'Verification code', | ||
12 | + 'form.title.label': 'Title', | ||
13 | + 'form.title.placeholder': 'Give the target a name', | ||
14 | + 'form.date.label': 'Start and end date', | ||
15 | + 'form.date.placeholder.start': 'Start date', | ||
16 | + 'form.date.placeholder.end': 'End date', | ||
17 | + 'form.goal.label': 'Goal description', | ||
18 | + 'form.goal.placeholder': 'Please enter your work goals', | ||
19 | + 'form.standard.label': 'Metrics', | ||
20 | + 'form.standard.placeholder': 'Please enter a metric', | ||
21 | + 'form.client.label': 'Client', | ||
22 | + 'form.client.label.tooltip': 'Target service object', | ||
23 | + 'form.client.placeholder': | ||
24 | + 'Please describe your customer service, internal customers directly @ Name / job number', | ||
25 | + 'form.invites.label': 'Inviting critics', | ||
26 | + 'form.invites.placeholder': 'Please direct @ Name / job number, you can invite up to 5 people', | ||
27 | + 'form.weight.label': 'Weight', | ||
28 | + 'form.weight.placeholder': 'Please enter weight', | ||
29 | + 'form.public.label': 'Target disclosure', | ||
30 | + 'form.public.label.help': 'Customers and invitees are shared by default', | ||
31 | + 'form.public.radio.public': 'Public', | ||
32 | + 'form.public.radio.partially-public': 'Partially public', | ||
33 | + 'form.public.radio.private': 'Private', | ||
34 | + 'form.publicUsers.placeholder': 'Open to', | ||
35 | + 'form.publicUsers.option.A': 'Colleague A', | ||
36 | + 'form.publicUsers.option.B': 'Colleague B', | ||
37 | + 'form.publicUsers.option.C': 'Colleague C', | ||
38 | +}; |
1 | +export default { | ||
2 | + 'form.get-captcha': '获取验证码', | ||
3 | + 'form.captcha.second': '秒', | ||
4 | + 'form.optional': '(选填)', | ||
5 | + 'form.submit': '提交', | ||
6 | + 'form.save': '保存', | ||
7 | + 'form.email.placeholder': '邮箱', | ||
8 | + 'form.password.placeholder': '至少6位密码,区分大小写', | ||
9 | + 'form.confirm-password.placeholder': '确认密码', | ||
10 | + 'form.phone-number.placeholder': '手机号', | ||
11 | + 'form.verification-code.placeholder': '验证码', | ||
12 | + 'form.title.label': '标题', | ||
13 | + 'form.title.placeholder': '给目标起个名字', | ||
14 | + 'form.date.label': '起止日期', | ||
15 | + 'form.date.placeholder.start': '开始日期', | ||
16 | + 'form.date.placeholder.end': '结束日期', | ||
17 | + 'form.goal.label': '目标描述', | ||
18 | + 'form.goal.placeholder': '请输入你的阶段性工作目标', | ||
19 | + 'form.standard.label': '衡量标准', | ||
20 | + 'form.standard.placeholder': '请输入衡量标准', | ||
21 | + 'form.client.label': '客户', | ||
22 | + 'form.client.label.tooltip': '目标的服务对象', | ||
23 | + 'form.client.placeholder': '请描述你服务的客户,内部客户直接 @姓名/工号', | ||
24 | + 'form.invites.label': '邀评人', | ||
25 | + 'form.invites.placeholder': '请直接 @姓名/工号,最多可邀请 5 人', | ||
26 | + 'form.weight.label': '权重', | ||
27 | + 'form.weight.placeholder': '请输入', | ||
28 | + 'form.public.label': '目标公开', | ||
29 | + 'form.public.label.help': '客户、邀评人默认被分享', | ||
30 | + 'form.public.radio.public': '公开', | ||
31 | + 'form.public.radio.partially-public': '部分公开', | ||
32 | + 'form.public.radio.private': '不公开', | ||
33 | + 'form.publicUsers.placeholder': '公开给', | ||
34 | + 'form.publicUsers.option.A': '同事甲', | ||
35 | + 'form.publicUsers.option.B': '同事乙', | ||
36 | + 'form.publicUsers.option.C': '同事丙', | ||
37 | +}; |
1 | +export default { | ||
2 | + 'form.get-captcha': '獲取驗證碼', | ||
3 | + 'form.captcha.second': '秒', | ||
4 | + 'form.optional': '(選填)', | ||
5 | + 'form.submit': '提交', | ||
6 | + 'form.save': '保存', | ||
7 | + 'form.email.placeholder': '郵箱', | ||
8 | + 'form.password.placeholder': '至少6位密碼,區分大小寫', | ||
9 | + 'form.confirm-password.placeholder': '確認密碼', | ||
10 | + 'form.phone-number.placeholder': '手機號', | ||
11 | + 'form.verification-code.placeholder': '驗證碼', | ||
12 | + 'form.title.label': '標題', | ||
13 | + 'form.title.placeholder': '給目標起個名字', | ||
14 | + 'form.date.label': '起止日期', | ||
15 | + 'form.date.placeholder.start': '開始日期', | ||
16 | + 'form.date.placeholder.end': '結束日期', | ||
17 | + 'form.goal.label': '目標描述', | ||
18 | + 'form.goal.placeholder': '請輸入妳的階段性工作目標', | ||
19 | + 'form.standard.label': '衡量標淮', | ||
20 | + 'form.standard.placeholder': '請輸入衡量標淮', | ||
21 | + 'form.client.label': '客戶', | ||
22 | + 'form.client.label.tooltip': '目標的服務對象', | ||
23 | + 'form.client.placeholder': '請描述妳服務的客戶,內部客戶直接 @姓名/工號', | ||
24 | + 'form.invites.label': '邀評人', | ||
25 | + 'form.invites.placeholder': '請直接 @姓名/工號,最多可邀請 5 人', | ||
26 | + 'form.weight.label': '權重', | ||
27 | + 'form.weight.placeholder': '請輸入', | ||
28 | + 'form.public.label': '目標公開', | ||
29 | + 'form.public.label.help': '客戶、邀評人默認被分享', | ||
30 | + 'form.public.radio.public': '公開', | ||
31 | + 'form.public.radio.partially-public': '部分公開', | ||
32 | + 'form.public.radio.private': '不公開', | ||
33 | + 'form.publicUsers.placeholder': '公開給', | ||
34 | + 'form.publicUsers.option.A': '同事甲', | ||
35 | + 'form.publicUsers.option.B': '同事乙', | ||
36 | + 'form.publicUsers.option.C': '同事丙', | ||
37 | +}; |
1 | +import { message } from 'antd'; | ||
2 | +import defaultSettings from '../defaultSettings'; | ||
3 | + | ||
4 | +let lessNodesAppended; | ||
5 | +const updateTheme = primaryColor => { | ||
6 | + // Don't compile less in production! | ||
7 | + if (APP_TYPE !== 'site') { | ||
8 | + return; | ||
9 | + } | ||
10 | + // Determine if the component is remounted | ||
11 | + if (!primaryColor) { | ||
12 | + return; | ||
13 | + } | ||
14 | + const hideMessage = message.loading('正在编译主题!', 0); | ||
15 | + function buildIt() { | ||
16 | + if (!window.less) { | ||
17 | + return; | ||
18 | + } | ||
19 | + setTimeout(() => { | ||
20 | + window.less | ||
21 | + .modifyVars({ | ||
22 | + '@primary-color': primaryColor, | ||
23 | + }) | ||
24 | + .then(() => { | ||
25 | + hideMessage(); | ||
26 | + }) | ||
27 | + .catch(() => { | ||
28 | + message.error('Failed to update theme'); | ||
29 | + hideMessage(); | ||
30 | + }); | ||
31 | + }, 200); | ||
32 | + } | ||
33 | + if (!lessNodesAppended) { | ||
34 | + // insert less.js and color.less | ||
35 | + const lessStyleNode = document.createElement('link'); | ||
36 | + const lessConfigNode = document.createElement('script'); | ||
37 | + const lessScriptNode = document.createElement('script'); | ||
38 | + lessStyleNode.setAttribute('rel', 'stylesheet/less'); | ||
39 | + lessStyleNode.setAttribute('href', '/color.less'); | ||
40 | + lessConfigNode.innerHTML = ` | ||
41 | + window.less = { | ||
42 | + async: true, | ||
43 | + env: 'production', | ||
44 | + javascriptEnabled: true | ||
45 | + }; | ||
46 | + `; | ||
47 | + lessScriptNode.src = 'https://gw.alipayobjects.com/os/lib/less.js/3.8.1/less.min.js'; | ||
48 | + lessScriptNode.async = true; | ||
49 | + lessScriptNode.onload = () => { | ||
50 | + buildIt(); | ||
51 | + lessScriptNode.onload = null; | ||
52 | + }; | ||
53 | + document.body.appendChild(lessStyleNode); | ||
54 | + document.body.appendChild(lessConfigNode); | ||
55 | + document.body.appendChild(lessScriptNode); | ||
56 | + lessNodesAppended = true; | ||
57 | + } else { | ||
58 | + buildIt(); | ||
59 | + } | ||
60 | +}; | ||
61 | + | ||
62 | +const updateColorWeak = colorWeak => { | ||
63 | + document.body.className = colorWeak ? 'colorWeak' : ''; | ||
64 | +}; | ||
65 | + | ||
66 | +export default { | ||
67 | + namespace: 'setting', | ||
68 | + state: defaultSettings, | ||
69 | + reducers: { | ||
70 | + getSetting(state) { | ||
71 | + const setting = {}; | ||
72 | + const urlParams = new URL(window.location.href); | ||
73 | + Object.keys(state).forEach(key => { | ||
74 | + if (urlParams.searchParams.has(key)) { | ||
75 | + const value = urlParams.searchParams.get(key); | ||
76 | + setting[key] = value === '1' ? true : value; | ||
77 | + } | ||
78 | + }); | ||
79 | + const { primaryColor, colorWeak } = setting; | ||
80 | + if (state.primaryColor !== primaryColor) { | ||
81 | + updateTheme(primaryColor); | ||
82 | + } | ||
83 | + updateColorWeak(colorWeak); | ||
84 | + return { | ||
85 | + ...state, | ||
86 | + ...setting, | ||
87 | + }; | ||
88 | + }, | ||
89 | + changeSetting(state, { payload }) { | ||
90 | + const urlParams = new URL(window.location.href); | ||
91 | + Object.keys(defaultSettings).forEach(key => { | ||
92 | + if (urlParams.searchParams.has(key)) { | ||
93 | + urlParams.searchParams.delete(key); | ||
94 | + } | ||
95 | + }); | ||
96 | + Object.keys(payload).forEach(key => { | ||
97 | + if (key === 'collapse') { | ||
98 | + return; | ||
99 | + } | ||
100 | + let value = payload[key]; | ||
101 | + if (value === true) { | ||
102 | + value = 1; | ||
103 | + } | ||
104 | + if (defaultSettings[key] !== value) { | ||
105 | + urlParams.searchParams.set(key, value); | ||
106 | + } | ||
107 | + }); | ||
108 | + const { primaryColor, colorWeak, contentWidth } = payload; | ||
109 | + if (state.primaryColor !== primaryColor) { | ||
110 | + updateTheme(primaryColor); | ||
111 | + } | ||
112 | + if (state.contentWidth !== contentWidth && window.dispatchEvent) { | ||
113 | + window.dispatchEvent(new Event('resize')); | ||
114 | + } | ||
115 | + updateColorWeak(colorWeak); | ||
116 | + window.history.replaceState(null, 'setting', urlParams.href); | ||
117 | + return { | ||
118 | + ...state, | ||
119 | + ...payload, | ||
120 | + }; | ||
121 | + }, | ||
122 | + }, | ||
123 | +}; |
ant-design-pro/BasicForm/src/style.less
0 → 100644
1 | +@import '~antd/lib/style/themes/default.less'; | ||
2 | + | ||
3 | +.card { | ||
4 | + margin-bottom: 24px; | ||
5 | +} | ||
6 | + | ||
7 | +.heading { | ||
8 | + font-size: 14px; | ||
9 | + line-height: 22px; | ||
10 | + margin: 0 0 16px 0; | ||
11 | +} | ||
12 | + | ||
13 | +.steps:global(.ant-steps) { | ||
14 | + max-width: 750px; | ||
15 | + margin: 16px auto; | ||
16 | +} | ||
17 | + | ||
18 | +.errorIcon { | ||
19 | + cursor: pointer; | ||
20 | + color: @error-color; | ||
21 | + margin-right: 24px; | ||
22 | + i { | ||
23 | + margin-right: 4px; | ||
24 | + } | ||
25 | +} | ||
26 | + | ||
27 | +.errorPopover { | ||
28 | + :global { | ||
29 | + .ant-popover-inner-content { | ||
30 | + padding: 0; | ||
31 | + max-height: 290px; | ||
32 | + overflow: auto; | ||
33 | + min-width: 256px; | ||
34 | + } | ||
35 | + } | ||
36 | +} | ||
37 | + | ||
38 | +.errorListItem { | ||
39 | + list-style: none; | ||
40 | + border-bottom: 1px solid @border-color-split; | ||
41 | + padding: 8px 16px; | ||
42 | + cursor: pointer; | ||
43 | + transition: all 0.3s; | ||
44 | + &:hover { | ||
45 | + background: @primary-1; | ||
46 | + } | ||
47 | + &:last-child { | ||
48 | + border: 0; | ||
49 | + } | ||
50 | + .errorIcon { | ||
51 | + color: @error-color; | ||
52 | + float: left; | ||
53 | + margin-top: 4px; | ||
54 | + margin-right: 12px; | ||
55 | + padding-bottom: 22px; | ||
56 | + } | ||
57 | + .errorField { | ||
58 | + font-size: 12px; | ||
59 | + color: @text-color-secondary; | ||
60 | + margin-top: 2px; | ||
61 | + } | ||
62 | +} | ||
63 | + | ||
64 | +.editable { | ||
65 | + td { | ||
66 | + padding-top: 13px !important; | ||
67 | + padding-bottom: 12.5px !important; | ||
68 | + } | ||
69 | +} | ||
70 | + | ||
71 | +// custom footer for fixed footer toolbar | ||
72 | +.advancedForm + div { | ||
73 | + padding-bottom: 64px; | ||
74 | +} | ||
75 | + | ||
76 | +.advancedForm { | ||
77 | + :global { | ||
78 | + .ant-form .ant-row:last-child .ant-form-item { | ||
79 | + margin-bottom: 24px; | ||
80 | + } | ||
81 | + .ant-table td { | ||
82 | + transition: none !important; | ||
83 | + } | ||
84 | + } | ||
85 | +} | ||
86 | + | ||
87 | +.optional { | ||
88 | + color: @text-color-secondary; | ||
89 | + font-style: normal; | ||
90 | +} |
请
注册
或
登录
后发表评论