正在显示
17 个修改的文件
包含
202 行增加
和
227 行删除
... | ... | @@ -11,16 +11,17 @@ |
11 | 11 | "url": "https://github.com/umijs/umi-blocks/advancedform" |
12 | 12 | }, |
13 | 13 | "dependencies": { |
14 | - "react": "^16.6.3", | |
15 | - "dva": "^2.4.0", | |
16 | 14 | "ant-design-pro": "^2.1.1", |
17 | 15 | "antd": "^3.10.9", |
18 | - "lodash": "^4.17.10", | |
19 | - "qs": "^6.6.0", | |
16 | + "dva": "^2.4.0", | |
20 | 17 | "hash.js": "^1.1.5", |
18 | + "lodash": "^4.17.10", | |
19 | + "mockjs": "*", | |
21 | 20 | "moment": "^2.22.2", |
22 | 21 | "nzh": "^1.0.3", |
23 | - "mockjs": "*" | |
22 | + "qs": "^6.6.0", | |
23 | + "react": "^16.6.3", | |
24 | + "umi-request": "^1.0.0" | |
24 | 25 | }, |
25 | 26 | "devDependencies": { |
26 | 27 | "umi": "^2.3.0-beta.1", | ... | ... |
1 | +import React from 'react'; | |
2 | +import { FormattedMessage } from 'umi/locale'; | |
3 | +import Link from 'umi/link'; | |
4 | +import { PageHeader } from 'ant-design-pro'; | |
5 | +import styles from './index.less'; | |
6 | + | |
7 | +const PageHeaderWrapper = ({ children, wrapperClassName, ...restProps }) => ( | |
8 | + <div style={{ margin: '-24px -24px 0' }} className={wrapperClassName}> | |
9 | + <PageHeader | |
10 | + home={<FormattedMessage id="menu.home" defaultMessage="Home" />} | |
11 | + key="pageheader" | |
12 | + {...restProps} | |
13 | + linkElement={Link} | |
14 | + itemRender={item => { | |
15 | + if (item.locale) { | |
16 | + return <FormattedMessage id={item.locale} defaultMessage={item.title} />; | |
17 | + } | |
18 | + return item.title; | |
19 | + }} | |
20 | + /> | |
21 | + {children ? ( | |
22 | + <div className={styles.content}> | |
23 | + {children} | |
24 | + </div> | |
25 | + ) : null} | |
26 | + </div> | |
27 | +); | |
28 | + | |
29 | +export default PageHeaderWrapper; | ... | ... |
1 | 1 | import React, { PureComponent, Fragment } from 'react'; |
2 | 2 | import { Table, Button, Input, message, Popconfirm, Divider } from 'antd'; |
3 | 3 | import isEqual from 'lodash/isEqual'; |
4 | -import styles from './style.less'; | |
4 | +import styles from '../style.less'; | |
5 | 5 | |
6 | 6 | class TableForm extends PureComponent { |
7 | 7 | index = 0; | ... | ... |
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 | -}; |
... | ... | @@ -13,9 +13,9 @@ import { |
13 | 13 | Popover, |
14 | 14 | } from 'antd'; |
15 | 15 | import { connect } from 'dva'; |
16 | -import FooterToolbar from 'ant-design-pro/lib/FooterToolbar'; | |
17 | -import PageHeaderWrapper from '@/components/PageHeaderWrapper'; | |
18 | -import TableForm from './TableForm'; | |
16 | +import { FooterToolbar } from 'ant-design-pro'; | |
17 | +import PageHeaderWrapper from './components/PageHeaderWrapper'; | |
18 | +import TableForm from './components/TableForm'; | |
19 | 19 | import styles from './style.less'; |
20 | 20 | |
21 | 21 | const { Option } = Select; | ... | ... |
1 | 1 | export default { |
2 | + 'app.forms.basic.title': 'Basic form', | |
3 | + 'app.forms.basic.description': | |
4 | + 'Form pages are used to collect or verify information to users, and basic forms are common in scenarios where there are fewer data items.', | |
5 | + | |
6 | + 'validation.email.required': 'Please enter your email!', | |
7 | + 'validation.email.wrong-format': 'The email address is in the wrong format!', | |
8 | + 'validation.userName.required': 'Please enter your userName!', | |
9 | + 'validation.password.required': 'Please enter your password!', | |
10 | + 'validation.password.twice': 'The passwords entered twice do not match!', | |
11 | + 'validation.password.strength.msg': | |
12 | + "Please enter at least 6 characters and don't use passwords that are easy to guess.", | |
13 | + 'validation.password.strength.strong': 'Strength: strong', | |
14 | + 'validation.password.strength.medium': 'Strength: medium', | |
15 | + 'validation.password.strength.short': 'Strength: too short', | |
16 | + 'validation.confirm-password.required': 'Please confirm your password!', | |
17 | + 'validation.phone-number.required': 'Please enter your phone number!', | |
18 | + 'validation.phone-number.wrong-format': 'Malformed phone number!', | |
19 | + 'validation.verification-code.required': 'Please enter the verification code!', | |
20 | + 'validation.title.required': 'Please enter a title', | |
21 | + 'validation.date.required': 'Please select the start and end date', | |
22 | + 'validation.goal.required': 'Please enter a description of the goal', | |
23 | + 'validation.standard.required': 'Please enter a metric', | |
24 | + | |
2 | 25 | 'form.get-captcha': 'Get Captcha', |
3 | 26 | 'form.captcha.second': 'sec', |
4 | 27 | 'form.optional': ' (optional) ', | ... | ... |
1 | +export default { | |
2 | + 'app.forms.basic.title': 'Basic form', | |
3 | + 'app.forms.basic.description': | |
4 | + 'Form pages are used to collect or verify information to users, and basic forms are common in scenarios where there are fewer data items.', | |
5 | + | |
6 | + 'validation.email.required': 'Por favor insira seu email!', | |
7 | + 'validation.email.wrong-format': 'O email está errado!', | |
8 | + 'validation.userName.required': 'Por favor insira nome de usuário!', | |
9 | + 'validation.password.required': 'Por favor insira sua senha!', | |
10 | + 'validation.password.twice': 'As senhas não estão iguais!', | |
11 | + 'validation.password.strength.msg': | |
12 | + 'Por favor insira pelo menos 6 caracteres e não use senhas fáceis de adivinhar.', | |
13 | + 'validation.password.strength.strong': 'Força: forte', | |
14 | + 'validation.password.strength.medium': 'Força: média', | |
15 | + 'validation.password.strength.short': 'Força: curta', | |
16 | + 'validation.confirm-password.required': 'Por favor confirme sua senha!', | |
17 | + 'validation.phone-number.required': 'Por favor insira seu telefone!', | |
18 | + 'validation.phone-number.wrong-format': 'Formato de telefone errado!', | |
19 | + 'validation.verification-code.required': 'Por favor insira seu código de verificação!', | |
20 | + | |
21 | + 'form.get-captcha': 'Get Captcha', | |
22 | + 'form.captcha.second': 'sec', | |
23 | + 'form.email.placeholder': 'Email', | |
24 | + 'form.password.placeholder': 'Senha', | |
25 | + 'form.confirm-password.placeholder': 'Confirme a senha', | |
26 | + 'form.phone-number.placeholder': 'Telefone', | |
27 | + 'form.verification-code.placeholder': 'Código de verificação', | |
28 | + 'form.optional': ' (optional) ', | |
29 | + 'form.submit': 'Submit', | |
30 | + 'form.save': 'Save', | |
31 | + 'form.title.label': 'Title', | |
32 | + 'form.title.placeholder': 'Give the target a name', | |
33 | + 'form.date.label': 'Start and end date', | |
34 | + 'form.date.placeholder.start': 'Start date', | |
35 | + 'form.date.placeholder.end': 'End date', | |
36 | + 'form.goal.label': 'Goal description', | |
37 | + 'form.goal.placeholder': 'Please enter your work goals', | |
38 | + 'form.standard.label': 'Metrics', | |
39 | + 'form.standard.placeholder': 'Please enter a metric', | |
40 | + 'form.client.label': 'Client', | |
41 | + 'form.client.label.tooltip': 'Target service object', | |
42 | + 'form.client.placeholder': | |
43 | + 'Please describe your customer service, internal customers directly @ Name / job number', | |
44 | + 'form.invites.label': 'Inviting critics', | |
45 | + 'form.invites.placeholder': 'Please direct @ Name / job number, you can invite up to 5 people', | |
46 | + 'form.weight.label': 'Weight', | |
47 | + 'form.weight.placeholder': 'Please enter weight', | |
48 | + 'form.public.label': 'Target disclosure', | |
49 | + 'form.public.label.help': 'Customers and invitees are shared by default', | |
50 | + 'form.public.radio.public': 'Public', | |
51 | + 'form.public.radio.partially-public': 'Partially public', | |
52 | + 'form.public.radio.private': 'Private', | |
53 | + 'form.publicUsers.placeholder': 'Open to', | |
54 | + 'form.publicUsers.option.A': 'Colleague A', | |
55 | + 'form.publicUsers.option.B': 'Colleague B', | |
56 | + 'form.publicUsers.option.C': 'Colleague C', | |
57 | +}; | ... | ... |
1 | 1 | export default { |
2 | + 'app.forms.basic.title': '基础表单', | |
3 | + 'app.forms.basic.description': | |
4 | + '表单页用于向用户收集或验证信息,基础表单常见于数据项较少的表单场景。', | |
5 | + | |
6 | + 'validation.email.required': '请输入邮箱地址!', | |
7 | + 'validation.email.wrong-format': '邮箱地址格式错误!', | |
8 | + 'validation.userName.required': '请输入用户名!', | |
9 | + 'validation.password.required': '请输入密码!', | |
10 | + 'validation.password.twice': '两次输入的密码不匹配!', | |
11 | + 'validation.password.strength.msg': '请至少输入 6 个字符。请不要使用容易被猜到的密码。', | |
12 | + 'validation.password.strength.strong': '强度:强', | |
13 | + 'validation.password.strength.medium': '强度:中', | |
14 | + 'validation.password.strength.short': '强度:太短', | |
15 | + 'validation.confirm-password.required': '请确认密码!', | |
16 | + 'validation.phone-number.required': '请输入手机号!', | |
17 | + 'validation.phone-number.wrong-format': '手机号格式错误!', | |
18 | + 'validation.verification-code.required': '请输入验证码!', | |
19 | + 'validation.title.required': '请输入标题', | |
20 | + 'validation.date.required': '请选择起止日期', | |
21 | + 'validation.goal.required': '请输入目标描述', | |
22 | + 'validation.standard.required': '请输入衡量标准', | |
23 | + | |
2 | 24 | 'form.get-captcha': '获取验证码', |
3 | 25 | 'form.captcha.second': '秒', |
4 | 26 | 'form.optional': '(选填)', | ... | ... |
1 | 1 | export default { |
2 | + 'app.forms.basic.title': '基礎表單', | |
3 | + 'app.forms.basic.description': | |
4 | + '表單頁用於向用戶收集或驗證信息,基礎表單常見於數據項較少的表單場景。', | |
5 | + | |
6 | + 'validation.email.required': '請輸入郵箱地址!', | |
7 | + 'validation.email.wrong-format': '郵箱地址格式錯誤!', | |
8 | + 'validation.userName.required': '請輸入賬戶!', | |
9 | + 'validation.password.required': '請輸入密碼!', | |
10 | + 'validation.password.twice': '兩次輸入的密碼不匹配!', | |
11 | + 'validation.password.strength.msg': '請至少輸入 6 個字符。請不要使用容易被猜到的密碼。', | |
12 | + 'validation.password.strength.strong': '強度:強', | |
13 | + 'validation.password.strength.medium': '強度:中', | |
14 | + 'validation.password.strength.short': '強度:太短', | |
15 | + 'validation.confirm-password.required': '請確認密碼!', | |
16 | + 'validation.phone-number.required': '請輸入手機號!', | |
17 | + 'validation.phone-number.wrong-format': '手機號格式錯誤!', | |
18 | + 'validation.verification-code.required': '請輸入驗證碼!', | |
19 | + 'validation.title.required': '請輸入標題', | |
20 | + 'validation.date.required': '請選擇起止日期', | |
21 | + 'validation.goal.required': '請輸入目標描述', | |
22 | + 'validation.standard.required': '請輸入衡量標淮', | |
23 | + | |
2 | 24 | 'form.get-captcha': '獲取驗證碼', |
3 | 25 | 'form.captcha.second': '秒', |
4 | 26 | 'form.optional': '(選填)', | ... | ... |
ant-design-pro/AdvancedForm/src/model.js
0 → 100644
1 | +import { routerRedux } from 'dva/router'; | |
2 | +import { message } from 'antd'; | |
3 | +import { fakeSubmitForm } from './service'; | |
4 | + | |
5 | +export default { | |
6 | + namespace: 'form', | |
7 | + | |
8 | + state: { | |
9 | + }, | |
10 | + | |
11 | + effects: { | |
12 | + *submitAdvancedForm({ payload }, { call }) { | |
13 | + yield call(fakeSubmitForm, payload); | |
14 | + message.success('提交成功'); | |
15 | + }, | |
16 | + }, | |
17 | +}; | ... | ... |
1 | -import { routerRedux } from 'dva/router'; | |
2 | -import { message } from 'antd'; | |
3 | -import { fakeSubmitForm } from '@/services/api'; | |
4 | - | |
5 | -export default { | |
6 | - namespace: 'form', | |
7 | - | |
8 | - state: { | |
9 | - step: { | |
10 | - payAccount: 'ant-design@alipay.com', | |
11 | - receiverAccount: 'test@example.com', | |
12 | - receiverName: 'Alex', | |
13 | - amount: '500', | |
14 | - }, | |
15 | - }, | |
16 | - | |
17 | - effects: { | |
18 | - *submitRegularForm({ payload }, { call }) { | |
19 | - yield call(fakeSubmitForm, payload); | |
20 | - message.success('提交成功'); | |
21 | - }, | |
22 | - *submitStepForm({ payload }, { call, put }) { | |
23 | - yield call(fakeSubmitForm, payload); | |
24 | - yield put({ | |
25 | - type: 'saveStepFormData', | |
26 | - payload, | |
27 | - }); | |
28 | - yield put(routerRedux.push('/form/step-form/result')); | |
29 | - }, | |
30 | - *submitAdvancedForm({ payload }, { call }) { | |
31 | - yield call(fakeSubmitForm, payload); | |
32 | - message.success('提交成功'); | |
33 | - }, | |
34 | - }, | |
35 | - | |
36 | - reducers: { | |
37 | - saveStepFormData(state, { payload }) { | |
38 | - return { | |
39 | - ...state, | |
40 | - step: { | |
41 | - ...state.step, | |
42 | - ...payload, | |
43 | - }, | |
44 | - }; | |
45 | - }, | |
46 | - }, | |
47 | -}; |
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/AdvancedForm/src/service.js
0 → 100644
... | ... | @@ -6,12 +6,6 @@ export default { |
6 | 6 | namespace: 'form', |
7 | 7 | |
8 | 8 | state: { |
9 | - step: { | |
10 | - payAccount: 'ant-design@alipay.com', | |
11 | - receiverAccount: 'test@example.com', | |
12 | - receiverName: 'Alex', | |
13 | - amount: '500', | |
14 | - }, | |
15 | 9 | }, |
16 | 10 | |
17 | 11 | effects: { |
... | ... | @@ -19,29 +13,5 @@ export default { |
19 | 13 | yield call(fakeSubmitForm, payload); |
20 | 14 | message.success('提交成功'); |
21 | 15 | }, |
22 | - *submitStepForm({ payload }, { call, put }) { | |
23 | - yield call(fakeSubmitForm, payload); | |
24 | - yield put({ | |
25 | - type: 'saveStepFormData', | |
26 | - payload, | |
27 | - }); | |
28 | - yield put(routerRedux.push('/form/step-form/result')); | |
29 | - }, | |
30 | - *submitAdvancedForm({ payload }, { call }) { | |
31 | - yield call(fakeSubmitForm, payload); | |
32 | - message.success('提交成功'); | |
33 | - }, | |
34 | - }, | |
35 | - | |
36 | - reducers: { | |
37 | - saveStepFormData(state, { payload }) { | |
38 | - return { | |
39 | - ...state, | |
40 | - step: { | |
41 | - ...state.step, | |
42 | - ...payload, | |
43 | - }, | |
44 | - }; | |
45 | - }, | |
46 | 16 | }, |
47 | 17 | }; | ... | ... |
... | ... | @@ -15,10 +15,6 @@ export default { |
15 | 15 | }, |
16 | 16 | |
17 | 17 | effects: { |
18 | - *submitRegularForm({ payload }, { call }) { | |
19 | - yield call(fakeSubmitForm, payload); | |
20 | - message.success('提交成功'); | |
21 | - }, | |
22 | 18 | *submitStepForm({ payload }, { call, put }) { |
23 | 19 | yield call(fakeSubmitForm, payload); |
24 | 20 | yield put({ |
... | ... | @@ -27,10 +23,6 @@ export default { |
27 | 23 | }); |
28 | 24 | yield put(routerRedux.push('result')); |
29 | 25 | }, |
30 | - *submitAdvancedForm({ payload }, { call }) { | |
31 | - yield call(fakeSubmitForm, payload); | |
32 | - message.success('提交成功'); | |
33 | - }, | |
34 | 26 | }, |
35 | 27 | |
36 | 28 | reducers: { | ... | ... |
请
注册
或
登录
后发表评论