Commit c8f1122a authored by 熊成伟's avatar 熊成伟

debug

parent 76d1c057
Pipeline #15336 passed with stages
in 55 seconds
...@@ -10,7 +10,7 @@ const CardItem = (props) => { ...@@ -10,7 +10,7 @@ const CardItem = (props) => {
}, [addStatus]) }, [addStatus])
const contentCLick = () => { const contentCLick = () => {
!status && !data.iconAdd && data.text && workUrl('/blank/work/1') !status && !data.iconAdd && data.text && workUrl(`/blank/work/${data.type}`)
data.iconAdd && addCommon() data.iconAdd && addCommon()
}; };
const iconClick = () => { const iconClick = () => {
......
import React, {useEffect, useState} from 'react'; import React, {useEffect, useState} from 'react';
import {ActivityIndicator, Toast, WhiteSpace, WingBlank} from 'antd-mobile' import {WhiteSpace, WingBlank} from 'antd-mobile'
import TodoCard from '../../components/LogCard' import TodoCard from '../../components/LogCard'
import TopNotice from '../../components/NoticeTab' import TopNotice from '../../components/NoticeTab'
import axiosRequest from '../../utils/request'; import axiosRequest from '../../utils/request';
import './index.less' import Skeleton from '../../components/Skeleton'
import Document from 'react-document-title'
import Empty from '../Empty' import Empty from '../Empty'
// import useDebounce from '../../useHooks/useDebounce' import Loading from "../../components/Loading";
const WorkDetail = (props) => { const Notice = (props) => {
const [start, setStart] = useState(true); const [start, setStart] = useState(true);
useEffect(() => { const [end, setEnd] = useState(true)
setLoading(true)
axiosRequest({
method: 'post',
url: '/idtAppServiceV6/oApp/getUnDone',
body: {nowPage: 1, pageSize: 10},
}).then(res => {
setLoading(false);
setStart(false)
let result = end && res.rows ? data.concat(res.rows) : data;
res.rows && res.rows.length >= 10 && setCurrent(1);
setEnd(res.rows && res.rows.length >= 10)
setData(result);
});
}, [])
const [current, setCurrent] = useState(0); const [current, setCurrent] = useState(0);
const [searchWord, setSearchWord] = useState(); const [searchWord, setSearchWord] = useState();
...@@ -31,31 +19,36 @@ const WorkDetail = (props) => { ...@@ -31,31 +19,36 @@ const WorkDetail = (props) => {
const [data, setData] = useState([]); const [data, setData] = useState([]);
const getData = () => { const getData = (scroll) => {
const pageMap ={searchWord, nowPage: current + 1, pageSize: 10}; const {type} = props.match.params
setLoading(true) const pageMap ={searchWord, nowPage: current + 1, pageSize: 10, FLAG: tab, bllx: type};
setLoading(true);
scroll && current > 0 && window.scrollTo(0, document.body.scrollHeight)
axiosRequest({ axiosRequest({
method: 'post', method: 'post',
url: '/idtAppServiceV6/oApp/getUnDone', url: '/idtAppServiceV6/oApp/getUnDone',
body: pageMap, body: pageMap,
}).then(res => { }).then(res => {
setLoading(false); setStart(false);
let result = end && res.rows ? data.concat(res.rows) : data;
res.rows && res.rows.length >= 10 ? setCurrent(current + 1) : Toast.info('当前是最后一页', 1);
setEnd(res.rows && res.rows.length >= 10) setEnd(res.rows && res.rows.length >= 10)
let result = end && res.rows ? data.concat(res.rows) : data;
console.log('end', end, 'result',result, 'res', res)
res.rows && res.rows.length >= 10 && setCurrent(1);
setData(result); setData(result);
setLoading(false);
}); });
}; };
//下拉加载 //下拉加载
const [end, setEnd] = useState(true)
const handleScroll = () => { const handleScroll = () => {
let scrollTop = document.documentElement.scrollTop || document.body.scrollTop; let scrollTop = document.documentElement.scrollTop || document.body.scrollTop;
let clientHeight = document.documentElement.clientHeight || document.body.clientHeight; let clientHeight = document.documentElement.clientHeight || document.body.clientHeight;
let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight; let scrollHeight = document.documentElement.scrollHeight || document.body.scrollHeight;
// alert(`${scrollTop} ${clientHeight} ${scrollHeight} ${scrollTop + clientHeight >= scrollHeight}`)
if(scrollHeight > clientHeight && scrollTop + clientHeight === scrollHeight) { if(scrollHeight > clientHeight && scrollTop + clientHeight >= scrollHeight) {
getData() getData(true)
} }
} }
useEffect(() => { useEffect(() => {
...@@ -63,67 +56,73 @@ const WorkDetail = (props) => { ...@@ -63,67 +56,73 @@ const WorkDetail = (props) => {
return () => window.removeEventListener('touchend', handleScroll, true); return () => window.removeEventListener('touchend', handleScroll, true);
}, [data]); }, [data]);
const checkLog = () => { const checkLog = (OPERATEID, UUID) => {
props.history.push(`/blank/info/example/1`) props.history.push(`/blank/info/${OPERATEID}/${UUID}`)
}; };
//回到顶部 //回到顶部
useEffect(() => { useEffect(() => {
const element = document.getElementById('work-content') window.scrollTo(0, 0)
element.scrollTo(0, 0)
}, []); }, []);
//tab已读未读切换 //tab已读未读切换
const [tab, setTab] = useState('N'); const [tab, setTab] = useState('N');
const tabData = () => {
const pageMap ={searchWord, nowPage: current + 1, pageSize: 10, FLAG: tab};
setLoading(true)
axiosRequest({
method: 'post',
url: '/idtAppServiceV6/oApp/getUnDone',
body: pageMap,
}).then(res => {
setLoading(false);
let result = end && res.rows ? [].concat(res.rows) : [];
res.rows && res.rows.length >= 10 ? setCurrent(current + 1) : Toast.info('当前是最后一页', 1);
setEnd(res.rows && res.rows.length >= 10)
setData(result);
});
};
const tabChange = val => { const tabChange = val => {
setCurrent(0);
setData([]);
setTab(val); setTab(val);
tabData() setEnd(true)
}; };
const tabSearch = val => {
setCurrent(0);
setData([])
setSearchWord(val)
setEnd(true)
}
useEffect(() => { useEffect(() => {
//回到顶部
window.scrollTo(0, 0)
getData() getData()
}, [searchWord, tab]) }, [])
useEffect(() => {
setStart(true);
getData(false, [])
}, [searchWord, tab]);
console.log(data.length)
return ( return (
<div id="work-content" className="work-content"> <Document title="通知">
<WingBlank> <WingBlank>
<ActivityIndicator
toast
text="加载中..."
animating={loading}
/>
<WhiteSpace/> <WhiteSpace/>
<TopNotice onSearch={setSearchWord} tabChange={tabChange}/> <TopNotice onSearch={tabSearch} tabChange={tabChange}/>
{ { start ? <div> <WhiteSpace/><Skeleton/><WhiteSpace/><Skeleton/><WhiteSpace/><Skeleton/></div> : ( !start && (
!start && (
data.length > 0 ? data.map((item, index) => ( data.length > 0 ? data.map((item, index) => (
<div key={index}> <div key={index}>
<WhiteSpace/> <WhiteSpace/>
<TodoCard data={item} onClick={checkLog}/> <TodoCard data={item} onClick={() => checkLog(item.OPERATEID, item.UUID)}/>
</div> </div>
)) : <Empty/> )) : <Empty/>
) ))}
<WhiteSpace/>
{loading && (
<div className="pos-line content-loading">
<Loading/>
<WhiteSpace/>
<WhiteSpace/>
</div>
)}
{!loading && !end && data.length > 0 && (
<div className="content-end">
—————— 我是有底线的 ——————
</div>
)}
}
</WingBlank> </WingBlank>
</div> </Document>
); );
}; };
export default WorkDetail; export default Notice;
...@@ -31,7 +31,7 @@ const ReactRouter = () => { ...@@ -31,7 +31,7 @@ const ReactRouter = () => {
}/> }/>
<Route path="/blank" component={() => <Route path="/blank" component={() =>
<BlankLayout> <BlankLayout>
<Route path="/blank/work/:id" component={WorkDetail}/> <Route path="/blank/work/:type" component={WorkDetail}/>
<Route path="/blank/submit/:type" component={SubmitDetail}/> <Route path="/blank/submit/:type" component={SubmitDetail}/>
<Route path="/blank/info/:id/:uuid" component={Process}/> <Route path="/blank/info/:id/:uuid" component={Process}/>
</BlankLayout> </BlankLayout>
......
...@@ -68,7 +68,7 @@ export const createAPI = (baseURL) => { ...@@ -68,7 +68,7 @@ export const createAPI = (baseURL) => {
} }
if (response && response.data && response.data.leftOperateBar) { if (response && response.data && response.data.leftOperateBar) {
localStorage.removeItem("menu"); localStorage.removeItem("menu");
const menu = response.data.leftOperateBar.map(item => ({ icon: item.imgType, text: item.nodeName })) const menu = response.data.leftOperateBar.map(item => ({ icon: item.imgType, text: item.nodeName, type: item.type }))
menu.length > 0 && localStorage.setItem("menu", JSON.stringify(menu)); menu.length > 0 && localStorage.setItem("menu", JSON.stringify(menu));
} }
......
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