From 088419a7f3f126b99fc9124704450f71d4d9a0af Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Wed, 2 Aug 2023 22:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=E7=BA=BF=E8=B7=AF=E7=BC=96?= =?UTF-8?q?=E7=A0=81=E7=B1=BB=E5=9E=8B=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/packages/patrol/index.jsx | 114 ++++++++++++++++------------ 1 file changed, 64 insertions(+), 50 deletions(-) diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx index fbff8176..ed1f1350 100644 --- a/weapp/src/packages/patrol/index.jsx +++ b/weapp/src/packages/patrol/index.jsx @@ -544,7 +544,57 @@ const Index = () => { } }) } - + function queryConserveInfo(roadCodeHead, value) { + let routeCode = '' + let roadStart = [] + let roadEnd = [] + let routeName = '' + for (const r of roadList) { + if (r.routeCode === roadCodeHead + value) { + 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 { + if (!patrolContentEdit) { + setPatrolContentEdit(true) + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + nextInfo[key].value = '' + }) + setConserveInfo(nextInfo) + } + } + }) + } else { + if (!patrolContentEdit) { + setPatrolContentEdit(true) + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + nextInfo[key].value = '' + }) + setConserveInfo(nextInfo) + } + } + }) + } + } function handleInput({ detail: { value } }, type, key) { switch (type) { case 'roadSectionStart': @@ -578,55 +628,7 @@ 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) { - 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 { - if (!patrolContentEdit) { - setPatrolContentEdit(true) - let nextInfo = { ...conserveInfo } - Object.keys(conserveInfo).forEach(key => { - nextInfo[key].value = '' - }) - setConserveInfo(nextInfo) - } - } - }) - } else { - if (!patrolContentEdit) { - setPatrolContentEdit(true) - let nextInfo = { ...conserveInfo } - Object.keys(conserveInfo).forEach(key => { - nextInfo[key].value = '' - }) - setConserveInfo(nextInfo) - } - } - }) - } + queryConserveInfo(roadCodeHead, value) } else { if (!patrolContentEdit) { setPatrolContentEdit(true) @@ -936,6 +938,18 @@ const Index = () => { 线路编码: { setRoadCodeHead(e.detail.value[0]); + if (roadCodeEnd.length >= 9) { + queryConserveInfo(e.detail.value[0], roadCodeEnd) + } else { + if (!patrolContentEdit) { + setPatrolContentEdit(true) + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + nextInfo[key].value = '' + }) + setConserveInfo(nextInfo) + } + } }}> X Y