Browse Source

拆分巡查、养护上报

dev
巴林闲侠 2 years ago
parent
commit
9adb0ad265
  1. 5
      api/app/lib/controllers/report/index.js
  2. 6
      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) {
try {
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 = {
where: {
@ -46,6 +46,9 @@ async function reportList (ctx) {
if (reportType) {
findOption.where.reportType = reportType
}
if (projectType) {
findOption.where.projectType = projectType
}
let reportRes = null;
if (isTop) {

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

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

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

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

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

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

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

@ -45,8 +45,9 @@ const Index = () => {
return (
<View className='page'>
<View className='card fill'>
<View className='title'> </View>
<View className='title'> </View>
<View className='btn' onClick={
isSuperAdmin ?
() => toPatrolView('patrol')
@ -55,6 +56,18 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'}
</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='title'> </View>
<View className='btn' onClick={
@ -65,6 +78,7 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
<View className='card fill_anomaly'>
<View className='title'> </View>
<View className='btn' onClick={
@ -75,6 +89,7 @@ const Index = () => {
{isSuperAdmin ? '查看' : '填报'}
</View>
</View>
{/* {
isSuperAdmin &&
<View className='card video'>
@ -82,6 +97,7 @@ const Index = () => {
<View className='btn' onClick={toVideo}>查看</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')}>
<Image className='box-img' src={reportImg} />
<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>
<Image className='img' src={moreImg} />
</View>

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

@ -272,8 +272,12 @@ const PatrolNameList = (props) => {
return {
onClick: () => {
if (record) {
setSelectRoad(record.id);
onChange(record);
let id = record.id
if (selectRoad == record.id) {
id = null
}
setSelectRoad(id);
onChange(id ? record : null);
}
},
};
@ -294,28 +298,35 @@ const MaintenanceTable = (props) => {
const { RangePicker } = DatePicker;
useEffect(() => {
if (userList && userList instanceof Array) {
let users = userList.filter(user => user.remark != 'sp');
queryData()
}, [])
setRecord(users[0]);
}
useEffect(() => {
// if (userList && userList instanceof Array) {
// let users = userList.filter(user => user.remark != 'sp');
// setRecord(users[0]);
// }
}, [userList])
useEffect(() => {
if (record) {
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));
}
// if (record) {
queryData()
// }
}, [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 = () => {
setDetailVisible(false)
}

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

@ -1,6 +1,6 @@
import { connect } from 'react-redux';
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 { getReportList, getReportDetail, handleReport } from '../actions/patrol';
import React, { useEffect, useState } from 'react';
@ -19,6 +19,7 @@ const DetailForm = (props) => {
const keyList = [
// { key: '编号', name: 'id' },
{ key: '工程类型', name: 'projectType', skip: !isPatrol },
{ key: '反馈类型', name: 'projectType', skip: !isAnomaly },
{ key: '工程名称', name: 'projectName', skip: !isRoad },
{ key: '所在路段', name: 'road', skip: isRoad },
{ key: '具体位置', name: 'address' },
@ -128,9 +129,9 @@ const DetailList = (props) => {
return moment(record.time).format("YYYYMMDD") * 10000 + counter;
}
} : '',
isPatrol ?
isPatrol || isAnomaly ?
{
title: '工程类型',
title: isPatrol ? '工程类型' : '反馈类型',
key: 'projectType',
dataIndex: 'projectType',
align: 'center',
@ -140,6 +141,9 @@ const DetailList = (props) => {
case 'bridge': return '桥梁';
case 'culvert': return '涵洞';
case 'other': return '其他';
case 'conserve': return '养护';
case 'patrol': return '巡查';
case 'construction': return '在建';
default: return text;
}
}
@ -268,9 +272,8 @@ const PatrolNameList = (props) => {
useEffect(() => {
if (userList && userList instanceof Array && userList.length) {
setSelectRoad(userList[0].id)
// setSelectRoad(userList[0].id)
// onChange(userList[0]);
}
if (activeTabKey1 == 'tab2') {
@ -333,7 +336,7 @@ const PatrolNameList = (props) => {
id = null
}
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 [record, setRecord] = useState();
const [dateRange, setDateRange] = useState();
const [selectProjectType, setSelectProjectType] = useState('');
const [detailVisible, setDetailVisible] = useState(false)
const [activeTabKey1, setActiveTabKey1] = useState('tab1');
@ -360,19 +364,21 @@ const PatrolTable = (props) => {
const reportType = isRoad ? 'road' : isAnomaly ? 'anomaly' : 'patrol';
useEffect(() => {
if (userList && userList instanceof Array) {
setRecord(userList[0]);
}
queryData();
}, [])
useEffect(() => {
// if (userList && userList instanceof Array) {
// setRecord(userList[0]);
// }
}, [userList])
useEffect(() => {
if (record) {
queryData();
}
}, [record, dateRange])
queryData();
}, [record, dateRange, selectProjectType])
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] != '')) {
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')
@ -384,7 +390,7 @@ const PatrolTable = (props) => {
if (activeTabKey1 && activeTabKey1 == 'tab2') {
setRecord(null);
} else if (activeTabKey1 && activeTabKey1 == 'tab1') {
setRecord(userList[0]);
// setRecord(userList[0]);
}
}, [activeTabKey1])
@ -428,7 +434,7 @@ const PatrolTable = (props) => {
const handleChangeRecord = (newRecord) => {
let target = null;
if (!record || newRecord.id != record.id) {
if (!record || (newRecord && newRecord.id != record.id)) {
target = newRecord;
}
setRecord(target);
@ -463,6 +469,25 @@ const PatrolTable = (props) => {
activeTabKey1 == 'tab1' ?
<div style={{ marginBottom: 20 }}>
<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 }} onClick={handleExport} >导出</Button> */}
</div> : ''

Loading…
Cancel
Save