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

Loading…
Cancel
Save