Browse Source

增加异常上报\道路巡检两个模块 web+小程序 88%

dev
巴林闲侠 2 years ago
parent
commit
df4b825b5f
  1. 3
      api/.vscode/launch.json
  2. 17
      api/app/lib/controllers/data/index.js
  3. 29
      api/app/lib/controllers/report/index.js
  4. 11
      api/app/lib/models/report.js
  5. 5
      api/app/lib/routes/report/index.js
  6. 7
      scripts/1.2.1/schema/1update_report.sql
  7. 12
      weapp/src/components/uploads/index.js
  8. 14
      weapp/src/packages/patrol/index.jsx
  9. 4
      web/client/src/layout/containers/layout/index.js
  10. 6
      web/client/src/sections/fillion/actions/patrol.js
  11. 25
      web/client/src/sections/fillion/components/patrolTable.js
  12. 5
      web/client/src/sections/fillion/containers/patrol.js
  13. 1
      web/client/src/utils/webapi.js

3
api/.vscode/launch.json

@ -15,7 +15,8 @@
"args": [ "args": [
"-p 13400", "-p 13400",
"-f http://localhost:13400", "-f http://localhost:13400",
"-g postgres://postgres:123@10.8.30.32:5432/highways4good", // "-g postgres://postgres:123@10.8.30.32:5432/highways4good",
"-g postgres://FashionAdmin:123456@10.8.30.156:5432/highway4goodn0728",
"--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5", "--qnak XuDgkao6cL0HidoMAPnA5OB10Mc_Ew08mpIfRJK5",
"--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa", "--qnsk yewcieZLzKZuDfig0wLZ9if9jKp2P_1jd3CMJPSa",
"--qnbkt dev-highways4good", "--qnbkt dev-highways4good",

17
api/app/lib/controllers/data/index.js

@ -8,7 +8,8 @@ async function dataExport (ctx) {
try { try {
const models = ctx.fs.dc.models; const models = ctx.fs.dc.models;
const { userId } = ctx.fs.api const { userId } = ctx.fs.api
const { exp, ids, roadLevel, municipalType } = ctx.query; const { exp, ids, roadLevel, municipalType,
patrolType } = ctx.query;
if (!exp) { if (!exp) {
throw '参数错误'; throw '参数错误';
@ -89,11 +90,23 @@ async function dataExport (ctx) {
const tableAttributes = models[modalOption.tableName].tableAttributes const tableAttributes = models[modalOption.tableName].tableAttributes
let header = [] let header = []
for (let k in tableAttributes) { for (let k in tableAttributes) {
const comment = tableAttributes[k].comment let comment = tableAttributes[k].comment
if (k != 'id' && comment) { if (k != 'id' && comment) {
if (comment == '品名' && municipalType == '出租车') { if (comment == '品名' && municipalType == '出租车') {
continue continue
} }
if (patrolType) {
if (patrolType == 'road') {
} else if (patrolType == 'anomaly') {
} else {
// 正常的之前的巡查内容
if (comment == '工程名称') {
continue
}
}
}
header.push({ header.push({
title: comment || '-', title: comment || '-',
key: k, key: k,

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

@ -9,7 +9,7 @@ async function reportList (ctx) {
where: { where: {
}, },
attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd', 'reportType', 'content', 'longitude', 'latitude', 'projectName'], attributes: ['id', 'road', 'time', 'projectType', 'roadSectionStart', 'roadSectionEnd', 'reportType', 'content', 'longitude', 'latitude', 'projectName', 'handleState'],
include: [{ include: [{
model: models.User, model: models.User,
attributes: ['name'] attributes: ['name']
@ -139,6 +139,31 @@ async function reportDetail (ctx) {
} }
} }
async function reportHandle (ctx) {
try {
const { models } = ctx.fs.dc;
const { reportId } = ctx.params
const { handleState } = ctx.request.body
await models.Report.update({
handleState: handleState
}, {
where: {
id: reportId
}
})
ctx.status = 200;
} catch (error) {
ctx.fs.logger.error(`path: ${ctx.path}, error: ${error}`);
ctx.status = 400;
ctx.body = {
message: typeof error == 'string' ? error : undefined
}
}
}
async function createReport (ctx) { async function createReport (ctx) {
try { try {
const { userId } = ctx.fs.api const { userId } = ctx.fs.api
@ -187,5 +212,5 @@ async function deleteReport (ctx) {
module.exports = { module.exports = {
reportList, reportList,
reportPosition, reportPosition,
reportDetail, createReport, deleteReport, reportDetail, createReport, deleteReport, reportHandle
}; };

11
api/app/lib/models/report.js

@ -167,6 +167,7 @@ module.exports = dc => {
autoIncrement: false autoIncrement: false
}, },
projectName: { projectName: {
index: 17,
type: DataTypes.STRING, type: DataTypes.STRING,
allowNull: true, allowNull: true,
defaultValue: null, defaultValue: null,
@ -175,6 +176,16 @@ module.exports = dc => {
field: "project_name", field: "project_name",
autoIncrement: false autoIncrement: false
}, },
handleState: {
index: 18,
type: DataTypes.STRING,
allowNull: false,
defaultValue: "已处理",
// comment: "处理状态",
primaryKey: false,
field: "handle_state",
autoIncrement: false
},
}, { }, {
tableName: "report", tableName: "report",
comment: "", comment: "",

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

@ -10,7 +10,10 @@ module.exports = function (app, router, opts) {
router.get('/report/position', report.reportPosition); router.get('/report/position', report.reportPosition);
app.fs.api.logAttr['GET/report/:reportId/detail'] = { content: '获取上报详情', visible: false }; app.fs.api.logAttr['GET/report/:reportId/detail'] = { content: '获取上报详情', visible: false };
router.get('/report/:reportId//detail', report.reportDetail); router.get('/report/:reportId/detail', report.reportDetail);
app.fs.api.logAttr['GET/report/:reportId/handle'] = { content: '处理上报详情', visible: false };
router.post('/report/:reportId/handle', report.reportHandle);
app.fs.api.logAttr['POST/report'] = { content: '创建上报', visible: false }; app.fs.api.logAttr['POST/report'] = { content: '创建上报', visible: false };
router.post('/report', report.createReport); router.post('/report', report.createReport);

7
scripts/1.2.1/schema/1update_report.sql

@ -1,4 +1,9 @@
alter table report alter table report
add project_name varchar(512); add project_name varchar(512);
alter table report alter column project_type drop not null; alter table report alter column project_type drop not null;
alter table report
add handle_state varchar(32) default '已处理' not null;
comment on column report.handle_state is '待处理 / 已处理 / 不处理';

12
weapp/src/components/uploads/index.js

@ -0,0 +1,12 @@
import React, { useState, useEffect } from 'react';
import Taro, { useRouter } from '@tarojs/taro';
import { View, RadioGroup, Radio, Image, Input, Picker } from '@tarojs/components';
const Index = () => {
return(
<View>123</View>
)
}
export default Index

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

@ -3,6 +3,7 @@ import Taro, { useRouter } from '@tarojs/taro';
import { View, RadioGroup, Radio, Image, Input, Picker } from '@tarojs/components'; import { View, RadioGroup, Radio, Image, Input, Picker } from '@tarojs/components';
import { AtButton, AtTextarea, AtImagePicker } from 'taro-ui'; import { AtButton, AtTextarea, AtImagePicker } from 'taro-ui';
import InputPicker from '../components/inputPicker'; import InputPicker from '../components/inputPicker';
import VideoUpload from '../../components/uploads'
import request from '@/services/request'; import request from '@/services/request';
import environment from '../../config'; import environment from '../../config';
import { getState } from '../../store/globalState'; import { getState } from '../../store/globalState';
@ -202,6 +203,7 @@ const Index = () => {
longitude, longitude,
latitude, latitude,
projectName, projectName,
handleState: isAnomaly ? '待处理' : undefined,
} }
if (reportType === 'patrol') { if (reportType === 'patrol') {
data['scenePic'] = sceneImg data['scenePic'] = sceneImg
@ -556,6 +558,17 @@ const Index = () => {
onImageClick={handleImgClick} onImageClick={handleImgClick}
/> />
} }
{/* <VideoUpload isUpload={true} />
<AtButton onClick={() => {
Taro.chooseVideo({
sourceType: ['album', 'camera'],
maxDuration: 60,
camera: 'back',
success: function (res) {
console.log(res.tempFilePath)
}
})
}}>v</AtButton> */}
</View> : </View> :
<View className='conserve-img'> <View className='conserve-img'>
养护图片: 养护图片:
@ -579,6 +592,7 @@ const Index = () => {
onImageClick={handleImgClick} onImageClick={handleImgClick}
/> />
} }
<View className='horizontal-line hl-two'> <View className='horizontal-line hl-two'>
<View className='circle c-two'></View> <View className='circle c-two'></View>
<View className='text t-two'>养护中</View> <View className='text t-two'>养护中</View>

4
web/client/src/layout/containers/layout/index.js

@ -75,9 +75,7 @@ const LayoutContainer = props => {
dom.scrollTop = 0; dom.scrollTop = 0;
} }
}) })
// if (depMessage) {
// console.log(depMessage);
// }
let contentStyle = { let contentStyle = {
position: 'relative', position: 'relative',
margin: '12px 12px 0px', margin: '12px 12px 0px',

6
web/client/src/sections/fillion/actions/patrol.js

@ -37,13 +37,13 @@ export function getUserList (query) {
}); });
} }
export function handleReport (data) { export function handleReport (reportId, data) {
return dispatch => basicAction({ return dispatch => basicAction({
type: 'post', type: 'post',
dispatch: dispatch, dispatch: dispatch,
actionType: 'HANDLE_REPORT', actionType: 'HANDLE_REPORT',
url: ApiTable.handleReport, url: ApiTable.handleReport.replace("{reportId}", reportId),
data: data, data: data,
msg: { option: '获取巡查数据失败' }, msg: { option: '处理数据' },
}); });
} }

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

@ -2,7 +2,7 @@ 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 } from 'antd';
import ProTable from '@ant-design/pro-table'; import ProTable from '@ant-design/pro-table';
import { getReportList, getReportDetail } from '../actions/patrol'; import { getReportList, getReportDetail, handleReport } from '../actions/patrol';
import React, { useEffect, useState } from 'react'; import React, { useEffect, useState } from 'react';
import { httpDel } from '@peace/utils' import { httpDel } from '@peace/utils'
import { PinyinHelper } from '@peace/utils'; import { PinyinHelper } from '@peace/utils';
@ -78,7 +78,7 @@ const DetailForm = (props) => {
} }
const DetailList = (props) => { const DetailList = (props) => {
const { reportList, loading, dispatch, handleOpen, handelRefresh, isAnomaly, isRoad, isPatrol } = props; const { reportList, loading, dispatch, handleOpen, handelRefresh, isAnomaly, isRoad, isPatrol, queryData } = props;
const [visible, setVisible] = useState(false) const [visible, setVisible] = useState(false)
const [selectRecord, setSelectRecord] = useState(); const [selectRecord, setSelectRecord] = useState();
const [noProcessingPopVisible, setNoProcessingPopVisible] = useState(false); const [noProcessingPopVisible, setNoProcessingPopVisible] = useState(false);
@ -200,19 +200,25 @@ const DetailList = (props) => {
<Button <Button
onClick={() => { checkDetail(record); handleOpen(); }} onClick={() => { checkDetail(record); handleOpen(); }}
style={{ marginRight: 10 }}>查看</Button>, style={{ marginRight: 10 }}>查看</Button>,
isAnomaly ? <Button>指派</Button> : null, isAnomaly && record.handleState != '已处理' ? <Button>指派</Button> : null,
isAnomaly ? isAnomaly && record.handleState != '已处理' ?
<Popover <Popover
content={[ content={[
<div style={{ width: '100%', height: 30 }}> <div style={{ width: '100%', height: 30 }}>
<Button onClick={() => setNoProcessingPopVisible(false)} style={{ float: "right" }} ></Button> <Button onClick={() => setNoProcessingPopVisible(false)} style={{ float: "right" }} ></Button>
<Button type="primary" onClick={() => handleRemove(record)} style={{ marginRight: 8, float: "right" }} ></Button> <Button type="primary" onClick={() => dispatch(handleReport(record.id, { handleState: '已处理' })).then(res => {
if (res.success) {
setNoProcessingPopVisible(false)
setNoProcessingSelectRecord(null)
handelRefresh()
}
})} style={{ marginRight: 8, float: "right" }} ></Button>
</div> </div>
]} ]}
visible={noProcessingSelectRecord == record.id && noProcessingPopVisible} visible={noProcessingSelectRecord == record.id && noProcessingPopVisible}
trigger="click" trigger="click"
onClick={() => setNoProcessingSelectRecord(record.id)} onClick={() => setNoProcessingSelectRecord(record.id)}
title="是否删除该记录?" title="是否不处理该记录?"
onVisibleChange={(newVisible) => setNoProcessingPopVisible(newVisible)} onVisibleChange={(newVisible) => setNoProcessingPopVisible(newVisible)}
> >
<Button>不处理</Button> <Button>不处理</Button>
@ -322,7 +328,6 @@ const PatrolNameList = (props) => {
return { return {
onClick: () => { onClick: () => {
if (record) { if (record) {
// console.log('record:', record)
let id = record.id let id = record.id
if (selectRoad == record.id) { if (selectRoad == record.id) {
id = null id = null
@ -353,7 +358,7 @@ const PatrolTable = (props) => {
const isAnomaly = pathname.includes('anomaly') const isAnomaly = pathname.includes('anomaly')
const isPatrol = !isRoad && !isAnomaly const isPatrol = !isRoad && !isAnomaly
const reportType = isRoad ? 'road' : isAnomaly ? 'anomaly' : 'patrol'; const reportType = isRoad ? 'road' : isAnomaly ? 'anomaly' : 'patrol';
console.log(isRoad, pathname, isPatrol);
useEffect(() => { useEffect(() => {
if (userList && userList instanceof Array) { if (userList && userList instanceof Array) {
setRecord(userList[0]); setRecord(userList[0]);
@ -410,7 +415,7 @@ const PatrolTable = (props) => {
<Card style={{ flex: 1 }}> <Card style={{ flex: 1 }}>
<DetailList <DetailList
reportList={reportList} record={record} loading={reportListLoading} dispatch={dispatch} handleOpen={handleOpen} handelRefresh={handelRefresh} reportList={reportList} record={record} loading={reportListLoading} dispatch={dispatch} handleOpen={handleOpen} handelRefresh={handelRefresh}
isPatrol={isPatrol} isRoad={isRoad} isAnomaly={isAnomaly} isPatrol={isPatrol} isRoad={isRoad} isAnomaly={isAnomaly} queryData={queryData}
/> />
</Card> </Card>
</div> </div>
@ -432,7 +437,7 @@ const PatrolTable = (props) => {
const handleExport = () => { const handleExport = () => {
if (reportList && reportList instanceof Array && reportList.length) { if (reportList && reportList instanceof Array && reportList.length) {
let ids = reportList.map(item => item.id); let ids = reportList.map(item => item.id);
exports(ids); exports(ids, reportType);
} }
} }

5
web/client/src/sections/fillion/containers/patrol.js

@ -17,12 +17,11 @@ const patrol = (props) => {
dispatch(getUserList()) dispatch(getUserList())
}, [true]) }, [true])
//批量导出 //批量导出
const exports = (ids, counts) => { const exports = (ids, reportType) => {
// console.log(user);
let reportIds = ids.toString(); let reportIds = ids.toString();
window.open( window.open(
'/_api/' + '/_api/' +
`data/export?exp=patrol&ids=${reportIds}&token=${user.token}`) `data/export?exp=patrol&ids=${reportIds}&token=${user.token}&patrolType=${reportType}`)
} }
return ( return (
<> <>

1
web/client/src/utils/webapi.js

@ -148,6 +148,7 @@ export const ApiTable = {
compileReportRectifyDetail: 'report/rectify/detail', compileReportRectifyDetail: 'report/rectify/detail',
getReportList: 'report/list', getReportList: 'report/list',
getReportDetail: 'report/{reportId}/detail', getReportDetail: 'report/{reportId}/detail',
handleReport:'report/{reportId}/handle',
getUsers: 'user', getUsers: 'user',

Loading…
Cancel
Save