From 5ba91f2019048751dd0cfda76e4353a761367b36 Mon Sep 17 00:00:00 2001 From: afc163 Date: Fri, 2 Feb 2018 17:41:41 +0800 Subject: [PATCH 01/25] move pro doc link to header --- src/common/menu.js | 5 ----- src/components/GlobalHeader/index.js | 11 ++++++++++- src/components/GlobalHeader/index.less | 1 + 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/common/menu.js b/src/common/menu.js index 75f47dcf..21b58d7a 100644 --- a/src/common/menu.js +++ b/src/common/menu.js @@ -113,11 +113,6 @@ const menuData = [{ name: '注册结果', path: 'register-result', }], -}, { - name: '使用文档', - icon: 'book', - path: 'http://pro.ant.design/docs/getting-started', - target: '_blank', }]; function formatter(data, parentPath = '', parentAuthority) { diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index f43be9d2..608e4223 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Menu, Icon, Spin, Tag, Dropdown, Avatar, Divider } from 'antd'; +import { Menu, Icon, Spin, Tag, Dropdown, Avatar, Divider, Tooltip } from 'antd'; import moment from 'moment'; import groupBy from 'lodash/groupBy'; import Debounce from 'lodash-decorators/debounce'; @@ -94,6 +94,15 @@ export default class GlobalHeader extends PureComponent { console.log('enter', value); // eslint-disable-line }} /> + + + + + i { font-size: 16px; vertical-align: middle; + color: @text-color; } &:hover, &:global(.ant-popover-open) { From 9c4e9c1b39ceacd9e0efdb666d4b6d1663b0daf6 Mon Sep 17 00:00:00 2001 From: Reed Sun Date: Fri, 2 Feb 2018 06:50:08 -0600 Subject: [PATCH 02/25] Add period in the end for the tip which don't has period before. (#877) * remove comma * add period in the end for the tip which don't has before --- src/utils/request.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index ccabf192..4113cc21 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -4,21 +4,21 @@ import { routerRedux } from 'dva/router'; import store from '../index'; const codeMessage = { - 200: '服务器成功返回请求的数据', + 200: '服务器成功返回请求的数据。', 201: '新建或修改数据成功。', - 202: '一个请求已经进入后台排队(异步任务)', + 202: '一个请求已经进入后台排队(异步任务)。', 204: '删除数据成功。', - 400: '发出的请求有错误,服务器没有进行新建或修改数据,的操作。', + 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。', 401: '用户没有权限(令牌、用户名、密码错误)。', 403: '用户得到授权,但是访问是被禁止的。', - 404: '发出的请求针对的是不存在的记录,服务器没有进行操作', + 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。', 406: '请求的格式不可得。', 410: '请求的资源被永久删除,且不会再得到的。', 422: '当创建一个对象时,发生一个验证错误。', - 500: '服务器发生错误,请检查服务器', - 502: '网关错误', - 503: '服务不可用,服务器暂时过载或维护', - 504: '网关超时', + 500: '服务器发生错误,请检查服务器。', + 502: '网关错误。', + 503: '服务不可用,服务器暂时过载或维护。', + 504: '网关超时。', }; function checkStatus(response) { if (response.status >= 200 && response.status < 300) { From 999436853318ec43471d5edda3f24fce760d330c Mon Sep 17 00:00:00 2001 From: Guangshuo Chen Date: Mon, 5 Feb 2018 07:52:50 +0100 Subject: [PATCH 03/25] let request.js be able to deal with FormData (#884) * let request.js be able to deal with FormData * Update request.js * Update request.js * Update request.js * Update request.js --- src/utils/request.js | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/src/utils/request.js b/src/utils/request.js index 4113cc21..9b58189a 100644 --- a/src/utils/request.js +++ b/src/utils/request.js @@ -48,12 +48,21 @@ export default function request(url, options) { }; const newOptions = { ...defaultOptions, ...options }; if (newOptions.method === 'POST' || newOptions.method === 'PUT') { - newOptions.headers = { - Accept: 'application/json', - 'Content-Type': 'application/json; charset=utf-8', - ...newOptions.headers, - }; - newOptions.body = JSON.stringify(newOptions.body); + if (!(newOptions.body instanceof FormData)) { + newOptions.headers = { + Accept: 'application/json', + 'Content-Type': 'application/json; charset=utf-8', + ...newOptions.headers, + }; + newOptions.body = JSON.stringify(newOptions.body); + } else { + // newOptions.body is FormData + newOptions.headers = { + Accept: 'application/json', + 'Content-Type': 'multipart/form-data', + ...newOptions.headers, + }; + } } return fetch(url, newOptions) From f388d9254002a09c6d656e31314d9419431ae813 Mon Sep 17 00:00:00 2001 From: PKAQ Date: Tue, 6 Feb 2018 10:01:24 +0800 Subject: [PATCH 04/25] =?UTF-8?q?=E4=BF=AE=E5=BE=A9=E7=82=B9=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E6=96=87=E6=A1=A3=E6=B2=A1=E6=9C=89=E8=BF=9B=E8=A1=8C?= =?UTF-8?q?=E6=AD=A3=E7=A1=AE=E7=9A=84=E8=B7=B3=E8=BD=AC=20(#893)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/GlobalHeader/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index 608e4223..61871a7d 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -95,13 +95,14 @@ export default class GlobalHeader extends PureComponent { }} /> - - + Date: Wed, 7 Feb 2018 11:32:44 +0800 Subject: [PATCH 05/25] Unit testing to increase breadcrumbs --- src/components/PageHeader/index.js | 18 ++++--- src/components/PageHeader/index.test.js | 71 +++++++++++++++++++++++++ 2 files changed, 83 insertions(+), 6 deletions(-) create mode 100644 src/components/PageHeader/index.test.js diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 7eb6de18..df514874 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -7,8 +7,7 @@ import styles from './index.less'; const { TabPane } = Tabs; - -function getBreadcrumb(breadcrumbNameMap, url) { +export function getBreadcrumb(breadcrumbNameMap, url) { let breadcrumb = breadcrumbNameMap[url]; if (!breadcrumb) { Object.keys(breadcrumbNameMap).forEach((item) => { @@ -20,6 +19,14 @@ function getBreadcrumb(breadcrumbNameMap, url) { return breadcrumb || {}; } +// /userinfo/2144/id => ['/userinfo','/useinfo/2144,'/userindo/2144/id'] +export function urlToList(url) { + const urllist = url.split('/').filter(i => i); + return urllist.map((urlItem, index) => { + return `/${urllist.slice(0, index + 1).join('/')}`; + }); +} + export default class PageHeader extends PureComponent { static contextTypes = { routes: PropTypes.array, @@ -62,11 +69,10 @@ export default class PageHeader extends PureComponent { } conversionFromLocation = (routerLocation, breadcrumbNameMap) => { const { breadcrumbSeparator, linkElement = 'a' } = this.props; - // Convert the path to an array - const pathSnippets = routerLocation.pathname.split('/').filter(i => i); + // Convert the url to an array + const pathSnippets = urlToList(routerLocation.pathname); // Loop data mosaic routing - const extraBreadcrumbItems = pathSnippets.map((_, index) => { - const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; + const extraBreadcrumbItems = pathSnippets.map((url, index) => { const currentBreadcrumb = getBreadcrumb(breadcrumbNameMap, url); const isLinkable = (index !== pathSnippets.length - 1) && currentBreadcrumb.component; return currentBreadcrumb.name && !currentBreadcrumb.hideInBreadcrumb ? ( diff --git a/src/components/PageHeader/index.test.js b/src/components/PageHeader/index.test.js new file mode 100644 index 00000000..385a3d31 --- /dev/null +++ b/src/components/PageHeader/index.test.js @@ -0,0 +1,71 @@ +import { getBreadcrumb, urlToList } from './index'; + +describe('test urlToList', () => { + it('A path', () => { + expect(urlToList('/userinfo')).toEqual(['/userinfo']); + }); + it('Secondary path', () => { + expect(urlToList('/userinfo/2144')).toEqual([ + '/userinfo', + '/userinfo/2144', + ]); + }); + it('Three paths', () => { + expect(urlToList('/userinfo/2144/addr')).toEqual([ + '/userinfo', + '/userinfo/2144', + '/userinfo/2144/addr', + ]); + }); +}); + +const routerData = { + '/dashboard/analysis': { + name: '分析页', + }, + '/userinfo': { + name: '用户列表', + }, + '/userinfo/:id': { + name: '用户信息', + }, + '/userinfo/:id/addr': { + name: '收货订单', + }, +}; +describe('test getBreadcrumb', () => { + it('Simple url', () => { + expect(getBreadcrumb(routerData, '/dashboard/analysis').name).toEqual( + '分析页' + ); + }); + it('Parameters url', () => { + expect(getBreadcrumb(routerData, '/userinfo/2144').name).toEqual( + '用户信息' + ); + }); + it('The middle parameter url', () => { + expect(getBreadcrumb(routerData, '/userinfo/2144/addr').name).toEqual( + '收货订单' + ); + }); + it('Loop through the parameters', () => { + const urlNameList = urlToList('/userinfo/2144/addr').map((url) => { + return getBreadcrumb(routerData, url).name; + }); + expect(urlNameList).toEqual(['用户列表', '用户信息', '收货订单']); + }); + + it('a path', () => { + const urlNameList = urlToList('/userinfo').map((url) => { + return getBreadcrumb(routerData, url).name; + }); + expect(urlNameList).toEqual(['用户列表']); + }); + it('Secondary path', () => { + const urlNameList = urlToList('/userinfo/2144').map((url) => { + return getBreadcrumb(routerData, url).name; + }); + expect(urlNameList).toEqual(['用户列表', '用户信息']); + }); +}); From b3af8f8570b4aaaa55c93c9023b356a81f4d45c5 Mon Sep 17 00:00:00 2001 From: jim Date: Wed, 7 Feb 2018 14:45:05 +0800 Subject: [PATCH 06/25] fix #821 Menu selection problem --- .gitignore | 1 + src/components/SiderMenu/SiderMenu.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index aa3fce58..409be881 100755 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,4 @@ yarn.lock package-lock.json *bak jsconfig.json +.prettierrc diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 5ddf6ed9..4811894d 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -87,12 +87,12 @@ export default class SiderMenu extends PureComponent { } /** * Get selected child nodes - * /user/chen => /user/:id + * /user/chen => ['user','/user/:id'] */ getSelectedMenuKeys = (path) => { const flatMenuKeys = this.getFlatMenuKeys(this.menus); return flatMenuKeys.filter((item) => { - return pathToRegexp(`/${item}`).test(path); + return pathToRegexp(`/${item}(.*)`).test(path); }); } /** From 6db2e48464d8f8edb06b8319422f7fb39da97d56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AF=B8=E5=B2=B3?= Date: Wed, 7 Feb 2018 15:15:33 +0800 Subject: [PATCH 07/25] Translate FooterToolbar (#903) * translate FooterToolbar * remove the unnessary demo code --- src/components/FooterToolbar/demo/basic.md | 48 +++++++++++-------- src/components/FooterToolbar/index.en-US.md | 18 +++++++ .../{index.md => index.zh-CN.md} | 4 +- 3 files changed, 47 insertions(+), 23 deletions(-) create mode 100644 src/components/FooterToolbar/index.en-US.md rename src/components/FooterToolbar/{index.md => index.zh-CN.md} (88%) diff --git a/src/components/FooterToolbar/demo/basic.md b/src/components/FooterToolbar/demo/basic.md index 6ce15e7c..1f678634 100644 --- a/src/components/FooterToolbar/demo/basic.md +++ b/src/components/FooterToolbar/demo/basic.md @@ -1,36 +1,44 @@ --- order: 0 -title: 演示 +title: + - zh-CN: 演示 + - en-US: demo iframe: 400 --- +## zh-CN + 浮动固定页脚。 +## en-US + +Fixed to the footer. + ````jsx import FooterToolbar from 'ant-design-pro/lib/FooterToolbar'; import { Button } from 'antd'; ReactDOM.render(
-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

-

页面内容 页面内容 页面内容 页面内容

- - - +

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+

Content Content Content Content

+ + +
, mountNode); -```` +```` \ No newline at end of file diff --git a/src/components/FooterToolbar/index.en-US.md b/src/components/FooterToolbar/index.en-US.md new file mode 100644 index 00000000..69fd80bd --- /dev/null +++ b/src/components/FooterToolbar/index.en-US.md @@ -0,0 +1,18 @@ +--- +title: FooterToolbar +cols: 1 +order: 6 +--- + +A toolbar fixed at the bottom. + +## Usage + +It is fixed at the bottom of the content area and does not move along with the scroll bar, which is usually used for data collection and submission for long pages. + +## API + +Property | Description | Type | Default +---------|-------------|------|-------- +children | toolbar content, align to the right | ReactNode | - +extra | extra information, align to the left | ReactNode | - \ No newline at end of file diff --git a/src/components/FooterToolbar/index.md b/src/components/FooterToolbar/index.zh-CN.md similarity index 88% rename from src/components/FooterToolbar/index.md rename to src/components/FooterToolbar/index.zh-CN.md index b0bea3d9..421ac08e 100644 --- a/src/components/FooterToolbar/index.md +++ b/src/components/FooterToolbar/index.zh-CN.md @@ -1,7 +1,5 @@ --- -title: - en-US: FooterToolbar - zh-CN: FooterToolbar +title: FooterToolbar subtitle: 底部工具栏 cols: 1 order: 6 From 3c18317cdecb91462a406d7e73a72649e4cde84c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= Date: Wed, 7 Feb 2018 15:16:09 +0800 Subject: [PATCH 08/25] div to fragment (#883) * div to fragment * Remove extra divs * fix indent --- src/components/Charts/Radar/index.js | 139 ++++++++++++++------------ src/components/StandardTable/index.js | 6 +- src/layouts/BasicLayout.js | 6 +- src/layouts/UserLayout.js | 4 +- src/routes/Dashboard/Analysis.js | 6 +- src/routes/Dashboard/Monitor.js | 6 +- src/routes/Forms/StepForm/Step1.js | 6 +- src/routes/Forms/StepForm/Step3.js | 6 +- src/routes/Forms/StepForm/index.js | 6 +- src/routes/Forms/TableForm.js | 6 +- src/routes/List/Articles.js | 6 +- src/routes/Profile/AdvancedProfile.js | 14 +-- src/routes/Result/Error.js | 6 +- src/routes/Result/Success.js | 10 +- 14 files changed, 117 insertions(+), 110 deletions(-) diff --git a/src/components/Charts/Radar/index.js b/src/components/Charts/Radar/index.js index 03aaa700..b7f7caf3 100644 --- a/src/components/Charts/Radar/index.js +++ b/src/components/Charts/Radar/index.js @@ -60,7 +60,9 @@ export default class Radar extends Component { const { legendData } = this.state; legendData[i] = newItem; - const filteredLegendData = legendData.filter(l => l.checked).map(l => l.name); + const filteredLegendData = legendData + .filter(l => l.checked) + .map(l => l.name); if (this.chart) { this.chart.filter('name', val => filteredLegendData.indexOf(val) > -1); @@ -109,71 +111,76 @@ export default class Radar extends Component { return (
-
- {title &&

{title}

} - - - - - - - - - {hasLegend && ( - - {legendData.map((item, i) => ( - this.handleLegendClick(item, i)} - > -
-

- - {item.name} -

-
{item.value}
-
- - ))} -
- )} -
+ {title &&

{title}

} + + + + + + + + + {hasLegend && ( + + {legendData.map((item, i) => ( + this.handleLegendClick(item, i)} + > +
+

+ + {item.name} +

+
{item.value}
+
+ + ))} +
+ )}
); } diff --git a/src/components/StandardTable/index.js b/src/components/StandardTable/index.js index 907e8280..a2c35eaf 100644 --- a/src/components/StandardTable/index.js +++ b/src/components/StandardTable/index.js @@ -1,4 +1,4 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, Fragment } from 'react'; import { Table, Alert } from 'antd'; import styles from './index.less'; @@ -84,7 +84,7 @@ class StandardTable extends PureComponent {
+ 已选择 {selectedRowKeys.length} 项   { needTotalList.map(item => ( @@ -97,7 +97,7 @@ class StandardTable extends PureComponent { ) } 清空 -
+ )} type="info" showIcon diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index f8c956a9..062198c1 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import PropTypes from 'prop-types'; import { Layout, Icon, message } from 'antd'; import DocumentTitle from 'react-document-title'; @@ -222,9 +222,9 @@ class BasicLayout extends React.PureComponent { blankTarget: true, }]} copyright={ -
+ Copyright 2018 蚂蚁金服体验技术部出品 -
+ } /> diff --git a/src/layouts/UserLayout.js b/src/layouts/UserLayout.js index 946fc953..e736b2a0 100644 --- a/src/layouts/UserLayout.js +++ b/src/layouts/UserLayout.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { Link, Redirect, Switch, Route } from 'dva/router'; import DocumentTitle from 'react-document-title'; import { Icon } from 'antd'; @@ -21,7 +21,7 @@ const links = [{ href: '', }]; -const copyright =
Copyright 2018 蚂蚁金服体验技术部出品
; +const copyright = Copyright 2018 蚂蚁金服体验技术部出品; class UserLayout extends React.PureComponent { getPageTitle() { diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 2f98da8d..f6df4406 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import { connect } from 'dva'; import { Row, @@ -241,7 +241,7 @@ export default class Analysis extends Component { }; return ( -
+ -
+ ); } } diff --git a/src/routes/Dashboard/Monitor.js b/src/routes/Dashboard/Monitor.js index 4526f121..897dc9ce 100644 --- a/src/routes/Dashboard/Monitor.js +++ b/src/routes/Dashboard/Monitor.js @@ -1,4 +1,4 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, Fragment } from 'react'; import { connect } from 'dva'; import { Row, Col, Card, Tooltip } from 'antd'; import numeral from 'numeral'; @@ -35,7 +35,7 @@ export default class Monitor extends PureComponent { const { tags } = monitor; return ( -
+ @@ -164,7 +164,7 @@ export default class Monitor extends PureComponent { -
+ ); } } diff --git a/src/routes/Forms/StepForm/Step1.js b/src/routes/Forms/StepForm/Step1.js index 2a962fbc..01cf0df2 100644 --- a/src/routes/Forms/StepForm/Step1.js +++ b/src/routes/Forms/StepForm/Step1.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { connect } from 'dva'; import { Form, Input, Button, Select, Divider } from 'antd'; import { routerRedux } from 'dva/router'; @@ -32,7 +32,7 @@ class Step1 extends React.PureComponent { }); }; return ( -
+
转账到银行卡

如果需要,这里可以放一些关于产品的常见问题说明。如果需要,这里可以放一些关于产品的常见问题说明。如果需要,这里可以放一些关于产品的常见问题说明。

- + ); } } diff --git a/src/routes/Forms/StepForm/Step3.js b/src/routes/Forms/StepForm/Step3.js index 78295ae4..8df6388d 100644 --- a/src/routes/Forms/StepForm/Step3.js +++ b/src/routes/Forms/StepForm/Step3.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { connect } from 'dva'; import { Button, Row, Col } from 'antd'; import { routerRedux } from 'dva/router'; @@ -32,14 +32,14 @@ class Step3 extends React.PureComponent { ); const actions = ( -
+ -
+ ); return ( -
+ @@ -45,7 +45,7 @@ export default class StepForm extends PureComponent { -
+
); diff --git a/src/routes/Forms/TableForm.js b/src/routes/Forms/TableForm.js index a8b18c6f..be01d82f 100644 --- a/src/routes/Forms/TableForm.js +++ b/src/routes/Forms/TableForm.js @@ -1,4 +1,4 @@ -import React, { PureComponent } from 'react'; +import React, { PureComponent, Fragment } from 'react'; import { Table, Button, Input, message, Popconfirm, Divider } from 'antd'; import styles from './style.less'; @@ -203,7 +203,7 @@ export default class TableForm extends PureComponent { }]; return ( -
+ 新增成员 - + ); } } diff --git a/src/routes/List/Articles.js b/src/routes/List/Articles.js index f7aac69a..436a7fa5 100644 --- a/src/routes/List/Articles.js +++ b/src/routes/List/Articles.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import moment from 'moment'; import { connect } from 'dva'; import { Form, Card, Select, List, Tag, Icon, Avatar, Row, Col, Button } from 'antd'; @@ -99,7 +99,7 @@ export default class SearchList extends Component { ) : null; return ( -
+ @@ -230,7 +230,7 @@ export default class SearchList extends Component { )} /> -
+ ); } } diff --git a/src/routes/Profile/AdvancedProfile.js b/src/routes/Profile/AdvancedProfile.js index 4f955079..3c0bb252 100644 --- a/src/routes/Profile/AdvancedProfile.js +++ b/src/routes/Profile/AdvancedProfile.js @@ -1,4 +1,4 @@ -import React, { Component } from 'react'; +import React, { Component, Fragment } from 'react'; import Debounce from 'lodash-decorators/debounce'; import Bind from 'lodash-decorators/bind'; import { connect } from 'dva'; @@ -23,7 +23,7 @@ const menu = ( ); const action = ( -
+ @@ -32,7 +32,7 @@ const action = ( -
+ ); const extra = ( @@ -69,20 +69,20 @@ const tabList = [{ const desc1 = (
-
+ 曲丽丽 -
+
2016-12-12 12:32
); const desc2 = (
-
+ 周毛毛 -
+
); diff --git a/src/routes/Result/Error.js b/src/routes/Result/Error.js index dee00f84..7ff64393 100644 --- a/src/routes/Result/Error.js +++ b/src/routes/Result/Error.js @@ -1,10 +1,10 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { Button, Icon, Card } from 'antd'; import Result from '../../components/Result'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; const extra = ( -
+
您提交的内容有如下错误:
@@ -16,7 +16,7 @@ const extra = ( 您的账户还不具备申请资格 立即升级
- + ); const actions = ; diff --git a/src/routes/Result/Success.js b/src/routes/Result/Success.js index 13dbbe85..f7aabd7f 100644 --- a/src/routes/Result/Success.js +++ b/src/routes/Result/Success.js @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Fragment } from 'react'; import { Button, Row, Col, Icon, Steps, Card } from 'antd'; import Result from '../../components/Result'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; @@ -24,7 +24,7 @@ const desc2 = ( ); const extra = ( -
+
项目名称
@@ -48,15 +48,15 @@ const extra = ( 财务复核} /> 完成} /> -
+ ); const actions = ( -
+ -
+ ); export default () => ( From 38f1302ab5716336401c32d352f4c918e38b3514 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E9=9B=86=E9=B9=84?= Date: Sun, 11 Feb 2018 16:45:41 +0800 Subject: [PATCH 09/25] =?UTF-8?q?=E2=9A=A1=EF=B8=8F=20Change=20'getUrlPara?= =?UTF-8?q?ms()'=20as=20standard=20library=20to=20'url.parse()'=20(#926)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🔥 Clean up unused code --- .roadhogrc.mock.js | 1 - mock/api.js | 4 ++-- mock/rule.js | 4 ++-- mock/utils.js | 45 --------------------------------------------- 4 files changed, 4 insertions(+), 50 deletions(-) delete mode 100644 mock/utils.js diff --git a/.roadhogrc.mock.js b/.roadhogrc.mock.js index 076ee0c6..284f3161 100644 --- a/.roadhogrc.mock.js +++ b/.roadhogrc.mock.js @@ -2,7 +2,6 @@ import mockjs from 'mockjs'; import { getRule, postRule } from './mock/rule'; import { getActivities, getNotice, getFakeList } from './mock/api'; import { getFakeChartData } from './mock/chart'; -import { imgMap } from './mock/utils'; import { getProfileBasicData } from './mock/profile'; import { getProfileAdvancedData } from './mock/profile'; import { getNotices } from './mock/notices'; diff --git a/mock/api.js b/mock/api.js index 35b64946..969c1518 100644 --- a/mock/api.js +++ b/mock/api.js @@ -1,4 +1,4 @@ -import { getUrlParams } from './utils'; +import { parse } from 'url'; const titles = [ 'Alipay', @@ -110,7 +110,7 @@ export function getFakeList(req, res, u) { url = req.url; // eslint-disable-line } - const params = getUrlParams(url); + const params = parse(url, true).query; const count = (params.count * 1) || 20; diff --git a/mock/rule.js b/mock/rule.js index 2090ce8e..78fb95d1 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -1,4 +1,4 @@ -import { getUrlParams } from './utils'; +import { parse } from 'url'; // mock tableListDataSource let tableListDataSource = []; @@ -26,7 +26,7 @@ export function getRule(req, res, u) { url = req.url; // eslint-disable-line } - const params = getUrlParams(url); + const params = parse(url, true).query; let dataSource = [...tableListDataSource]; diff --git a/mock/utils.js b/mock/utils.js deleted file mode 100644 index 8438a265..00000000 --- a/mock/utils.js +++ /dev/null @@ -1,45 +0,0 @@ -export const imgMap = { - user: 'https://gw.alipayobjects.com/zos/rmsportal/UjusLxePxWGkttaqqmUI.png', - a: 'https://gw.alipayobjects.com/zos/rmsportal/ZrkcSjizAKNWwJTwcadT.png', - b: 'https://gw.alipayobjects.com/zos/rmsportal/KYlwHMeomKQbhJDRUVvt.png', - c: 'https://gw.alipayobjects.com/zos/rmsportal/gabvleTstEvzkbQRfjxu.png', - d: 'https://gw.alipayobjects.com/zos/rmsportal/jvpNzacxUYLlNsHTtrAD.png', -}; - -// refers: https://www.sitepoint.com/get-url-parameters-with-javascript/ -export function getUrlParams(url) { - const d = decodeURIComponent; - let queryString = url ? url.split('?')[1] : window.location.search.slice(1); - const obj = {}; - if (queryString) { - queryString = queryString.split('#')[0]; // eslint-disable-line - const arr = queryString.split('&'); - for (let i = 0; i < arr.length; i += 1) { - const a = arr[i].split('='); - let paramNum; - const paramName = a[0].replace(/\[\d*\]/, (v) => { - paramNum = v.slice(1, -1); - return ''; - }); - const paramValue = typeof (a[1]) === 'undefined' ? true : a[1]; - if (obj[paramName]) { - if (typeof obj[paramName] === 'string') { - obj[paramName] = d([obj[paramName]]); - } - if (typeof paramNum === 'undefined') { - obj[paramName].push(d(paramValue)); - } else { - obj[paramName][paramNum] = d(paramValue); - } - } else { - obj[paramName] = d(paramValue); - } - } - } - return obj; -} - -export default { - getUrlParams, - imgMap, -}; From fd9773f5c3ac1a6b561b8982a6c030e6ca7af327 Mon Sep 17 00:00:00 2001 From: jim Date: Tue, 13 Feb 2018 01:14:38 +0800 Subject: [PATCH 10/25] fix #933 add className prop --- src/components/Ellipsis/index.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index 8421b951..4b57452f 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -4,6 +4,7 @@ export interface EllipsisProps { length?: number; lines?: number; style?: React.CSSProperties; + className?:string; } export default class Ellipsis extends React.Component< From bd391d7e6c14ff922ed1c3f773a944864d290a59 Mon Sep 17 00:00:00 2001 From: jim Date: Thu, 15 Feb 2018 00:01:22 +0800 Subject: [PATCH 11/25] Format the code --- src/components/Ellipsis/index.d.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/components/Ellipsis/index.d.ts b/src/components/Ellipsis/index.d.ts index 4b57452f..4f84c7ae 100644 --- a/src/components/Ellipsis/index.d.ts +++ b/src/components/Ellipsis/index.d.ts @@ -1,13 +1,10 @@ -import * as React from "react"; +import * as React from 'react'; export interface EllipsisProps { tooltip?: boolean; length?: number; lines?: number; style?: React.CSSProperties; - className?:string; + className?: string; } -export default class Ellipsis extends React.Component< - EllipsisProps, - any -> {} +export default class Ellipsis extends React.Component {} From 44ca66763a2651a1234d846799a5361456277e60 Mon Sep 17 00:00:00 2001 From: ddcat1115 Date: Fri, 2 Feb 2018 10:37:00 +0800 Subject: [PATCH 12/25] New page - step modal (#855) * temp save * add new page & make some improve --- mock/rule.js | 24 ++- src/models/rule.js | 10 +- src/routes/List/TableList.js | 372 ++++++++++++++++++++++++++++------- src/services/api.js | 10 + 4 files changed, 332 insertions(+), 84 deletions(-) diff --git a/mock/rule.js b/mock/rule.js index 78fb95d1..8a733298 100644 --- a/mock/rule.js +++ b/mock/rule.js @@ -8,10 +8,10 @@ for (let i = 0; i < 46; i += 1) { disabled: ((i % 6) === 0), href: 'https://ant.design', avatar: ['https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'][i % 2], - no: `TradeCode ${i}`, + name: `TradeCode ${i}`, title: `一个任务名称 ${i}`, owner: '曲丽丽', - description: '这是一段描述', + desc: '这是一段描述', callNo: Math.floor(Math.random() * 1000), status: Math.floor(Math.random() * 10) % 4, updatedAt: new Date(`2017-07-${Math.floor(i / 2) + 1}`), @@ -51,8 +51,8 @@ export function getRule(req, res, u) { dataSource = filterDataSource; } - if (params.no) { - dataSource = dataSource.filter(data => data.no.indexOf(params.no) > -1); + if (params.name) { + dataSource = dataSource.filter(data => data.name.indexOf(params.name) > -1); } let pageSize = 10; @@ -83,12 +83,12 @@ export function postRule(req, res, u, b) { } const body = (b && b.body) || req.body; - const { method, no, description } = body; + const { method, name, desc, key } = body; switch (method) { /* eslint no-case-declarations:0 */ case 'delete': - tableListDataSource = tableListDataSource.filter(item => no.indexOf(item.no) === -1); + tableListDataSource = tableListDataSource.filter(item => key.indexOf(item.key) === -1); break; case 'post': const i = Math.ceil(Math.random() * 10000); @@ -96,10 +96,10 @@ export function postRule(req, res, u, b) { key: i, href: 'https://ant.design', avatar: ['https://gw.alipayobjects.com/zos/rmsportal/eeHMaZBwmTvLdIwMfBpg.png', 'https://gw.alipayobjects.com/zos/rmsportal/udxAbMEhpwthVVcjLXik.png'][i % 2], - no: `TradeCode ${i}`, + name: `TradeCode ${i}`, title: `一个任务名称 ${i}`, owner: '曲丽丽', - description, + desc, callNo: Math.floor(Math.random() * 1000), status: Math.floor(Math.random() * 10) % 2, updatedAt: new Date(), @@ -107,6 +107,14 @@ export function postRule(req, res, u, b) { progress: Math.ceil(Math.random() * 100), }); break; + case 'update': + tableListDataSource = tableListDataSource.map((item) => { + if (item.key === key) { + return { ...item, desc, name }; + } + return item; + }); + break; default: break; } diff --git a/src/models/rule.js b/src/models/rule.js index 9ae968f8..8303dd21 100644 --- a/src/models/rule.js +++ b/src/models/rule.js @@ -1,4 +1,4 @@ -import { queryRule, removeRule, addRule } from '../services/api'; +import { queryRule, removeRule, addRule, updateRule } from '../services/api'; export default { namespace: 'rule', @@ -34,6 +34,14 @@ export default { }); if (callback) callback(); }, + *update({ payload, callback }, { call, put }) { + const response = yield call(updateRule, payload); + yield put({ + type: 'save', + payload: response, + }); + if (callback) callback(); + }, }, reducers: { diff --git a/src/routes/List/TableList.js b/src/routes/List/TableList.js index a74860c7..507442cc 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -1,77 +1,21 @@ import React, { PureComponent, Fragment } from 'react'; import { connect } from 'dva'; import moment from 'moment'; -import { Row, Col, Card, Form, Input, Select, Icon, Button, Dropdown, Menu, InputNumber, DatePicker, Modal, message, Badge, Divider } from 'antd'; +import { Row, Col, Card, Form, Input, Select, Icon, Button, Dropdown, Menu, + InputNumber, DatePicker, Modal, message, Badge, Divider, Steps, Radio } from 'antd'; import StandardTable from '../../components/StandardTable'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import styles from './TableList.less'; const FormItem = Form.Item; +const { Step } = Steps; +const { TextArea } = Input; const { Option } = Select; +const RadioGroup = Radio.Group; const getValue = obj => Object.keys(obj).map(key => obj[key]).join(','); const statusMap = ['default', 'processing', 'success', 'error']; const status = ['关闭', '运行中', '已上线', '异常']; -const columns = [ - { - title: '规则编号', - dataIndex: 'no', - }, - { - title: '描述', - dataIndex: 'description', - }, - { - title: '服务调用次数', - dataIndex: 'callNo', - sorter: true, - align: 'right', - render: val => `${val} 万`, - // mark to display a total number - needTotal: true, - }, - { - title: '状态', - dataIndex: 'status', - filters: [ - { - text: status[0], - value: 0, - }, - { - text: status[1], - value: 1, - }, - { - text: status[2], - value: 2, - }, - { - text: status[3], - value: 3, - }, - ], - render(val) { - return ; - }, - }, - { - title: '更新时间', - dataIndex: 'updatedAt', - sorter: true, - render: val => {moment(val).format('YYYY-MM-DD HH:mm:ss')}, - }, - { - title: '操作', - render: () => ( - - 配置 - - 订阅警报 - - ), - }, -]; const CreateForm = Form.create()((props) => { const { modalVisible, form, handleAdd, handleModalVisible } = props; @@ -83,6 +27,7 @@ const CreateForm = Form.create()((props) => { }; return ( { label="描述" > {form.getFieldDecorator('desc', { - rules: [{ required: true, message: 'Please input some description...' }], + rules: [{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }], })( )} @@ -103,6 +48,190 @@ const CreateForm = Form.create()((props) => { ); }); +@Form.create() +class UpdateForm extends PureComponent { + constructor(props) { + super(props); + + this.state = { + formVals: { + name: props.values.name, + desc: props.values.desc, + key: props.values.key, + target: '0', + template: '0', + type: '1', + time: '', + frequency: 'month', + }, + currentStep: 0, + }; + + this.formLayout = { + labelCol: { span: 7 }, + wrapperCol: { span: 13 }, + }; + } + handleNext = (currentStep) => { + const { form, handleUpdate } = this.props; + form.validateFields((err, fieldsValue) => { + if (err) return; + const formVals = { ...this.state.formVals, ...fieldsValue }; + this.setState({ + formVals, + }, () => { + if (currentStep < 2) { + this.forward(); + } else { + handleUpdate(this.state.formVals); + } + }); + }); + } + backward = () => { + this.setState({ + currentStep: this.state.currentStep - 1, + }); + } + forward = () => { + this.setState({ + currentStep: this.state.currentStep + 1, + }); + } + renderContent = (currentStep, formVals) => { + const { form } = this.props; + if (currentStep === 1) { + return [ + + {form.getFieldDecorator('target', { + initialValue: formVals.target, + })( + + )} + , + + {form.getFieldDecorator('template', { + initialValue: formVals.template, + })( + + )} + , + + {form.getFieldDecorator('type', { + initialValue: formVals.type, + })( + + + + + )} + , + ]; + } + if (currentStep === 2) { + return [ + + {form.getFieldDecorator('time', { + rules: [{ required: true, message: '请选择开始时间!' }], + })( + + )} + , + + {form.getFieldDecorator('frequency', { + initialValue: formVals.frequency, + })( + + )} + , + ]; + } + return [ + + {form.getFieldDecorator('name', { + rules: [{ required: true, message: '请输入规则名称!' }], + initialValue: formVals.name, + })( + + )} + , + + {form.getFieldDecorator('desc', { + rules: [{ required: true, message: '请输入至少五个字符的规则描述!', min: 5 }], + initialValue: formVals.desc, + })( +