diff --git a/package.json b/package.json index 4b7f7f15..ceef972c 100755 --- a/package.json +++ b/package.json @@ -35,6 +35,7 @@ "eslint-plugin-babel": "^4.0.0", "eslint-plugin-import": "^2.2.0", "eslint-plugin-jsx-a11y": "^5.0.1", + "eslint-plugin-markdown": "^1.0.0-beta.6", "eslint-plugin-react": "^7.0.1", "gh-pages": "^1.0.0", "husky": "^0.13.4", diff --git a/src/components/ActiveChart/index.js b/src/components/ActiveChart/index.js new file mode 100644 index 00000000..1ab1cd54 --- /dev/null +++ b/src/components/ActiveChart/index.js @@ -0,0 +1,77 @@ +import React, { PureComponent } from 'react'; + +import { NumberInfo, MiniArea } from '../Charts'; +import { fixedZero } from '../../utils/utils'; + +import styles from './index.less'; + +function getActiveData() { + const activeData = []; + for (let i = 0; i < 24; i += 1) { + activeData.push({ + x: `${fixedZero(i)}:00`, + y: (i * 50) + (Math.floor(Math.random() * 200)), + }); + } + return activeData; +} + +export default class ActiveChart extends PureComponent { + state = { + activeData: getActiveData(), + } + + componentDidMount() { + setInterval(() => { + this.setState({ + activeData: getActiveData(), + }); + }, 1000); + } + + render() { + const { activeData = [] } = this.state; + + return ( +
+ +
+ +
+ { + activeData && ( +
+

{[...activeData].sort()[activeData.length - 1].y + 200} 亿元

+

{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元

+
+ ) + } + { + activeData && ( +
+ 00:00 + {activeData[Math.floor(activeData.length / 2)].x} + {activeData[activeData.length - 1].x} +
+ ) + } +
+ ); + } +} diff --git a/src/components/ActiveChart/index.less b/src/components/ActiveChart/index.less new file mode 100644 index 00000000..0f781470 --- /dev/null +++ b/src/components/ActiveChart/index.less @@ -0,0 +1,34 @@ +@import "~antd/lib/style/themes/default.less"; +@import "../../utils/utils.less"; + +.activeChart { + position: relative; +} +.activeChartGrid { + p { + position: absolute; + top: 80px; + } + p:last-child { + top: 115px; + } +} +.activeChartLegend { + position: relative; + font-size: 0; + margin-top: 8px; + height: 20px; + line-height: 20px; + span { + display: inline-block; + font-size: 12px; + text-align: center; + width: 33.33%; + } + span:first-child { + text-align: left; + } + span:last-child { + text-align: right; + } +} diff --git a/src/components/Charts/Bar/index.js b/src/components/Charts/Bar/index.js index 537c4fc4..765f5eb4 100644 --- a/src/components/Charts/Bar/index.js +++ b/src/components/Charts/Bar/index.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import G2 from 'g2'; +import equal from '../equal'; import styles from '../index.less'; class Bar extends PureComponent { @@ -8,7 +9,7 @@ class Bar extends PureComponent { } componentWillReceiveProps(nextProps) { - if (nextProps.data !== this.props.data) { + if (!equal(this.props, nextProps)) { this.renderChart(nextProps.data); } } diff --git a/src/components/Charts/Gauge/index.js b/src/components/Charts/Gauge/index.js index 0c53540e..dcd3779c 100644 --- a/src/components/Charts/Gauge/index.js +++ b/src/components/Charts/Gauge/index.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import G2 from 'g2'; +import equal from '../equal'; const Shape = G2.Shape; @@ -10,7 +11,9 @@ class Gauge extends PureComponent { } componentWillReceiveProps(nextProps) { - this.renderChart(nextProps); + if (!equal(this.props, nextProps)) { + this.renderChart(nextProps); + } } handleRef = (n) => { diff --git a/src/components/Charts/MiniArea/index.js b/src/components/Charts/MiniArea/index.js index 5807c352..12fe4c45 100644 --- a/src/components/Charts/MiniArea/index.js +++ b/src/components/Charts/MiniArea/index.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import G2 from 'g2'; +import equal from '../equal'; import styles from '../index.less'; class MiniArea extends PureComponent { @@ -8,7 +9,7 @@ class MiniArea extends PureComponent { } componentWillReceiveProps(nextProps) { - if (nextProps.data !== this.props.data) { + if (!equal(this.props, nextProps)) { this.renderChart(nextProps.data); } } @@ -18,7 +19,7 @@ class MiniArea extends PureComponent { } renderChart(data) { - const { height = 0, fit = true, color = '#33abfb', line, xAxis, yAxis } = this.props; + const { height = 0, fit = true, color = '#33abfb', line, xAxis, yAxis, animate = true } = this.props; if (!data || (data && data.length < 1)) { return; @@ -31,6 +32,7 @@ class MiniArea extends PureComponent { container: this.node, forceFit: fit, height: height + 54, + animate, plotCfg: { margin: [36, 0, 30, 0], }, diff --git a/src/components/Charts/MiniBar/index.js b/src/components/Charts/MiniBar/index.js index d0553a7f..d71517f8 100644 --- a/src/components/Charts/MiniBar/index.js +++ b/src/components/Charts/MiniBar/index.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import G2 from 'g2'; +import equal from '../equal'; import styles from '../index.less'; class MiniBar extends PureComponent { @@ -8,7 +9,7 @@ class MiniBar extends PureComponent { } componentWillReceiveProps(nextProps) { - if (nextProps.data !== this.props.data) { + if (!equal(this.props, nextProps)) { this.renderChart(nextProps.data); } } diff --git a/src/components/Charts/MiniProgress/index.js b/src/components/Charts/MiniProgress/index.js index 63037a1c..8d1d82a2 100644 --- a/src/components/Charts/MiniProgress/index.js +++ b/src/components/Charts/MiniProgress/index.js @@ -1,16 +1,19 @@ import React from 'react'; +import { Popover } from 'antd'; import styles from './index.less'; const MiniProgress = ({ target, color, strokeWidth, percent }) => (
-
- - -
+ +
+ + +
+
{ diff --git a/src/components/Charts/Radar/index.js b/src/components/Charts/Radar/index.js index 1ac14375..12640774 100644 --- a/src/components/Charts/Radar/index.js +++ b/src/components/Charts/Radar/index.js @@ -1,6 +1,7 @@ import React, { PureComponent } from 'react'; import G2 from 'g2'; import { Row, Col } from 'antd'; +import equal from '../equal'; import styles from './index.less'; /* eslint react/no-danger:0 */ @@ -14,7 +15,7 @@ class Radar extends PureComponent { } componentWillReceiveProps(nextProps) { - if (nextProps.data !== this.props.data) { + if (!equal(this.props, nextProps)) { this.renderChart(nextProps.data); } } diff --git a/src/components/Charts/equal.js b/src/components/Charts/equal.js new file mode 100644 index 00000000..ff3a4c70 --- /dev/null +++ b/src/components/Charts/equal.js @@ -0,0 +1,17 @@ +/* eslint eqeqeq: 0 */ + +function equal(old, target) { + let r = true; + for (const prop in old) { + if (typeof old[prop] === 'function' && typeof target[prop] === 'function') { + if (old[prop].toString() != target[prop].toString()) { + r = false; + } + } else if (old[prop] != target[prop]) { + r = false; + } + } + return r; +} + +export default equal; diff --git a/src/components/SearchInput/index.js b/src/components/SearchInput/index.js index e5e4403c..36bb90ff 100644 --- a/src/components/SearchInput/index.js +++ b/src/components/SearchInput/index.js @@ -3,13 +3,43 @@ import { Button, Input } from 'antd'; import styles from './index.less'; -export default ({ onSearch = () => ({}), text = '搜索', ...reset }) => ( -
- {text}} - /> -
-); +export default class SearchInput extends React.Component { + state = { + value: this.props.defaultValue, + } + + handleOnChange = (e) => { + this.setState({ + value: e.target.value, + }); + } + + handleOnSearch = () => { + if (this.props.onSearch) { + this.props.onSearch(this.state.value); + } + } + + handleOnKey = (e) => { + if (e.keyCode === 13) { + this.handleOnSearch(); + } + } + + render() { + const { text = '搜索', reset } = this.props; + return ( +
+ {text}} + /> +
+ ); + } +} diff --git a/src/components/SearchInput/index.less b/src/components/SearchInput/index.less index 7d00f448..2e8ab24b 100644 --- a/src/components/SearchInput/index.less +++ b/src/components/SearchInput/index.less @@ -1,5 +1,4 @@ @import "~antd/lib/style/themes/default.less"; -@import "../../utils/utils.less"; .search { display: inline-block; @@ -23,23 +22,3 @@ height: 40px; } } - -@media screen and (max-width: @screen-sm) { - .search { - :global { - .ant-input-group .ant-input { - width: 300px; - } - } - } -} - -@media screen and (max-width: @screen-xs) { - .search { - :global { - .ant-input-group .ant-input { - width: 200px; - } - } - } -} diff --git a/src/components/TagCloud/index.js b/src/components/TagCloud/index.js index 0ade0e71..72693b95 100644 --- a/src/components/TagCloud/index.js +++ b/src/components/TagCloud/index.js @@ -79,7 +79,7 @@ class TagCloud extends PureComponent { height, // 设定文字大小配置函数(默认为12-40px的随机大小) - size: words => (((words.value - min) / (max - min)) * 10) + 12, + size: words => (((words.value - min) / (max - min)) * 12) + 6, // 设定文字内容 text: words => words.name, diff --git a/src/layouts/PageHeaderLayout.js b/src/layouts/PageHeaderLayout.js index 1573b8a9..0b04067a 100644 --- a/src/layouts/PageHeaderLayout.js +++ b/src/layouts/PageHeaderLayout.js @@ -1,8 +1,9 @@ import React from 'react'; import PageHeader from '../components/PageHeader'; -export default ({ children, wrapperClassName, ...restProps }) => ( +export default ({ children, wrapperClassName, top, ...restProps }) => (
+ {top} {children ?
{children}
: null}
diff --git a/src/routes/Dashboard/Analysis.js b/src/routes/Dashboard/Analysis.js index 33f88963..014289f9 100644 --- a/src/routes/Dashboard/Analysis.js +++ b/src/routes/Dashboard/Analysis.js @@ -60,6 +60,10 @@ export default class Analysis extends Component { this.setState({ rangePickerValue, }); + + this.props.dispatch({ + type: 'chart/fetchSalesData', + }); } selectDate = (type) => { @@ -84,7 +88,7 @@ export default class Analysis extends Component { salesTypeData, salesTypeDataOnline, salesTypeDataOffline, - } = chart; + } = chart; const salesPieData = salesType === 'all' ? salesTypeData @@ -140,6 +144,8 @@ export default class Analysis extends Component { }, ]; + const activeKey = currentTabKey || (offlineData[0] && offlineData[0].name); + const CustomTab = ({ data, currentTabKey: currentKey }) => ( @@ -152,7 +158,7 @@ export default class Analysis extends Component { { offlineData.map(shop => ( } + tab={} key={shop.name} >
diff --git a/src/routes/Dashboard/Analysis.less b/src/routes/Dashboard/Analysis.less index e00a01ee..69eb7a1d 100644 --- a/src/routes/Dashboard/Analysis.less +++ b/src/routes/Dashboard/Analysis.less @@ -3,8 +3,13 @@ .iconGroup { i { + transition: color 0.32s; + color: @text-color-secondary; cursor: pointer; margin-left: 16px; + &:hover { + color: @text-color; + } } } .rankingList { diff --git a/src/routes/Dashboard/Monitor.js b/src/routes/Dashboard/Monitor.js index b7977e73..9fd1b2d5 100644 --- a/src/routes/Dashboard/Monitor.js +++ b/src/routes/Dashboard/Monitor.js @@ -3,22 +3,14 @@ import { connect } from 'dva'; import { Row, Col, Card } from 'antd'; import numeral from 'numeral'; -import { NumberInfo, MiniArea, Pie, WaterWave, Gauge } from '../../components/Charts'; +import { NumberInfo, Pie, WaterWave, Gauge } from '../../components/Charts'; import MapChart from '../../components/MapChart'; import TagCloud from '../../components/TagCloud'; import Countdown from '../../components/Countdown'; -import { fixedZero } from '../../utils/utils'; +import ActiveChart from '../../components/ActiveChart'; import styles from './Monitor.less'; -const activeData = []; -for (let i = 0; i < 24; i += 1) { - activeData.push({ - x: `${fixedZero(i)}:00`, - y: (i * 50) + (Math.floor(Math.random() * 200)), - }); -} - const MapData = []; for (let i = 0; i < 50; i += 1) { MapData.push({ @@ -83,44 +75,7 @@ export default class Monitor extends PureComponent { -
- -
- -
- { - activeData && ( -
-

{[...activeData].sort()[activeData.length - 1].y + 200} 亿元

-

{[...activeData].sort()[Math.floor(activeData.length / 2)].y} 亿元

-
- ) - } - { - activeData && ( -
- 00:00 - {activeData[Math.floor(activeData.length / 2)].x} - {activeData[activeData.length - 1].x} -
- ) - } -
+
@@ -143,7 +98,7 @@ export default class Monitor extends PureComponent { style={{ marginBottom: 24 }} bordered={false} > - + - + diff --git a/src/routes/List/CardList.js b/src/routes/List/CardList.js index 36c15e7b..97c6f98c 100644 --- a/src/routes/List/CardList.js +++ b/src/routes/List/CardList.js @@ -1,5 +1,6 @@ import React, { PureComponent } from 'react'; import { connect } from 'dva'; +import { Link } from 'dva/router'; import { Card, Avatar, Button, Icon, List } from 'antd'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; @@ -65,19 +66,22 @@ export default class CardList extends PureComponent { { list && list.map(item => ( - 操作一, 操作二]} - > - } - title={item.title} - description={( -

- {item.description} -

- )} - /> -
+ + 操作一, 操作二]} + > + } + title={item.title} + description={( +

+ {item.description} +

+ )} + /> +
+
)) } diff --git a/src/routes/List/CardList.less b/src/routes/List/CardList.less index e8b4c44a..b6780136 100644 --- a/src/routes/List/CardList.less +++ b/src/routes/List/CardList.less @@ -31,6 +31,7 @@ .cardDescription { .textOverflowMulti(); + color: @text-color; } .pageHeaderContent { diff --git a/src/routes/List/CoverCardList.js b/src/routes/List/CoverCardList.js index e0869866..1f2aaff2 100644 --- a/src/routes/List/CoverCardList.js +++ b/src/routes/List/CoverCardList.js @@ -161,9 +161,15 @@ export default class CoverCardList extends PureComponent { 类目二 类目三 类目四 + 类目五 + 类目六 + 类目七 + 类目八 + 类目九 + 类目十 - 类目五 - 类目六 + 类目十一 + 类目十二 )} diff --git a/src/routes/List/FilterCardList.js b/src/routes/List/FilterCardList.js index 81710b99..9b1ee007 100644 --- a/src/routes/List/FilterCardList.js +++ b/src/routes/List/FilterCardList.js @@ -2,7 +2,7 @@ import React, { PureComponent } from 'react'; import numeral from 'numeral'; import { connect } from 'dva'; import { routerRedux } from 'dva/router'; -import { Row, Col, Form, Card, Select, Spin, Icon, Avatar } from 'antd'; +import { Row, Col, Form, Card, Select, Icon, Avatar, List, Tooltip } from 'antd'; import PageHeaderLayout from '../../layouts/PageHeaderLayout'; import StandardFormRow from '../../components/StandardFormRow'; @@ -199,15 +199,21 @@ export default class FilterCardList extends PureComponent {
- - { - loading && - } + { - !loading && list && list.map(item => ( - + list && list.map(item => ( + , , , ]} + actions={[ + , + , + , + , + ]} > } @@ -220,10 +226,10 @@ export default class FilterCardList extends PureComponent { />
- + )) } -
+
);