Browse Source

抽查调整优化

dev
liujiangyong 1 year ago
parent
commit
dd96280972
  1. 74
      weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx

74
weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx

@ -24,6 +24,8 @@ function Index() {
startingPlaceName: '', startingPlaceName: '',
stopPlaceName: '', stopPlaceName: '',
}) })
const [routeCodeDisabled, setRouteCodeDisabled] = useState(true);
const [sectionNoDisabled, setSectionNoDisabled] = useState(true);
useEffect(() => { useEffect(() => {
getRoad() getRoad()
@ -75,35 +77,71 @@ function Index() {
[key]: value [key]: value
} }
let name = [] let routeName = []
let code = [] let routeCode = []
let no = [] let sectionNo = []
let data = road?.filter(d => (nextValue?.routeName ? nextValue?.routeName == d?.routeName : true) let data = [...road]
&& (nextValue?.routeCode ? nextValue?.routeCode == d?.routeCode : true)
&& (nextValue?.sectionNo ? nextValue?.sectionNo == d?.sectionNo : true))
data.forEach(v => { data.forEach(v => {
if (v.routeName && !name.includes(v.routeName)) { if (v.routeName && !routeName.includes(v.routeName)) {
name.push(v.routeName) routeName.push(v.routeName)
} }
if (v.routeCode && !code.includes(v.routeCode)) { });
code.push(v.routeCode)
if (key == 'routeName') {
nextValue.routeCode = ''
nextValue.sectionNo = ''
data?.forEach(v => {
if (nextValue?.routeName && nextValue?.routeName == v.routeName && v.routeCode && !routeCode.includes(v.routeCode)) {
routeCode.push(v.routeCode)
} }
if (v.sectionNo && !no.includes(v.sectionNo)) { });
no.push(v.sectionNo) setCodeList(routeCode)
}
if (key == 'routeCode') {
nextValue.sectionNo = ''
data = road?.filter(s => nextValue?.routeName == s?.routeName)
data?.forEach(v => {
if (nextValue?.routeCode && nextValue?.routeCode == v?.routeCode && v.sectionNo && !sectionNo.includes(v.sectionNo)) {
sectionNo.push(v.sectionNo)
}
if (!nextValue?.routeCode && v.routeCode && !routeCode.includes(v.routeCode)) {
routeCode.push(v.routeCode)
} }
}); });
setNameList(name) if (!nextValue?.routeCode) {
setCodeList(code) setCodeList(routeCode)
setNoList(no) }
setNoList(sectionNo)
}
setNameList(routeName)
if (nextValue?.routeName) {
setRouteCodeDisabled(false)
} else {
setRouteCodeDisabled(true)
}
if (nextValue?.routeName && nextValue?.routeCode) {
setSectionNoDisabled(false)
} else {
setSectionNoDisabled(true)
}
if (nextValue.routeName && nextValue.routeCode && nextValue.sectionNo) { if (nextValue.routeName && nextValue.routeCode && nextValue.sectionNo) {
nextValue.startingPlaceName = data[0]?.startingPlaceName let find = road?.find(
nextValue.stopPlaceName = data[0]?.stopPlaceName s => nextValue.routeName == s.routeName
&& nextValue.routeCode == s.routeCode
&& nextValue.sectionNo == s.sectionNo
)
nextValue.startingPlaceName = find?.startingPlaceName
nextValue.stopPlaceName = find?.stopPlaceName
} else { } else {
nextValue.startingPlaceName = '' nextValue.startingPlaceName = ''
nextValue.stopPlaceName = '' nextValue.stopPlaceName = ''
} }
setChecked(nextValue) setChecked(nextValue)
} }
@ -168,6 +206,7 @@ function Index() {
mode='selector' mode='selector'
range={codeList} range={codeList}
onChange={e => handleCheckChange(codeList[e.detail.value], 'routeCode')} onChange={e => handleCheckChange(codeList[e.detail.value], 'routeCode')}
disabled={routeCodeDisabled}
> >
<View className='picker'> <View className='picker'>
<View>{checked.routeCode || '请选择'}</View> <View>{checked.routeCode || '请选择'}</View>
@ -189,6 +228,7 @@ function Index() {
mode='selector' mode='selector'
range={noList} range={noList}
onChange={e => handleCheckChange(noList[e.detail.value], 'sectionNo')} onChange={e => handleCheckChange(noList[e.detail.value], 'sectionNo')}
disabled={sectionNoDisabled}
> >
<View className='picker'> <View className='picker'>
<View>{checked.sectionNo || '请选择'}</View> <View>{checked.sectionNo || '请选择'}</View>

Loading…
Cancel
Save