diff --git a/package.json b/package.json
index e3252241eb1ded6b5acb6b2b8631effd531555c5..51bf8abe42c9a69c758e820ac453ccf645ce5e96 100755
--- a/package.json
+++ b/package.json
@@ -24,7 +24,7 @@
"@babel/polyfill": "^7.0.0-beta.36",
"antd": "^3.1.0",
"babel-runtime": "^6.9.2",
- "bizcharts": "^3.1.0-beta.4",
+ "bizcharts": "^3.1.3-beta.1",
"bizcharts-plugin-slider": "^2.0.1",
"classnames": "^2.2.5",
"dva": "^2.1.0",
diff --git a/src/components/Authorized/Authorized.js b/src/components/Authorized/Authorized.js
index d9a2a781d4a34b3b6c49f7c0a9571ce98102a9ba..8e7aacb21f921ccc31cf22c1d0d9af6a8459aa8d 100644
--- a/src/components/Authorized/Authorized.js
+++ b/src/components/Authorized/Authorized.js
@@ -5,11 +5,7 @@ class Authorized extends React.Component {
render() {
const { children, authority, noMatch = null } = this.props;
const childrenRender = typeof children === 'undefined' ? null : children;
- return CheckPermissions(
- authority,
- childrenRender,
- noMatch
- );
+ return CheckPermissions(authority, childrenRender, noMatch);
}
}
diff --git a/src/components/Authorized/AuthorizedRoute.js b/src/components/Authorized/AuthorizedRoute.js
index 3d03226abee91d973468871a092ead775e039b1f..f7cd679d955e8ca532e680e001b01aa716bec775 100644
--- a/src/components/Authorized/AuthorizedRoute.js
+++ b/src/components/Authorized/AuthorizedRoute.js
@@ -4,16 +4,28 @@ import Authorized from './Authorized';
class AuthorizedRoute extends React.Component {
render() {
- const { component: Component, render, authority,
- redirectPath, ...rest } = this.props;
+ const {
+ component: Component,
+ render,
+ authority,
+ redirectPath,
+ ...rest
+ } = this.props;
return (
} />}
+ noMatch={
+ }
+ />
+ }
>
(Component ? : render(props))}
+ render={props =>
+ (Component ? : render(props))
+ }
/>
);
diff --git a/src/components/Authorized/CheckPermissions.js b/src/components/Authorized/CheckPermissions.js
index 0a7dbaedf7d9c99b8f0d17cfd517f1b42325cdd2..d51e98333014d1705fab88d2ee13ae0c1d1948dc 100644
--- a/src/components/Authorized/CheckPermissions.js
+++ b/src/components/Authorized/CheckPermissions.js
@@ -3,7 +3,11 @@ import PromiseRender from './PromiseRender';
import { CURRENT } from './index';
function isPromise(obj) {
- return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
+ return (
+ !!obj &&
+ (typeof obj === 'object' || typeof obj === 'function') &&
+ typeof obj.then === 'function'
+ );
}
/**
@@ -38,9 +42,7 @@ const checkPermissions = (authority, currentAuthority, target, Exception) => {
// Promise 处理
if (isPromise(authority)) {
- return () => (
-
- );
+ return ;
}
// Function 处理
diff --git a/src/components/Authorized/PromiseRender.js b/src/components/Authorized/PromiseRender.js
index 78f762d92870fa282bb5b64ec2de9ef1d76d221c..22f1fcb720af8bf4e3f3c769b9c9bf5a46945958 100644
--- a/src/components/Authorized/PromiseRender.js
+++ b/src/components/Authorized/PromiseRender.js
@@ -3,25 +3,37 @@ import { Spin } from 'antd';
export default class PromiseRender extends React.PureComponent {
state = {
- component: false,
+ component: null,
};
- async componentDidMount() {
+ componentDidMount() {
+ const ok = this.checkIsInstantiation(this.props.ok);
+ const error = this.checkIsInstantiation(this.props.error);
this.props.promise
.then(() => {
this.setState({
- component: this.props.ok,
+ component: ok,
});
})
.catch(() => {
this.setState({
- component: this.props.error,
+ component: error,
});
});
}
+ // Determine whether the incoming component has been instantiated
+ // AuthorizedRoute is already instantiated
+ // Authorized render is already instantiated, children is no instantiated
+ // Secured is not instantiated
+ checkIsInstantiation = (target) => {
+ if (!React.isValidElement(target)) {
+ return target;
+ }
+ return () => target;
+ };
render() {
- const C = this.state.component;
- return C ? (
-
+ const Component = this.state.component;
+ return Component ? (
+
) : (
(
);
+// Determine whether the incoming component has been instantiated
+// AuthorizedRoute is already instantiated
+// Authorized render is already instantiated, children is no instantiated
+// Secured is not instantiated
+const checkIsInstantiation = (target) => {
+ if (!React.isValidElement(target)) {
+ return target;
+ }
+ return () => target;
+};
+
/**
* 用于判断是否拥有权限访问此view权限
* authority 支持传入 string ,funtion:()=>boolean|Promise
@@ -38,11 +49,8 @@ const authorize = (authority, error) => {
throw new Error('authority is required');
}
return function decideAuthority(targer) {
- return CheckPermissions(
- authority,
- targer,
- classError || Exception403
- );
+ const component = CheckPermissions(authority, targer, classError || Exception403);
+ return checkIsInstantiation(component);
};
};
diff --git a/src/components/Charts/Pie/index.js b/src/components/Charts/Pie/index.js
index ac5703ce29215db845c72ca35fec098a15ae271f..528b2519d21b41dc3fbd75ffa5c3270534400c1b 100644
--- a/src/components/Charts/Pie/index.js
+++ b/src/components/Charts/Pie/index.js
@@ -26,7 +26,16 @@ export default class Pie extends Component {
componentWillReceiveProps(nextProps) {
if (this.props.data !== nextProps.data) {
- this.getLengendData();
+ // because of charts data create when rendered
+ // so there is a trick for get rendered time
+ this.setState(
+ {
+ legendData: [...this.state.legendData],
+ },
+ () => {
+ this.getLengendData();
+ }
+ );
}
}
diff --git a/src/components/GlobalHeader/index.js b/src/components/GlobalHeader/index.js
index 8ce5e66ffda0e2a920bc47f725c82189f88d66bb..f43be9d2401de686e7013533b5df7bab17c5f6ca 100644
--- a/src/components/GlobalHeader/index.js
+++ b/src/components/GlobalHeader/index.js
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
-import { Layout, Menu, Icon, Spin, Tag, Dropdown, Avatar, Divider } from 'antd';
+import { Menu, Icon, Spin, Tag, Dropdown, Avatar, Divider } from 'antd';
import moment from 'moment';
import groupBy from 'lodash/groupBy';
import Debounce from 'lodash-decorators/debounce';
@@ -8,8 +8,6 @@ import NoticeIcon from '../NoticeIcon';
import HeaderSearch from '../HeaderSearch';
import styles from './index.less';
-const { Header } = Layout;
-
export default class GlobalHeader extends PureComponent {
componentWillUnmount() {
this.triggerResizeEvent.cancel();
@@ -68,7 +66,7 @@ export default class GlobalHeader extends PureComponent {
);
const noticeData = this.getNoticeData();
return (
-
+
{isMobile && (
[
(
@@ -135,7 +133,7 @@ export default class GlobalHeader extends PureComponent {
) : }
-
+
);
}
}
diff --git a/src/components/GlobalHeader/index.less b/src/components/GlobalHeader/index.less
index f1c38bde709b6da4d62abfdcaa9e7c2d3cb5a136..6f885152242e24b977871b8eabcdea7c5eb54db0 100644
--- a/src/components/GlobalHeader/index.less
+++ b/src/components/GlobalHeader/index.less
@@ -1,6 +1,7 @@
@import "~antd/lib/style/themes/default.less";
.header {
+ height: 64px;
padding: 0 12px 0 0;
background: #fff;
box-shadow: 0 1px 4px rgba(0, 21, 41, .08);
diff --git a/src/layouts/BasicLayout.js b/src/layouts/BasicLayout.js
index 584848038c11e6256236c4eed67e6c44bc2f2c89..f8c956a9a33112670bbfb9a1b4c487d437da6b71 100644
--- a/src/layouts/BasicLayout.js
+++ b/src/layouts/BasicLayout.js
@@ -16,7 +16,7 @@ import Authorized from '../utils/Authorized';
import { getMenuData } from '../common/menu';
import logo from '../assets/logo.svg';
-const { Content } = Layout;
+const { Content, Header, Footer } = Layout;
const { AuthorizedRoute } = Authorized;
/**
@@ -164,18 +164,20 @@ class BasicLayout extends React.PureComponent {
onCollapse={this.handleMenuCollapse}
/>
-
+
{
@@ -201,29 +203,31 @@ class BasicLayout extends React.PureComponent {
- ,
- href: 'https://github.com/ant-design/ant-design-pro',
- blankTarget: true,
- }, {
- key: 'Ant Design',
- title: 'Ant Design',
- href: 'http://ant.design',
- blankTarget: true,
- }]}
- copyright={
-
- Copyright 2018 蚂蚁金服体验技术部出品
-
- }
- />
+
);
diff --git a/src/router.js b/src/router.js
index 54eefd1702fc5b99c336fb5a82c9c7d1005f0215..23fdae17c321d284205ebdec29704cbfaed61c4c 100644
--- a/src/router.js
+++ b/src/router.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { routerRedux, Switch } from 'dva/router';
+import { routerRedux, Route, Switch } from 'dva/router';
import { LocaleProvider, Spin } from 'antd';
import zhCN from 'antd/lib/locale-provider/zh_CN';
import dynamic from 'dva/dynamic';
@@ -21,10 +21,9 @@ function RouterConfig({ history, app }) {
- }
- redirectPath="/"
+ component={UserLayout}
/>
@@ -147,7 +146,7 @@ export default class Monitor extends PureComponent {
-
+
-
+
-
+
{getFieldDecorator('members', {
initialValue: tableData,
})()}
diff --git a/src/routes/Forms/TableForm.js b/src/routes/Forms/TableForm.js
index 7eb0665f5f46683aaed984c5a389834b868c7c42..a8b18c6f03782dafb060cf2ca4e98d4585327086 100644
--- a/src/routes/Forms/TableForm.js
+++ b/src/routes/Forms/TableForm.js
@@ -23,17 +23,6 @@ export default class TableForm extends PureComponent {
}
index = 0;
cacheOriginData = {};
- handleSubmit = (e) => {
- e.preventDefault();
- this.props.form.validateFieldsAndScroll((err, values) => {
- if (!err) {
- this.props.dispatch({
- type: 'form/submit',
- payload: values,
- });
- }
- });
- }
toggleEditable=(e, key) => {
e.preventDefault();
const newData = this.state.data.map(item => ({ ...item }));
@@ -83,12 +72,7 @@ export default class TableForm extends PureComponent {
this.setState({
loading: true,
});
- // save field when blur input
setTimeout(() => {
- if (document.activeElement.tagName === 'INPUT' &&
- document.activeElement !== e.target) {
- return;
- }
if (this.clickedCancel) {
this.clickedCancel = false;
return;
@@ -121,6 +105,7 @@ export default class TableForm extends PureComponent {
delete this.cacheOriginData[key];
}
this.setState({ data: newData });
+ this.clickedCancel = false;
}
render() {
const columns = [{
@@ -135,7 +120,6 @@ export default class TableForm extends PureComponent {
value={text}
autoFocus
onChange={e => this.handleFieldChange(e, 'name', record.key)}
- onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="成员姓名"
/>
@@ -154,7 +138,6 @@ export default class TableForm extends PureComponent {
this.handleFieldChange(e, 'workId', record.key)}
- onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="工号"
/>
@@ -173,7 +156,6 @@ export default class TableForm extends PureComponent {
this.handleFieldChange(e, 'department', record.key)}
- onBlur={e => this.saveRow(e, record.key)}
onKeyPress={e => this.handleKeyPress(e, record.key)}
placeholder="所属部门"
/>
@@ -192,7 +174,7 @@ export default class TableForm extends PureComponent {
if (record.isNew) {
return (
- 保存
+ this.saveRow(e, record.key)}>添加
this.remove(record.key)}>
删除
@@ -202,7 +184,7 @@ export default class TableForm extends PureComponent {
}
return (
- 保存
+ this.saveRow(e, record.key)}>保存
this.cancel(e, record.key)}>取消
diff --git a/src/routes/Profile/AdvancedProfile.less b/src/routes/Profile/AdvancedProfile.less
index eb24e15e4abe7f2f0f1b64c6b6282d4c42d869c6..679a57209c4c5fa1371c816bcb99a36e6200ed22 100644
--- a/src/routes/Profile/AdvancedProfile.less
+++ b/src/routes/Profile/AdvancedProfile.less
@@ -5,7 +5,6 @@
}
.tabsCard {
- margin-bottom: 24px;
:global {
.ant-card-head {
padding: 0 16px;