diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx index fc52c940..0b39afad 100644 --- a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx @@ -15,6 +15,7 @@ function Index() { const [keyword, setKeyword] = useState('') const [roadDetailList, setRoadDetailList] = useState([]) + const [isNoData, setIsNoData] = useState(false) useDidShow(() => { getDetail() @@ -30,21 +31,17 @@ function Index() { } else { Taro.showToast({ title: '获取详情失败', icon: 'error' }) } + if (res.data?.length) { + setIsNoData(false) + } else { + setIsNoData(true) + } }) } } - return ( - setKeyword(v)} - onActionClick={getDetail} - /> - 抽查日期:{moment(spotItem.date).format('YYYY-MM-DD')} - - {roadDetailList.length ? roadDetailList.map(item => + const renderList = () => { + return roadDetailList.length ? roadDetailList.map(item => 道路类型:{item.road?.level ? (item.road?.level + '道') : '--'} 路线名称:{item.road?.routeName || '--'} @@ -71,7 +68,23 @@ function Index() { >调整 - ) : } + ) : + } + + const renderNoData = () => { + return + } + + return ( + setKeyword(v)} + onActionClick={getDetail} + /> + 抽查日期:{moment(spotItem.date).format('YYYY-MM-DD')} + {isNoData ? renderNoData() : renderList()} ) }