From d7b87c27dbb0f1a70352e0c702516128f8907d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E5=B8=85?= 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 {
{title && {title}} -

{percent}%

+

+ {percent} + % +

); 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 => ( // {moment(time).format('hh:mm:ss')} // ); @@ -70,10 +73,15 @@ class CountDown extends Component { const s = Math.floor((time - h * hours - m * minutes) / 1000); return ( - {fixedZero(h)}:{fixedZero(m)}:{fixedZero(s)} + {fixedZero(h)} + : + {fixedZero(m)} + : + {fixedZero(s)} ); }; + 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 ( {term &&
{term}
} - {children !== null && children !== undefined && -
{children}
} + {children !== null && + children !== undefined &&
{children}
} ); }; 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 = ({
{title ?
{title}
: null} - {React.Children.map(children, child => child ? React.cloneElement(child, { column }) : child)} + {React.Children.map( + children, + child => (child ? React.cloneElement(child, { column }) : child) + )}
); 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 = ( 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 ; } 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 { ); } + 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 { ); }; + 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 { ); }; + /** * 将参数转化为面包屑 * 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 { ); }; + /** * get SubMenu or Item */ @@ -141,6 +147,7 @@ export default class SiderMenu extends PureComponent { return {this.getMenuItemPath(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 { 已选择 {selectedRowKeys.length} 项   {needTotalList.map(item => ( - {item.title}总计  + {item.title} + 总计  {item.render ? item.render(item.total) : item.total} 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 }) => ( - /* eslint-disable-line react/no-danger */ + /* 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 = ( @@ -201,7 +205,10 @@ export default class Analysis extends Component { sorter: (a, b) => a.range - b.range, render: (text, record) => ( - {text}% + + {text} + % + ), align: 'right', @@ -261,10 +268,12 @@ export default class Analysis extends Component { contentHeight={46} > - 周同比12% + 周同比 + 12% - 日环比11% + 日环比 + 11% @@ -313,10 +322,12 @@ export default class Analysis extends Component { footer={
- 周同比12% + 周同比 + 12% - 日环比11% + 日环比 + 11%
} @@ -455,9 +466,7 @@ export default class Analysis extends Component { {salesPieData.reduce((pre, now) => now.y + pre, 0)} - } + total={() => {salesPieData.reduce((pre, now) => now.y + pre, 0)}} data={salesPieData} valueFormat={value => {value}} 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 {

团队内排名

- 8 / 24 + 8 + / 24

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 ( 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={ - 邀评人(选填) + 邀评人 + (选填) } > @@ -146,7 +148,8 @@ export default class BasicForms extends PureComponent { {...formItemLayout} label={ - 权重(选填) + 权重 + (选填) } > 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 { {data.amount} - ({digitUppercase(data.amount)}) + + ( + {digitUppercase(data.amount)} + ) + 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 {
{content}
- {owner} 发布在 {href} + {owner} 发布在 + {href} {moment(updatedAt).format('YYYY-MM-DD HH:mm')}
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 }) => (
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 = (
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 {
- 暂无数据 + + 暂无数据
- 您的账户已被冻结 + + 您的账户已被冻结 立即解冻
- 您的账户还不具备申请资格 + + 您的账户还不具备申请资格 立即升级 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 = ( }} >
- 曲丽丽 + 曲丽丽 +
2016-12-12 12:32
@@ -24,7 +25,8 @@ const desc1 = ( const desc2 = (
- 周毛毛 + 周毛毛 +
催一下 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={
- 你的账户:{location.state ? location.state.account : 'AntDesign@example.com'} 注册成功 + 你的账户: + {location.state ? location.state.account : 'AntDesign@example.com'} 注册成功
} description="激活邮件已发送到你的邮箱中,邮件有效期为24小时。请及时登录邮箱,点击邮件中的链接激活帐户。" -- GitLab