diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx index 319ae94f..2916ca25 100644 --- a/weapp/src/packages/patrol/index.jsx +++ b/weapp/src/packages/patrol/index.jsx @@ -399,10 +399,6 @@ const Index = () => { } }, []) - useEffect(() => { - setRoadStartSel(sourceRoadStartSel) - setRoadEndSel(sourceRoadEndSel) - }, [sourceRoadStartSel, sourceRoadEndSel]) useEffect(() => { setTypeList([ { @@ -576,32 +572,41 @@ const Index = () => { case "roadCodeEnd": setRoadCodeEnd(value) if (value.length >= 9) { + let routeCode = '' + let roadStart = [] + let roadEnd = [] + let routeName = '' for (const r of roadList) { if (r.routeCode === roadCodeHead + value) { - setRoad(r.routeName) - setRoadSectionStart(r.startingPlaceName) - setRoadSectionEnd(r.stopPlaceName) - request.get(getReportList(), { limit: 1, page: 0, codeRoad: r.routeCode }).then(res => { - if (res.statusCode === 200 && res.data.length) { - request.get(getReportDetail(res.data[0].id)).then(detailRes => { - if (res.statusCode === 200) { - let nextInfo = { ...conserveInfo } - Object.keys(conserveInfo).forEach(key => { - if (detailRes.data[key]) nextInfo[key].value = detailRes.data[key] - }) - setConserveInfo(nextInfo) - setPatrolContentEdit(false) - } else { - setPatrolContentEdit(true) - } - }) - } else { - setPatrolContentEdit(true) - } - }) - break; + roadStart.push(r.startingPlaceName) + roadEnd.push(r.stopPlaceName) + routeCode = r.routeCode + routeName = r.routeName } } + setRoadStartSel(roadStart) + setRoadEndSel(roadEnd) + if (routeName) setRoad(routeName) + if (kind === 'conserve' && routeCode) { + request.get(getReportList(), { limit: 1, page: 0, codeRoad: routeCode }).then(res => { + if (res.statusCode === 200 && res.data.length) { + request.get(getReportDetail(res.data[0].id)).then(detailRes => { + if (res.statusCode === 200) { + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + if (detailRes.data[key]) nextInfo[key].value = detailRes.data[key] + }) + setConserveInfo(nextInfo) + setPatrolContentEdit(false) + } else { + setPatrolContentEdit(true) + } + }) + } else { + setPatrolContentEdit(true) + } + }) + } } break; case "conserveInfo": @@ -611,6 +616,11 @@ const Index = () => { break; case "conserveContent": let nextContent = { ...conserveContent } + if (value.split('.')[1] && value.split('.')[1].length > 3) { + setConserveContent(nextContent) + Taro.showToast({ title: '最多输入三位小数', icon: 'none', duration: 1500 }) + return; + } nextContent[key].value = value setConserveContent(nextContent) break;