Browse Source

拆分巡查、养护上报

dev
巴林闲侠 2 years ago
parent
commit
9adb0ad265
  1. 5
      api/app/lib/controllers/report/index.js
  2. 4
      weapp/src/packages/components/inputPicker/index.jsx
  3. 77
      weapp/src/packages/patrol/index.jsx
  4. 16
      weapp/src/packages/patrolView/index.jsx
  5. 18
      weapp/src/pages/home/index.jsx
  6. 10
      weapp/src/pages/user/index.jsx
  7. 47
      web/client/src/sections/fillion/components/maintenanceTable.js
  8. 57
      web/client/src/sections/fillion/components/patrolTable.js

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

@ -4,7 +4,7 @@ const { QueryTypes } = require('sequelize');
async function reportList (ctx) { async function reportList (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc } = ctx.query const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType } = ctx.query
let findOption = { let findOption = {
where: { where: {
@ -46,6 +46,9 @@ async function reportList (ctx) {
if (reportType) { if (reportType) {
findOption.where.reportType = reportType findOption.where.reportType = reportType
} }
if (projectType) {
findOption.where.projectType = projectType
}
let reportRes = null; let reportRes = null;
if (isTop) { if (isTop) {

4
weapp/src/packages/components/inputPicker/index.jsx

@ -14,6 +14,10 @@ export default function InputPicker(props) {
setCurSelector(selector) setCurSelector(selector)
}, []) }, [])
useEffect(()=>{
handleInput({ detail: { value: value } })
},[value])
function handleInput({ detail: { value: v } }) { function handleInput({ detail: { value: v } }) {
onInput(v) onInput(v)
if (v) { if (v) {

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

@ -21,11 +21,11 @@ const Index = () => {
const { params: { type, kind } } = router const { params: { type, kind } } = router
const isView = type === 'view' ? true : false const isView = type === 'view' ? true : false
const isPatrol = kind === 'patrol' ? true : false const isPatrol = kind === 'patrol' || kind == 'conserve' ? true : false
const isRoad = kind === 'road' ? true : false const isRoad = kind === 'road' ? true : false
const isAnomaly = kind === 'anomaly' ? true : false const isAnomaly = kind === 'anomaly' ? true : false
const [reportType, setReportType] = useState('patrol') // const [reportType, setReportType] = useState(kind || 'patrol') //
const [projectType, setProjectType] = useState('') // const [projectType, setProjectType] = useState('') //
const [projectName, setProjectName] = useState('') // const [projectName, setProjectName] = useState('') //
const [road, setRoad] = useState('') // const [road, setRoad] = useState('') //
@ -49,13 +49,32 @@ const Index = () => {
const [sourceRoadStartSel, setSourceRoadStartSel] = useState([]) const [sourceRoadStartSel, setSourceRoadStartSel] = useState([])
const [sourceRoadEndSel, setSourceRoadEndSel] = useState([]) const [sourceRoadEndSel, setSourceRoadEndSel] = useState([])
const prjType = [ const prjType =
{ text: '道路', value: 'road' }, isAnomaly ?
{ text: '桥梁', value: 'bridge' }, [
{ text: '涵洞', value: 'culvert' }, { text: '养护', value: 'conserve' },
{ text: '其他', value: 'other' }, { text: '巡查', value: 'patrol' },
] { text: '在建', value: 'construction' },
const prjTypeSelector = ['道路', '桥梁', '涵洞', '其他'] ]
:
[
{ text: '道路', value: 'road', onlyView: true },
{ text: '县道', value: 'countyRoad' },
{ text: '乡道', value: 'villageRoad' },
{ text: '村道', value: 'rusticRoad' },
{ text: '桥梁', value: 'bridge' },
{ text: '涵洞', value: 'culvert' },
{ text: '其他', value: 'other' },
]
const prjTypeSelector = prjType.map(item => {
return item.onlyView ? '' : item.text
}).filter(item => item)
// [
// // '',
// '', '', '',
// '', '', ''
// ]
const [roadStartSel, setRoadStartSel] = useState([]) const [roadStartSel, setRoadStartSel] = useState([])
const [roadEndSel, setRoadEndSel] = useState([]) const [roadEndSel, setRoadEndSel] = useState([])
@ -77,8 +96,12 @@ const Index = () => {
useEffect(() => { useEffect(() => {
if (isRoad) { if (isRoad) {
Taro.setNavigationBarTitle({ title: '在建道路' }) Taro.setNavigationBarTitle({ title: '在建道路' })
} if (isAnomaly) { } else if (isAnomaly) {
Taro.setNavigationBarTitle({ title: '异常反馈' }) Taro.setNavigationBarTitle({ title: '异常反馈' })
} else if (kind == 'conserve') {
Taro.setNavigationBarTitle({ title: '养护上报' })
} else {
Taro.setNavigationBarTitle({ title: '巡查上报' })
} }
if (isView) { // if (isView) { //
@ -124,9 +147,17 @@ const Index = () => {
url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${key}`, url: `https://apis.map.qq.com/ws/geocoder/v1/?location=${res.latitude},${res.longitude}&key=${key}`,
success: function (res) { success: function (res) {
// res // res
// let addresscity = res.data.result.address_component.province + res.data.result.address_component.city + res.data.result.address_component.district let addresscity = ''
// console.log(res, 'res') addresscity =
setAddress(res.data.result.formatted_addresses.standard_address) res.data.result.address_component.province
+ res.data.result.address_component.city
+ res.data.result.address_component.district
+ res.data.result.address_component.street_number
// addresscity = res.data.result.formatted_addresses.standard_address
console.log(res, 'res')
let street = res.data.result.address_component.street
setRoad(street)
setAddress(addresscity)
} }
}) })
} }
@ -412,7 +443,7 @@ const Index = () => {
return ( return (
<View className='patrol'> <View className='patrol'>
{ {/* {
(!isSuperAdmin || isView) (!isSuperAdmin || isView)
&& !isRoad && !isAnomaly && !isRoad && !isAnomaly
&& &&
@ -437,13 +468,25 @@ const Index = () => {
} }
</RadioGroup> </RadioGroup>
</View> </View>
} } */}
{ {
isPatrol ? isPatrol ?
<InputPicker <InputPicker
title='工程类型:' title='道路类型:'
placeholder='请选择工程类型' placeholder='请选择道路类型'
value={projectType}
onInput={setProjectType}
selector={prjTypeSelector}
isView={isView}
/> : ''
}
{
isAnomaly ?
<InputPicker
title='反馈类型:'
placeholder='请选择反馈类型'
value={projectType} value={projectType}
onInput={setProjectType} onInput={setProjectType}
selector={prjTypeSelector} selector={prjTypeSelector}

16
weapp/src/packages/patrolView/index.jsx

@ -19,7 +19,7 @@ function Index () {
const router = useRouter() const router = useRouter()
const { params: { filter, kind } } = router const { params: { filter, kind } } = router
const isPatrol = kind === 'patrol' ? true : false const isPatrol = kind === 'patrol' || kind == 'conserve' ? true : false
const isRoad = kind === 'road' ? true : false const isRoad = kind === 'road' ? true : false
const isAnomaly = kind === 'anomaly' ? true : false const isAnomaly = kind === 'anomaly' ? true : false
@ -36,8 +36,12 @@ function Index () {
useEffect(() => { useEffect(() => {
if (isRoad) { if (isRoad) {
Taro.setNavigationBarTitle({ title: '在建道路' }) Taro.setNavigationBarTitle({ title: '在建道路' })
} if (isAnomaly) { } else if (isAnomaly) {
Taro.setNavigationBarTitle({ title: '异常反馈' }) Taro.setNavigationBarTitle({ title: '异常反馈' })
} else if (kind == 'conserve') {
Taro.setNavigationBarTitle({ title: '养护上报' })
} else {
Taro.setNavigationBarTitle({ title: '巡查上报' })
} }
}, []) }, [])
@ -134,7 +138,7 @@ function Index () {
return ( return (
<View> <View>
{ {/* {
isPatrol ? isPatrol ?
<View className='type-box'> <View className='type-box'>
<View className='item' onClick={() => setReportType('patrol')}> <View className='item' onClick={() => setReportType('patrol')}>
@ -148,9 +152,9 @@ function Index () {
</View> </View>
</View> </View>
: "" : ""
} } */}
<View className='filter-box' style={{ top: isPatrol ? "40px" : '0' }}> <View className='filter-box' style={{ top: isPatrol && false ? "40px" : '0' }}>
<View className='filter-item'> <View className='filter-item'>
<View style={{ float: 'left', marginLeft: '20rpx', color: '#333' }}>日期</View> <View style={{ float: 'left', marginLeft: '20rpx', color: '#333' }}>日期</View>
<Picker <Picker
@ -172,7 +176,7 @@ function Index () {
</View> </View>
</View> </View>
<View style={{ marginTop: isPatrol ? '110px' : "80px" }}> <View style={{ marginTop: isPatrol && false ? '110px' : "80px" }}>
{ {
listData && listData.length > 0 ? listData && listData.map((e, index) => { listData && listData.length > 0 ? listData && listData.map((e, index) => {
return ( return (

18
weapp/src/pages/home/index.jsx

@ -45,8 +45,9 @@ const Index = () => {
return ( return (
<View className='page'> <View className='page'>
<View className='card fill'> <View className='card fill'>
<View className='title'> </View> <View className='title'> </View>
<View className='btn' onClick={ <View className='btn' onClick={
isSuperAdmin ? isSuperAdmin ?
() => toPatrolView('patrol') () => toPatrolView('patrol')
@ -55,6 +56,18 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'} {isSuperAdmin ? '查看' : '填报'}
</View> </View>
</View> </View>
<View className='card fill'>
<View className='title'> </View>
<View className='btn' onClick={
isSuperAdmin ?
() => toPatrolView('conserve')
: () => toPatrol('conserve')
}>
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
<View className='card fill_road'> <View className='card fill_road'>
<View className='title'> </View> <View className='title'> </View>
<View className='btn' onClick={ <View className='btn' onClick={
@ -65,6 +78,7 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'} {isSuperAdmin ? '查看' : '填报'}
</View> </View>
</View> </View>
<View className='card fill_anomaly'> <View className='card fill_anomaly'>
<View className='title'> </View> <View className='title'> </View>
<View className='btn' onClick={ <View className='btn' onClick={
@ -75,6 +89,7 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'} {isSuperAdmin ? '查看' : '填报'}
</View> </View>
</View> </View>
{/* { {/* {
isSuperAdmin && isSuperAdmin &&
<View className='card video'> <View className='card video'>
@ -82,6 +97,7 @@ const Index = () => {
<View className='btn' onClick={toVideo}>查看</View> <View className='btn' onClick={toVideo}>查看</View>
</View> </View>
} */} } */}
</View> </View>
); );
} }

10
weapp/src/pages/user/index.jsx

@ -67,7 +67,15 @@ const Index = ({ ...props }) => {
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('patrol') : () => toMyReport('patrol')}> <View className='box' onClick={isSuperAdmin ? () => toPatrolReport('patrol') : () => toMyReport('patrol')}>
<Image className='box-img' src={reportImg} /> <Image className='box-img' src={reportImg} />
<View className='box-txt'> <View className='box-txt'>
{isSuperAdmin ? '巡查上报' : '我的上报'} {isSuperAdmin ? '巡查上报' : '巡查上报'}
</View>
<Image className='img' src={moreImg} />
</View>
<View className='box' onClick={isSuperAdmin ? () => toPatrolReport('conserve') : () => toMyReport('conserve')}>
<Image className='box-img' src={reportImg} />
<View className='box-txt'>
{isSuperAdmin ? '养护上报' : '养护上报'}
</View> </View>
<Image className='img' src={moreImg} /> <Image className='img' src={moreImg} />
</View> </View>

47
web/client/src/sections/fillion/components/maintenanceTable.js

@ -272,8 +272,12 @@ const PatrolNameList = (props) => {
return { return {
onClick: () => { onClick: () => {
if (record) { if (record) {
setSelectRoad(record.id); let id = record.id
onChange(record); if (selectRoad == record.id) {
id = null
}
setSelectRoad(id);
onChange(id ? record : null);
} }
}, },
}; };
@ -294,28 +298,35 @@ const MaintenanceTable = (props) => {
const { RangePicker } = DatePicker; const { RangePicker } = DatePicker;
useEffect(() => { useEffect(() => {
if (userList && userList instanceof Array) { queryData()
let users = userList.filter(user => user.remark != 'sp'); }, [])
setRecord(users[0]); useEffect(() => {
} // if (userList && userList instanceof Array) {
// let users = userList.filter(user => user.remark != 'sp');
// setRecord(users[0]);
// }
}, [userList]) }, [userList])
useEffect(() => { useEffect(() => {
if (record) { // if (record) {
let query = { queryData()
userId: record.id, // }
reportType: 'conserve',
asc: true
}
if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
}
dispatch(getReportList(query));
}
}, [record, dateRange]) }, [record, dateRange])
const queryData = () => {
let query = {
userId: record?.id,
reportType: 'conserve',
asc: true
}
if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
}
dispatch(getReportList(query));
}
const handleClose = () => { const handleClose = () => {
setDetailVisible(false) setDetailVisible(false)
} }

57
web/client/src/sections/fillion/components/patrolTable.js

@ -1,6 +1,6 @@
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import './protable.less' import './protable.less'
import { Card, Button, Popconfirm, Badge, Col, Row, DatePicker, Input, Modal, Spin, Image, message, Popover } from 'antd'; import { Card, Button, Popconfirm, Badge, Col, Row, DatePicker, Input, Modal, Spin, Image, message, Popover, Select } from 'antd';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import { getReportList, getReportDetail, handleReport } from '../actions/patrol'; import { getReportList, getReportDetail, handleReport } from '../actions/patrol';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
@ -19,6 +19,7 @@ const DetailForm = (props) => {
const keyList = [ const keyList = [
// { key: '编号', name: 'id' }, // { key: '编号', name: 'id' },
{ key: '工程类型', name: 'projectType', skip: !isPatrol }, { key: '工程类型', name: 'projectType', skip: !isPatrol },
{ key: '反馈类型', name: 'projectType', skip: !isAnomaly },
{ key: '工程名称', name: 'projectName', skip: !isRoad }, { key: '工程名称', name: 'projectName', skip: !isRoad },
{ key: '所在路段', name: 'road', skip: isRoad }, { key: '所在路段', name: 'road', skip: isRoad },
{ key: '具体位置', name: 'address' }, { key: '具体位置', name: 'address' },
@ -128,9 +129,9 @@ const DetailList = (props) => {
return moment(record.time).format("YYYYMMDD") * 10000 + counter; return moment(record.time).format("YYYYMMDD") * 10000 + counter;
} }
} : '', } : '',
isPatrol ? isPatrol || isAnomaly ?
{ {
title: '工程类型', title: isPatrol ? '工程类型' : '反馈类型',
key: 'projectType', key: 'projectType',
dataIndex: 'projectType', dataIndex: 'projectType',
align: 'center', align: 'center',
@ -140,6 +141,9 @@ const DetailList = (props) => {
case 'bridge': return '桥梁'; case 'bridge': return '桥梁';
case 'culvert': return '涵洞'; case 'culvert': return '涵洞';
case 'other': return '其他'; case 'other': return '其他';
case 'conserve': return '养护';
case 'patrol': return '巡查';
case 'construction': return '在建';
default: return text; default: return text;
} }
} }
@ -268,9 +272,8 @@ const PatrolNameList = (props) => {
useEffect(() => { useEffect(() => {
if (userList && userList instanceof Array && userList.length) { if (userList && userList instanceof Array && userList.length) {
setSelectRoad(userList[0].id) // setSelectRoad(userList[0].id)
// onChange(userList[0]); // onChange(userList[0]);
} }
if (activeTabKey1 == 'tab2') { if (activeTabKey1 == 'tab2') {
@ -333,7 +336,7 @@ const PatrolNameList = (props) => {
id = null id = null
} }
setSelectRoad(id); setSelectRoad(id);
onChange(record); onChange(id ? record : null);
} }
}, },
}; };
@ -349,6 +352,7 @@ const PatrolTable = (props) => {
const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname } = props; const { userList, reportList, dispatch, reportListLoading, reportDetail, reportDetailLoading, userLoading, exports, pathname } = props;
const [record, setRecord] = useState(); const [record, setRecord] = useState();
const [dateRange, setDateRange] = useState(); const [dateRange, setDateRange] = useState();
const [selectProjectType, setSelectProjectType] = useState('');
const [detailVisible, setDetailVisible] = useState(false) const [detailVisible, setDetailVisible] = useState(false)
const [activeTabKey1, setActiveTabKey1] = useState('tab1'); const [activeTabKey1, setActiveTabKey1] = useState('tab1');
@ -360,19 +364,21 @@ const PatrolTable = (props) => {
const reportType = isRoad ? 'road' : isAnomaly ? 'anomaly' : 'patrol'; const reportType = isRoad ? 'road' : isAnomaly ? 'anomaly' : 'patrol';
useEffect(() => { useEffect(() => {
if (userList && userList instanceof Array) { queryData();
setRecord(userList[0]); }, [])
}
useEffect(() => {
// if (userList && userList instanceof Array) {
// setRecord(userList[0]);
// }
}, [userList]) }, [userList])
useEffect(() => { useEffect(() => {
if (record) { queryData();
queryData(); }, [record, dateRange, selectProjectType])
}
}, [record, dateRange])
const queryData = () => { const queryData = () => {
let query = { userId: record.id, reportType: reportType, asc: true } let query = { userId: record?.id, reportType: reportType, projectType: selectProjectType, asc: true }
if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) { if ((dateRange && dateRange instanceof Array && dateRange[0] != '')) {
query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss') query.startTime = moment(dateRange[0]).startOf('day').format('YYYY-MM-DD HH:mm:ss')
query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss') query.endTime = moment(dateRange[1]).endOf('day').format('YYYY-MM-DD HH:mm:ss')
@ -384,7 +390,7 @@ const PatrolTable = (props) => {
if (activeTabKey1 && activeTabKey1 == 'tab2') { if (activeTabKey1 && activeTabKey1 == 'tab2') {
setRecord(null); setRecord(null);
} else if (activeTabKey1 && activeTabKey1 == 'tab1') { } else if (activeTabKey1 && activeTabKey1 == 'tab1') {
setRecord(userList[0]); // setRecord(userList[0]);
} }
}, [activeTabKey1]) }, [activeTabKey1])
@ -428,7 +434,7 @@ const PatrolTable = (props) => {
const handleChangeRecord = (newRecord) => { const handleChangeRecord = (newRecord) => {
let target = null; let target = null;
if (!record || newRecord.id != record.id) { if (!record || (newRecord && newRecord.id != record.id)) {
target = newRecord; target = newRecord;
} }
setRecord(target); setRecord(target);
@ -463,6 +469,25 @@ const PatrolTable = (props) => {
activeTabKey1 == 'tab1' ? activeTabKey1 == 'tab1' ?
<div style={{ marginBottom: 20 }}> <div style={{ marginBottom: 20 }}>
<RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} /> <RangePicker onChange={(date, dateString) => { setDateRange(dateString) }} />
{
isAnomaly ?
<Select
style={{
width: 120,
marginLeft: 20
}}
options={[
{ label: '养护', value: 'conserve' },
{ label: '巡查', value: 'patrol' },
{ label: '在建', value: 'construction' },
]}
placeholder="反馈类型"
onChange={(value) => {
setSelectProjectType(value)
}}
/>
: ''
}
<Button style={{ marginLeft: 20 }}>查询</Button> <Button style={{ marginLeft: 20 }}>查询</Button>
{/* <Button style={{ marginLeft: 20 }} onClick={handleExport} >导出</Button> */} {/* <Button style={{ marginLeft: 20 }} onClick={handleExport} >导出</Button> */}
</div> : '' </div> : ''

Loading…
Cancel
Save