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

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

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

@ -12,13 +12,15 @@ import { fetchStaticList } from "../../services/staticService";
export const staticList = (id) => {
return (dispatch, getState) => {
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 => {
// console.log('统计数据=====>>>>>', res);
const {data} = res;
if (data.status === 0) {
dispatch({
type: types.GET_STATIC_INFO,
other_info:data.data.other_info,
payload: data.data
});
}

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

Loading…
Cancel
Save