Commit cfbf108b authored by 陈帅's avatar 陈帅

fix the problem that the chart cannot be displayed

parent 64f9cbe6
...@@ -31,14 +31,14 @@ ...@@ -31,14 +31,14 @@
"dva-loading": "^2.0.3", "dva-loading": "^2.0.3",
"enquire-js": "^0.2.1", "enquire-js": "^0.2.1",
"lodash": "^4.17.4", "lodash": "^4.17.4",
"lodash-decorators": "^5.0.1", "lodash-decorators": "^6.0.0",
"moment": "^2.22.0", "moment": "^2.22.0",
"numeral": "^2.0.6", "numeral": "^2.0.6",
"omit.js": "^1.0.0", "omit.js": "^1.0.0",
"path-to-regexp": "^2.1.0", "path-to-regexp": "^2.1.0",
"prop-types": "^15.5.10", "prop-types": "^15.5.10",
"qs": "^6.5.0", "qs": "^6.5.0",
"rc-drawer": "^1.2.0", "rc-drawer": "^1.3.1",
"react": "^16.4.0", "react": "^16.4.0",
"react-container-query": "^0.11.0", "react-container-query": "^0.11.0",
"react-document-title": "^2.0.3", "react-document-title": "^2.0.3",
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
"cross-port-killer": "^1.0.1", "cross-port-killer": "^1.0.1",
"enzyme": "^3.1.0", "enzyme": "^3.1.0",
"eslint": "^4.14.0", "eslint": "^4.14.0",
"eslint-config-airbnb": "^16.0.0", "eslint-config-airbnb": "^17.0.0",
"eslint-config-prettier": "^2.9.0", "eslint-config-prettier": "^2.9.0",
"eslint-plugin-babel": "^5.1.0", "eslint-plugin-babel": "^5.1.0",
"eslint-plugin-compat": "^2.4.0", "eslint-plugin-compat": "^2.4.0",
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
"roadhog": "^2.4.2", "roadhog": "^2.4.2",
"roadhog-api-doc": "^1.0.4", "roadhog-api-doc": "^1.0.4",
"stylelint": "^9.2.1", "stylelint": "^9.2.1",
"stylelint-config-prettier": "^3.0.4", "stylelint-config-prettier": "^3.3.0",
"stylelint-config-standard": "^18.0.0" "stylelint-config-standard": "^18.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
......
...@@ -20,19 +20,9 @@ const renderTotal = total => { ...@@ -20,19 +20,9 @@ const renderTotal = total => {
}; };
class ChartCard extends React.PureComponent { class ChartCard extends React.PureComponent {
state = {
loading: true,
};
componentDidMount() {
requestAnimationFrame(() => {
this.setState({
loading: false,
});
});
}
renderConnet = () => { renderConnet = () => {
const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props; const { contentHeight, title, avatar, action, total, footer, children, loading } = this.props;
if (loading || this.state.loading) { if (loading) {
return false; return false;
} }
return ( return (
...@@ -68,6 +58,7 @@ class ChartCard extends React.PureComponent { ...@@ -68,6 +58,7 @@ class ChartCard extends React.PureComponent {
</div> </div>
); );
}; };
render() { render() {
const { const {
loading = false, loading = false,
...@@ -81,11 +72,7 @@ class ChartCard extends React.PureComponent { ...@@ -81,11 +72,7 @@ class ChartCard extends React.PureComponent {
...rest ...rest
} = this.props; } = this.props;
return ( return (
<Card <Card loading={loading} bodyStyle={{ padding: '20px 24px 8px 24px' }} {...rest}>
loading={loading || this.state.loading}
bodyStyle={{ padding: '20px 24px 8px 24px' }}
{...rest}
>
{this.renderConnet()} {this.renderConnet()}
</Card> </Card>
); );
......
...@@ -34,36 +34,44 @@ class LoadingPage extends PureComponent { ...@@ -34,36 +34,44 @@ class LoadingPage extends PureComponent {
loading: true, loading: true,
isMobile: false, isMobile: false,
}; };
componentDidMount() { componentDidMount() {
const { dispatch } = this.props;
this.enquireHandler = enquireScreen(mobile => { this.enquireHandler = enquireScreen(mobile => {
this.setState({ this.setState({
isMobile: mobile, isMobile: mobile,
}); });
}); });
this.props.dispatch({ dispatch({
type: 'user/fetchCurrent', type: 'user/fetchCurrent',
}); });
this.hideLoading(); this.hideLoading();
this.initSetting(); this.initSetting();
} }
componentWillUnmount() { componentWillUnmount() {
unenquireScreen(this.enquireHandler); unenquireScreen(this.enquireHandler);
} }
hideLoading() { hideLoading() {
this.setState({ this.setState({
loading: false, loading: false,
}); });
} }
/** /**
* get setting from url params * get setting from url params
*/ */
initSetting() { initSetting() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'setting/getSetting', type: 'setting/getSetting',
}); });
} }
render() { render() {
if (this.state.loading) { const { loading, isMobile } = this.state;
if (loading) {
return ( return (
<div <div
style={{ style={{
...@@ -80,7 +88,7 @@ class LoadingPage extends PureComponent { ...@@ -80,7 +88,7 @@ class LoadingPage extends PureComponent {
} }
return ( return (
<BasicLayout <BasicLayout
isMobile={this.state.isMobile} isMobile={isMobile}
menuData={MenuData} menuData={MenuData}
redirectData={redirectData} redirectData={redirectData}
{...this.props} {...this.props}
......
...@@ -55,7 +55,8 @@ export default class Analysis extends Component { ...@@ -55,7 +55,8 @@ export default class Analysis extends Component {
}; };
componentDidMount() { componentDidMount() {
this.props.dispatch({ const { dispatch } = this.props;
dispatch({
type: 'chart/fetch', type: 'chart/fetch',
}); });
} }
...@@ -80,21 +81,23 @@ export default class Analysis extends Component { ...@@ -80,21 +81,23 @@ export default class Analysis extends Component {
}; };
handleRangePickerChange = rangePickerValue => { handleRangePickerChange = rangePickerValue => {
const { dispatch } = this.props;
this.setState({ this.setState({
rangePickerValue, rangePickerValue,
}); });
this.props.dispatch({ dispatch({
type: 'chart/fetchSalesData', type: 'chart/fetchSalesData',
}); });
}; };
selectDate = type => { selectDate = type => {
const { dispatch } = this.props;
this.setState({ this.setState({
rangePickerValue: getTimeDistance(type), rangePickerValue: getTimeDistance(type),
}); });
this.props.dispatch({ dispatch({
type: 'chart/fetchSalesData', type: 'chart/fetchSalesData',
}); });
}; };
...@@ -200,7 +203,10 @@ export default class Analysis extends Component { ...@@ -200,7 +203,10 @@ export default class Analysis extends Component {
sorter: (a, b) => a.range - b.range, sorter: (a, b) => a.range - b.range,
render: (text, record) => ( render: (text, record) => (
<Trend flag={record.status === 1 ? 'down' : 'up'}> <Trend flag={record.status === 1 ? 'down' : 'up'}>
<span style={{ marginRight: 4 }}>{text}%</span> <span style={{ marginRight: 4 }}>
{text}
%
</span>
</Trend> </Trend>
), ),
align: 'right', align: 'right',
...@@ -255,21 +261,25 @@ export default class Analysis extends Component { ...@@ -255,21 +261,25 @@ export default class Analysis extends Component {
<Icon type="info-circle-o" /> <Icon type="info-circle-o" />
</Tooltip> </Tooltip>
} }
loading={loading}
total={() => <Yuan>126560</Yuan>} total={() => <Yuan>126560</Yuan>}
footer={<Field label="日均销售额" value={`¥${numeral(12423).format('0,0')}`} />} footer={<Field label="日均销售额" value={`¥${numeral(12423).format('0,0')}`} />}
contentHeight={46} contentHeight={46}
> >
<Trend flag="up" style={{ marginRight: 16 }}> <Trend flag="up" style={{ marginRight: 16 }}>
周同比<span className={styles.trendText}>12%</span> 周同比
<span className={styles.trendText}>12%</span>
</Trend> </Trend>
<Trend flag="down"> <Trend flag="down">
日环比<span className={styles.trendText}>11%</span> 日环比
<span className={styles.trendText}>11%</span>
</Trend> </Trend>
</ChartCard> </ChartCard>
</Col> </Col>
<Col {...topColResponsiveProps}> <Col {...topColResponsiveProps}>
<ChartCard <ChartCard
bordered={false} bordered={false}
loading={loading}
title="访问量" title="访问量"
action={ action={
<Tooltip title="指标说明"> <Tooltip title="指标说明">
...@@ -286,6 +296,7 @@ export default class Analysis extends Component { ...@@ -286,6 +296,7 @@ export default class Analysis extends Component {
<Col {...topColResponsiveProps}> <Col {...topColResponsiveProps}>
<ChartCard <ChartCard
bordered={false} bordered={false}
loading={loading}
title="支付笔数" title="支付笔数"
action={ action={
<Tooltip title="指标说明"> <Tooltip title="指标说明">
...@@ -301,6 +312,7 @@ export default class Analysis extends Component { ...@@ -301,6 +312,7 @@ export default class Analysis extends Component {
</Col> </Col>
<Col {...topColResponsiveProps}> <Col {...topColResponsiveProps}>
<ChartCard <ChartCard
loading={loading}
bordered={false} bordered={false}
title="运营活动效果" title="运营活动效果"
action={ action={
...@@ -312,10 +324,12 @@ export default class Analysis extends Component { ...@@ -312,10 +324,12 @@ export default class Analysis extends Component {
footer={ footer={
<div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}> <div style={{ whiteSpace: 'nowrap', overflow: 'hidden' }}>
<Trend flag="up" style={{ marginRight: 16 }}> <Trend flag="up" style={{ marginRight: 16 }}>
周同比<span className={styles.trendText}>12%</span> 周同比
<span className={styles.trendText}>12%</span>
</Trend> </Trend>
<Trend flag="down"> <Trend flag="down">
日环比<span className={styles.trendText}>11%</span> 日环比
<span className={styles.trendText}>11%</span>
</Trend> </Trend>
</div> </div>
} }
......
...@@ -71,7 +71,9 @@ export default class Workplace extends PureComponent { ...@@ -71,7 +71,9 @@ export default class Workplace extends PureComponent {
} }
renderActivities() { renderActivities() {
const { activities: { list } } = this.props; const {
activities: { list },
} = this.props;
return list.map(item => { return list.map(item => {
const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => { const events = item.template.split(/@\{([^{}]*)\}/gi).map(key => {
if (item[key]) { if (item[key]) {
......
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