diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index d5474115..c1638f9c 100644 --- a/api/app/lib/controllers/report/index.js +++ b/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) { diff --git a/weapp/src/packages/components/inputPicker/index.jsx b/weapp/src/packages/components/inputPicker/index.jsx index 03f9b94a..c28d1d87 100644 --- a/weapp/src/packages/components/inputPicker/index.jsx +++ b/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) { } ) -} \ No newline at end of file +} diff --git a/weapp/src/packages/patrol/index.jsx b/weapp/src/packages/patrol/index.jsx index e0dbab9e..5451b8e6 100644 --- a/weapp/src/packages/patrol/index.jsx +++ b/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 ( - { + {/* { (!isSuperAdmin || isView) && !isRoad && !isAnomaly && @@ -437,13 +468,25 @@ const Index = () => { } - } + } */} { isPatrol ? : '' + } + + { + isAnomaly ? + { 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 ( - { + {/* { isPatrol ? setReportType('patrol')}> @@ -148,9 +152,9 @@ function Index () { : "" - } + } */} - + 日期: - + { listData && listData.length > 0 ? listData && listData.map((e, index) => { return ( diff --git a/weapp/src/pages/home/index.jsx b/weapp/src/pages/home/index.jsx index 18db4a91..e6a155d2 100644 --- a/weapp/src/pages/home/index.jsx +++ b/weapp/src/pages/home/index.jsx @@ -45,8 +45,9 @@ const Index = () => { return ( + - 巡 查 养 护 + 巡 查 上 报 toPatrolView('patrol') @@ -55,6 +56,18 @@ const Index = () => { {isSuperAdmin ? '查看' : '填报'} + + + 养 护 上 报 + toPatrolView('conserve') + : () => toPatrol('conserve') + }> + {isSuperAdmin ? '查看' : '填报'} + + + 在 建 道 路 { {isSuperAdmin ? '查看' : '填报'} + 异 常 反 馈 { {isSuperAdmin ? '查看' : '填报'} + {/* { isSuperAdmin && @@ -82,6 +97,7 @@ const Index = () => { 查看 } */} + ); } diff --git a/weapp/src/pages/user/index.jsx b/weapp/src/pages/user/index.jsx index 14b73fd2..83c5c9c2 100644 --- a/weapp/src/pages/user/index.jsx +++ b/weapp/src/pages/user/index.jsx @@ -67,7 +67,15 @@ const Index = ({ ...props }) => { toPatrolReport('patrol') : () => toMyReport('patrol')}> - {isSuperAdmin ? '巡查上报' : '我的上报'} + {isSuperAdmin ? '巡查上报' : '巡查上报'} + + + + + toPatrolReport('conserve') : () => toMyReport('conserve')}> + + + {isSuperAdmin ? '养护上报' : '养护上报'} diff --git a/web/client/src/sections/fillion/components/maintenanceTable.js b/web/client/src/sections/fillion/components/maintenanceTable.js index c26c6c8d..45adec67 100644 --- a/web/client/src/sections/fillion/components/maintenanceTable.js +++ b/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) } diff --git a/web/client/src/sections/fillion/components/patrolTable.js b/web/client/src/sections/fillion/components/patrolTable.js index 2bb587ce..c1333337 100644 --- a/web/client/src/sections/fillion/components/patrolTable.js +++ b/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' ?
{ setDateRange(dateString) }} /> + { + isAnomaly ? +