Commit 533c091b authored by 陈帅's avatar 陈帅

fix lint error

parent cfbf108b
...@@ -19,6 +19,7 @@ module.exports = { ...@@ -19,6 +19,7 @@ module.exports = {
'react/jsx-no-bind': [0], 'react/jsx-no-bind': [0],
'react/prop-types': [0], 'react/prop-types': [0],
'react/prefer-stateless-function': [0], 'react/prefer-stateless-function': [0],
'react/jsx-one-expression-per-line': [0],
'react/jsx-wrap-multilines': [ 'react/jsx-wrap-multilines': [
'error', 'error',
{ {
......
...@@ -32,6 +32,7 @@ export default class ActiveChart extends Component { ...@@ -32,6 +32,7 @@ export default class ActiveChart extends Component {
componentWillUnmount() { componentWillUnmount() {
clearTimeout(this.timer); clearTimeout(this.timer);
} }
loopData = () => { loopData = () => {
this.timer = setTimeout(() => { this.timer = setTimeout(() => {
this.setState( this.setState(
...@@ -46,6 +47,7 @@ export default class ActiveChart extends Component { ...@@ -46,6 +47,7 @@ export default class ActiveChart extends Component {
); );
}, 1000); }, 1000);
}; };
render() { render() {
const { activeData = [] } = this.state; const { activeData = [] } = this.state;
......
...@@ -5,13 +5,16 @@ export default class PromiseRender extends React.PureComponent { ...@@ -5,13 +5,16 @@ export default class PromiseRender extends React.PureComponent {
state = { state = {
component: null, component: null,
}; };
componentDidMount() { componentDidMount() {
this.setRenderComponent(this.props); this.setRenderComponent(this.props);
} }
componentDidUpdate(nextProps) { componentDidUpdate(nextProps) {
// new Props enter // new Props enter
this.setRenderComponent(nextProps); this.setRenderComponent(nextProps);
} }
// set render Component : ok or error // set render Component : ok or error
setRenderComponent(props) { setRenderComponent(props) {
const ok = this.checkIsInstantiation(props.ok); const ok = this.checkIsInstantiation(props.ok);
...@@ -28,6 +31,7 @@ export default class PromiseRender extends React.PureComponent { ...@@ -28,6 +31,7 @@ export default class PromiseRender extends React.PureComponent {
}); });
}); });
} }
// Determine whether the incoming component has been instantiated // Determine whether the incoming component has been instantiated
// AuthorizedRoute is already instantiated // AuthorizedRoute is already instantiated
// Authorized render is already instantiated, children is no instantiated // Authorized render is already instantiated, children is no instantiated
...@@ -38,10 +42,11 @@ export default class PromiseRender extends React.PureComponent { ...@@ -38,10 +42,11 @@ export default class PromiseRender extends React.PureComponent {
} }
return () => target; return () => target;
}; };
render() { render() {
const Component = this.state.component; const { component } = this.state;
return Component ? ( return component ? (
<Component {...this.props} /> <component {...this.props} />
) : ( ) : (
<div <div
style={{ style={{
......
...@@ -29,12 +29,14 @@ export default class Pie extends Component { ...@@ -29,12 +29,14 @@ export default class Pie extends Component {
} }
componentDidUpdate(preProps) { componentDidUpdate(preProps) {
if (this.props.data !== preProps.data) { const { data } = this.props;
if (data !== preProps.data) {
// because of charts data create when rendered // because of charts data create when rendered
// so there is a trick for get rendered time // so there is a trick for get rendered time
this.getLegendData(); this.getLegendData();
} }
} }
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('resize', this.resize); window.removeEventListener('resize', this.resize);
this.resize.cancel(); this.resize.cancel();
...@@ -68,28 +70,6 @@ export default class Pie extends Component { ...@@ -68,28 +70,6 @@ export default class Pie extends Component {
}); });
}; };
// for window resize auto responsive legend
@Bind()
@Debounce(300)
resize() {
const { hasLegend } = this.props;
if (!hasLegend || !this.root) {
window.removeEventListener('resize', this.resize);
return;
}
if (this.root.parentNode.clientWidth <= 380) {
if (!this.state.legendBlock) {
this.setState({
legendBlock: true,
});
}
} else if (this.state.legendBlock) {
this.setState({
legendBlock: false,
});
}
}
handleRoot = n => { handleRoot = n => {
this.root = n; this.root = n;
}; };
...@@ -112,6 +92,29 @@ export default class Pie extends Component { ...@@ -112,6 +92,29 @@ export default class Pie extends Component {
}); });
}; };
// for window resize auto responsive legend
@Bind()
@Debounce(300)
resize() {
const { hasLegend } = this.props;
const { legendBlock } = this.state;
if (!hasLegend || !this.root) {
window.removeEventListener('resize', this.resize);
return;
}
if (this.root.parentNode.clientWidth <= 380) {
if (!legendBlock) {
this.setState({
legendBlock: true,
});
}
} else if (legendBlock) {
this.setState({
legendBlock: false,
});
}
}
render() { render() {
const { const {
valueFormat, valueFormat,
...@@ -137,9 +140,10 @@ export default class Pie extends Component { ...@@ -137,9 +140,10 @@ export default class Pie extends Component {
}); });
const defaultColors = colors; const defaultColors = colors;
let data = this.props.data || []; let { data, selected, tooltip } = this.props;
let selected = this.props.selected || true; data = data || [];
let tooltip = this.props.tooltip || true; selected = selected || true;
tooltip = tooltip || true;
let formatColor; let formatColor;
const scale = { const scale = {
......
...@@ -23,32 +23,25 @@ const initTime = props => { ...@@ -23,32 +23,25 @@ const initTime = props => {
}; };
class CountDown extends Component { class CountDown extends Component {
timer = 0;
interval = 1000;
constructor(props) { constructor(props) {
super(props); super(props);
const { lastTime } = initTime(props); const { lastTime } = initTime(props);
this.state = { this.state = {
lastTime, lastTime,
}; };
} }
static getDerivedStateFromProps(nextProps, preState) {
const { lastTime } = initTime(nextProps);
if (preState.lastTime !== lastTime) {
return {
lastTime,
};
}
return null;
}
componentDidMount() { componentDidMount() {
this.tick(); this.tick();
} }
componentDidUpdate(prevProps) { componentDidUpdate(prevProps) {
if (this.props.target !== prevProps.target) { const { target } = this.props;
if (target !== prevProps.target) {
clearTimeout(this.timer); clearTimeout(this.timer);
this.tick(); this.tick();
} }
...@@ -58,8 +51,16 @@ class CountDown extends Component { ...@@ -58,8 +51,16 @@ class CountDown extends Component {
clearTimeout(this.timer); clearTimeout(this.timer);
} }
timer = 0; static getDerivedStateFromProps(nextProps, preState) {
interval = 1000; const { lastTime } = initTime(nextProps);
if (preState.lastTime !== lastTime) {
return {
lastTime,
};
}
return null;
}
// defaultFormat = time => ( // defaultFormat = time => (
// <span>{moment(time).format('hh:mm:ss')}</span> // <span>{moment(time).format('hh:mm:ss')}</span>
// ); // );
...@@ -76,6 +77,7 @@ class CountDown extends Component { ...@@ -76,6 +77,7 @@ class CountDown extends Component {
</span> </span>
); );
}; };
tick = () => { tick = () => {
const { onEnd } = this.props; const { onEnd } = this.props;
let { lastTime } = this.state; let { lastTime } = this.state;
......
...@@ -3,23 +3,32 @@ import { Input, Icon } from 'antd'; ...@@ -3,23 +3,32 @@ import { Input, Icon } from 'antd';
import styles from './index.less'; import styles from './index.less';
export default class EditableItem extends PureComponent { export default class EditableItem extends PureComponent {
state = { constructor(props) {
value: this.props.value, super(props);
this.state = {
value: props.value,
editable: false, editable: false,
}; };
}
handleChange = e => { handleChange = e => {
const { value } = e.target; const { value } = e.target;
this.setState({ value }); this.setState({ value });
}; };
check = () => { check = () => {
this.setState({ editable: false }); this.setState({ editable: false });
if (this.props.onChange) { const { value } = this.state;
this.props.onChange(this.state.value); const { onChange } = this.state;
if (onChange) {
onChange(value);
} }
}; };
edit = () => { edit = () => {
this.setState({ editable: true }); this.setState({ editable: true });
}; };
render() { render() {
const { value, editable } = this.state; const { value, editable } = this.state;
return ( return (
......
...@@ -17,6 +17,7 @@ class EditableLinkGroup extends PureComponent { ...@@ -17,6 +17,7 @@ class EditableLinkGroup extends PureComponent {
onAdd: () => {}, onAdd: () => {},
linkElement: 'a', linkElement: 'a',
}; };
render() { render() {
const { links, linkElement, onAdd } = this.props; const { links, linkElement, onAdd } = this.props;
return ( return (
......
...@@ -38,6 +38,7 @@ export default class GlobalHeaderRight extends PureComponent { ...@@ -38,6 +38,7 @@ export default class GlobalHeaderRight extends PureComponent {
}); });
return groupBy(newNotices, 'type'); return groupBy(newNotices, 'type');
} }
render() { render() {
const { const {
currentUser, currentUser,
...@@ -45,6 +46,7 @@ export default class GlobalHeaderRight extends PureComponent { ...@@ -45,6 +46,7 @@ export default class GlobalHeaderRight extends PureComponent {
onNoticeVisibleChange, onNoticeVisibleChange,
onMenuClick, onMenuClick,
onNoticeClear, onNoticeClear,
theme,
} = this.props; } = this.props;
const menu = ( const menu = (
<Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}> <Menu className={styles.menu} selectedKeys={[]} onClick={onMenuClick}>
...@@ -65,7 +67,7 @@ export default class GlobalHeaderRight extends PureComponent { ...@@ -65,7 +67,7 @@ export default class GlobalHeaderRight extends PureComponent {
); );
const noticeData = this.getNoticeData(); const noticeData = this.getNoticeData();
let className = styles.right; let className = styles.right;
if (this.props.theme === 'dark') { if (theme === 'dark') {
className = `${styles.right} ${styles.dark}`; className = `${styles.right} ${styles.dark}`;
} }
return ( return (
......
...@@ -25,44 +25,58 @@ export default class HeaderSearch extends PureComponent { ...@@ -25,44 +25,58 @@ export default class HeaderSearch extends PureComponent {
defaultOpen: false, defaultOpen: false,
}; };
state = { constructor(props) {
searchMode: this.props.defaultOpen, super(props);
this.state = {
searchMode: props.defaultOpen,
value: '', value: '',
}; };
}
componentWillUnmount() { componentWillUnmount() {
clearTimeout(this.timeout); clearTimeout(this.timeout);
} }
onKeyDown = e => { onKeyDown = e => {
if (e.key === 'Enter') { if (e.key === 'Enter') {
const { onPressEnter } = this.props;
const { value } = this.state;
this.timeout = setTimeout(() => { this.timeout = setTimeout(() => {
this.props.onPressEnter(this.state.value); // Fix duplicate onPressEnter onPressEnter(value); // Fix duplicate onPressEnter
}, 0); }, 0);
} }
}; };
onChange = value => { onChange = value => {
const { onChange } = this.props;
this.setState({ value }); this.setState({ value });
if (this.props.onChange) { if (onChange) {
this.props.onChange(); onChange();
} }
}; };
enterSearchMode = () => { enterSearchMode = () => {
this.setState({ searchMode: true }, () => { this.setState({ searchMode: true }, () => {
if (this.state.searchMode) { const { searchMode } = this.state;
if (searchMode) {
this.input.focus(); this.input.focus();
} }
}); });
}; };
leaveSearchMode = () => { leaveSearchMode = () => {
this.setState({ this.setState({
searchMode: false, searchMode: false,
value: '', value: '',
}); });
}; };
render() { render() {
const { className, placeholder, ...restProps } = this.props; const { className, placeholder, ...restProps } = this.props;
delete restProps.defaultOpen; // for rc-select not affected delete restProps.defaultOpen; // for rc-select not affected
const { searchMode, value } = this.state;
const inputClass = classNames(styles.input, { const inputClass = classNames(styles.input, {
[styles.show]: this.state.searchMode, [styles.show]: searchMode,
}); });
return ( return (
<span className={classNames(className, styles.headerSearch)} onClick={this.enterSearchMode}> <span className={classNames(className, styles.headerSearch)} onClick={this.enterSearchMode}>
...@@ -71,7 +85,7 @@ export default class HeaderSearch extends PureComponent { ...@@ -71,7 +85,7 @@ export default class HeaderSearch extends PureComponent {
key="AutoComplete" key="AutoComplete"
{...restProps} {...restProps}
className={inputClass} className={inputClass}
value={this.state.value} value={value}
onChange={this.onChange} onChange={this.onChange}
> >
<Input <Input
......
...@@ -14,14 +14,18 @@ class WarpFormItem extends Component { ...@@ -14,14 +14,18 @@ class WarpFormItem extends Component {
count: 0, count: 0,
}; };
} }
componentDidMount() { componentDidMount() {
if (this.props.updateActive) { const { updateActive, name } = this.props;
this.props.updateActive(this.props.name); if (updateActive) {
updateActive(name);
} }
} }
componentWillUnmount() { componentWillUnmount() {
clearInterval(this.interval); clearInterval(this.interval);
} }
onGetCaptcha = () => { onGetCaptcha = () => {
const { onGetCaptcha } = this.props; const { onGetCaptcha } = this.props;
const result = onGetCaptcha ? onGetCaptcha() : null; const result = onGetCaptcha ? onGetCaptcha() : null;
...@@ -34,6 +38,7 @@ class WarpFormItem extends Component { ...@@ -34,6 +38,7 @@ class WarpFormItem extends Component {
this.runGetCaptchaCountDown(); this.runGetCaptchaCountDown();
} }
}; };
getFormItemOptions = ({ onChange, defaultValue, rules }) => { getFormItemOptions = ({ onChange, defaultValue, rules }) => {
const options = { const options = {
rules: rules || this.customprops.rules, rules: rules || this.customprops.rules,
...@@ -46,8 +51,10 @@ class WarpFormItem extends Component { ...@@ -46,8 +51,10 @@ class WarpFormItem extends Component {
} }
return options; return options;
}; };
runGetCaptchaCountDown = () => { runGetCaptchaCountDown = () => {
let count = this.props.countDown || 59; const { countDown } = this.props;
let count = countDown || 59;
this.setState({ count }); this.setState({ count });
this.interval = setInterval(() => { this.interval = setInterval(() => {
count -= 1; count -= 1;
...@@ -57,10 +64,13 @@ class WarpFormItem extends Component { ...@@ -57,10 +64,13 @@ class WarpFormItem extends Component {
} }
}, 1000); }, 1000);
}; };
render() { render() {
const { count } = this.state; const { count } = this.state;
const { getFieldDecorator } = this.props.form; const {
form: { getFieldDecorator },
} = this.props;
// 这么写是为了防止restProps中 带入 onChange, defaultValue, rules props // 这么写是为了防止restProps中 带入 onChange, defaultValue, rules props
const { const {
...@@ -70,6 +80,7 @@ class WarpFormItem extends Component { ...@@ -70,6 +80,7 @@ class WarpFormItem extends Component {
rules, rules,
name, name,
updateActive, updateActive,
type,
...restProps ...restProps
} = this.props; } = this.props;
...@@ -77,15 +88,13 @@ class WarpFormItem extends Component { ...@@ -77,15 +88,13 @@ class WarpFormItem extends Component {
const options = this.getFormItemOptions(this.props); const options = this.getFormItemOptions(this.props);
const otherProps = restProps || {}; const otherProps = restProps || {};
if (this.props.type === 'Captcha') { if (type === 'Captcha') {
const inputProps = omit(otherProps, ['onGetCaptcha']); const inputProps = omit(otherProps, ['onGetCaptcha']);
return ( return (
<FormItem> <FormItem>
<Row gutter={8}> <Row gutter={8}>
<Col span={16}> <Col span={16}>
{getFieldDecorator(name, options)( {getFieldDecorator(name, options)(<Input {...customprops} {...inputProps} />)}
<Input {...this.props.customprops} {...inputProps} />
)}
</Col> </Col>
<Col span={8}> <Col span={8}>
<Button <Button
...@@ -103,7 +112,7 @@ class WarpFormItem extends Component { ...@@ -103,7 +112,7 @@ class WarpFormItem extends Component {
} }
return ( return (
<FormItem> <FormItem>
{getFieldDecorator(name, options)(<Input {...this.props.customprops} {...otherProps} />)} {getFieldDecorator(name, options)(<Input {...customprops} {...otherProps} />)}
</FormItem> </FormItem>
); );
} }
......
...@@ -17,11 +17,15 @@ class LoginTab extends Component { ...@@ -17,11 +17,15 @@ class LoginTab extends Component {
super(props); super(props);
this.uniqueId = generateId('login-tab-'); this.uniqueId = generateId('login-tab-');
} }
componentDidMount() { componentDidMount() {
this.props.tabUtil.addTab(this.uniqueId); const { tabUtil } = this.props;
tabUtil.addTab(this.uniqueId);
} }
render() { render() {
return <TabPane {...this.props}>{this.props.children}</TabPane>; const { children } = this.props;
return <TabPane {...this.props}>{children}</TabPane>;
} }
} }
......
...@@ -23,32 +23,40 @@ class Login extends Component { ...@@ -23,32 +23,40 @@ class Login extends Component {
onSubmit: () => {}, onSubmit: () => {},
}; };
state = { constructor(props) {
type: this.props.defaultActiveKey, super(props);
this.state = {
type: props.defaultActiveKey,
tabs: [], tabs: [],
active: {}, active: {},
}; };
}
onSwitch = type => { onSwitch = type => {
this.setState({ this.setState({
type, type,
}); });
this.props.onTabChange(type); const { onTabChange } = this.props;
onTabChange(type);
}; };
getContext = () => { getContext = () => {
const { tabs } = this.state;
const { form } = this.props;
return { return {
tabUtil: { tabUtil: {
addTab: id => { addTab: id => {
this.setState({ this.setState({
tabs: [...this.state.tabs, id], tabs: [...tabs, id],
}); });
}, },
removeTab: id => { removeTab: id => {
this.setState({ this.setState({
tabs: this.state.tabs.filter(currentId => currentId !== id), tabs: tabs.filter(currentId => currentId !== id),
}); });
}, },
}, },
form: this.props.form, form,
updateActive: activeItem => { updateActive: activeItem => {
const { type, active } = this.state; const { type, active } = this.state;
if (active[type]) { if (active[type]) {
...@@ -62,14 +70,17 @@ class Login extends Component { ...@@ -62,14 +70,17 @@ class Login extends Component {
}, },
}; };
}; };
handleSubmit = e => { handleSubmit = e => {
e.preventDefault(); e.preventDefault();
const { active, type } = this.state; const { active, type } = this.state;
const activeFileds = active[type]; const activeFileds = active[type];
this.props.form.validateFields(activeFileds, { force: true }, (err, values) => { const { form, onSubmit } = this.props;
this.props.onSubmit(err, values); form.validateFields(activeFileds, { force: true }, (err, values) => {
onSubmit(err, values);
}); });
}; };
render() { render() {
const { className, children } = this.props; const { className, children } = this.props;
const { type, tabs } = this.state; const { type, tabs } = this.state;
......
...@@ -21,23 +21,19 @@ export default class NoticeIcon extends PureComponent { ...@@ -21,23 +21,19 @@ export default class NoticeIcon extends PureComponent {
}, },
emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg', emptyImage: 'https://gw.alipayobjects.com/zos/rmsportal/wAhyIChODzsoKIOBHcBk.svg',
}; };
constructor(props) {
super(props);
this.state = {};
if (props.children && props.children[0]) {
this.state.tabType = props.children[0].props.title;
}
}
onItemClick = (item, tabProps) => { onItemClick = (item, tabProps) => {
const { onItemClick } = this.props; const { onItemClick } = this.props;
onItemClick(item, tabProps); onItemClick(item, tabProps);
}; };
onTabChange = tabType => { onTabChange = tabType => {
this.setState({ tabType }); const onTabChange = this.props;
this.props.onTabChange(tabType); onTabChange(tabType);
}; };
getNotificationBox() { getNotificationBox() {
const { children, loading, locale } = this.props; const { children, loading, locale, onClear } = this.props;
if (!children) { if (!children) {
return null; return null;
} }
...@@ -52,7 +48,7 @@ export default class NoticeIcon extends PureComponent { ...@@ -52,7 +48,7 @@ export default class NoticeIcon extends PureComponent {
{...child.props} {...child.props}
data={child.props.list} data={child.props.list}
onClick={item => this.onItemClick(item, child.props)} onClick={item => this.onItemClick(item, child.props)}
onClear={() => this.props.onClear(child.props.title)} onClear={() => onClear(child.props.title)}
title={child.props.title} title={child.props.title}
locale={locale} locale={locale}
/> />
...@@ -67,8 +63,9 @@ export default class NoticeIcon extends PureComponent { ...@@ -67,8 +63,9 @@ export default class NoticeIcon extends PureComponent {
</Spin> </Spin>
); );
} }
render() { render() {
const { className, count, popupAlign, onPopupVisibleChange } = this.props; const { className, count, popupAlign, popupVisible, onPopupVisibleChange } = this.props;
const noticeButtonClass = classNames(className, styles.noticeButton); const noticeButtonClass = classNames(className, styles.noticeButton);
const notificationBox = this.getNotificationBox(); const notificationBox = this.getNotificationBox();
const trigger = ( const trigger = (
...@@ -83,7 +80,7 @@ export default class NoticeIcon extends PureComponent { ...@@ -83,7 +80,7 @@ export default class NoticeIcon extends PureComponent {
} }
const popoverProps = {}; const popoverProps = {};
if ('popupVisible' in this.props) { if ('popupVisible' in this.props) {
popoverProps.visible = this.props.popupVisible; popoverProps.visible = popupVisible;
} }
return ( return (
<Popover <Popover
......
...@@ -27,29 +27,36 @@ export default class PageHeader extends PureComponent { ...@@ -27,29 +27,36 @@ export default class PageHeader extends PureComponent {
} }
componentDidUpdate(preProps) { componentDidUpdate(preProps) {
if (preProps.tabActiveKey !== this.props.tabActiveKey) { const { tabActiveKey } = this.props;
if (preProps.tabActiveKey !== tabActiveKey) {
this.getBreadcrumbDom(); this.getBreadcrumbDom();
} }
} }
onChange = key => { onChange = key => {
if (this.props.onTabChange) { const { onTabChange } = this.props;
this.props.onTabChange(key); if (onTabChange) {
onTabChange(key);
} }
}; };
getBreadcrumbProps = () => { getBreadcrumbProps = () => {
const { routes, params, location, breadcrumbNameMap } = this.props;
return { return {
routes: this.props.routes, routes,
params: this.props.params, params,
routerLocation: this.props.location, routerLocation: location,
breadcrumbNameMap: this.props.breadcrumbNameMap, breadcrumbNameMap,
}; };
}; };
getBreadcrumbDom = () => { getBreadcrumbDom = () => {
const breadcrumb = this.conversionBreadcrumbList(); const breadcrumb = this.conversionBreadcrumbList();
this.setState({ this.setState({
breadcrumb, breadcrumb,
}); });
}; };
// Generated according to props // Generated according to props
conversionFromProps = () => { conversionFromProps = () => {
const { breadcrumbList, breadcrumbSeparator, linkElement = 'a' } = this.props; const { breadcrumbList, breadcrumbSeparator, linkElement = 'a' } = this.props;
...@@ -71,6 +78,7 @@ export default class PageHeader extends PureComponent { ...@@ -71,6 +78,7 @@ export default class PageHeader extends PureComponent {
</Breadcrumb> </Breadcrumb>
); );
}; };
conversionFromLocation = (routerLocation, breadcrumbNameMap) => { conversionFromLocation = (routerLocation, breadcrumbNameMap) => {
const { breadcrumbSeparator, linkElement = 'a' } = this.props; const { breadcrumbSeparator, linkElement = 'a' } = this.props;
// Convert the url to an array // Convert the url to an array
...@@ -107,6 +115,7 @@ export default class PageHeader extends PureComponent { ...@@ -107,6 +115,7 @@ export default class PageHeader extends PureComponent {
</Breadcrumb> </Breadcrumb>
); );
}; };
/** /**
* 将参数转化为面包屑 * 将参数转化为面包屑
* Convert parameters into breadcrumbs * Convert parameters into breadcrumbs
...@@ -137,6 +146,7 @@ export default class PageHeader extends PureComponent { ...@@ -137,6 +146,7 @@ export default class PageHeader extends PureComponent {
} }
return null; return null;
}; };
// 渲染Breadcrumb 子节点 // 渲染Breadcrumb 子节点
// Render the Breadcrumb child node // Render the Breadcrumb child node
itemRender = (route, params, routes, paths) => { itemRender = (route, params, routes, paths) => {
...@@ -178,10 +188,10 @@ export default class PageHeader extends PureComponent { ...@@ -178,10 +188,10 @@ export default class PageHeader extends PureComponent {
if (tabActiveKey !== undefined) { if (tabActiveKey !== undefined) {
activeKeyProps.activeKey = tabActiveKey; activeKeyProps.activeKey = tabActiveKey;
} }
const { breadcrumb } = this.state;
return ( return (
<div className={clsString}> <div className={clsString}>
{this.state.breadcrumb} {breadcrumb}
<div className={styles.detail}> <div className={styles.detail}>
{logo && <div className={styles.logo}>{logo}</div>} {logo && <div className={styles.logo}>{logo}</div>}
<div className={styles.main}> <div className={styles.main}>
......
...@@ -21,7 +21,9 @@ const Body = ({ children, title, style }) => ( ...@@ -21,7 +21,9 @@ const Body = ({ children, title, style }) => (
@connect(({ setting }) => ({ setting })) @connect(({ setting }) => ({ setting }))
class SettingDarwer extends PureComponent { class SettingDarwer extends PureComponent {
componentDidMount() { componentDidMount() {
const { themeColor, colorWeak } = this.props.setting; const {
setting: { themeColor, colorWeak },
} = this.props;
if (themeColor !== '#1890FF') { if (themeColor !== '#1890FF') {
window.less.refresh().then(() => { window.less.refresh().then(() => {
this.colorChange(themeColor); this.colorChange(themeColor);
...@@ -31,8 +33,11 @@ class SettingDarwer extends PureComponent { ...@@ -31,8 +33,11 @@ class SettingDarwer extends PureComponent {
document.body.className = 'colorWeak'; document.body.className = 'colorWeak';
} }
} }
getLayOutSetting = () => { getLayOutSetting = () => {
const { grid, fixedHeader, autoHideHeader, fixSiderbar } = this.props.setting; const {
setting: { grid, fixedHeader, autoHideHeader, fixSiderbar },
} = this.props;
return [ return [
{ {
title: '栅格模式', title: '栅格模式',
...@@ -83,8 +88,10 @@ class SettingDarwer extends PureComponent { ...@@ -83,8 +88,10 @@ class SettingDarwer extends PureComponent {
return !item.hide; return !item.hide;
}); });
}; };
changeSetting = (key, value) => { changeSetting = (key, value) => {
const nextState = { ...this.props.setting }; const { setting } = this.props;
const nextState = { ...setting };
nextState[key] = value; nextState[key] = value;
if (key === 'layout') { if (key === 'layout') {
if (value === 'topmenu') { if (value === 'topmenu') {
...@@ -106,15 +113,19 @@ class SettingDarwer extends PureComponent { ...@@ -106,15 +113,19 @@ class SettingDarwer extends PureComponent {
} }
} }
this.setState(nextState, () => { this.setState(nextState, () => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'setting/changeSetting', type: 'setting/changeSetting',
payload: this.state, payload: this.state,
}); });
}); });
}; };
togglerContent = () => { togglerContent = () => {
this.changeSetting('collapse', !this.props.setting.collapse); const { setting } = this.props;
this.changeSetting('collapse', !setting.collapse);
}; };
colorChange = color => { colorChange = color => {
this.changeSetting('themeColor', color); this.changeSetting('themeColor', color);
const hideMessage = message.loading('正在编译主题!', 0); const hideMessage = message.loading('正在编译主题!', 0);
...@@ -131,8 +142,11 @@ class SettingDarwer extends PureComponent { ...@@ -131,8 +142,11 @@ class SettingDarwer extends PureComponent {
}); });
}, 200); }, 200);
}; };
render() { render() {
const { collapse, silderTheme, themeColor, layout, colorWeak } = this.props.setting; const {
setting: { collapse, silderTheme, themeColor, layout, colorWeak },
} = this.props;
return ( return (
<div className={styles.settingDarwer}> <div className={styles.settingDarwer}>
<DrawerMenu <DrawerMenu
......
...@@ -32,6 +32,7 @@ export default class BaseMenu extends PureComponent { ...@@ -32,6 +32,7 @@ export default class BaseMenu extends PureComponent {
super(props); super(props);
this.flatMenuKeys = this.getFlatMenuKeys(props.menuData); this.flatMenuKeys = this.getFlatMenuKeys(props.menuData);
} }
/** /**
* Recursively flatten the data * Recursively flatten the data
* [{path:string},{path:string}] => {path,path2} * [{path:string},{path:string}] => {path,path2}
...@@ -47,6 +48,7 @@ export default class BaseMenu extends PureComponent { ...@@ -47,6 +48,7 @@ export default class BaseMenu extends PureComponent {
}); });
return keys; return keys;
} }
/** /**
* 获得菜单子节点 * 获得菜单子节点
* @memberof SiderMenu * @memberof SiderMenu
...@@ -64,6 +66,7 @@ export default class BaseMenu extends PureComponent { ...@@ -64,6 +66,7 @@ export default class BaseMenu extends PureComponent {
}) })
.filter(item => item); .filter(item => item);
}; };
// Get the currently selected menu // Get the currently selected menu
getSelectedMenuKeys = () => { getSelectedMenuKeys = () => {
const { const {
...@@ -71,6 +74,7 @@ export default class BaseMenu extends PureComponent { ...@@ -71,6 +74,7 @@ export default class BaseMenu extends PureComponent {
} = this.props; } = this.props;
return urlToList(pathname).map(itemPath => getMenuMatches(this.flatMenuKeys, itemPath).pop()); return urlToList(pathname).map(itemPath => getMenuMatches(this.flatMenuKeys, itemPath).pop());
}; };
/** /**
* get SubMenu or Item * get SubMenu or Item
*/ */
...@@ -97,6 +101,7 @@ export default class BaseMenu extends PureComponent { ...@@ -97,6 +101,7 @@ export default class BaseMenu extends PureComponent {
return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>; return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>;
} }
}; };
/** /**
* 判断是否是http链接.返回 Link 或 a * 判断是否是http链接.返回 Link 或 a
* Judge whether it is http link.return a or Link * Judge whether it is http link.return a or Link
...@@ -115,15 +120,16 @@ export default class BaseMenu extends PureComponent { ...@@ -115,15 +120,16 @@ export default class BaseMenu extends PureComponent {
</a> </a>
); );
} }
const { location, isMobile, onCollapse } = this.props;
return ( return (
<Link <Link
to={itemPath} to={itemPath}
target={target} target={target}
replace={itemPath === this.props.location.pathname} replace={itemPath === location.pathname}
onClick={ onClick={
this.props.isMobile isMobile
? () => { ? () => {
this.props.onCollapse(true); onCollapse(true);
} }
: undefined : undefined
} }
...@@ -133,14 +139,17 @@ export default class BaseMenu extends PureComponent { ...@@ -133,14 +139,17 @@ export default class BaseMenu extends PureComponent {
</Link> </Link>
); );
}; };
// permission to check // permission to check
checkPermissionItem = (authority, ItemDom) => { checkPermissionItem = (authority, ItemDom) => {
if (this.props.Authorized && this.props.Authorized.check) { const { Authorized } = this.props;
const { check } = this.props.Authorized; if (Authorized && Authorized.check) {
const { check } = Authorized;
return check(authority, ItemDom); return check(authority, ItemDom);
} }
return ItemDom; return ItemDom;
}; };
conversionPath = path => { conversionPath = path => {
if (path && path.indexOf('http') === 0) { if (path && path.indexOf('http') === 0) {
return path; return path;
...@@ -148,6 +157,7 @@ export default class BaseMenu extends PureComponent { ...@@ -148,6 +157,7 @@ export default class BaseMenu extends PureComponent {
return `/${path || ''}`.replace(/\/+/g, '/'); return `/${path || ''}`.replace(/\/+/g, '/');
} }
}; };
render() { render() {
const { openKeys, theme, mode } = this.props; const { openKeys, theme, mode } = this.props;
// if pathname can't match, use the nearest parent's key // if pathname can't match, use the nearest parent's key
...@@ -161,17 +171,18 @@ export default class BaseMenu extends PureComponent { ...@@ -161,17 +171,18 @@ export default class BaseMenu extends PureComponent {
openKeys, openKeys,
}; };
} }
const { handleOpenChange, style, menuData } = this.props;
return ( return (
<Menu <Menu
key="Menu" key="Menu"
mode={mode} mode={mode}
theme={theme} theme={theme}
onOpenChange={this.props.handleOpenChange} onOpenChange={handleOpenChange}
selectedKeys={selectedKeys} selectedKeys={selectedKeys}
style={this.props.style} style={style}
{...props} {...props}
> >
{this.getNavMenuItems(this.props.menuData)} {this.getNavMenuItems(menuData)}
</Menu> </Menu>
); );
} }
......
...@@ -16,10 +16,11 @@ const { SubMenu } = Menu; ...@@ -16,10 +16,11 @@ const { SubMenu } = Menu;
const getDefaultCollapsedSubMenus = props => { const getDefaultCollapsedSubMenus = props => {
const { const {
location: { pathname }, location: { pathname },
flatMenuKeys,
} = props; } = props;
return urlToList(pathname) return urlToList(pathname)
.map(item => { .map(item => {
return getMenuMatches(props.flatMenuKeys, item)[0]; return getMenuMatches(flatMenuKeys, item)[0];
}) })
.filter(item => item); .filter(item => item);
}; };
...@@ -69,7 +70,6 @@ export default class SiderMenu extends PureComponent { ...@@ -69,7 +70,6 @@ export default class SiderMenu extends PureComponent {
super(props); super(props);
this.flatMenuKeys = getFlatMenuKeys(props.menuData); this.flatMenuKeys = getFlatMenuKeys(props.menuData);
this.state = { this.state = {
pathname: props.location.pathname,
openKeys: getDefaultCollapsedSubMenus(props), openKeys: getDefaultCollapsedSubMenus(props),
}; };
} }
...@@ -84,6 +84,7 @@ export default class SiderMenu extends PureComponent { ...@@ -84,6 +84,7 @@ export default class SiderMenu extends PureComponent {
} }
return null; return null;
} }
/** /**
* Convert pathname to openKeys * Convert pathname to openKeys
* /list/search/articles = > ['list','/list/search'] * /list/search/articles = > ['list','/list/search']
...@@ -96,6 +97,7 @@ export default class SiderMenu extends PureComponent { ...@@ -96,6 +97,7 @@ export default class SiderMenu extends PureComponent {
props || this.props; props || this.props;
return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname));
} }
/** /**
* 判断是否是http链接.返回 Link 或 a * 判断是否是http链接.返回 Link 或 a
* Judge whether it is http link.return a or Link * Judge whether it is http link.return a or Link
...@@ -114,15 +116,16 @@ export default class SiderMenu extends PureComponent { ...@@ -114,15 +116,16 @@ export default class SiderMenu extends PureComponent {
</a> </a>
); );
} }
const { pathname, isMobile, onCollapse } = this.props;
return ( return (
<Link <Link
to={itemPath} to={itemPath}
target={target} target={target}
replace={itemPath === this.state.pathname} replace={itemPath === pathname}
onClick={ onClick={
this.props.isMobile isMobile
? () => { ? () => {
this.props.onCollapse(true); onCollapse(true);
} }
: undefined : undefined
} }
...@@ -132,6 +135,7 @@ export default class SiderMenu extends PureComponent { ...@@ -132,6 +135,7 @@ export default class SiderMenu extends PureComponent {
</Link> </Link>
); );
}; };
/** /**
* get SubMenu or Item * get SubMenu or Item
*/ */
...@@ -163,6 +167,7 @@ export default class SiderMenu extends PureComponent { ...@@ -163,6 +167,7 @@ export default class SiderMenu extends PureComponent {
return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>; return <Menu.Item key={item.path}>{this.getMenuItemPath(item)}</Menu.Item>;
} }
}; };
/** /**
* 获得菜单子节点 * 获得菜单子节点
* @memberof SiderMenu * @memberof SiderMenu
...@@ -180,6 +185,7 @@ export default class SiderMenu extends PureComponent { ...@@ -180,6 +185,7 @@ export default class SiderMenu extends PureComponent {
}) })
.filter(item => item); .filter(item => item);
}; };
// Get the currently selected menu // Get the currently selected menu
getSelectedMenuKeys = () => { getSelectedMenuKeys = () => {
const { const {
...@@ -187,6 +193,7 @@ export default class SiderMenu extends PureComponent { ...@@ -187,6 +193,7 @@ export default class SiderMenu extends PureComponent {
} = this.props; } = this.props;
return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname)); return getMenuMatchKeys(this.flatMenuKeys, urlToList(pathname));
}; };
// conversion Path // conversion Path
// 转化路径 // 转化路径
conversionPath = path => { conversionPath = path => {
...@@ -196,28 +203,34 @@ export default class SiderMenu extends PureComponent { ...@@ -196,28 +203,34 @@ export default class SiderMenu extends PureComponent {
return `/${path || ''}`.replace(/\/+/g, '/'); return `/${path || ''}`.replace(/\/+/g, '/');
} }
}; };
// permission to check // permission to check
checkPermissionItem = (authority, ItemDom) => { checkPermissionItem = (authority, ItemDom) => {
if (this.props.Authorized && this.props.Authorized.check) { const { Authorized } = this.props;
const { check } = this.props.Authorized; if (Authorized && Authorized.check) {
const { check } = Authorized;
return check(authority, ItemDom); return check(authority, ItemDom);
} }
return ItemDom; return ItemDom;
}; };
isMainMenu = key => { isMainMenu = key => {
return this.props.menuData.some(item => { const { menuData } = this.props;
return menuData.some(item => {
if (key) { if (key) {
return item.key === key || item.path === key; return item.key === key || item.path === key;
} }
return false; return false;
}); });
}; };
handleOpenChange = openKeys => { handleOpenChange = openKeys => {
const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1; const moreThanOne = openKeys.filter(openKey => this.isMainMenu(openKey)).length > 1;
this.setState({ this.setState({
openKeys: moreThanOne ? [openKeys.pop()] : [...openKeys], openKeys: moreThanOne ? [openKeys.pop()] : [...openKeys],
}); });
}; };
render() { render() {
const { logo, collapsed, onCollapse, fixSiderbar, theme } = this.props; const { logo, collapsed, onCollapse, fixSiderbar, theme } = this.props;
const { openKeys } = this.state; const { openKeys } = this.state;
......
...@@ -23,6 +23,7 @@ class StandardTable extends PureComponent { ...@@ -23,6 +23,7 @@ class StandardTable extends PureComponent {
needTotalList, needTotalList,
}; };
} }
static getDerivedStateFromProps(nextProps) { static getDerivedStateFromProps(nextProps) {
// clean state // clean state
if (nextProps.selectedRows.length === 0) { if (nextProps.selectedRows.length === 0) {
...@@ -34,8 +35,9 @@ class StandardTable extends PureComponent { ...@@ -34,8 +35,9 @@ class StandardTable extends PureComponent {
} }
return null; return null;
} }
handleRowSelectChange = (selectedRowKeys, selectedRows) => { handleRowSelectChange = (selectedRowKeys, selectedRows) => {
let needTotalList = [...this.state.needTotalList]; let { needTotalList } = this.state;
needTotalList = needTotalList.map(item => { needTotalList = needTotalList.map(item => {
return { return {
...item, ...item,
...@@ -44,16 +46,19 @@ class StandardTable extends PureComponent { ...@@ -44,16 +46,19 @@ class StandardTable extends PureComponent {
}, 0), }, 0),
}; };
}); });
const { onSelectRow } = this.props;
if (this.props.onSelectRow) { if (onSelectRow) {
this.props.onSelectRow(selectedRows); onSelectRow(selectedRows);
} }
this.setState({ selectedRowKeys, needTotalList }); this.setState({ selectedRowKeys, needTotalList });
}; };
handleTableChange = (pagination, filters, sorter) => { handleTableChange = (pagination, filters, sorter) => {
this.props.onChange(pagination, filters, sorter); const { onChange } = this.props;
if (onChange) {
onChange(pagination, filters, sorter);
}
}; };
cleanSelectedKeys = () => { cleanSelectedKeys = () => {
......
...@@ -15,17 +15,14 @@ const TagSelectOption = ({ children, checked, onChange, value }) => ( ...@@ -15,17 +15,14 @@ const TagSelectOption = ({ children, checked, onChange, value }) => (
TagSelectOption.isTagSelectOption = true; TagSelectOption.isTagSelectOption = true;
class TagSelect extends Component { class TagSelect extends Component {
state = { constructor(props) {
super(props);
this.state = {
expand: false, expand: false,
value: this.props.value || this.props.defaultValue || [], value: props.value || props.defaultValue || [],
}; };
static getDerivedStateFromProps(nextProps) {
if ('value' in nextProps && nextProps.value) {
return { value: nextProps.value };
}
return null;
} }
onChange = value => { onChange = value => {
const { onChange } = this.props; const { onChange } = this.props;
if (!('value' in this.props)) { if (!('value' in this.props)) {
...@@ -44,6 +41,13 @@ class TagSelect extends Component { ...@@ -44,6 +41,13 @@ class TagSelect extends Component {
this.onChange(checkedTags); this.onChange(checkedTags);
}; };
static getDerivedStateFromProps(nextProps) {
if ('value' in nextProps && nextProps.value) {
return { value: nextProps.value };
}
return null;
}
getAllTags() { getAllTags() {
let { children } = this.props; let { children } = this.props;
children = React.Children.toArray(children); children = React.Children.toArray(children);
...@@ -54,7 +58,8 @@ class TagSelect extends Component { ...@@ -54,7 +58,8 @@ class TagSelect extends Component {
} }
handleTagChange = (value, checked) => { handleTagChange = (value, checked) => {
const checkedTags = [...this.state.value]; const { value: StateValue } = this.state;
const checkedTags = [...StateValue];
const index = checkedTags.indexOf(value); const index = checkedTags.indexOf(value);
if (checked && index === -1) { if (checked && index === -1) {
...@@ -66,8 +71,9 @@ class TagSelect extends Component { ...@@ -66,8 +71,9 @@ class TagSelect extends Component {
}; };
handleExpand = () => { handleExpand = () => {
const { expand } = this.state;
this.setState({ this.setState({
expand: !this.state.expand, expand: !expand,
}); });
}; };
......
...@@ -67,6 +67,7 @@ class BasicLayout extends React.PureComponent { ...@@ -67,6 +67,7 @@ class BasicLayout extends React.PureComponent {
breadcrumbNameMap: getBreadcrumbNameMap(menuData, routerData), breadcrumbNameMap: getBreadcrumbNameMap(menuData, routerData),
}; };
} }
getPageTitle() { getPageTitle() {
const { routerData, location } = this.props; const { routerData, location } = this.props;
const { pathname } = location; const { pathname } = location;
...@@ -83,6 +84,7 @@ class BasicLayout extends React.PureComponent { ...@@ -83,6 +84,7 @@ class BasicLayout extends React.PureComponent {
} }
return title; return title;
} }
getLayoutStyle = () => { getLayoutStyle = () => {
const { fixSiderbar, collapsed, layout } = this.props; const { fixSiderbar, collapsed, layout } = this.props;
if (fixSiderbar && layout !== 'topmenu') { if (fixSiderbar && layout !== 'topmenu') {
...@@ -92,6 +94,7 @@ class BasicLayout extends React.PureComponent { ...@@ -92,6 +94,7 @@ class BasicLayout extends React.PureComponent {
} }
return null; return null;
}; };
getContentStyle = () => { getContentStyle = () => {
const { fixedHeader } = this.props; const { fixedHeader } = this.props;
return { return {
...@@ -99,6 +102,7 @@ class BasicLayout extends React.PureComponent { ...@@ -99,6 +102,7 @@ class BasicLayout extends React.PureComponent {
paddingTop: fixedHeader ? 64 : 0, paddingTop: fixedHeader ? 64 : 0,
}; };
}; };
getBashRedirect = () => { getBashRedirect = () => {
// According to the url parameter to redirect // According to the url parameter to redirect
// 这里是重定向的,重定向到 url 的 redirect 参数所示地址 // 这里是重定向的,重定向到 url 的 redirect 参数所示地址
...@@ -119,16 +123,25 @@ class BasicLayout extends React.PureComponent { ...@@ -119,16 +123,25 @@ class BasicLayout extends React.PureComponent {
} }
return redirect; return redirect;
}; };
handleMenuCollapse = collapsed => { handleMenuCollapse = collapsed => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'global/changeLayoutCollapsed', type: 'global/changeLayoutCollapsed',
payload: collapsed, payload: collapsed,
}); });
}; };
render() { render() {
const { isMobile, redirectData, routerData, match } = this.props; const {
const isTop = this.props.layout === 'topmenu'; isMobile,
redirectData,
routerData,
silderTheme,
layout: PropsLayout,
match,
} = this.props;
const isTop = PropsLayout === 'topmenu';
const bashRedirect = this.getBashRedirect(); const bashRedirect = this.getBashRedirect();
const myRedirectData = redirectData || []; const myRedirectData = redirectData || [];
const layout = ( const layout = (
...@@ -137,7 +150,7 @@ class BasicLayout extends React.PureComponent { ...@@ -137,7 +150,7 @@ class BasicLayout extends React.PureComponent {
<SiderMenu <SiderMenu
logo={logo} logo={logo}
Authorized={Authorized} Authorized={Authorized}
theme={this.props.silderTheme} theme={silderTheme}
onCollapse={this.handleMenuCollapse} onCollapse={this.handleMenuCollapse}
{...this.props} {...this.props}
/> />
......
...@@ -14,12 +14,15 @@ class HeaderView extends PureComponent { ...@@ -14,12 +14,15 @@ class HeaderView extends PureComponent {
state = { state = {
visible: true, visible: true,
}; };
componentDidMount() { componentDidMount() {
document.getElementById('root').addEventListener('scroll', this.handScroll); document.getElementById('root').addEventListener('scroll', this.handScroll);
} }
componentWillUnmount() { componentWillUnmount() {
document.getElementById('root').removeEventListener('scroll', this.handScroll); document.getElementById('root').removeEventListener('scroll', this.handScroll);
} }
getHeadWidth = () => { getHeadWidth = () => {
const { isMobile, collapsed, setting } = this.props; const { isMobile, collapsed, setting } = this.props;
const { fixedHeader, layout } = setting; const { fixedHeader, layout } = setting;
...@@ -28,53 +31,62 @@ class HeaderView extends PureComponent { ...@@ -28,53 +31,62 @@ class HeaderView extends PureComponent {
} }
return collapsed ? 'calc(100% - 80px)' : 'calc(100% - 256px)'; return collapsed ? 'calc(100% - 80px)' : 'calc(100% - 256px)';
}; };
handleNoticeClear = type => { handleNoticeClear = type => {
message.success(`清空了${type}`); message.success(`清空了${type}`);
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'global/clearNotices', type: 'global/clearNotices',
payload: type, payload: type,
}); });
}; };
handleMenuClick = ({ key }) => { handleMenuClick = ({ key }) => {
const { dispatch } = this.props;
if (key === 'userCenter') { if (key === 'userCenter') {
this.props.dispatch(routerRedux.push('/account/center')); dispatch(routerRedux.push('/account/center'));
return; return;
} }
if (key === 'triggerError') { if (key === 'triggerError') {
this.props.dispatch(routerRedux.push('/exception/trigger')); dispatch(routerRedux.push('/exception/trigger'));
return; return;
} }
if (key === 'userinfo') { if (key === 'userinfo') {
this.props.dispatch(routerRedux.push('/account/settings/base')); dispatch(routerRedux.push('/account/settings/base'));
return; return;
} }
if (key === 'logout') { if (key === 'logout') {
this.props.dispatch({ dispatch({
type: 'login/logout', type: 'login/logout',
}); });
} }
}; };
handleNoticeVisibleChange = visible => { handleNoticeVisibleChange = visible => {
if (visible) { if (visible) {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'global/fetchNotices', type: 'global/fetchNotices',
}); });
} }
}; };
handScroll = () => { handScroll = () => {
if (!this.props.autoHideHeader) { const { autoHideHeader } = this.props;
const { visible } = this.state;
if (!autoHideHeader) {
return; return;
} }
const { scrollTop } = document.getElementById('root'); const { scrollTop } = document.getElementById('root');
if (!this.ticking) { if (!this.ticking) {
this.ticking = false; this.ticking = false;
requestAnimationFrame(() => { requestAnimationFrame(() => {
if (scrollTop > 400 && this.state.visible) { if (scrollTop > 400 && visible) {
this.setState({ this.setState({
visible: false, visible: false,
}); });
} }
if (scrollTop < 400 && !this.state.visible) { if (scrollTop < 400 && !visible) {
this.setState({ this.setState({
visible: true, visible: true,
}); });
...@@ -83,11 +95,13 @@ class HeaderView extends PureComponent { ...@@ -83,11 +95,13 @@ class HeaderView extends PureComponent {
}); });
} }
}; };
render() { render() {
const { isMobile, handleMenuCollapse } = this.props; const { isMobile, handleMenuCollapse, setting } = this.props;
const { silderTheme, layout, fixedHeader } = this.props.setting; const { silderTheme, layout, fixedHeader } = setting;
const { visible } = this.state;
const isTop = layout === 'topmenu'; const isTop = layout === 'topmenu';
const HeaderDom = this.state.visible ? ( const HeaderDom = visible ? (
<Header <Header
style={{ padding: 0, width: this.getHeadWidth() }} style={{ padding: 0, width: this.getHeadWidth() }}
className={fixedHeader ? styles.fixedHeader : ''} className={fixedHeader ? styles.fixedHeader : ''}
......
...@@ -41,6 +41,7 @@ class UserLayout extends React.PureComponent { ...@@ -41,6 +41,7 @@ class UserLayout extends React.PureComponent {
} }
return title; return title;
} }
render() { render() {
const { routerData, match } = this.props; const { routerData, match } = this.props;
return ( return (
......
...@@ -44,7 +44,7 @@ export default class Center extends PureComponent { ...@@ -44,7 +44,7 @@ export default class Center extends PureComponent {
componentDidMount() { componentDidMount() {
const { dispatch } = this.props; const { dispatch } = this.props;
this.props.dispatch({ dispatch({
type: 'user/fetchCurrent', type: 'user/fetchCurrent',
}); });
dispatch({ dispatch({
...@@ -58,7 +58,7 @@ export default class Center extends PureComponent { ...@@ -58,7 +58,7 @@ export default class Center extends PureComponent {
}); });
} }
onTabChange = (key) => { onTabChange = key => {
this.setState({ key }); this.setState({ key });
}; };
...@@ -66,11 +66,11 @@ export default class Center extends PureComponent { ...@@ -66,11 +66,11 @@ export default class Center extends PureComponent {
this.setState({ inputVisible: true }, () => this.input.focus()); this.setState({ inputVisible: true }, () => this.input.focus());
}; };
saveInputRef = (input) => { saveInputRef = input => {
this.input = input; this.input = input;
}; };
handleInputChange = (e) => { handleInputChange = e => {
this.setState({ inputValue: e.target.value }); this.setState({ inputValue: e.target.value });
}; };
...@@ -78,14 +78,8 @@ export default class Center extends PureComponent { ...@@ -78,14 +78,8 @@ export default class Center extends PureComponent {
const { state } = this; const { state } = this;
const { inputValue } = state; const { inputValue } = state;
let { newTags } = state; let { newTags } = state;
if ( if (inputValue && newTags.filter(tag => tag.label === inputValue).length === 0) {
inputValue && newTags = [...newTags, { key: `new-${newTags.length}`, label: inputValue }];
newTags.filter(tag => tag.label === inputValue).length === 0
) {
newTags = [
...newTags,
{ key: `new-${newTags.length}`, label: inputValue },
];
} }
this.setState({ this.setState({
newTags, newTags,
...@@ -101,9 +95,7 @@ export default class Center extends PureComponent { ...@@ -101,9 +95,7 @@ export default class Center extends PureComponent {
{text} {text}
</span> </span>
); );
const ListContent = ({ const ListContent = ({ data: { content, updatedAt, avatar, owner, href } }) => (
data: { content, updatedAt, avatar, owner, href },
}) => (
<div className={stylesArticles.listContent}> <div className={stylesArticles.listContent}>
<div className={stylesArticles.description}>{content}</div> <div className={stylesArticles.description}>{content}</div>
<div className={stylesArticles.extra}> <div className={stylesArticles.extra}>
...@@ -132,10 +124,7 @@ export default class Center extends PureComponent { ...@@ -132,10 +124,7 @@ export default class Center extends PureComponent {
> >
<List.Item.Meta <List.Item.Meta
title={ title={
<a <a className={stylesArticles.listItemMetaTitle} href={item.href}>
className={stylesArticles.listItemMetaTitle}
href={item.href}
>
{item.title} {item.title}
</a> </a>
} }
...@@ -158,29 +147,17 @@ export default class Center extends PureComponent { ...@@ -158,29 +147,17 @@ export default class Center extends PureComponent {
const itemMenu = ( const itemMenu = (
<Menu> <Menu>
<Menu.Item> <Menu.Item>
<a <a target="_blank" rel="noopener noreferrer" href="http://www.alipay.com/">
target="_blank"
rel="noopener noreferrer"
href="http://www.alipay.com/"
>
1st menu item 1st menu item
</a> </a>
</Menu.Item> </Menu.Item>
<Menu.Item> <Menu.Item>
<a <a target="_blank" rel="noopener noreferrer" href="http://www.taobao.com/">
target="_blank"
rel="noopener noreferrer"
href="http://www.taobao.com/"
>
2nd menu item 2nd menu item
</a> </a>
</Menu.Item> </Menu.Item>
<Menu.Item> <Menu.Item>
<a <a target="_blank" rel="noopener noreferrer" href="http://www.tmall.com/">
target="_blank"
rel="noopener noreferrer"
href="http://www.tmall.com/"
>
3d menu item 3d menu item
</a> </a>
</Menu.Item> </Menu.Item>
...@@ -225,10 +202,7 @@ export default class Center extends PureComponent { ...@@ -225,10 +202,7 @@ export default class Center extends PureComponent {
</Dropdown>, </Dropdown>,
]} ]}
> >
<Card.Meta <Card.Meta avatar={<Avatar size="small" src={item.avatar} />} title={item.title} />
avatar={<Avatar size="small" src={item.avatar} />}
title={item.title}
/>
<div className={stylesApplications.cardItemContent}> <div className={stylesApplications.cardItemContent}>
<CardInfo <CardInfo
activeUser={formatWan(item.activeUser)} activeUser={formatWan(item.activeUser)}
...@@ -257,10 +231,7 @@ export default class Center extends PureComponent { ...@@ -257,10 +231,7 @@ export default class Center extends PureComponent {
hoverable hoverable
cover={<img alt={item.title} src={item.cover} />} cover={<img alt={item.title} src={item.cover} />}
> >
<Card.Meta <Card.Meta title={<a href="#">{item.title}</a>} description={item.subDescription} />
title={<a href="#">{item.title}</a>}
description={item.subDescription}
/>
<div className={stylesProjects.cardItemContent}> <div className={stylesProjects.cardItemContent}>
<span>{moment(item.updatedAt).fromNow()}</span> <span>{moment(item.updatedAt).fromNow()}</span>
<div className={stylesProjects.avatarList}> <div className={stylesProjects.avatarList}>
...@@ -281,6 +252,7 @@ export default class Center extends PureComponent { ...@@ -281,6 +252,7 @@ export default class Center extends PureComponent {
/> />
); );
}; };
renderContent() { renderContent() {
const { newTags, inputVisible, inputValue } = this.state; const { newTags, inputVisible, inputValue } = this.state;
const { const {
...@@ -335,9 +307,7 @@ export default class Center extends PureComponent { ...@@ -335,9 +307,7 @@ export default class Center extends PureComponent {
<Divider dashed /> <Divider dashed />
<div className={styles.tags}> <div className={styles.tags}>
<div className={styles.tagsTitle}>标签</div> <div className={styles.tagsTitle}>标签</div>
{currentUser.tags {currentUser.tags.concat(newTags).map(item => <Tag key={item.key}>{item.label}</Tag>)}
.concat(newTags)
.map(item => <Tag key={item.key}>{item.label}</Tag>)}
{inputVisible && ( {inputVisible && (
<Input <Input
ref={this.saveInputRef} ref={this.saveInputRef}
...@@ -351,10 +321,7 @@ export default class Center extends PureComponent { ...@@ -351,10 +321,7 @@ export default class Center extends PureComponent {
/> />
)} )}
{!inputVisible && ( {!inputVisible && (
<Tag <Tag onClick={this.showInput} style={{ background: '#fff', borderStyle: 'dashed' }}>
onClick={this.showInput}
style={{ background: '#fff', borderStyle: 'dashed' }}
>
<Icon type="plus" /> <Icon type="plus" />
</Tag> </Tag>
)} )}
...@@ -378,6 +345,7 @@ export default class Center extends PureComponent { ...@@ -378,6 +345,7 @@ export default class Center extends PureComponent {
</div> </div>
); );
} }
render() { render() {
const { const {
list: { list }, list: { list },
...@@ -416,17 +384,13 @@ export default class Center extends PureComponent { ...@@ -416,17 +384,13 @@ export default class Center extends PureComponent {
application: this.renderApplications(list, listLoading), application: this.renderApplications(list, listLoading),
project: this.renderProjects(list, listLoading), project: this.renderProjects(list, listLoading),
}; };
const { key } = this.state;
return ( return (
<GridContent> <GridContent>
<div className={styles.userCenter}> <div className={styles.userCenter}>
<Row gutter={24}> <Row gutter={24}>
<Col lg={7} md={24}> <Col lg={7} md={24}>
<Card <Card bordered={false} style={{ marginBottom: 24 }} loading={currentUserLoading}>
bordered={false}
style={{ marginBottom: 24 }}
loading={currentUserLoading}
>
{currentUser && Object.keys(currentUser).length {currentUser && Object.keys(currentUser).length
? this.renderContent() ? this.renderContent()
: 'loading...'} : 'loading...'}
...@@ -439,7 +403,7 @@ export default class Center extends PureComponent { ...@@ -439,7 +403,7 @@ export default class Center extends PureComponent {
tabList={operationTabList} tabList={operationTabList}
onTabChange={this.onTabChange} onTabChange={this.onTabChange}
> >
{contentMap[this.state.key]} {contentMap[key]}
</Card> </Card>
</Col> </Col>
</Row> </Row>
......
...@@ -22,7 +22,7 @@ export default class Center extends PureComponent { ...@@ -22,7 +22,7 @@ export default class Center extends PureComponent {
componentDidMount() { componentDidMount() {
const { dispatch } = this.props; const { dispatch } = this.props;
this.props.dispatch({ dispatch({
type: 'user/fetchCurrent', type: 'user/fetchCurrent',
}); });
dispatch({ dispatch({
......
...@@ -49,26 +49,33 @@ export default class BaseView extends Component { ...@@ -49,26 +49,33 @@ export default class BaseView extends Component {
componentDidMount() { componentDidMount() {
this.setBaseInfo(); this.setBaseInfo();
} }
setBaseInfo = () => { setBaseInfo = () => {
const { currentUser } = this.props; const { currentUser, form } = this.props;
Object.keys(this.props.form.getFieldsValue()).forEach(key => { Object.keys(form.getFieldsValue()).forEach(key => {
const obj = {}; const obj = {};
obj[key] = currentUser[key] || null; obj[key] = currentUser[key] || null;
this.props.form.setFieldsValue(obj); form.setFieldsValue(obj);
}); });
}; };
getAvatarURL() { getAvatarURL() {
if (this.props.currentUser.avatar) { const { currentUser } = this.props;
return this.props.currentUser.avatar; if (currentUser.avatar) {
return currentUser.avatar;
} }
const url = 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png'; const url = 'https://gw.alipayobjects.com/zos/rmsportal/BiazfanxmamNRoxxVxka.png';
return url; return url;
} }
getViewDom = ref => { getViewDom = ref => {
this.view = ref; this.view = ref;
}; };
render() { render() {
const { getFieldDecorator } = this.props.form; const {
form: { getFieldDecorator },
} = this.props;
return ( return (
<div className={styles.baseView} ref={this.getViewDom}> <div className={styles.baseView} ref={this.getViewDom}>
<div className={styles.left}> <div className={styles.left}>
......
...@@ -24,6 +24,7 @@ export default class BindingView extends Component { ...@@ -24,6 +24,7 @@ export default class BindingView extends Component {
}, },
]; ];
}; };
render() { render() {
return ( return (
<Fragment> <Fragment>
......
...@@ -20,24 +20,33 @@ const nullSlectItem = { ...@@ -20,24 +20,33 @@ const nullSlectItem = {
}) })
export default class GeographicView extends PureComponent { export default class GeographicView extends PureComponent {
componentDidMount = () => { componentDidMount = () => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'geographic/fetchProvince', type: 'geographic/fetchProvince',
}); });
}; };
componentDidUpdate(props) { componentDidUpdate(props) {
if (!props.value && !!this.props.value && !!this.props.value.province) { const { dispatch, value } = this.props;
this.props.dispatch({
if (!props.value && !!value && !!value.province) {
dispatch({
type: 'geographic/fetchCity', type: 'geographic/fetchCity',
payload: this.props.value.province.key, payload: value.province.key,
}); });
} }
} }
getProvinceOption() { getProvinceOption() {
return this.getOption(this.props.province); const { province } = this.props;
return this.getOption(province);
} }
getCityOption = () => { getCityOption = () => {
return this.getOption(this.props.city); const { city } = this.props;
return this.getOption(city);
}; };
getOption = list => { getOption = list => {
if (!list || list.length < 1) { if (!list || list.length < 1) {
return ( return (
...@@ -54,22 +63,27 @@ export default class GeographicView extends PureComponent { ...@@ -54,22 +63,27 @@ export default class GeographicView extends PureComponent {
); );
}); });
}; };
selectProvinceItem = item => { selectProvinceItem = item => {
this.props.dispatch({ const { dispatch, onChange } = this.props;
dispatch({
type: 'geographic/fetchCity', type: 'geographic/fetchCity',
payload: item.key, payload: item.key,
}); });
this.props.onChange({ onChange({
province: item, province: item,
city: nullSlectItem, city: nullSlectItem,
}); });
}; };
selectCityItem = item => { selectCityItem = item => {
this.props.onChange({ const { value, onChange } = this.props;
province: this.props.value.province, onChange({
province: value.province,
city: item, city: item,
}); });
}; };
conversionObject() { conversionObject() {
const { value } = this.props; const { value } = this.props;
if (!value) { if (!value) {
...@@ -84,10 +98,12 @@ export default class GeographicView extends PureComponent { ...@@ -84,10 +98,12 @@ export default class GeographicView extends PureComponent {
city: city || nullSlectItem, city: city || nullSlectItem,
}; };
} }
render() { render() {
const { province, city } = this.conversionObject(); const { province, city } = this.conversionObject();
const { isLoading } = this.props;
return ( return (
<Spin spinning={this.props.isLoading} wrapperClassName={styles.row}> <Spin spinning={isLoading} wrapperClassName={styles.row}>
<Select <Select
className={styles.item} className={styles.item}
value={province} value={province}
......
...@@ -29,6 +29,16 @@ export default class Info extends Component { ...@@ -29,6 +29,16 @@ export default class Info extends Component {
mode: 'inline', mode: 'inline',
}; };
} }
componentDidMount() {
window.addEventListener('resize', this.resize);
this.resize();
}
componentWillUnmount() {
window.removeEventListener('resize', this.resize);
}
static getDerivedStateFromProps(props, state) { static getDerivedStateFromProps(props, state) {
const { match, location } = props; const { match, location } = props;
let selectKey = location.pathname.replace(`${match.path}/`, ''); let selectKey = location.pathname.replace(`${match.path}/`, '');
...@@ -38,25 +48,24 @@ export default class Info extends Component { ...@@ -38,25 +48,24 @@ export default class Info extends Component {
} }
return null; return null;
} }
componentDidMount() {
window.addEventListener('resize', this.resize);
this.resize();
}
componentWillUnmount() {
window.removeEventListener('resize', this.resize);
}
getmenu = () => { getmenu = () => {
return Object.keys(menuMap).map(item => <Item key={item}>{menuMap[item]}</Item>); return Object.keys(menuMap).map(item => <Item key={item}>{menuMap[item]}</Item>);
}; };
getRightTitle = () => { getRightTitle = () => {
return menuMap[this.state.selectKey]; const { selectKey } = this.state;
return menuMap[selectKey];
}; };
selectKey = ({ key }) => { selectKey = ({ key }) => {
this.props.dispatch(routerRedux.push(`/account/settings/${key}`)); const { dispatch } = this.props;
dispatch(routerRedux.push(`/account/settings/${key}`));
this.setState({ this.setState({
selectKey: key, selectKey: key,
}); });
}; };
resize = () => { resize = () => {
if (!this.main) { if (!this.main) {
return; return;
...@@ -75,11 +84,13 @@ export default class Info extends Component { ...@@ -75,11 +84,13 @@ export default class Info extends Component {
}); });
}); });
}; };
render() { render() {
const { match, routerData, currentUser } = this.props; const { match, routerData, currentUser } = this.props;
if (!currentUser.userid) { if (!currentUser.userid) {
return ''; return '';
} }
const { mode, selectKey } = this.state;
return ( return (
<GridContent> <GridContent>
<div <div
...@@ -89,11 +100,7 @@ export default class Info extends Component { ...@@ -89,11 +100,7 @@ export default class Info extends Component {
}} }}
> >
<div className={styles.leftmenu}> <div className={styles.leftmenu}>
<Menu <Menu mode={mode} selectedKeys={[selectKey]} onClick={this.selectKey}>
mode={this.state.mode}
selectedKeys={[this.state.selectKey]}
onClick={this.selectKey}
>
{this.getmenu()} {this.getmenu()}
</Menu> </Menu>
</div> </div>
......
...@@ -23,6 +23,7 @@ export default class NotificationView extends Component { ...@@ -23,6 +23,7 @@ export default class NotificationView extends Component {
}, },
]; ];
}; };
render() { render() {
return ( return (
<Fragment> <Fragment>
......
...@@ -37,6 +37,7 @@ export default class SecurityView extends Component { ...@@ -37,6 +37,7 @@ export default class SecurityView extends Component {
}, },
]; ];
}; };
render() { render() {
return ( return (
<Fragment> <Fragment>
......
...@@ -27,7 +27,8 @@ const havePermissionAsync = new Promise(resolve => { ...@@ -27,7 +27,8 @@ const havePermissionAsync = new Promise(resolve => {
})) }))
export default class Monitor extends PureComponent { export default class Monitor extends PureComponent {
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'monitor/fetchTags', type: 'monitor/fetchTags',
}); });
} }
......
...@@ -10,21 +10,25 @@ export default class TriggerException extends PureComponent { ...@@ -10,21 +10,25 @@ export default class TriggerException extends PureComponent {
state = { state = {
isloading: false, isloading: false,
}; };
triggerError = code => { triggerError = code => {
this.setState({ this.setState({
isloading: true, isloading: true,
}); });
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'error/query', type: 'error/query',
payload: { payload: {
code, code,
}, },
}); });
}; };
render() { render() {
const { isloading } = this.state;
return ( return (
<Card> <Card>
<Spin spinning={this.state.isloading} wrapperClassName={styles.trigger}> <Spin spinning={isloading} wrapperClassName={styles.trigger}>
<Button type="danger" onClick={() => this.triggerError(401)}> <Button type="danger" onClick={() => this.triggerError(401)}>
触发401 触发401
</Button> </Button>
......
...@@ -61,21 +61,26 @@ class AdvancedForm extends PureComponent { ...@@ -61,21 +61,26 @@ class AdvancedForm extends PureComponent {
state = { state = {
width: '100%', width: '100%',
}; };
componentDidMount() { componentDidMount() {
window.addEventListener('resize', this.resizeFooterToolbar, { passive: true }); window.addEventListener('resize', this.resizeFooterToolbar, { passive: true });
} }
componentWillUnmount() { componentWillUnmount() {
window.removeEventListener('resize', this.resizeFooterToolbar); window.removeEventListener('resize', this.resizeFooterToolbar);
} }
resizeFooterToolbar = () => { resizeFooterToolbar = () => {
requestAnimationFrame(() => { requestAnimationFrame(() => {
const sider = document.querySelectorAll('.ant-layout-sider')[0]; const sider = document.querySelectorAll('.ant-layout-sider')[0];
const width = `calc(100% - ${sider.style.width})`; const width = `calc(100% - ${sider.style.width})`;
if (this.state.width !== width) { const { width: stateWidth } = this.state;
if (stateWidth !== width) {
this.setState({ width }); this.setState({ width });
} }
}); });
}; };
render() { render() {
const { form, dispatch, submitting } = this.props; const { form, dispatch, submitting } = this.props;
const { getFieldDecorator, validateFieldsAndScroll, getFieldsError } = form; const { getFieldDecorator, validateFieldsAndScroll, getFieldsError } = form;
...@@ -129,6 +134,7 @@ class AdvancedForm extends PureComponent { ...@@ -129,6 +134,7 @@ class AdvancedForm extends PureComponent {
</span> </span>
); );
}; };
const { width } = this.state;
return ( return (
<PageHeaderLayout <PageHeaderLayout
title="高级表单" title="高级表单"
...@@ -285,7 +291,7 @@ class AdvancedForm extends PureComponent { ...@@ -285,7 +291,7 @@ class AdvancedForm extends PureComponent {
initialValue: tableData, initialValue: tableData,
})(<TableForm />)} })(<TableForm />)}
</Card> </Card>
<FooterToolbar style={{ width: this.state.width }}> <FooterToolbar style={{ width }}>
{getErrorInfo()} {getErrorInfo()}
<Button type="primary" onClick={validate} loading={submitting}> <Button type="primary" onClick={validate} loading={submitting}>
提交 提交
......
...@@ -26,19 +26,23 @@ const { TextArea } = Input; ...@@ -26,19 +26,23 @@ const { TextArea } = Input;
@Form.create() @Form.create()
export default class BasicForms extends PureComponent { export default class BasicForms extends PureComponent {
handleSubmit = e => { handleSubmit = e => {
const { dispatch, form } = this.props;
e.preventDefault(); e.preventDefault();
this.props.form.validateFieldsAndScroll((err, values) => { form.validateFieldsAndScroll((err, values) => {
if (!err) { if (!err) {
this.props.dispatch({ dispatch({
type: 'form/submitRegularForm', type: 'form/submitRegularForm',
payload: values, payload: values,
}); });
} }
}); });
}; };
render() { render() {
const { submitting } = this.props; const { submitting } = this.props;
const { getFieldDecorator, getFieldValue } = this.props.form; const {
form: { getFieldDecorator, getFieldValue },
} = this.props;
const formItemLayout = { const formItemLayout = {
labelCol: { labelCol: {
......
...@@ -23,6 +23,7 @@ export default class StepForm extends PureComponent { ...@@ -23,6 +23,7 @@ export default class StepForm extends PureComponent {
return 0; return 0;
} }
} }
render() { render() {
const { match, routerData, location } = this.props; const { match, routerData, location } = this.props;
return ( return (
......
...@@ -3,6 +3,10 @@ import { Table, Button, Input, message, Popconfirm, Divider } from 'antd'; ...@@ -3,6 +3,10 @@ import { Table, Button, Input, message, Popconfirm, Divider } from 'antd';
import styles from './style.less'; import styles from './style.less';
export default class TableForm extends PureComponent { export default class TableForm extends PureComponent {
index = 0;
cacheOriginData = {};
constructor(props) { constructor(props) {
super(props); super(props);
...@@ -21,14 +25,16 @@ export default class TableForm extends PureComponent { ...@@ -21,14 +25,16 @@ export default class TableForm extends PureComponent {
} }
return null; return null;
} }
getRowByKey(key, newData) { getRowByKey(key, newData) {
return (newData || this.state.data).filter(item => item.key === key)[0]; const { data } = this.state;
return (newData || data).filter(item => item.key === key)[0];
} }
index = 0;
cacheOriginData = {};
toggleEditable = (e, key) => { toggleEditable = (e, key) => {
e.preventDefault(); e.preventDefault();
const newData = this.state.data.map(item => ({ ...item })); const { data } = this.state;
const newData = data.map(item => ({ ...item }));
const target = this.getRowByKey(key, newData); const target = this.getRowByKey(key, newData);
if (target) { if (target) {
// 进入编辑状态时保存原始数据 // 进入编辑状态时保存原始数据
...@@ -39,13 +45,30 @@ export default class TableForm extends PureComponent { ...@@ -39,13 +45,30 @@ export default class TableForm extends PureComponent {
this.setState({ data: newData }); this.setState({ data: newData });
} }
}; };
newMember = () => {
this.index += 1;
this.setState({
editData: [
{
key: `NEW_TEMP_ID_${this.index}`,
workId: '',
name: '',
department: '',
editable: true,
isNew: true,
},
],
});
};
remove(key) { remove(key) {
const { editData } = this.state; const { editData, data } = this.state;
const { onChange } = this.props;
const editItem = editData.find(item => item.key === key); const editItem = editData.find(item => item.key === key);
if (editItem && editItem.key) { if (editItem && editItem.key) {
// 如果存在缓存 // 如果存在缓存
if (this.cacheOriginData[key]) { if (this.cacheOriginData[key]) {
const data = [...this.state.data];
data.push(this.cacheOriginData[key]); data.push(this.cacheOriginData[key]);
this.setState( this.setState(
{ {
...@@ -62,39 +85,24 @@ export default class TableForm extends PureComponent { ...@@ -62,39 +85,24 @@ export default class TableForm extends PureComponent {
}); });
return; return;
} }
const newData = this.state.data.filter(item => item.key !== key); const newData = data.filter(item => item.key !== key);
this.setState({ data: newData }); this.setState({ data: newData });
this.props.onChange(newData); onChange(newData);
}
newMember = () => {
this.index += 1;
this.setState({
editData: [
{
key: `NEW_TEMP_ID_${this.index}`,
workId: '',
name: '',
department: '',
editable: true,
isNew: true,
},
],
});
};
handleKeyPress(e, key) {
if (e.key === 'Enter') {
this.saveRow(e, key);
}
} }
handleFieldChange(e, fieldName, key) { handleFieldChange(e, fieldName, key) {
const newData = this.state.data.map(item => ({ ...item })); const { data } = this.state;
const newData = data.map(item => ({ ...item }));
const target = this.getRowByKey(key, newData); const target = this.getRowByKey(key, newData);
if (target) { if (target) {
target[fieldName] = e.target.value; target[fieldName] = e.target.value;
this.setState({ data: newData }); this.setState({ data: newData });
} }
} }
saveRow(e, key) { saveRow(e, key) {
const { data } = this.state;
const { onChange } = this.props;
e.persist(); e.persist();
this.setState({ this.setState({
loading: true, loading: true,
...@@ -115,16 +123,18 @@ export default class TableForm extends PureComponent { ...@@ -115,16 +123,18 @@ export default class TableForm extends PureComponent {
} }
delete target.isNew; delete target.isNew;
this.toggleEditable(e, key); this.toggleEditable(e, key);
this.props.onChange(this.state.data); onChange(data);
this.setState({ this.setState({
loading: false, loading: false,
}); });
}, 500); }, 500);
} }
cancel(e, key) { cancel(e, key) {
const { data } = this.state;
this.clickedCancel = true; this.clickedCancel = true;
e.preventDefault(); e.preventDefault();
const newData = this.state.data.map(item => ({ ...item })); const newData = data.map(item => ({ ...item }));
const target = this.getRowByKey(key, newData); const target = this.getRowByKey(key, newData);
if (this.cacheOriginData[key]) { if (this.cacheOriginData[key]) {
Object.assign(target, this.cacheOriginData[key]); Object.assign(target, this.cacheOriginData[key]);
...@@ -134,6 +144,7 @@ export default class TableForm extends PureComponent { ...@@ -134,6 +144,7 @@ export default class TableForm extends PureComponent {
this.setState({ data: newData }); this.setState({ data: newData });
this.clickedCancel = false; this.clickedCancel = false;
} }
render() { render() {
const columns = [ const columns = [
{ {
...@@ -198,7 +209,8 @@ export default class TableForm extends PureComponent { ...@@ -198,7 +209,8 @@ export default class TableForm extends PureComponent {
title: '操作', title: '操作',
key: 'action', key: 'action',
render: (text, record) => { render: (text, record) => {
if (!!record.editable && this.state.loading) { const { loading } = this.state;
if (!!record.editable && loading) {
return null; return null;
} }
if (record.editable) { if (record.editable) {
...@@ -233,11 +245,12 @@ export default class TableForm extends PureComponent { ...@@ -233,11 +245,12 @@ export default class TableForm extends PureComponent {
}, },
}, },
]; ];
const dataSource = this.state.data.concat(this.state.editData); const { data, editData, loading } = this.state;
const dataSource = data.concat(editData);
return ( return (
<Fragment> <Fragment>
<Table <Table
loading={this.state.loading} loading={loading}
columns={columns} columns={columns}
dataSource={dataSource} dataSource={dataSource}
pagination={false} pagination={false}
......
...@@ -19,7 +19,8 @@ const FormItem = Form.Item; ...@@ -19,7 +19,8 @@ const FormItem = Form.Item;
})) }))
export default class FilterCardList extends PureComponent { export default class FilterCardList extends PureComponent {
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/fetch', type: 'list/fetch',
payload: { payload: {
count: 8, count: 8,
...@@ -46,7 +47,11 @@ export default class FilterCardList extends PureComponent { ...@@ -46,7 +47,11 @@ export default class FilterCardList extends PureComponent {
}; };
render() { render() {
const { list: { list }, loading, form } = this.props; const {
list: { list },
loading,
form,
} = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const CardInfo = ({ activeUser, newUser }) => ( const CardInfo = ({ activeUser, newUser }) => (
......
...@@ -30,7 +30,8 @@ export default class SearchList extends Component { ...@@ -30,7 +30,8 @@ export default class SearchList extends Component {
}; };
fetchMore = () => { fetchMore = () => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/appendFetch', type: 'list/appendFetch',
payload: { payload: {
count: pageSize, count: pageSize,
...@@ -39,7 +40,11 @@ export default class SearchList extends Component { ...@@ -39,7 +40,11 @@ export default class SearchList extends Component {
}; };
render() { render() {
const { form, list: { list }, loading } = this.props; const {
form,
list: { list },
loading,
} = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const owners = [ const owners = [
......
...@@ -38,32 +38,37 @@ const { Search, TextArea } = Input; ...@@ -38,32 +38,37 @@ const { Search, TextArea } = Input;
})) }))
@Form.create() @Form.create()
export default class BasicList extends PureComponent { export default class BasicList extends PureComponent {
formLayout = {
labelCol: { span: 7 },
wrapperCol: { span: 13 },
};
state = { visible: false, done: false }; state = { visible: false, done: false };
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/fetch', type: 'list/fetch',
payload: { payload: {
count: 5, count: 5,
}, },
}); });
} }
formLayout = {
labelCol: { span: 7 },
wrapperCol: { span: 13 },
};
showModal = () => { showModal = () => {
this.setState({ this.setState({
visible: true, visible: true,
current: undefined, current: undefined,
}); });
}; };
showEditModal = item => { showEditModal = item => {
this.setState({ this.setState({
visible: true, visible: true,
current: item, current: item,
}); });
}; };
handleDone = () => { handleDone = () => {
setTimeout(() => this.addBtn.blur(), 0); setTimeout(() => this.addBtn.blur(), 0);
this.setState({ this.setState({
...@@ -71,16 +76,19 @@ export default class BasicList extends PureComponent { ...@@ -71,16 +76,19 @@ export default class BasicList extends PureComponent {
visible: false, visible: false,
}); });
}; };
handleCancel = () => { handleCancel = () => {
setTimeout(() => this.addBtn.blur(), 0); setTimeout(() => this.addBtn.blur(), 0);
this.setState({ this.setState({
visible: false, visible: false,
}); });
}; };
handleSubmit = e => { handleSubmit = e => {
e.preventDefault(); e.preventDefault();
const { dispatch, form } = this.props; const { dispatch, form } = this.props;
const id = this.state.current ? this.state.current.id : ''; const { current } = this.state;
const id = current ? current.id : '';
setTimeout(() => this.addBtn.blur(), 0); setTimeout(() => this.addBtn.blur(), 0);
form.validateFields((err, fieldsValue) => { form.validateFields((err, fieldsValue) => {
...@@ -94,16 +102,23 @@ export default class BasicList extends PureComponent { ...@@ -94,16 +102,23 @@ export default class BasicList extends PureComponent {
}); });
}); });
}; };
deleteItem = id => { deleteItem = id => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/submit', type: 'list/submit',
payload: { id }, payload: { id },
}); });
}; };
render() { render() {
const { list: { list }, loading } = this.props; const {
const { getFieldDecorator } = this.props.form; list: { list },
loading,
} = this.props;
const {
form: { getFieldDecorator },
} = this.props;
const { visible, done, current = {} } = this.state; const { visible, done, current = {} } = this.state;
const editAndDelete = (key, currentItem) => { const editAndDelete = (key, currentItem) => {
...@@ -237,7 +252,6 @@ export default class BasicList extends PureComponent { ...@@ -237,7 +252,6 @@ export default class BasicList extends PureComponent {
</Form> </Form>
); );
}; };
return ( return (
<PageHeaderLayout> <PageHeaderLayout>
<div className={styles.standardList}> <div className={styles.standardList}>
...@@ -308,7 +322,7 @@ export default class BasicList extends PureComponent { ...@@ -308,7 +322,7 @@ export default class BasicList extends PureComponent {
</Card> </Card>
</div> </div>
<Modal <Modal
title={done ? null : `任务${this.state.current ? '编辑' : '添加'}`} title={done ? null : `任务${current ? '编辑' : '添加'}`}
className={styles.standardListForm} className={styles.standardListForm}
width={640} width={640}
bodyStyle={done ? { padding: '72px 0' } : { padding: '28px 0 0' }} bodyStyle={done ? { padding: '72px 0' } : { padding: '28px 0 0' }}
......
...@@ -13,7 +13,8 @@ import styles from './CardList.less'; ...@@ -13,7 +13,8 @@ import styles from './CardList.less';
})) }))
export default class CardList extends PureComponent { export default class CardList extends PureComponent {
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/fetch', type: 'list/fetch',
payload: { payload: {
count: 8, count: 8,
...@@ -22,7 +23,10 @@ export default class CardList extends PureComponent { ...@@ -22,7 +23,10 @@ export default class CardList extends PureComponent {
} }
render() { render() {
const { list: { list }, loading } = this.props; const {
list: { list },
loading,
} = this.props;
const content = ( const content = (
<div className={styles.pageHeaderContent}> <div className={styles.pageHeaderContent}>
......
...@@ -21,7 +21,8 @@ const FormItem = Form.Item; ...@@ -21,7 +21,8 @@ const FormItem = Form.Item;
})) }))
export default class CoverCardList extends PureComponent { export default class CoverCardList extends PureComponent {
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'list/fetch', type: 'list/fetch',
payload: { payload: {
count: 8, count: 8,
...@@ -48,7 +49,11 @@ export default class CoverCardList extends PureComponent { ...@@ -48,7 +49,11 @@ export default class CoverCardList extends PureComponent {
}; };
render() { render() {
const { list: { list = [] }, loading, form } = this.props; const {
list: { list = [] },
loading,
form,
} = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const cardList = list ? ( const cardList = list ? (
......
...@@ -88,11 +88,13 @@ class UpdateForm extends PureComponent { ...@@ -88,11 +88,13 @@ class UpdateForm extends PureComponent {
wrapperCol: { span: 13 }, wrapperCol: { span: 13 },
}; };
} }
handleNext = currentStep => { handleNext = currentStep => {
const { form, handleUpdate } = this.props; const { form, handleUpdate } = this.props;
const { formVals: oldValue } = this.state;
form.validateFields((err, fieldsValue) => { form.validateFields((err, fieldsValue) => {
if (err) return; if (err) return;
const formVals = { ...this.state.formVals, ...fieldsValue }; const formVals = { ...oldValue, ...fieldsValue };
this.setState( this.setState(
{ {
formVals, formVals,
...@@ -101,22 +103,27 @@ class UpdateForm extends PureComponent { ...@@ -101,22 +103,27 @@ class UpdateForm extends PureComponent {
if (currentStep < 2) { if (currentStep < 2) {
this.forward(); this.forward();
} else { } else {
handleUpdate(this.state.formVals); handleUpdate(formVals);
} }
} }
); );
}); });
}; };
backward = () => { backward = () => {
const { currentStep } = this.state;
this.setState({ this.setState({
currentStep: this.state.currentStep - 1, currentStep: currentStep - 1,
}); });
}; };
forward = () => { forward = () => {
const { currentStep } = this.state;
this.setState({ this.setState({
currentStep: this.state.currentStep + 1, currentStep: currentStep + 1,
}); });
}; };
renderContent = (currentStep, formVals) => { renderContent = (currentStep, formVals) => {
const { form } = this.props; const { form } = this.props;
if (currentStep === 1) { if (currentStep === 1) {
...@@ -194,6 +201,7 @@ class UpdateForm extends PureComponent { ...@@ -194,6 +201,7 @@ class UpdateForm extends PureComponent {
</FormItem>, </FormItem>,
]; ];
}; };
renderFooter = currentStep => { renderFooter = currentStep => {
const { handleUpdateModalVisible } = this.props; const { handleUpdateModalVisible } = this.props;
if (currentStep === 1) { if (currentStep === 1) {
...@@ -231,6 +239,7 @@ class UpdateForm extends PureComponent { ...@@ -231,6 +239,7 @@ class UpdateForm extends PureComponent {
</Button>, </Button>,
]; ];
}; };
render() { render() {
const { updateModalVisible, handleUpdateModalVisible } = this.props; const { updateModalVisible, handleUpdateModalVisible } = this.props;
const { currentStep, formVals } = this.state; const { currentStep, formVals } = this.state;
...@@ -263,22 +272,6 @@ class UpdateForm extends PureComponent { ...@@ -263,22 +272,6 @@ class UpdateForm extends PureComponent {
})) }))
@Form.create() @Form.create()
export default class TableList extends PureComponent { export default class TableList extends PureComponent {
state = {
modalVisible: false,
updateModalVisible: false,
expandForm: false,
selectedRows: [],
formValues: {},
stepFormValues: {},
};
componentDidMount() {
const { dispatch } = this.props;
dispatch({
type: 'rule/fetch',
});
}
columns = [ columns = [
{ {
title: '规则名称', title: '规则名称',
...@@ -340,6 +333,22 @@ export default class TableList extends PureComponent { ...@@ -340,6 +333,22 @@ export default class TableList extends PureComponent {
}, },
]; ];
state = {
modalVisible: false,
updateModalVisible: false,
expandForm: false,
selectedRows: [],
formValues: {},
stepFormValues: {},
};
componentDidMount() {
const { dispatch } = this.props;
dispatch({
type: 'rule/fetch',
});
}
handleStandardTableChange = (pagination, filtersArg, sorter) => { handleStandardTableChange = (pagination, filtersArg, sorter) => {
const { dispatch } = this.props; const { dispatch } = this.props;
const { formValues } = this.state; const { formValues } = this.state;
...@@ -379,8 +388,9 @@ export default class TableList extends PureComponent { ...@@ -379,8 +388,9 @@ export default class TableList extends PureComponent {
}; };
toggleForm = () => { toggleForm = () => {
const { expandForm } = this.state;
this.setState({ this.setState({
expandForm: !this.state.expandForm, expandForm: !expandForm,
}); });
}; };
...@@ -452,7 +462,8 @@ export default class TableList extends PureComponent { ...@@ -452,7 +462,8 @@ export default class TableList extends PureComponent {
}; };
handleAdd = fields => { handleAdd = fields => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'rule/add', type: 'rule/add',
payload: { payload: {
desc: fields.desc, desc: fields.desc,
...@@ -464,7 +475,8 @@ export default class TableList extends PureComponent { ...@@ -464,7 +475,8 @@ export default class TableList extends PureComponent {
}; };
handleUpdate = fields => { handleUpdate = fields => {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'rule/update', type: 'rule/update',
payload: { payload: {
name: fields.name, name: fields.name,
...@@ -478,7 +490,9 @@ export default class TableList extends PureComponent { ...@@ -478,7 +490,9 @@ export default class TableList extends PureComponent {
}; };
renderSimpleForm() { renderSimpleForm() {
const { getFieldDecorator } = this.props.form; const {
form: { getFieldDecorator },
} = this.props;
return ( return (
<Form onSubmit={this.handleSearch} layout="inline"> <Form onSubmit={this.handleSearch} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}> <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
...@@ -516,7 +530,9 @@ export default class TableList extends PureComponent { ...@@ -516,7 +530,9 @@ export default class TableList extends PureComponent {
} }
renderAdvancedForm() { renderAdvancedForm() {
const { getFieldDecorator } = this.props.form; const {
form: { getFieldDecorator },
} = this.props;
return ( return (
<Form onSubmit={this.handleSearch} layout="inline"> <Form onSubmit={this.handleSearch} layout="inline">
<Row gutter={{ md: 8, lg: 24, xl: 48 }}> <Row gutter={{ md: 8, lg: 24, xl: 48 }}>
...@@ -588,11 +604,15 @@ export default class TableList extends PureComponent { ...@@ -588,11 +604,15 @@ export default class TableList extends PureComponent {
} }
renderForm() { renderForm() {
return this.state.expandForm ? this.renderAdvancedForm() : this.renderSimpleForm(); const { expandForm } = this.state;
return expandForm ? this.renderAdvancedForm() : this.renderSimpleForm();
} }
render() { render() {
const { rule: { data }, loading } = this.props; const {
rule: { data },
loading,
} = this.props;
const { selectedRows, modalVisible, updateModalVisible, stepFormValues } = this.state; const { selectedRows, modalVisible, updateModalVisible, stepFormValues } = this.state;
const menu = ( const menu = (
<Menu onClick={this.handleMenuClick} selectedKeys={[]}> <Menu onClick={this.handleMenuClick} selectedKeys={[]}>
......
...@@ -27,8 +27,8 @@ export default class LoginPage extends Component { ...@@ -27,8 +27,8 @@ export default class LoginPage extends Component {
if (err) { if (err) {
reject(err); reject(err);
} else { } else {
this.props const { dispatch } = this.props;
.dispatch({ dispatch({
type: 'login/getCaptcha', type: 'login/getCaptcha',
payload: values.mobile, payload: values.mobile,
}) })
...@@ -38,11 +38,12 @@ export default class LoginPage extends Component { ...@@ -38,11 +38,12 @@ export default class LoginPage extends Component {
}); });
}); });
}; };
loginForm;
handleSubmit = (err, values) => { handleSubmit = (err, values) => {
const { type } = this.state; const { type } = this.state;
if (!err) { if (!err) {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'login/login', type: 'login/login',
payload: { payload: {
...values, ...values,
...@@ -58,13 +59,15 @@ export default class LoginPage extends Component { ...@@ -58,13 +59,15 @@ export default class LoginPage extends Component {
}); });
}; };
loginForm;
renderMessage = content => { renderMessage = content => {
return <Alert style={{ marginBottom: 24 }} message={content} type="error" showIcon />; return <Alert style={{ marginBottom: 24 }} message={content} type="error" showIcon />;
}; };
render() { render() {
const { login, submitting } = this.props; const { login, submitting } = this.props;
const { type } = this.state; const { type, autoLogin } = this.state;
return ( return (
<div className={styles.main}> <div className={styles.main}>
<Login <Login
...@@ -92,7 +95,7 @@ export default class LoginPage extends Component { ...@@ -92,7 +95,7 @@ export default class LoginPage extends Component {
<Captcha name="captcha" countDown={120} onGetCaptcha={this.onGetCaptcha} /> <Captcha name="captcha" countDown={120} onGetCaptcha={this.onGetCaptcha} />
</Tab> </Tab>
<div> <div>
<Checkbox checked={this.state.autoLogin} onChange={this.changeAutoLogin}> <Checkbox checked={autoLogin} onChange={this.changeAutoLogin}>
自动登录 自动登录
</Checkbox> </Checkbox>
<a style={{ float: 'right' }} href=""> <a style={{ float: 'right' }} href="">
......
...@@ -35,9 +35,10 @@ export default class Register extends Component { ...@@ -35,9 +35,10 @@ export default class Register extends Component {
}; };
componentDidUpdate() { componentDidUpdate() {
const account = this.props.form.getFieldValue('mail'); const { form, register, dispatch } = this.props;
if (this.props.register.status === 'ok') { const account = form.getFieldValue('mail');
this.props.dispatch( if (register.status === 'ok') {
dispatch(
routerRedux.push({ routerRedux.push({
pathname: '/user/register-result', pathname: '/user/register-result',
state: { state: {
...@@ -47,6 +48,7 @@ export default class Register extends Component { ...@@ -47,6 +48,7 @@ export default class Register extends Component {
); );
} }
} }
componentWillUnmount() { componentWillUnmount() {
clearInterval(this.interval); clearInterval(this.interval);
} }
...@@ -77,13 +79,15 @@ export default class Register extends Component { ...@@ -77,13 +79,15 @@ export default class Register extends Component {
handleSubmit = e => { handleSubmit = e => {
e.preventDefault(); e.preventDefault();
this.props.form.validateFields({ force: true }, (err, values) => { const { form, dispatch } = this.props;
form.validateFields({ force: true }, (err, values) => {
if (!err) { if (!err) {
this.props.dispatch({ const { prefix } = this.state;
dispatch({
type: 'register/submit', type: 'register/submit',
payload: { payload: {
...values, ...values,
prefix: this.state.prefix, prefix,
}, },
}); });
} }
...@@ -92,7 +96,8 @@ export default class Register extends Component { ...@@ -92,7 +96,8 @@ export default class Register extends Component {
handleConfirmBlur = e => { handleConfirmBlur = e => {
const { value } = e.target; const { value } = e.target;
this.setState({ confirmDirty: this.state.confirmDirty || !!value }); const { confirmDirty } = this.state;
this.setState({ confirmDirty: confirmDirty || !!value });
}; };
checkConfirm = (rule, value, callback) => { checkConfirm = (rule, value, callback) => {
...@@ -105,6 +110,7 @@ export default class Register extends Component { ...@@ -105,6 +110,7 @@ export default class Register extends Component {
}; };
checkPassword = (rule, value, callback) => { checkPassword = (rule, value, callback) => {
const { visible, confirmDirty } = this.state;
if (!value) { if (!value) {
this.setState({ this.setState({
help: '请输入密码!', help: '请输入密码!',
...@@ -115,7 +121,7 @@ export default class Register extends Component { ...@@ -115,7 +121,7 @@ export default class Register extends Component {
this.setState({ this.setState({
help: '', help: '',
}); });
if (!this.state.visible) { if (!visible) {
this.setState({ this.setState({
visible: !!value, visible: !!value,
}); });
...@@ -124,7 +130,7 @@ export default class Register extends Component { ...@@ -124,7 +130,7 @@ export default class Register extends Component {
callback('error'); callback('error');
} else { } else {
const { form } = this.props; const { form } = this.props;
if (value && this.state.confirmDirty) { if (value && confirmDirty) {
form.validateFields(['confirm'], { force: true }); form.validateFields(['confirm'], { force: true });
} }
callback(); callback();
...@@ -158,7 +164,7 @@ export default class Register extends Component { ...@@ -158,7 +164,7 @@ export default class Register extends Component {
render() { render() {
const { form, submitting } = this.props; const { form, submitting } = this.props;
const { getFieldDecorator } = form; const { getFieldDecorator } = form;
const { count, prefix } = this.state; const { count, prefix, help, visible } = this.state;
return ( return (
<div className={styles.main}> <div className={styles.main}>
<h3>注册</h3> <h3>注册</h3>
...@@ -177,7 +183,7 @@ export default class Register extends Component { ...@@ -177,7 +183,7 @@ export default class Register extends Component {
], ],
})(<Input size="large" placeholder="邮箱" />)} })(<Input size="large" placeholder="邮箱" />)}
</FormItem> </FormItem>
<FormItem help={this.state.help}> <FormItem help={help}>
<Popover <Popover
content={ content={
<div style={{ padding: '4px 0' }}> <div style={{ padding: '4px 0' }}>
...@@ -190,7 +196,7 @@ export default class Register extends Component { ...@@ -190,7 +196,7 @@ export default class Register extends Component {
} }
overlayStyle={{ width: 240 }} overlayStyle={{ width: 240 }}
placement="right" placement="right"
visible={this.state.visible} visible={visible}
> >
{getFieldDecorator('password', { {getFieldDecorator('password', {
rules: [ rules: [
......
...@@ -7,14 +7,18 @@ export default class Yuan extends React.PureComponent { ...@@ -7,14 +7,18 @@ export default class Yuan extends React.PureComponent {
componentDidMount() { componentDidMount() {
this.rendertoHtml(); this.rendertoHtml();
} }
componentDidUpdate() { componentDidUpdate() {
this.rendertoHtml(); this.rendertoHtml();
} }
rendertoHtml = () => { rendertoHtml = () => {
const { children } = this.props;
if (this.main) { if (this.main) {
this.main.innerHTML = yuan(this.props.children); this.main.innerHTML = yuan(children);
} }
}; };
render() { render() {
return ( return (
<span <span
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment