Browse Source

切换线路编码类型相关逻辑

dev
liujiangyong 1 year ago
parent
commit
088419a7f3
  1. 114
      weapp/src/packages/patrol/index.jsx

114
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 = () => {
<Text style={{ color: 'red' }}>*&nbsp;</Text>线路编码
<RadioGroup onChange={(e) => {
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)
}
}
}}>
<Radio value='X' checked={roadCodeHead === 'X'} color='#0080EE' className='radio' disabled={isView}>X</Radio>
<Radio value='Y' checked={roadCodeHead === 'Y'} color='#0080EE' className='radio' disabled={isView}>Y</Radio>

Loading…
Cancel
Save