Browse Source

上报-道路相关字段逻辑修改

dev
liujiangyong 1 year ago
parent
commit
a0ed7c0da0
  1. 2
      api/app/lib/controllers/data/road.js
  2. 6
      api/app/lib/controllers/report/index.js
  3. 363
      weapp/src/packages/patrol/index.jsx
  4. 21
      weapp/src/packages/patrol/index.scss

2
api/app/lib/controllers/data/road.js

@ -93,7 +93,7 @@ async function getRoadSection (ctx) {
let findOption = { let findOption = {
where: {}, where: {},
order: [['id', 'DESC']], order: [['id', 'DESC']],
attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName', 'routeCode'] attributes: ['id', 'routeName', 'startingPlaceName', 'stopPlaceName', 'routeCode', 'sectionNo']
} }
if (level) { if (level) {

6
api/app/lib/controllers/report/index.js

@ -207,7 +207,11 @@ async function reportDetail (ctx) {
const reportRes = await models.Report.findOne({ const reportRes = await models.Report.findOne({
where: { where: {
id: reportId id: reportId
} },
include: [{
model: models.Road,
as: 'road_',
}],
}) })
ctx.status = 200; ctx.status = 200;

363
weapp/src/packages/patrol/index.jsx

@ -47,7 +47,6 @@ const Index = () => {
const [conserveUnderwayImg, setConserveUnderwayImg] = useState([]) // const [conserveUnderwayImg, setConserveUnderwayImg] = useState([]) //
const [conserveAfterImg, setConserveAfterImg] = useState([]) // const [conserveAfterImg, setConserveAfterImg] = useState([]) //
const [sourceRoadSel, setSourceRoadSel] = useState([])
const [sourceRoadStartSel, setSourceRoadStartSel] = useState([]) const [sourceRoadStartSel, setSourceRoadStartSel] = useState([])
const [sourceRoadEndSel, setSourceRoadEndSel] = useState([]) const [sourceRoadEndSel, setSourceRoadEndSel] = useState([])
@ -65,7 +64,6 @@ const Index = () => {
const [roadCodeHead, setRoadCodeHead] = useState('X') const [roadCodeHead, setRoadCodeHead] = useState('X')
const [roadCodeEnd, setRoadCodeEnd] = useState('') const [roadCodeEnd, setRoadCodeEnd] = useState('')
const [otherType, setOtherType] = useState('') // -
const [patrolContentEdit, setPatrolContentEdit] = useState(true) // const [patrolContentEdit, setPatrolContentEdit] = useState(true) //
const [patrolContent, setPatrolContent] = useState({ const [patrolContent, setPatrolContent] = useState({
@ -208,6 +206,19 @@ const Index = () => {
const [appointUser, setAppointUser] = useState(null) // userListindex const [appointUser, setAppointUser] = useState(null) // userListindex
const [handleAdvice, setHandleAdvice] = useState('') // const [handleAdvice, setHandleAdvice] = useState('') //
const [routeNameList, setRouteNameList] = useState([]);
const [routeCodeList, setRouteCodeList] = useState([]);
const [sectionNoList, setSectionNoList] = useState([]);
const [roadChecked, setRoadChecked] = useState({
routeName: '',
routeCode: '',
sectionNo: '',
startingPlaceName: '',
stopPlaceName: '',
})
const [routeCodeDisabled, setRouteCodeDisabled] = useState(true);
const [sectionNoDisabled, setSectionNoDisabled] = useState(true);
const prjType = const prjType =
isAnomaly ? isAnomaly ?
[ [
@ -240,18 +251,6 @@ const Index = () => {
const [canReport, setCanReport] = useState(true) const [canReport, setCanReport] = useState(true)
const [typeList, setTypeList] = useState([
{
value: 'patrol',
text: '巡查',
checked: true
},
{
value: 'conserve',
text: '养护',
checked: false
}
])
useEffect(() => { useEffect(() => {
if (isRoad) { if (isRoad) {
Taro.setNavigationBarTitle({ title: '在建项目' }) Taro.setNavigationBarTitle({ title: '在建项目' })
@ -329,6 +328,14 @@ const Index = () => {
setHandleCenter(data.handleContent) setHandleCenter(data.handleContent)
} }
setIsBeforeReport(dayjs(data.time).diff('2023-08-03 00:00:00', 'h') < 0) setIsBeforeReport(dayjs(data.time).diff('2023-08-03 00:00:00', 'h') < 0)
setRoadChecked({
routeName: data.road,
routeCode: data.codeRoad,
sectionNo: data.road_?.sectionNo || '-',
startingPlaceName: data.roadSectionStart,
stopPlaceName: data.roadSectionEnd,
})
} else { } else {
Taro.showToast({ title: res.data.message || '请求出错', icon: 'none' }) Taro.showToast({ title: res.data.message || '请求出错', icon: 'none' })
} }
@ -375,21 +382,37 @@ const Index = () => {
Taro.hideLoading() Taro.hideLoading()
if (res.statusCode == 200 || res.statusCode == 204) { if (res.statusCode == 200 || res.statusCode == 204) {
const { data } = res const { data } = res
let nextSourceRoadSel = []
let nextSourceRoadStartSel = [] let nextSourceRoadStartSel = []
let nextSourceRoadEndSel = [] let nextSourceRoadEndSel = []
let nextCodeRoadSel = [] let nextCodeRoadSel = []
data.map(item => {
nextSourceRoadSel.push(item.routeName) let routeName = []
let routeCode = []
let sectionNo = []
data.forEach(item => {
nextSourceRoadStartSel.push(item.startingPlaceName) nextSourceRoadStartSel.push(item.startingPlaceName)
nextSourceRoadEndSel.push(item.stopPlaceName) nextSourceRoadEndSel.push(item.stopPlaceName)
nextCodeRoadSel.push(item.routeCode) nextCodeRoadSel.push(item.routeCode)
if (item.routeName && !routeName.includes(item.routeName)) {
routeName.push(item.routeName)
}
if (item.routeCode && !routeCode.includes(item.routeCode)) {
routeCode.push(item.routeCode)
}
if (item.sectionNo && !sectionNo.includes(item.sectionNo)) {
sectionNo.push(item.sectionNo)
}
}) })
setSourceRoadSel(nextSourceRoadSel)
setSourceRoadStartSel(nextSourceRoadStartSel) setSourceRoadStartSel(nextSourceRoadStartSel)
setSourceRoadEndSel(nextSourceRoadEndSel) setSourceRoadEndSel(nextSourceRoadEndSel)
setCodeRoadSel(nextCodeRoadSel) setCodeRoadSel(nextCodeRoadSel)
setRoadList(data) setRoadList(data)
setRouteNameList(routeName)
setRouteCodeList(routeCode)
setSectionNoList(sectionNo)
} else { } else {
Taro.showToast({ title: res.data.message || '请求出错', icon: 'none' }) Taro.showToast({ title: res.data.message || '请求出错', icon: 'none' })
} }
@ -426,26 +449,10 @@ const Index = () => {
} }
}, []) }, [])
useEffect(() => {
setTypeList([
{
value: 'patrol',
text: '巡查',
checked: reportType === 'patrol' ? true : false
},
{
value: 'conserve',
text: '养护',
checked: reportType === 'conserve' ? true : false
}
])
}, [reportType])
function report() { function report() {
if (!canReport) { return } if (!canReport) { return }
if ( if (
(isPatrol && (!road || !roadCodeEnd)) ((isPatrol || isAnomaly) && (!roadChecked.routeCode || !roadChecked.sectionNo || !roadChecked.routeName))
|| (isAnomaly && !road)
|| (kind === 'patrol' || (kind === 'patrol'
&& (Object.values(patrolContent).every(c => c.value === '') && !patrolContent.inspectionNoException.selected && (Object.values(patrolContent).every(c => c.value === '') && !patrolContent.inspectionNoException.selected
|| Object.values(patrolContent).some(c => c.label !== '巡查结果无异常' && c.selected && c.value === ''))) || Object.values(patrolContent).some(c => c.label !== '巡查结果无异常' && c.selected && c.value === '')))
@ -476,17 +483,21 @@ const Index = () => {
let data = { let data = {
reportType: isPatrol ? reportType : kind, reportType: isPatrol ? reportType : kind,
projectType: reportProjectType, projectType: reportProjectType,
road, road: roadChecked.routeName,
roadSectionStart, roadSectionStart: roadChecked.startingPlaceName,
roadSectionEnd, roadSectionEnd: roadChecked.stopPlaceName,
address, address,
content, content,
longitude, longitude,
latitude, latitude,
codeRoad, codeRoad: roadChecked.routeCode,
projectName, projectName,
handleState: isAnomaly ? '待处理' : undefined, handleState: isAnomaly ? '待处理' : undefined,
videoUrl: videoqn videoUrl: videoqn,
roadId: roadList.find(r => roadChecked?.routeName == r?.routeName
&& roadChecked?.routeCode == r?.routeCode
&& roadChecked?.sectionNo == r?.sectionNo
)?.id,
} }
if (reportType === 'patrol' || isAnomaly || isRoad) { if (reportType === 'patrol' || isAnomaly || isRoad) {
data['scenePic'] = sceneImg data['scenePic'] = sceneImg
@ -496,7 +507,6 @@ const Index = () => {
data['conserveAfterPic'] = conserveAfterImg data['conserveAfterPic'] = conserveAfterImg
} }
if (isPatrol) { if (isPatrol) {
data.codeRoad = roadCodeHead + roadCodeEnd
if (kind === 'patrol') { if (kind === 'patrol') {
Object.keys(patrolContent).forEach(key => { Object.keys(patrolContent).forEach(key => {
data[key] = patrolContent[key].value data[key] = patrolContent[key].value
@ -716,8 +726,72 @@ const Index = () => {
} }
} }
function handleTypeChange(e) { const handleRoadCheckChange = (value, key) => {
setReportType(e.detail.value) let nextValue = {
...roadChecked,
[key]: value
}
let routeName = []
let routeCode = []
let sectionNo = []
let data = [...roadList]
data.forEach(v => {
if (v.routeName && !routeName.includes(v.routeName)) {
routeName.push(v.routeName)
}
});
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)
}
});
setRouteCodeList(routeCode)
}
if (key == 'routeCode') {
nextValue.sectionNo = ''
data = roadList?.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)
}
});
if (!nextValue?.routeCode) {
setRouteCodeList(routeCode)
}
setSectionNoList(sectionNo)
}
setRouteNameList(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
setRoadCodeHead(data[0]?.routeCode?.charAt(0))
} else {
nextValue.startingPlaceName = ''
nextValue.stopPlaceName = ''
}
setRoadChecked(nextValue)
} }
function handleImgChange(files, operationType, index, type) { function handleImgChange(files, operationType, index, type) {
@ -962,71 +1036,74 @@ const Index = () => {
} }
return ( return (
<View className='patrol'> <View className='patrol'>
{/* {
(!isSuperAdmin || isView)
&& !isRoad && !isAnomaly
&&
<View className='report-type'>
<View className='text'>上报类型</View>
<RadioGroup onChange={handleTypeChange}>
{ {
typeList.map((item, i) => { isPatrol || isAnomaly ? <>
return ( <View className='code-choice'>
<Radio <Text style={{ color: 'red' }}>*&nbsp;</Text>路线名称
key={i} <View className='select-box'>
value={item.value} <Picker
checked={item.checked} mode='selector'
className='radio' range={routeNameList}
color='#346FC2' onChange={e => handleRoadCheckChange(routeNameList[e.detail.value], 'routeName')}
disabled={isView} disabled={isView}
> >
{item.text} <View className='picker'>
</Radio> <View>{roadChecked.routeName || '请选择路线名称'}</View>
) <AtIcon className='arrow' value='chevron-down' size='20' color='#999' />
})
}
</RadioGroup>
</View> </View>
} */} </Picker>
{!isView && <AtIcon
{ value='close-circle'
isPatrol ? <> size='20'
{!(isView && isBeforeReport) && <View className='code-choice'> color='#999'
onClick={() => handleRoadCheckChange('', 'routeName')}
/>}
</View>
</View>
{!(isView && isBeforeReport) && <View className={`code-choice ${routeCodeDisabled && !isView ? ` disabled` : ``}`}>
<Text style={{ color: 'red' }}>*&nbsp;</Text>线路编码 <Text style={{ color: 'red' }}>*&nbsp;</Text>线路编码
<RadioGroup onChange={(e) => { <View className='select-box'>
setRoadCodeHead(e.detail.value[0]); <Picker
if (roadCodeEnd.length >= 9) { mode='selector'
queryConserveInfo(e.detail.value[0], roadCodeEnd) range={routeCodeList}
} else { onChange={e => handleRoadCheckChange(routeCodeList[e.detail.value], 'routeCode')}
setRoadStartSel([]) disabled={routeCodeDisabled}
setRoadEndSel([]) >
setRoadSectionStart('') <View className='picker'>
setRoadSectionEnd('') <View>{roadChecked.routeCode || '请选择线路编码'}</View>
setRoad('') <AtIcon className='arrow' value='chevron-down' size='20' color='#999' />
if (!patrolContentEdit) { </View>
setPatrolContentEdit(true) </Picker>
let nextInfo = { ...conserveInfo } {roadChecked.routeCode && !isView && <AtIcon
Object.keys(conserveInfo).forEach(key => { value='close-circle'
nextInfo[key].value = '' size='20'
}) color='#999'
setConserveInfo(nextInfo) onClick={() => handleRoadCheckChange('', 'routeCode')}
} />}
} </View>
}}>
<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>
<Radio value='C' checked={roadCodeHead === 'C'} color='#0080EE' className='radio' disabled={isView}>C</Radio>
</RadioGroup>
<Input
style={{ width: 140 }}
type='text'
placeholder={isView ? '' : '输入后9位线路编码'}
value={roadCodeEnd}
maxlength={10}
onInput={e => handleInput(e, 'roadCodeEnd')}
disabled={isView}
/>
</View>} </View>}
<View className={`code-choice ${sectionNoDisabled && !isView ? ` disabled` : ``}`}>
<Text style={{ color: 'red' }}>*&nbsp;</Text>路段序号
<View className='select-box'>
<Picker
mode='selector'
range={sectionNoList}
onChange={e => handleRoadCheckChange(sectionNoList[e.detail.value], 'sectionNo')}
disabled={sectionNoDisabled}
>
<View className='picker'>
<View>{roadChecked.sectionNo || '请选择路段序号'}</View>
<AtIcon className='arrow' value='chevron-down' size='20' color='#999' />
</View>
</Picker>
{roadChecked.sectionNo && !isView && <AtIcon
value='close-circle'
size='20'
color='#999'
onClick={() => handleRoadCheckChange('', 'sectionNo')}
/>}
</View>
</View>
<View className='code-choice'> <View className='code-choice'>
<Text style={{ color: 'red' }}>*&nbsp;</Text>道路类型 <Text style={{ color: 'red' }}>*&nbsp;</Text>道路类型
<Input <Input
@ -1038,29 +1115,7 @@ const Index = () => {
onInput={() => { }} onInput={() => { }}
disabled={true} disabled={true}
/> />
{!(isView && isBeforeReport) && <>
<Text>其他</Text>
<InputPicker
width='30%'
star={false}
onlySelect
title=''
placeholder=''
value={projectType}
onInput={(value) => setProjectType(value === '无' ? '' : value)}
selector={prjTypeSelector}
isView={isView}
/>
</>}
</View> </View>
<InputPicker
title='路线名称:'
placeholder='请输入路线名称'
value={road}
onInput={setRoad}
selector={sourceRoadSel}
isView={isView}
/>
</> : '' </> : ''
} }
@ -1104,73 +1159,25 @@ const Index = () => {
/> : '' /> : ''
} }
{
isAnomaly ?
<InputPicker
key={123} // keyselector
title='所在道路:'
placeholder='请选择或输入您所在的道路'
value={road}
onInput={setRoad}
selector={sourceRoadSel}
isView={isView}
/> : ''
}
{
isAnomaly || (isView && isBeforeReport) ?
<InputPickers
key={456} // keyselector
title='线路编码:'
value={codeRoad}
onInput={setCodeRoad}
selector={codeRoadSel}
isView={isView}
/> : ''
}
{ {
isPatrol || isAnomaly ? isPatrol || isAnomaly ?
<View className='road-section'> <View className='road-section'>
<View className='title'>所属路段</View> <View className='title'>所属路段</View>
<Input <Input
className='input' className='input text---'
type='text' type='text'
placeholder={isView ? '' : '路段名称'}
border={false} border={false}
value={roadSectionStart} value={roadChecked.startingPlaceName}
onInput={e => handleInput(e, 'roadSectionStart')} disabled={true}
disabled={isView}
/> />
{
!isView &&
<Picker
mode='selector'
range={roadStartSel}
onChange={e => setRoadSectionStart(roadStartSel[e.detail.value])}
>
<Image src={arrowIcon} className='img-l' />
</Picker>
}
<View>&nbsp;</View> <View>&nbsp;</View>
<Input <Input
className='input' className='input text---'
type='text' type='text'
placeholder={isView ? '' : '路段名称'}
border={false} border={false}
value={roadSectionEnd} value={roadChecked.stopPlaceName}
onInput={e => handleInput(e, 'roadSectionEnd')} disabled={true}
disabled={isView}
/> />
{
!isView &&
<Picker
mode='selector'
range={roadEndSel}
onChange={e => setRoadSectionEnd(roadEndSel[e.detail.value])}
>
<Image src={arrowIcon} className='img-r' />
</Picker>
}
</View> : '' </View> : ''
} }

21
weapp/src/packages/patrol/index.scss

@ -182,6 +182,10 @@ page {
} }
} }
.disabled {
background-color: #eee;
}
.patrol-content { .patrol-content {
background-color: #fff; background-color: #fff;
margin-bottom: 5px; margin-bottom: 5px;
@ -330,4 +334,21 @@ page {
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
} }
.select-box {
width: calc(100% - 192px - 16px);
display: flex;
justify-content: flex-end;
.picker {
width: 400px;
display: flex;
justify-content: flex-end;
align-items: center;
.arrow {
margin: 0 32px;
}
}
}
} }
Loading…
Cancel
Save