Commit b35b9488 authored by 刘松's avatar 刘松

优化

parent e3ac86cb
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3,5 +3,6 @@ module.exports = {
CURRENTPAGE: 'CURRENTPAGE',
MAINDATA:'MAINDATA',
COUNTDATA:'COUNTDATA',
DETAILDATA:'DETAILDATA'
DETAILDATA:'DETAILDATA',
STATUS:'STATUS'
};
......@@ -23,6 +23,7 @@ exports.getSession = (data) => {
exports.getMainData = (data) => {
return (dispatch) => {
api('POST', 'data', data).then((res) => {
dispatch({status: 'pending', type: types.STATUS});
dispatch({ status:res.result, data:res.data, type: types.MAINDATA});
});
};
......@@ -39,6 +40,7 @@ exports.getCountData= () => {
exports.getDetailData = (data) => {
return (dispatch) => {
dispatch({status: 'pending', type: types.STATUS});
api('POST', 'detail', data).then((res) => {
dispatch({ status:res.result, data:res.data, type: types.DETAILDATA});
});
......
......@@ -26,6 +26,8 @@ module.exports = function data (state = defaultData, action) {
return _.assign({}, state, {count:action.data});
case types.DETAILDATA:
return _.assign({}, state, {status: action.status,detail:action.data});
case types.STATUS:
return _.assign({}, state, {status: action.status});
default:
return state;
}
......
......@@ -7,6 +7,7 @@ const rootReducer = require('../reducers');
const createDevTools = require('redux-devtools-ie8').createDevTools;
const LogMonitor = require('redux-devtools-log-monitor-ie8').default;
const DockMonitor = require('redux-devtools-dock-monitor-ie8').default;
import sequenceAction from 'redux-sequence-action';
const thunk = require('redux-thunk').default;
......@@ -23,7 +24,7 @@ module.exports.configureStore = function configureStore () {
return redux.createStore(
rootReducer,
redux.compose(
redux.applyMiddleware(thunk),
redux.applyMiddleware(thunk,sequenceAction),
ReduxDevTools.instrument()
)
)
......
......@@ -3,7 +3,7 @@ const connect = require('react-redux').connect;
const actions = require('../../js/actions');
const moment = require('moment');
import { Table, Icon, DatePicker, Alert, Row, Col} from 'antd';
import { Table, Icon, DatePicker, Alert, Row, Col, Spin} from 'antd';
const { RangePicker } = DatePicker;
class DashBoard extends React.Component{
......@@ -157,7 +157,9 @@ class DashBoard extends React.Component{
</Col>
</Row>
<RangePicker onChange={ this.onChange.bind(this) } value={ ranges } format={'YYYYMMDD'} style={{margin:'10px 0px'}}/>
<Table columns={columns} dataSource = { data } size="middle" />
<Spin spinning= { this.props.data.status == 'pending' }>
<Table columns={columns} dataSource = { data } size="middle" />
</Spin>
</div>
)
}
......
......@@ -15,17 +15,13 @@ class Detail extends React.Component{
componentDidMount (){
let limit = 30;
let skip = 0;
// await this.props.dispatch({status:'pending',type:types.DETAILDATA});
//await this.props.dispatch({status:'pending',type:types.DETAILDATA});
this.props.dispatch(actions.getDetailData({limit,skip}));
}
handleTableChange (pagination, filters, sorter) {
const pager = this.props.data.detail.pagination;
pager.current = pagination.current;
// this.props.dispatch({
// pagination: pager,
// type:types.DETAILDATA
// })
this.props.dispatch(actions.getDetailData({limit: 30,skip: parseInt(pager.current)-1 }));
}
......@@ -76,12 +72,13 @@ class Detail extends React.Component{
name : item['username'] || '-',
phone : item['phone'] || '-',
ups : upMap[ item['_id'] ] || 0,
date : moment(item['createdAt']).format('YYYY/MM/DD hh:mm:ss')
date : moment(item['createdAt']).format('YYYY/MM/DD HH:mm:ss')
})
}
return (
<Spin spinning= { this.props.data.status == 'pending' }>
<Table columns={columns} dataSource = { data } pagination={ this.props.data.detail.pagination } size="middle" onChange = { this.handleTableChange.bind(this) }/>
</Spin>
)
}
}
......
......@@ -48,7 +48,7 @@ exports.data = async (req,res,next) => {
exports.count = async(req,res,next) => {
const userPromise = await user.count({});
const upstreamPromise = await upstream.count({});
const upstreamPromise = await upstream.count({_id: {$exists: true}});
const adminPromise = await upstream.count({ creater:mongoose.Types.ObjectId('58afdd80aa96916a41598698') });
let userCount= 0;
let upstreamCount = 0;
......
......@@ -31,6 +31,7 @@
"react-tap-event-plugin": "^0.2.2",
"redux": "^3.3.1",
"redux-devtools-ie8": "0.0.1",
"redux-sequence-action": "^0.2.1",
"redux-thunk": "^2.2.0",
"request": "^2.81.0",
"request-promise": "^4.2.1"
......
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