统计页面返回值会叠加及返回值会换成在另外一个课堂数据不对的情况

dev_aliyun2
dinglink 5 years ago committed by harry
parent 4c164a7e58
commit 90f19b3a39

@ -23,7 +23,7 @@ const App = (props) => {
total, total,
staticList, staticList,
changeParams, changeParams,
initTotal initTotal,
} = props; } = props;
// const [datas, setDatas] = useState([]); // const [datas, setDatas] = useState([]);
// const [sortedInfo, setSortedInfo] = useState({}); // const [sortedInfo, setSortedInfo] = useState({});
@ -200,7 +200,8 @@ const App = (props) => {
sorter: (a, b) => a.cost_time - b.cost_time sorter: (a, b) => a.cost_time - b.cost_time
} }
]; ];
useEffect(() => { useEffect(() => {
changeParams({ changeParams({
page: 1 page: 1
@ -212,14 +213,15 @@ const App = (props) => {
pathId && staticList(pathId); pathId && staticList(pathId);
} }
const {
study_count, // const {
course_study_count, // study_count,
initiative_study, // course_study_count,
passed_count, // initiative_study,
course_used_count, // passed_count,
school_used_count // course_used_count,
} = subject_info; // school_used_count
// } = subject_info;
const maps = { const maps = {
1: 'subject_info', // 实践课程使用情况 1: 'subject_info', // 实践课程使用情况
@ -237,7 +239,6 @@ const App = (props) => {
// 恢复初始值 // 恢复初始值
changeParams(params); changeParams(params);
initTotal(); initTotal();
console.log(staticList)
pathId && staticList(pathId); pathId && staticList(pathId);
} }
@ -323,8 +324,9 @@ const mapStateToProps = (state) => {
return { return {
subject_info, subject_info,
other_info, other_info,
total total,
} }
}; };
const mapDispatchToProps = (dispatch) => ({ const mapDispatchToProps = (dispatch) => ({

@ -12,13 +12,15 @@ import { fetchStaticList } from "../../services/staticService";
export const staticList = (id) => { export const staticList = (id) => {
return (dispatch, getState) => { return (dispatch, getState) => {
const { params, total_count, other_info } = getState().staticReducer; const { params, total_count, other_info } = getState().staticReducer;
if (other_info.length===20||total_count !== 0 && total_count === other_info.length) return; // console.log('统计数据=====>>>>>', params);
// if (total_count !== 0 && total_count === other_info.length) return;
fetchStaticList(id, params).then(res => { fetchStaticList(id, params).then(res => {
// console.log('统计数据=====>>>>>', res); // console.log('统计数据=====>>>>>', res);
const {data} = res; const {data} = res;
if (data.status === 0) { if (data.status === 0) {
dispatch({ dispatch({
type: types.GET_STATIC_INFO, type: types.GET_STATIC_INFO,
other_info:data.data.other_info,
payload: data.data payload: data.data
}); });
} }

@ -38,12 +38,14 @@ const initalState = {
const staticReducer = (state = initalState, action) => { const staticReducer = (state = initalState, action) => {
const { payload = {}, type } = action; const { payload = {}, type } = action;
const {subject_info, other_info = [], total = {}, total_count} = payload; const {subject_info, other_info = [], total = {}, total_count} = payload;
switch (type) { switch (type) {
case types.GET_STATIC_INFO: case types.GET_STATIC_INFO:
return { return {
...state, ...state,
subject_info, subject_info,
other_info: state.other_info.concat(other_info), other_info,
// other_info: state.other_info.concat(other_info),
total, total,
total_count, total_count,
params: Object.assign({}, state.params, { page: state.params.page + 1 }) params: Object.assign({}, state.params, { page: state.params.page + 1 })

Loading…
Cancel
Save