From 0cc65ee485d15612480a8bc0d97d1de1ef960eb0 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Tue, 1 Aug 2023 22:04:14 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=B7=A1=E6=9F=A5?= =?UTF-8?q?=E5=85=BB=E6=8A=A4=E4=B8=8A=E6=8A=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/app/lib/controllers/report/index.js | 5 +- .../packages/components/inputPicker/index.jsx | 10 +- weapp/src/packages/patrol/index.jsx | 431 ++++++++++++++++-- weapp/src/packages/patrol/index.scss | 119 +++++ 4 files changed, 529 insertions(+), 36 deletions(-) diff --git a/api/app/lib/controllers/report/index.js b/api/app/lib/controllers/report/index.js index 1c2e8973..0e1067a8 100644 --- a/api/app/lib/controllers/report/index.js +++ b/api/app/lib/controllers/report/index.js @@ -4,7 +4,7 @@ const moment = require('moment') async function reportList (ctx) { try { const models = ctx.fs.dc.models; - const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType, handleState = '', performerId = '' } = ctx.query + const { limit, page, startTime, endTime, keyword, userId, reportType, isTop, asc, projectType, handleState = '', performerId = '', codeRoad } = ctx.query const { userInfo } = ctx.fs.api const sequelize = ctx.fs.dc.orm; @@ -96,6 +96,9 @@ async function reportList (ctx) { if (handleState) { findOption.where.handleState = handleState } + if (codeRoad) { + findOption.where.codeRoad = codeRoad + } let reportRes = null; diff --git a/weapp/src/packages/components/inputPicker/index.jsx b/weapp/src/packages/components/inputPicker/index.jsx index 580f13d0..5bb539df 100644 --- a/weapp/src/packages/components/inputPicker/index.jsx +++ b/weapp/src/packages/components/inputPicker/index.jsx @@ -6,8 +6,8 @@ import { View, Picker, Image, Input, Text } from '@tarojs/components' import arrowIcon from '../../../static/img/patrol/arrow-down.svg' import './index.scss' -export default function InputPicker (props) { - const { title, placeholder, selector, value, onInput, isView, onlySelect } = props +export default function InputPicker(props) { + const { title, placeholder, selector, value, onInput, isView, onlySelect, width, star = true } = props const [curSelector, setCurSelector] = useState([]) useEffect(() => { @@ -18,7 +18,7 @@ export default function InputPicker (props) { handleInput({ detail: { value: value } }) }, [value]) - function handleInput ({ detail: { value: v } }) { + function handleInput({ detail: { value: v } }) { onInput(v) if (v && !onlySelect) { setCurSelector(selector.filter(item => item && item.includes(v))) @@ -31,9 +31,9 @@ export default function InputPicker (props) { onInput(curSelector[e.detail.value]) } return ( - + - {title} + {star ? : null}{title} { const [videoqn, setVideoqn] = useState([]) const [handleType, setHandleType] = useState('') + const [roadCodeHead, setRoadCodeHead] = useState('X') + const [roadCodeEnd, setRoadCodeEnd] = useState('') + const [otherType, setOtherType] = useState('') // 道路类型-其他 + const [patrolContentEdit, setPatrolContentEdit] = useState(false) // 养护基本信息是否可编辑 + + const [patrolContent, setPatrolContent] = useState({ + inspectionNoException: { + label: '巡查结果无异常', + selected: false, + value: '', + }, + roadDamage: { + label: '路面损坏', + selected: false, + value: '', + }, + securityDamage: { + label: '安防损坏', + selected: false, + value: '', + }, + bridgeDamage: { + label: '桥梁损坏', + selected: false, + value: '', + }, + culvertDamage: { + label: '涵洞损坏', + selected: false, + value: '', + }, + securityDeficiency: { + label: '安防缺失', + selected: false, + value: '', + }, + encounteredEnvironment: { + label: '路域环境', + selected: false, + value: '', + }, + otherDescription: { + label: '其他', + selected: false, + value: '', + }, + }) + const [conserveInfo, setConserveInfo] = useState({ + roadType: { + label: '路面类型', + value: '', + unit: '', + }, + roadWidth: { + label: '路面宽度', + value: '', + unit: '米', + }, + wrongLane: { + label: '错车道', + value: '', + unit: '个', + }, + roadsideTrees: { + label: '行道树', + value: '', + unit: '棵', + }, + roadsideDitch: { + label: '边沟', + value: '', + unit: '米', + }, + guardrail: { + label: '护栏', + value: '', + unit: '米', + }, + roadMarking: { + label: '标线', + value: '', + unit: '米', + }, + }) + const [conserveContent, setConserveContent] = useState({ + maintenanceStaffCount: { + label: '本次养护共安排养护人员', + value: '', + unit: '人', + }, + shoulderRepair: { + label: '整修路肩、边坡', + value: '', + unit: '平米', + }, + ditchCleaning: { + label: '开挖、清理边坡', + value: '', + unit: '米', + }, + asphaltRepair: { + label: '修补沥青路面', + value: '', + unit: '平米', + }, + concreteRepair: { + label: '修补水泥路面', + value: '', + unit: '平米', + }, + grassMowing: { + label: '除草', + value: '', + unit: '米', + }, + treeWhitening: { + label: '行道树刷白', + value: '', + unit: '株/公里', + }, + pileWhitening: { + label: '公里桩/百米桩刷漆', + value: '', + unit: '个', + }, + guardrailMaintenance: { + label: '维修护栏', + value: '', + unit: '米', + }, + endHeadRepair: { + label: '修复端头', + value: '', + unit: '块', + }, + }) + const prjType = isAnomaly ? [ @@ -70,10 +207,11 @@ const Index = () => { ] : [ + { text: '无', value: '' }, { text: '道路', value: 'road', onlyView: true }, - { text: '县道', value: 'countyRoad' }, - { text: '乡道', value: 'villageRoad' }, - { text: '村道', value: 'rusticRoad' }, + { text: '县道', value: 'countyRoad', onlyView: true }, + { text: '乡道', value: 'villageRoad', onlyView: true }, + { text: '村道', value: 'rusticRoad', onlyView: true }, { text: '桥梁', value: 'bridge' }, { text: '涵洞', value: 'culvert' }, { text: '其他', value: 'other' }, @@ -149,6 +287,30 @@ const Index = () => { setConserveAfterPic(data.conserveAfterPic ? data.conserveAfterPic.map(item => ({ url: imgUrl + item })) : []) setHandleId(data.id) setVideo(data.videoUrl[0] ? imgUrl + data.videoUrl[0] : '') + setRoadCodeHead(data.codeRoad ? data.codeRoad.slice(0, 1) : '') + setRoadCodeEnd(data.codeRoad ? data.codeRoad.slice(1) : '') + if (data.reportType === 'patrol') { + let next = { ...patrolContent } + next.inspectionNoException.selected = data.inspectionNoException + Object.keys(patrolContent).forEach(key => { + if (data[key]) { + next[key].selected = true + next[key].value = data[key] + } + }) + setPatrolContent(next) + } else if (data.reportType === 'conserve') { + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + if (data[key]) nextInfo[key].value = data[key] + }) + setConserveInfo(nextInfo) + let nextContent = { ...conserveContent } + Object.keys(conserveContent).forEach(key => { + if (data[key]) nextContent[key].value = data[key] + }) + setConserveContent(nextContent) + } if (data.handleContent) { setHandleCenter(data.handleContent) } @@ -159,6 +321,7 @@ const Index = () => { Taro.showToast({ title: err.message || '请求出错', icon: 'none' }) }) } else { // 填报 + if (isPatrol) setProjectType('县道') Taro.showLoading({ title: '加载中' }) let key = 'ODQBZ-3FZAU-6VIVL-2XXNM-F7CP7-WVFCY' // 写自己申请的key Taro.getLocation({ @@ -258,14 +421,18 @@ const Index = () => { function report() { if (!canReport) { return } if ( - (isPatrol && (!projectType || !road)) + (isPatrol && (!projectType || !road || !roadCodeEnd)) || (isAnomaly && !road) + || (kind === 'patrol' && Object.values(patrolContent).every(c => c.value.trim() === '') && !patrolContent.巡查结果无异常.selected) + || (kind === 'conserve' + && (Object.values(conserveInfo).every(c => c.value.trim() === '') + || Object.values(conserveContent).every(c => c.value.trim() === ''))) ) { Taro.showToast({ title: '请完善必填信息', icon: 'none' }) return } - if ((isPatrol || isAnomaly) && prjTypeSelector.indexOf(projectType) === -1) { + if (isAnomaly && prjTypeSelector.indexOf(projectType) === -1) { Taro.showToast({ title: isAnomaly ? '反馈类型错误' : '工程类型错误', icon: 'none' }) return } @@ -279,7 +446,6 @@ const Index = () => { } const reportProjectType = prjType.find(p => p.text == projectType)?.value || '' - let data = { reportType: isPatrol ? reportType : kind, projectType: reportProjectType, @@ -302,6 +468,24 @@ const Index = () => { data['conserveUnderwayPic'] = conserveUnderwayImg data['conserveAfterPic'] = conserveAfterImg } + if (isPatrol) { + data.codeRoad = roadCodeHead + roadCodeEnd + if (otherType) data.projectType = otherType + if (kind === 'patrol') { + Object.keys(patrolContent).forEach(key => { + data[key] = patrolContent[key].value + }) + data.inspectionNoException = patrolContent.inspectionNoException.selected + } else if (kind === 'conserve') { + Object.keys(conserveInfo).forEach(key => { + data[key] = key === 'roadType' ? conserveInfo[key].value : Number(conserveInfo[key].value) + }) + Object.keys(conserveContent).forEach(key => { + data[key] = Number(conserveContent[key].value) + }) + } + } + Taro.showModal({ title: '提示', content: '您要进行信息上报么?', @@ -359,7 +543,7 @@ const Index = () => { }) } - function handleInput({ detail: { value } }, type) { + function handleInput({ detail: { value } }, type, key) { switch (type) { case 'roadSectionStart': setRoadSectionStart(value) @@ -389,6 +573,64 @@ const Index = () => { case "wait": setHandleCenter(value) break; + case "roadCodeEnd": + setRoadCodeEnd(value) + if (value.length >= 9) { + for (const r of roadList) { + if (r.routeCode === roadCodeHead + value) { + setRoad(r.routeName) + setRoadSectionStart(r.startingPlaceName) + setRoadSectionEnd(r.stopPlaceName) + request.get(getReportList(), { limit: 1, page: 0, codeRoad: r.routeCode }).then(res => { + if (res.statusCode === 200 && res.data.length) { + request.get(getReportDetail(res.data[0].id)).then(detailRes => { + if (res.statusCode === 200) { + let nextInfo = { ...conserveInfo } + Object.keys(conserveInfo).forEach(key => { + if (detailRes.data[key]) nextInfo[key].value = detailRes.data[key] + }) + setConserveInfo(nextInfo) + setPatrolContentEdit(false) + } else { + setPatrolContentEdit(true) + } + }) + } else { + setPatrolContentEdit(true) + } + }) + break; + } + } + } + break; + case "conserveInfo": + let nextInfo = { ...conserveInfo } + nextInfo[key].value = value + setConserveInfo(nextInfo) + break; + case "conserveContent": + let nextContent = { ...conserveContent } + nextContent[key].value = value + setConserveContent(nextContent) + break; + case "contentCheck": + let nextCheck = { ...patrolContent } + Object.keys(patrolContent).forEach(key => { + if (value.indexOf(key) !== -1) { + nextCheck[key].selected = true + } else { + nextCheck[key].selected = false + } + }) + setPatrolContent(nextCheck) + break; + case "patrolContent": + let nextPatrolContent = { ...patrolContent } + nextPatrolContent[key].value = value + if (value) nextPatrolContent[key].selected = true + setPatrolContent(nextPatrolContent) + break; default: break; } @@ -647,15 +889,56 @@ const Index = () => { } */} { - isPatrol ? + isPatrol ? <> + + 线路编码: + { + setRoadCodeHead(e.detail.value[0]); + setProjectType(e.detail.value[0] === 'X' ? '县道' : e.detail.value[0] === 'Y' ? '乡道' : '村道'); + }}> + X + Y + C + + handleInput(e, 'roadCodeEnd')} + disabled={isView} + /> + + + 道路类型: + { }} + disabled={true} + /> + 其他: + setOtherType(value === '无' ? '' : value)} + selector={prjTypeSelector} + isView={isView} + /> + : '' + /> + : '' } { @@ -699,7 +982,7 @@ const Index = () => { } { - isPatrol || isAnomaly ? + isAnomaly ? { /> : '' } { - isPatrol || isAnomaly ? + isAnomaly ? { disabled={isView} /> - - handleInput(e, 'content')} - disabled={isView} - maxLength={50} - /> + { + kind === 'patrol' && + + 巡查内容 + + + handleInput(e, 'contentCheck')}> + { + Object.keys(patrolContent).map(key => + + {patrolContent[key].label + (patrolContent[key].label !== '巡查结果无异常' ? ':' : '')} + {patrolContent[key].label !== '巡查结果无异常' &&