From d7b87c27dbb0f1a70352e0c702516128f8907d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= <qixian.cs@outlook.com> Date: Sun, 24 Jun 2018 09:42:24 +0800 Subject: [PATCH] fix some eslint error --- .eslintrc.js | 1 + src/components/Authorized/PromiseRender.js | 5 +++ src/components/Charts/TimelineChart/index.js | 3 +- src/components/Charts/WaterWave/index.js | 5 ++- src/components/CountDown/index.js | 10 ++++- src/components/DescriptionList/Description.js | 4 +- .../DescriptionList/DescriptionList.js | 5 ++- src/components/EditableItem/index.js | 4 ++ src/components/EditableLinkGroup/index.js | 1 + src/components/GlobalHeader/index.js | 6 ++- src/components/HeaderSearch/index.js | 6 +++ src/components/Login/LoginItem.js | 5 +++ src/components/Login/LoginTab.js | 4 ++ src/components/Login/index.js | 4 ++ src/components/NoticeIcon/index.js | 5 +++ src/components/PageHeader/index.js | 7 +++ src/components/SiderMenu/SiderMenu.js | 45 ++++++++++++------- src/components/StandardTable/index.js | 10 ++++- src/components/TagSelect/index.js | 1 + src/layouts/BasicLayout.js | 11 +++++ src/layouts/UserLayout.js | 1 + src/routes/Dashboard/Analysis.js | 29 +++++++----- src/routes/Dashboard/Workplace.js | 7 ++- src/routes/Exception/triggerException.js | 2 + src/routes/Forms/AdvancedForm.js | 4 ++ src/routes/Forms/BasicForm.js | 7 ++- src/routes/Forms/StepForm/Step2.js | 6 ++- src/routes/Forms/StepForm/index.js | 1 + src/routes/Forms/TableForm.js | 12 +++++ src/routes/List/Applications.js | 6 ++- src/routes/List/Articles.js | 9 +++- src/routes/List/BasicList.js | 5 ++- src/routes/List/CardList.js | 5 ++- src/routes/List/Projects.js | 6 ++- src/routes/List/TableList.js | 5 ++- src/routes/Profile/AdvancedProfile.js | 3 +- src/routes/Result/Error.js | 6 ++- src/routes/Result/Success.js | 6 ++- src/routes/User/RegisterResult.js | 3 +- 39 files changed, 211 insertions(+), 54 deletions(-) diff --git a/.eslintrc.js b/.eslintrc.js index e29c1a8a..c20a185d 100755 --- a/.eslintrc.js +++ b/.eslintrc.js @@ -19,6 +19,7 @@ module.exports = { 'react/jsx-no-bind': [0], 'react/prop-types': [0], 'react/prefer-stateless-function': [0], + 'react/jsx-one-expression-per-line': [0], 'react/jsx-wrap-multilines': [ 'error', { diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js index 02518ad5..b18bcbec 100644 --- a/src/components/Authorized/PromiseRender.js +++ b/src/components/Authorized/PromiseRender.js @@ -5,13 +5,16 @@ export default class PromiseRender extends React.PureComponent { state = { component: null, }; + componentDidMount() { this.setRenderComponent(this.props); } + componentWillReceiveProps(nextProps) { // new Props enter this.setRenderComponent(nextProps); } + // set render Component : ok or error setRenderComponent(props) { const ok = this.checkIsInstantiation(props.ok); @@ -28,6 +31,7 @@ export default class PromiseRender extends React.PureComponent { }); }); } + // Determine whether the incoming component has been instantiated // AuthorizedRoute is already instantiated // Authorized render is already instantiated, children is no instantiated @@ -38,6 +42,7 @@ export default class PromiseRender extends React.PureComponent { } return () => target; }; + render() { const Component = this.state.component; return Component ? ( diff --git a/src/components/Charts/TimelineChart/index.js b/src/components/Charts/TimelineChart/index.js index e7ab6b11..018464da 100644 --- a/src/components/Charts/TimelineChart/index.js +++ b/src/components/Charts/TimelineChart/index.js @@ -44,8 +44,7 @@ export default class TimelineChart extends React.Component { }); const dv = ds.createView(); - dv - .source(data) + dv.source(data) .transform({ type: 'filter', callback: obj => { diff --git a/src/components/Charts/WaterWave/index.js b/src/components/Charts/WaterWave/index.js index 70938427..5ea6dcc3 100644 --- a/src/components/Charts/WaterWave/index.js +++ b/src/components/Charts/WaterWave/index.js @@ -189,7 +189,10 @@ export default class WaterWave extends PureComponent { </div> <div className={styles.text} style={{ width: height }}> {title && <span>{title}</span>} - <h4>{percent}%</h4> + <h4> + {percent} + % + </h4> </div> </div> ); diff --git a/src/components/CountDown/index.js b/src/components/CountDown/index.js index 875fb1e2..b67fab2f 100644 --- a/src/components/CountDown/index.js +++ b/src/components/CountDown/index.js @@ -39,7 +39,9 @@ class CountDown extends Component { } timer = 0; + interval = 1000; + initTime = props => { let lastTime = 0; let targetTime = 0; @@ -58,6 +60,7 @@ class CountDown extends Component { lastTime: lastTime < 0 ? 0 : lastTime, }; }; + // defaultFormat = time => ( // <span>{moment(time).format('hh:mm:ss')}</span> // ); @@ -70,10 +73,15 @@ class CountDown extends Component { const s = Math.floor((time - h * hours - m * minutes) / 1000); return ( <span> - {fixedZero(h)}:{fixedZero(m)}:{fixedZero(s)} + {fixedZero(h)} + : + {fixedZero(m)} + : + {fixedZero(s)} </span> ); }; + tick = () => { const { onEnd } = this.props; let { lastTime } = this.state; diff --git a/src/components/DescriptionList/Description.js b/src/components/DescriptionList/Description.js index 3e41c071..002ad284 100644 --- a/src/components/DescriptionList/Description.js +++ b/src/components/DescriptionList/Description.js @@ -10,8 +10,8 @@ const Description = ({ term, column, className, children, ...restProps }) => { return ( <Col className={clsString} {...responsive[column]} {...restProps}> {term && <div className={styles.term}>{term}</div>} - {children !== null && children !== undefined && - <div className={styles.detail}>{children}</div>} + {children !== null && + children !== undefined && <div className={styles.detail}>{children}</div>} </Col> ); }; diff --git a/src/components/DescriptionList/DescriptionList.js b/src/components/DescriptionList/DescriptionList.js index 382d7e85..73bb5f5f 100644 --- a/src/components/DescriptionList/DescriptionList.js +++ b/src/components/DescriptionList/DescriptionList.js @@ -22,7 +22,10 @@ const DescriptionList = ({ <div className={clsString} {...restProps}> {title ? <div className={styles.title}>{title}</div> : null} <Row gutter={gutter}> - {React.Children.map(children, child => child ? React.cloneElement(child, { column }) : child)} + {React.Children.map( + children, + child => (child ? React.cloneElement(child, { column }) : child) + )} </Row> </div> ); diff --git a/src/components/EditableItem/index.js b/src/components/EditableItem/index.js index fcda844e..5b22631c 100644 --- a/src/components/EditableItem/index.js +++ b/src/components/EditableItem/index.js @@ -7,19 +7,23 @@ export default class EditableItem extends PureComponent { value: this.props.value, editable: false, }; + handleChange = e => { const { value } = e.target; this.setState({ value }); }; + check = () => { this.setState({ editable: false }); if (this.props.onChange) { this.props.onChange(this.state.value); } }; + edit = () => { this.setState({ editable: true }); }; + render() { const { value, editable } = this.state; return ( diff --git a/src/components/EditableLinkGroup/index.js b/src/components/EditableLinkGroup/index.js index 2d0b4aa8..ae3d93c7 100644 --- a/src/components/EditableLinkGroup/index.js +++ b/src/components/EditableLinkGroup/index.js @@ -17,6 +17,7 @@ class EditableLinkGroup extends PureComponent { onAdd: () => {}, linkElement: 'a', }; + render() { const { links, linkElement, onAdd } = this.props; return ( diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js index 0f405f7b..f84d2d2e 100644 --- a/src/components/GlobalHeader/index.js +++ b/src/components/GlobalHeader/index.js @@ -12,8 +12,9 @@ export default class GlobalHeader extends PureComponent { componentWillUnmount() { this.triggerResizeEvent.cancel(); } + getNoticeData() { - const { notices} = this.props; + const { notices } = this.props; if (notices == null || notices.length === 0) { return {}; } @@ -43,6 +44,7 @@ export default class GlobalHeader extends PureComponent { }); return groupBy(newNotices, 'type'); } + toggle = () => { const { collapsed, onCollapse } = this.props; onCollapse(!collapsed); @@ -67,7 +69,7 @@ export default class GlobalHeader extends PureComponent { onNoticeClear, } = this.props; if (currentUser == null) { - currentUser = {} + currentUser = {}; } const menu = ( <Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}> diff --git a/src/components/HeaderSearch/index.js b/src/components/HeaderSearch/index.js index a08ad7f4..de8a6be5 100644 --- a/src/components/HeaderSearch/index.js +++ b/src/components/HeaderSearch/index.js @@ -31,17 +31,20 @@ export default class HeaderSearch extends PureComponent { searchMode: this.props.defaultOpen, value: '', }; + onKeyDown = e => { if (e.key === 'Enter') { this.debouncePressEnter(); } }; + onChange = value => { this.setState({ value }); if (this.props.onChange) { this.props.onChange(); } }; + // NOTE: ä¸èƒ½å°äºŽ500,如果长按æŸé”®ï¼Œç¬¬ä¸€æ¬¡è§¦å‘auto repeat的间隔是500ms,å°äºŽ500会导致触å‘2次 @Bind() @Debounce(500, { @@ -51,6 +54,7 @@ export default class HeaderSearch extends PureComponent { debouncePressEnter() { this.props.onPressEnter(this.state.value); } + enterSearchMode = () => { this.setState({ searchMode: true }, () => { if (this.state.searchMode) { @@ -58,12 +62,14 @@ export default class HeaderSearch extends PureComponent { } }); }; + leaveSearchMode = () => { this.setState({ searchMode: false, value: '', }); }; + render() { const { className, placeholder, ...restProps } = this.props; delete restProps.defaultOpen; // for rc-select not affected diff --git a/src/components/Login/LoginItem.js b/src/components/Login/LoginItem.js index 98efb333..a4504ad5 100644 --- a/src/components/Login/LoginItem.js +++ b/src/components/Login/LoginItem.js @@ -14,20 +14,24 @@ function generator({ defaultProps, defaultRules, type }) { form: PropTypes.object, updateActive: PropTypes.func, }; + constructor(props) { super(props); this.state = { count: 0, }; } + componentDidMount() { if (this.context.updateActive) { this.context.updateActive(this.props.name); } } + componentWillUnmount() { clearInterval(this.interval); } + onGetCaptcha = () => { let count = 59; this.setState({ count }); @@ -42,6 +46,7 @@ function generator({ defaultProps, defaultRules, type }) { } }, 1000); }; + render() { const { getFieldDecorator } = this.context.form; const options = {}; diff --git a/src/components/Login/LoginTab.js b/src/components/Login/LoginTab.js index 750bfe7c..52de12d2 100644 --- a/src/components/Login/LoginTab.js +++ b/src/components/Login/LoginTab.js @@ -14,18 +14,22 @@ const generateId = (() => { export default class LoginTab extends Component { static __ANT_PRO_LOGIN_TAB = true; + static contextTypes = { tabUtil: PropTypes.object, }; + constructor(props) { super(props); this.uniqueId = generateId('login-tab-'); } + componentWillMount() { if (this.context.tabUtil) { this.context.tabUtil.addTab(this.uniqueId); } } + render() { return <TabPane {...this.props} />; } diff --git a/src/components/Login/index.js b/src/components/Login/index.js index 58c4e468..31235017 100644 --- a/src/components/Login/index.js +++ b/src/components/Login/index.js @@ -33,6 +33,7 @@ class Login extends Component { tabs: [], active: {}, }; + getChildContext() { return { tabUtil: { @@ -61,12 +62,14 @@ class Login extends Component { }, }; } + onSwitch = type => { this.setState({ type, }); this.props.onTabChange(type); }; + handleSubmit = e => { e.preventDefault(); const { active, type } = this.state; @@ -75,6 +78,7 @@ class Login extends Component { this.props.onSubmit(err, values); }); }; + render() { const { className, children } = this.props; const { type, tabs } = this.state; diff --git a/src/components/NoticeIcon/index.js b/src/components/NoticeIcon/index.js index a207be86..5561f0ef 100644 --- a/src/components/NoticeIcon/index.js +++ b/src/components/NoticeIcon/index.js @@ -21,6 +21,7 @@ export default class NoticeIcon extends PureComponent { }, emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg', }; + constructor(props) { super(props); this.state = {}; @@ -28,14 +29,17 @@ export default class NoticeIcon extends PureComponent { this.state.tabType = props.children[0].props.title; } } + onItemClick = (item, tabProps) => { const { onItemClick } = this.props; onItemClick(item, tabProps); }; + onTabChange = tabType => { this.setState({ tabType }); this.props.onTabChange(tabType); }; + getNotificationBox() { const { children, loading, locale } = this.props; if (!children) { @@ -67,6 +71,7 @@ export default class NoticeIcon extends PureComponent { </Spin> ); } + render() { const { className, count, popupAlign, onPopupVisibleChange } = this.props; const noticeButtonClass = classNames(className, styles.noticeButton); diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 3080ed04..ac9f628c 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -40,11 +40,13 @@ export default class PageHeader extends PureComponent { this.getBreadcrumbDom(); } } + onChange = key => { if (this.props.onTabChange) { this.props.onTabChange(key); } }; + getBreadcrumbProps = () => { return { routes: this.props.routes || this.context.routes, @@ -53,12 +55,14 @@ export default class PageHeader extends PureComponent { breadcrumbNameMap: this.props.breadcrumbNameMap || this.context.breadcrumbNameMap, }; }; + getBreadcrumbDom = () => { const breadcrumb = this.conversionBreadcrumbList(); this.setState({ breadcrumb, }); }; + // Generated according to props conversionFromProps = () => { const { breadcrumbList, breadcrumbSeparator, linkElement = 'a' } = this.props; @@ -80,6 +84,7 @@ export default class PageHeader extends PureComponent { </Breadcrumb> ); }; + conversionFromLocation = (routerLocation, breadcrumbNameMap) => { const { breadcrumbSeparator, linkElement = 'a' } = this.props; // Convert the url to an array @@ -116,6 +121,7 @@ export default class PageHeader extends PureComponent { </Breadcrumb> ); }; + /** * 将傿•°è½¬åŒ–为é¢åŒ…屑 * Convert parameters into breadcrumbs @@ -146,6 +152,7 @@ export default class PageHeader extends PureComponent { } return null; }; + // 渲染Breadcrumb å节点 // Render the Breadcrumb child node itemRender = (route, params, routes, paths) => { diff --git a/src/components/SiderMenu/SiderMenu.js b/src/components/SiderMenu/SiderMenu.js index 2068b7b8..fc93fca8 100644 --- a/src/components/SiderMenu/SiderMenu.js +++ b/src/components/SiderMenu/SiderMenu.js @@ -28,14 +28,13 @@ const getIcon = icon => { * @param menu */ export const getFlatMenuKeys = menu => - menu - .reduce((keys, item) => { - keys.push(item.path); - if (item.children) { - return keys.concat(getFlatMenuKeys(item.children)); - } - return keys; - }, []); + menu.reduce((keys, item) => { + keys.push(item.path); + if (item.children) { + return keys.concat(getFlatMenuKeys(item.children)); + } + return keys; + }, []); /** * Find all matched menu keys based on paths @@ -43,11 +42,11 @@ export const getFlatMenuKeys = menu => * @param paths: [/abc, /abc/11, /abc/11/info] */ export const getMenuMatchKeys = (flatMenuKeys, paths) => - paths - .reduce((matchKeys, path) => ( - matchKeys.concat( - flatMenuKeys.filter(item => pathToRegexp(item).test(path)) - )), []); + paths.reduce( + (matchKeys, path) => + matchKeys.concat(flatMenuKeys.filter(item => pathToRegexp(item).test(path))), + [] + ); export default class SiderMenu extends PureComponent { constructor(props) { @@ -58,6 +57,7 @@ export default class SiderMenu extends PureComponent { openKeys: this.getDefaultCollapsedSubMenus(props), }; } + componentWillReceiveProps(nextProps) { if (nextProps.location.pathname !== this.props.location.pathname) { this.setState({ @@ -65,15 +65,20 @@ export default class SiderMenu extends PureComponent { }); } } + /** * Convert pathname to openKeys * /list/search/articles = > ['list','/list/search'] * @param props */ getDefaultCollapsedSubMenus(props) { - const { location: { pathname } } = props || this.props; + const { + location: { pathname }, + } = + props || this.props; return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); } + /** * åˆ¤æ–æ˜¯å¦æ˜¯http链接.返回 Link 或 a * Judge whether it is http link.return a or Link @@ -110,6 +115,7 @@ export default class SiderMenu extends PureComponent { </Link> ); }; + /** * get SubMenu or Item */ @@ -141,6 +147,7 @@ export default class SiderMenu extends PureComponent { return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>; } }; + /** * 获得èœå•å节点 * @memberof SiderMenu @@ -158,11 +165,15 @@ export default class SiderMenu extends PureComponent { }) .filter(item => item); }; + // Get the currently selected menu getSelectedMenuKeys = () => { - const { location: { pathname } } = this.props; + const { + location: { pathname }, + } = this.props; return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); }; + // conversion Path // 转化路径 conversionPath = path => { @@ -172,6 +183,7 @@ export default class SiderMenu extends PureComponent { return `/${path || ''}`.replace(/\/+/g, '/'); } }; + // permission to check checkPermissionItem = (authority, ItemDom) => { if (this.props.Authorized && this.props.Authorized.check) { @@ -180,9 +192,11 @@ export default class SiderMenu extends PureComponent { } return ItemDom; }; + isMainMenu = key => { return this.menus.some(item => key && (item.key === key || item.path === key)); }; + handleOpenChange = openKeys => { const lastOpenKey = openKeys[openKeys.length - 1]; const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; @@ -190,6 +204,7 @@ export default class SiderMenu extends PureComponent { openKeys: moreThanOne ? [lastOpenKey] : [...openKeys], }); }; + render() { const { logo, collapsed, onCollapse } = this.props; const { openKeys } = this.state; diff --git a/src/components/StandardTable/index.js b/src/components/StandardTable/index.js index 281d60e6..ea255cf8 100644 --- a/src/components/StandardTable/index.js +++ b/src/components/StandardTable/index.js @@ -63,7 +63,12 @@ class StandardTable extends PureComponent { render() { const { selectedRowKeys, needTotalList } = this.state; - const { data: { list, pagination }, loading, columns, rowKey } = this.props; + const { + data: { list, pagination }, + loading, + columns, + rowKey, + } = this.props; const paginationProps = { showSizeChanger: true, @@ -88,7 +93,8 @@ class StandardTable extends PureComponent { 已选择 <a style={{ fontWeight: 600 }}>{selectedRowKeys.length}</a> 项 {needTotalList.map(item => ( <span style={{ marginLeft: 8 }} key={item.dataIndex}> - {item.title}总计 + {item.title} + 总计 <span style={{ fontWeight: 600 }}> {item.render ? item.render(item.total) : item.total} </span> diff --git a/src/components/TagSelect/index.js b/src/components/TagSelect/index.js index 773b9c84..d86425c1 100644 --- a/src/components/TagSelect/index.js +++ b/src/components/TagSelect/index.js @@ -19,6 +19,7 @@ class TagSelect extends Component { expand: false, value: this.props.value || this.props.defaultValue || [], }; + componentWillReceiveProps(nextProps) { if ('value' in nextProps && nextProps.value) { this.setState({ value: nextProps.value }); diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js index e587bc95..a6350edf 100644 --- a/src/layouts/BasicLayout.js +++ b/src/layouts/BasicLayout.js @@ -89,9 +89,11 @@ class BasicLayout extends React.PureComponent { location: PropTypes.object, breadcrumbNameMap: PropTypes.object, }; + state = { isMobile, }; + getChildContext() { const { location, routerData } = this.props; return { @@ -99,6 +101,7 @@ class BasicLayout extends React.PureComponent { breadcrumbNameMap: getBreadcrumbNameMap(getMenuData(), routerData), }; } + componentDidMount() { this.enquireHandler = enquireScreen(mobile => { this.setState({ @@ -109,9 +112,11 @@ class BasicLayout extends React.PureComponent { type: 'user/fetchCurrent', }); } + componentWillUnmount() { unenquireScreen(this.enquireHandler); } + getPageTitle() { const { routerData, location } = this.props; const { pathname } = location; @@ -128,6 +133,7 @@ class BasicLayout extends React.PureComponent { } return title; } + getBaseRedirect = () => { // According to the url parameter to redirect // 这里是é‡å®šå‘çš„,é‡å®šå‘到 url çš„ redirect 傿•°æ‰€ç¤ºåœ°å€ @@ -148,12 +154,14 @@ class BasicLayout extends React.PureComponent { } return redirect; }; + handleMenuCollapse = collapsed => { this.props.dispatch({ type: 'global/changeLayoutCollapsed', payload: collapsed, }); }; + handleNoticeClear = type => { message.success(`清空了${type}`); this.props.dispatch({ @@ -161,6 +169,7 @@ class BasicLayout extends React.PureComponent { payload: type, }); }; + handleMenuClick = ({ key }) => { if (key === 'triggerError') { this.props.dispatch(routerRedux.push('/exception/trigger')); @@ -172,6 +181,7 @@ class BasicLayout extends React.PureComponent { }); } }; + handleNoticeVisibleChange = visible => { if (visible) { this.props.dispatch({ @@ -179,6 +189,7 @@ class BasicLayout extends React.PureComponent { }); } }; + render() { const { currentUser, diff --git a/src/layouts/UserLayout.js b/src/layouts/UserLayout.js index 8fb53534..447f44fb 100644 --- a/src/layouts/UserLayout.js +++ b/src/layouts/UserLayout.js @@ -41,6 +41,7 @@ class UserLayout extends React.PureComponent { } return title; } + render() { const { routerData, match } = this.props; return ( diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 5e691e42..61704899 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -43,7 +43,9 @@ for (let i = 0; i < 7; i += 1) { } const Yuan = ({ children }) => ( - <span dangerouslySetInnerHTML={{ __html: yuan(children) }} /> /* eslint-disable-line react/no-danger */ + <span + dangerouslySetInnerHTML={{ __html: yuan(children) }} + /> /* eslint-disable-line react/no-danger */ ); @connect(({ chart, loading }) => ({ @@ -134,7 +136,9 @@ export default class Analysis extends Component { const salesPieData = salesType === 'all' ? salesTypeData - : salesType === 'online' ? salesTypeDataOnline : salesTypeDataOffline; + : salesType === 'online' + ? salesTypeDataOnline + : salesTypeDataOffline; const menu = ( <Menu> @@ -201,7 +205,10 @@ export default class Analysis extends Component { sorter: (a, b) => a.range - b.range, render: (text, record) => ( <Trend flag={record.status === 1 ? 'down' : 'up'}> - <span style={{ marginRight: 4 }}>{text}%</span> + <span style={{ marginRight: 4 }}> + {text} + % + </span> </Trend> ), align: 'right', @@ -261,10 +268,12 @@ export default class Analysis extends Component { contentHeight={46} > <Trend flag="up" style={{ marginRight: 16 }}> - å‘¨åŒæ¯”<span className={styles.trendText}>12%</span> + å‘¨åŒæ¯” + <span className={styles.trendText}>12%</span> </Trend> <Trend flag="down"> - 日环比<span className={styles.trendText}>11%</span> + 日环比 + <span className={styles.trendText}>11%</span> </Trend> </ChartCard> </Col> @@ -313,10 +322,12 @@ export default class Analysis extends Component { footer={ <div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}> <Trend flag="up" style={{ marginRight: 16 }}> - å‘¨åŒæ¯”<span className={styles.trendText}>12%</span> + å‘¨åŒæ¯” + <span className={styles.trendText}>12%</span> </Trend> <Trend flag="down"> - 日环比<span className={styles.trendText}>11%</span> + 日环比 + <span className={styles.trendText}>11%</span> </Trend> </div> } @@ -455,9 +466,7 @@ export default class Analysis extends Component { <Pie hasLegend subTitle="销售é¢" - total={ - () => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan> - } + total={() => <Yuan>{salesPieData.reduce((pre, now) => now.y + pre, 0)}</Yuan>} data={salesPieData} valueFormat={value => <Yuan>{value}</Yuan>} height={248} diff --git a/src/routes/Dashboard/Workplace.js b/src/routes/Dashboard/Workplace.js index 9c8bdc79..44885618 100644 --- a/src/routes/Dashboard/Workplace.js +++ b/src/routes/Dashboard/Workplace.js @@ -99,7 +99,9 @@ export default class Workplace extends PureComponent { } renderActivities() { - const { activities: { list } } = this.props; + const { + activities: { list }, + } = this.props; return list.map(item => { const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { if (item[key]) { @@ -165,7 +167,8 @@ export default class Workplace extends PureComponent { <div className={styles.statItem}> <p>团队内排å</p> <p> - 8<span> / 24</span> + 8 + <span> / 24</span> </p> </div> <div className={styles.statItem}> diff --git a/src/routes/Exception/triggerException.js b/src/routes/Exception/triggerException.js index 2dccfb75..4699d458 100644 --- a/src/routes/Exception/triggerException.js +++ b/src/routes/Exception/triggerException.js @@ -10,6 +10,7 @@ export default class TriggerException extends PureComponent { state = { isloading: false, }; + triggerError = code => { this.setState({ isloading: true, @@ -21,6 +22,7 @@ export default class TriggerException extends PureComponent { }, }); }; + render() { return ( <Card> diff --git a/src/routes/Forms/AdvancedForm.js b/src/routes/Forms/AdvancedForm.js index 16b7e3b0..741a37b1 100644 --- a/src/routes/Forms/AdvancedForm.js +++ b/src/routes/Forms/AdvancedForm.js @@ -61,12 +61,15 @@ class AdvancedForm extends PureComponent { state = { width: '100%', }; + componentDidMount() { window.addEventListener('resize', this.resizeFooterToolbar); } + componentWillUnmount() { window.removeEventListener('resize', this.resizeFooterToolbar); } + resizeFooterToolbar = () => { const sider = document.querySelectorAll('.ant-layout-sider')[0]; const width = `calc(100% - ${sider.style.width})`; @@ -74,6 +77,7 @@ class AdvancedForm extends PureComponent { this.setState({ width }); } }; + render() { const { form, dispatch, submitting } = this.props; const { getFieldDecorator, validateFieldsAndScroll, getFieldsError } = form; diff --git a/src/routes/Forms/BasicForm.js b/src/routes/Forms/BasicForm.js index ed41cb3b..7f5c7e0b 100644 --- a/src/routes/Forms/BasicForm.js +++ b/src/routes/Forms/BasicForm.js @@ -36,6 +36,7 @@ export default class BasicForms extends PureComponent { } }); }; + render() { const { submitting } = this.props; const { getFieldDecorator, getFieldValue } = this.props.form; @@ -134,7 +135,8 @@ export default class BasicForms extends PureComponent { {...formItemLayout} label={ <span> - 邀评人<em className={styles.optional}>(选填)</em> + 邀评人 + <em className={styles.optional}>(选填)</em> </span> } > @@ -146,7 +148,8 @@ export default class BasicForms extends PureComponent { {...formItemLayout} label={ <span> - æƒé‡<em className={styles.optional}>(选填)</em> + æƒé‡ + <em className={styles.optional}>(选填)</em> </span> } > diff --git a/src/routes/Forms/StepForm/Step2.js b/src/routes/Forms/StepForm/Step2.js index 4e7df540..9b142007 100644 --- a/src/routes/Forms/StepForm/Step2.js +++ b/src/routes/Forms/StepForm/Step2.js @@ -55,7 +55,11 @@ class Step2 extends React.PureComponent { </Form.Item> <Form.Item {...formItemLayout} className={styles.stepFormText} label="转账金é¢"> <span className={styles.money}>{data.amount}</span> - <span className={styles.uppercase}>({digitUppercase(data.amount)})</span> + <span className={styles.uppercase}> + ( + {digitUppercase(data.amount)} + ) + </span> </Form.Item> <Divider style={{ margin: '24px 0' }} /> <Form.Item {...formItemLayout} label="支付密ç " required={false}> diff --git a/src/routes/Forms/StepForm/index.js b/src/routes/Forms/StepForm/index.js index 3ab2374b..5b7f703c 100644 --- a/src/routes/Forms/StepForm/index.js +++ b/src/routes/Forms/StepForm/index.js @@ -24,6 +24,7 @@ export default class StepForm extends PureComponent { return 0; } } + render() { const { match, routerData, location } = this.props; return ( diff --git a/src/routes/Forms/TableForm.js b/src/routes/Forms/TableForm.js index 0cc07fd1..65b679d5 100644 --- a/src/routes/Forms/TableForm.js +++ b/src/routes/Forms/TableForm.js @@ -11,6 +11,7 @@ export default class TableForm extends PureComponent { loading: false, }; } + componentWillReceiveProps(nextProps) { if ('value' in nextProps) { this.setState({ @@ -18,11 +19,15 @@ export default class TableForm extends PureComponent { }); } } + getRowByKey(key, newData) { return (newData || this.state.data).filter(item => item.key === key)[0]; } + index = 0; + cacheOriginData = {}; + toggleEditable = (e, key) => { e.preventDefault(); const newData = this.state.data.map(item => ({ ...item })); @@ -36,11 +41,13 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); } }; + remove(key) { const newData = this.state.data.filter(item => item.key !== key); this.setState({ data: newData }); this.props.onChange(newData); } + newMember = () => { const newData = this.state.data.map(item => ({ ...item })); newData.push({ @@ -54,11 +61,13 @@ export default class TableForm extends PureComponent { this.index += 1; this.setState({ data: newData }); }; + handleKeyPress(e, key) { if (e.key === 'Enter') { this.saveRow(e, key); } } + handleFieldChange(e, fieldName, key) { const newData = this.state.data.map(item => ({ ...item })); const target = this.getRowByKey(key, newData); @@ -67,6 +76,7 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); } } + saveRow(e, key) { e.persist(); this.setState({ @@ -94,6 +104,7 @@ export default class TableForm extends PureComponent { }); }, 500); } + cancel(e, key) { this.clickedCancel = true; e.preventDefault(); @@ -107,6 +118,7 @@ export default class TableForm extends PureComponent { this.setState({ data: newData }); this.clickedCancel = false; } + render() { const columns = [ { diff --git a/src/routes/List/Applications.js b/src/routes/List/Applications.js index bfc33375..60a846f5 100644 --- a/src/routes/List/Applications.js +++ b/src/routes/List/Applications.js @@ -63,7 +63,11 @@ export default class FilterCardList extends PureComponent { }; render() { - const { list: { list }, loading, form } = this.props; + const { + list: { list }, + loading, + form, + } = this.props; const { getFieldDecorator } = form; const CardInfo = ({ activeUser, newUser }) => ( diff --git a/src/routes/List/Articles.js b/src/routes/List/Articles.js index 2f6b639d..405f8ec5 100644 --- a/src/routes/List/Articles.js +++ b/src/routes/List/Articles.js @@ -39,7 +39,11 @@ export default class SearchList extends Component { }; render() { - const { form, list: { list }, loading } = this.props; + const { + form, + list: { list }, + loading, + } = this.props; const { getFieldDecorator } = form; const owners = [ @@ -77,7 +81,8 @@ export default class SearchList extends Component { <div className={styles.description}>{content}</div> <div className={styles.extra}> <Avatar src={avatar} size="small" /> - <a href={href}>{owner}</a> å‘布在 <a href={href}>{href}</a> + <a href={href}>{owner}</a> å‘布在 + <a href={href}>{href}</a> <em>{moment(updatedAt).format('YYYY-MM-DD HH:mm')}</em> </div> </div> diff --git a/src/routes/List/BasicList.js b/src/routes/List/BasicList.js index 78e81192..155be87c 100644 --- a/src/routes/List/BasicList.js +++ b/src/routes/List/BasicList.js @@ -39,7 +39,10 @@ export default class BasicList extends PureComponent { } render() { - const { list: { list }, loading } = this.props; + const { + list: { list }, + loading, + } = this.props; const Info = ({ title, value, bordered }) => ( <div className={styles.headerInfo}> diff --git a/src/routes/List/CardList.js b/src/routes/List/CardList.js index 8111770f..1441596e 100644 --- a/src/routes/List/CardList.js +++ b/src/routes/List/CardList.js @@ -22,7 +22,10 @@ export default class CardList extends PureComponent { } render() { - const { list: { list }, loading } = this.props; + const { + list: { list }, + loading, + } = this.props; const content = ( <div className={styles.pageHeaderContent}> diff --git a/src/routes/List/Projects.js b/src/routes/List/Projects.js index 1617cf55..b1720972 100644 --- a/src/routes/List/Projects.js +++ b/src/routes/List/Projects.js @@ -48,7 +48,11 @@ export default class CoverCardList extends PureComponent { }; render() { - const { list: { list = [] }, loading, form } = this.props; + const { + list: { list = [] }, + loading, + form, + } = this.props; const { getFieldDecorator } = form; const cardList = list ? ( diff --git a/src/routes/List/TableList.js b/src/routes/List/TableList.js index d67fef72..fa8b6d12 100644 --- a/src/routes/List/TableList.js +++ b/src/routes/List/TableList.js @@ -312,7 +312,10 @@ export default class TableList extends PureComponent { } render() { - const { rule: { data }, loading } = this.props; + const { + rule: { data }, + loading, + } = this.props; const { selectedRows, modalVisible } = this.state; const columns = [ diff --git a/src/routes/Profile/AdvancedProfile.js b/src/routes/Profile/AdvancedProfile.js index cb0ccce9..0df2beae 100644 --- a/src/routes/Profile/AdvancedProfile.js +++ b/src/routes/Profile/AdvancedProfile.js @@ -333,7 +333,8 @@ export default class AdvancedProfile extends Component { </Card> <Card title="用户近åŠå¹´æ¥ç”µè®°å½•" style={{ marginBottom: 24 }} bordered={false}> <div className={styles.noData}> - <Icon type="frown-o" />æš‚æ— æ•°æ® + <Icon type="frown-o" /> + æš‚æ— æ•°æ® </div> </Card> <Card diff --git a/src/routes/Result/Error.js b/src/routes/Result/Error.js index 856b51aa..3663dbc2 100644 --- a/src/routes/Result/Error.js +++ b/src/routes/Result/Error.js @@ -16,13 +16,15 @@ const extra = ( 您æäº¤çš„内容有如下错误: </div> <div style={{ marginBottom: 16 }}> - <Icon style={{ color: '#f5222d', marginRight: 8 }} type="close-circle-o" />您的账户已被冻结 + <Icon style={{ color: '#f5222d', marginRight: 8 }} type="close-circle-o" /> + 您的账户已被冻结 <a style={{ marginLeft: 16 }}> ç«‹å³è§£å†» <Icon type="right" /> </a> </div> <div> - <Icon style={{ color: '#f5222d', marginRight: 8 }} type="close-circle-o" />您的账户还ä¸å…·å¤‡ç”³è¯·èµ„æ ¼ + <Icon style={{ color: '#f5222d', marginRight: 8 }} type="close-circle-o" /> + 您的账户还ä¸å…·å¤‡ç”³è¯·èµ„æ ¼ <a style={{ marginLeft: 16 }}> ç«‹å³å‡çº§ <Icon type="right" /> </a> diff --git a/src/routes/Result/Success.js b/src/routes/Result/Success.js index 9e20e278..61263b56 100644 --- a/src/routes/Result/Success.js +++ b/src/routes/Result/Success.js @@ -15,7 +15,8 @@ const desc1 = ( }} > <div style={{ margin: '8px 0 4px' }}> - 曲丽丽<Icon style={{ marginLeft: 8 }} type="dingding-o" /> + 曲丽丽 + <Icon style={{ marginLeft: 8 }} type="dingding-o" /> </div> <div>2016-12-12 12:32</div> </div> @@ -24,7 +25,8 @@ const desc1 = ( const desc2 = ( <div style={{ fontSize: 12, position: 'relative', left: 42 }}> <div style={{ margin: '8px 0 4px' }}> - 周毛毛<Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} /> + 周毛毛 + <Icon type="dingding-o" style={{ color: '#00A0E9', marginLeft: 8 }} /> </div> <div> <a href="">催一下</a> diff --git a/src/routes/User/RegisterResult.js b/src/routes/User/RegisterResult.js index 9c9bbe5f..3e86ee6e 100644 --- a/src/routes/User/RegisterResult.js +++ b/src/routes/User/RegisterResult.js @@ -23,7 +23,8 @@ export default ({ location }) => ( type="success" title={ <div className={styles.title}> - ä½ çš„è´¦æˆ·ï¼š{location.state ? location.state.account : 'AntDesign@example.com'} 注册æˆåŠŸ + ä½ çš„è´¦æˆ·ï¼š + {location.state ? location.state.account : 'AntDesign@example.com'} 注册æˆåŠŸ </div> } description="激活邮件已å‘é€åˆ°ä½ 的邮箱ä¸ï¼Œé‚®ä»¶æœ‰æ•ˆæœŸä¸º24å°æ—¶ã€‚è¯·åŠæ—¶ç™»å½•邮箱,点击邮件ä¸çš„é“¾æŽ¥æ¿€æ´»å¸æˆ·ã€‚" -- GitLab