From 2911823934465935f9885c3ca9bda651219d5e99 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Wed, 2 Aug 2023 14:49:53 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=86=E8=8A=82=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/packages/patrol/index.jsx | 62 +++++++++++++++++------------ 1 file changed, 36 insertions(+), 26 deletions(-) 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;