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

debug

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