diff --git a/package.json b/package.json index 4b7f7f15f1a6eaef084ddca81a5bbe1aeb58497a..ceef972cfd8bc30d1bcc239eb2347ecf411b5677 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 0000000000000000000000000000000000000000..1ab1cd54cb8b9de2a79aadda68686cb05e245dd0 --- /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 0000000000000000000000000000000000000000..0f7814702c7164b7e6685f29e85b883b348d5313 --- /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 537c4fc49406ea47f4e15ffdbf0099d8d2cb35f6..765f5eb457d72bd4f4dcd1d2daf0ac8444d47ebb 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 0c53540e63900620579cc61cbd444f20d61f51f0..dcd3779c1a08bca1e502508fddbe99dbae37ad10 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 5807c352fae25fc1c0abbc1f96f8381750588264..12fe4c45f33740fafff0bbc468c8bdd60cc18532 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 d0553a7f185f77fca9fa11347978cc25124df943..d71517f84fc6b86be90d32d43ccb47e33fd62bcd 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 63037a1ce9f6a3b81284ad58185078c55a3713b1..8d1d82a26791e61f5a5c3df41ffe3556bfca654c 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 1ac14375e6561cac72ff1c976a4dc872fdb09c64..12640774de940a9ed9832b85a753419e46c89272 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 0000000000000000000000000000000000000000..ff3a4c70a8fd689fa7633d209b45039bb29ecc08 --- /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 e5e4403c402466b334cde54f9c44d6279b3f35e2..36bb90ff153a8b79950f76bf0e09298d4c7e0e6b 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 7d00f4487fa719fee7e3ad4e05d3aa34161aa744..2e8ab24ba98a43f698748c18ccc61be1b77a745d 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 0ade0e71e7221cf59ba2283ca0beda79f467cf60..72693b956b3e8c58bf2a0d6f6c76950372169eae 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 1573b8a97e5f609eede924c343e1c1bf8eaf98c4..0b04067a3eacf0a81ce9b5bbca7a4f5226be50cd 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 33f88963ccd11c1da70e0bf77f59c29ef52626fb..014289f973ef7c6a853d24e73c51a86db5e117d8 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 e00a01eeb0935532754c4c67a4f66f3e6d9cf30f..69eb7a1d42c0e3edfeef5d97abf3ce43c4908969 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 b7977e734da06340efc768f737323f50505ba6e2..9fd1b2d59642e2dcab3a70bffe2f1e18bd811564 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 36c15e7b2152a4ee919e57ad16acfe721e42f5a7..97c6f98c1f3af70f5bfad3b2e3b89112747e5e2a 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 e8b4c44ab34d9c9f5a36ec1be95d7cc2861ea6f2..b67801360642e4ef86393b8d85054ba5ccf5c783 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 e0869866ef60bc335957ff4792381cf4516c0b20..1f2aaff21872d2e8d4f21c12d2b1628932ba95a6 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 81710b9925f9eb2a1d6ad12c2cef022bb3578bbe..9b1ee007015310264fa096c6c0b621a8ee6b6ac5 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 { />
- + )) } -
+
);