From 329fcd15df0b2432725564b05fba06591e023669 Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Thu, 14 Dec 2023 11:04:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=8F=E7=A8=8B=E5=BA=8F=E5=85=BB=E6=8A=A4?= =?UTF-8?q?=E6=8A=BD=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weapp/src/app.config.js | 4 + .../maintenanceSpotCheck/index.config.js | 3 + .../packages/maintenanceSpotCheck/index.jsx | 112 +++++++++ .../packages/maintenanceSpotCheck/index.scss | 44 ++++ .../spotChange/index.config.js | 3 + .../maintenanceSpotCheck/spotChange/index.jsx | 224 ++++++++++++++++++ .../spotChange/index.scss | 54 +++++ .../spotCheckRoadDetail/index.config.js | 3 + .../spotCheckRoadDetail/index.jsx | 73 ++++++ .../spotCheckRoadDetail/index.scss | 29 +++ .../startSpotCheck/index.config.js | 3 + .../startSpotCheck/index.jsx | 85 +++++++ .../startSpotCheck/index.scss | 43 ++++ weapp/src/pages/home/index.jsx | 17 +- weapp/src/services/api.js | 29 ++- 15 files changed, 720 insertions(+), 6 deletions(-) create mode 100644 weapp/src/packages/maintenanceSpotCheck/index.config.js create mode 100644 weapp/src/packages/maintenanceSpotCheck/index.jsx create mode 100644 weapp/src/packages/maintenanceSpotCheck/index.scss create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotChange/index.config.js create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotChange/index.scss create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.config.js create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx create mode 100644 weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.scss create mode 100644 weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.config.js create mode 100644 weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx create mode 100644 weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss diff --git a/weapp/src/app.config.js b/weapp/src/app.config.js index a846996f..e70f0d41 100644 --- a/weapp/src/app.config.js +++ b/weapp/src/app.config.js @@ -12,6 +12,10 @@ export default { 'changePassword/index', 'changePassword/success/index', 'video/index', + 'maintenanceSpotCheck/index', + 'maintenanceSpotCheck/startSpotCheck/index', + 'maintenanceSpotCheck/spotCheckRoadDetail/index', + 'maintenanceSpotCheck/spotChange/index', ] }], permission: { diff --git a/weapp/src/packages/maintenanceSpotCheck/index.config.js b/weapp/src/packages/maintenanceSpotCheck/index.config.js new file mode 100644 index 00000000..690c0e41 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/index.config.js @@ -0,0 +1,3 @@ +export default { + navigationBarTitleText: '养护抽查' +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/index.jsx b/weapp/src/packages/maintenanceSpotCheck/index.jsx new file mode 100644 index 00000000..cac10c08 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/index.jsx @@ -0,0 +1,112 @@ +import React, { useEffect, useState } from 'react' +import Taro, { useDidShow } from '@tarojs/taro' +import { View, Input, Picker, ScrollView } from '@tarojs/components' +import { AtButton, AtIcon } from 'taro-ui' +import { NoData } from '@/components/index' +import moment from 'moment' +import request from '@/services/request' +import { getRoadSpotList } from '@/services/api' +import './index.scss' + +function Index() { + // const pageSize = 10 + // const count = 0 + // const [page, setPage] = useState(1) + const [startTime, setStartTime] = useState('') + const [endTime, setEndTime] = useState('') + const [roadSpotList, setRoadSpotList] = useState([]) + + useDidShow(() => { + getSpotList() + }) + + const getSpotList = () => { + request.get(`${getRoadSpotList()}?startTime=${startTime}&endTime=${endTime}`) + .then(res => { + if (res.statusCode === 200) { + setRoadSpotList(res.data) + } + }) + } + + const resetTime = () => { + setStartTime('') + setEndTime('') + } + + const navigateTo = (url) => { + Taro.navigateTo({ url }) + } + + const onScrollToLower = (e) => { + console.log(e) + } + + return ( + + + setStartTime(e.detail.value)} + > + + + + + + setEndTime(e.detail.value)} + > + + + + + + 查询 + 重置 + + + + {roadSpotList.length ? roadSpotList.map(item => navigateTo(`/packages/maintenanceSpotCheck/spotCheckRoadDetail/index?item=${encodeURIComponent(JSON.stringify(item))}` + )} + > + 抽查县道比例(%):{item.countyPercentage} + 抽查县道(条):{item.spotCountyRoadCount} + 抽查乡道(条):{item.spotTownRoadCount} + 抽查村道(条):{item.spotVillageRoadCount} + 抽查日期:{moment(item.date).format('YYYY-MM-DD')} + ) : } + + navigateTo('/packages/maintenanceSpotCheck/startSpotCheck/index')} + >发起抽查 + + ) +} + +export default Index \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/index.scss b/weapp/src/packages/maintenanceSpotCheck/index.scss new file mode 100644 index 00000000..0aebec0e --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/index.scss @@ -0,0 +1,44 @@ +.page { + height: 100vh; + background-color: #fff; + font-size: 28px; + + .spot-check-filter-box { + box-sizing: border-box; + width: 100%; + padding: 15px 20px; + + .input { + margin-left: 10px; + } + + .reset-bth { + margin-left: 20px; + } + } + + .scrollview { + height: calc(100vh - 280px); + margin-bottom: 40px; + + .card { + padding: 20px; + border: gainsboro 1px solid; + border-radius: 10px; + background-color: #fff; + box-shadow: 10px 10px 5px rgb(219, 218, 218); + margin: 0 0 20px 20px; + width: calc(100% - 40px); + box-sizing: border-box; + + .item { + padding: 10px 0; + } + } + } + + .to-start-btn { + width: 70%; + margin: 0 auto; + } +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotChange/index.config.js b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.config.js new file mode 100644 index 00000000..0b049910 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.config.js @@ -0,0 +1,3 @@ +export default { + navigationBarTitleText: '调整' +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx new file mode 100644 index 00000000..e272ddf6 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.jsx @@ -0,0 +1,224 @@ +import React, { useEffect, useState } from 'react' +import Taro, { useRouter } from '@tarojs/taro' +import { View, Text, Picker, } from '@tarojs/components' +import { AtButton, AtIcon, } from 'taro-ui' +import request from '@/services/request' +import { roadSpotChange, roadUrl } from '@/services/api' +import './index.scss' + +function Index() { + const { spot, detail } = useRouter().params + const spotItem = spot ? JSON.parse(decodeURIComponent(spot)) : null + const detailItem = detail ? JSON.parse(decodeURIComponent(detail)) : null + + const [road, setRoad] = useState([]) + const [roadLevel, setRoadLevel] = useState('') + + const [nameList, setNameList] = useState([]); + const [codeList, setCodeList] = useState([]); + const [noList, setNoList] = useState([]); + const [checked, setChecked] = useState({ + routeName: '', + routeCode: '', + sectionNo: '', + startingPlaceName: '', + stopPlaceName: '', + }) + + useEffect(() => { + getRoad() + }, []) + + const getRoad = () => { + if (!detailItem) return + + const level = detailItem.road?.level + setRoadLevel(level) + + const alterIdArr = level == '县' ? spotItem.countyRoadId + : level == '乡' ? spotItem.townshipRoadId + : level == '村' ? spotItem.villageRoadId : [] + let query = `?level=${level}` + for (let i = 0; i < alterIdArr.length; i++) { + query += `&alterId=${alterIdArr[i]}` + } + request.get(`${roadUrl()}${query}`).then(res => { + if (res.statusCode === 200) { + let name = [] + let code = [] + let no = [] + res.data?.forEach(v => { + if (v.routeName && !name.includes(v.routeName)) { + name.push(v.routeName) + } + if (v.routeCode && !code.includes(v.routeCode)) { + code.push(v.routeCode) + } + if (v.sectionNo && !no.includes(v.sectionNo)) { + no.push(v.sectionNo) + } + }); + setRoad(res.data) + setNameList(name) + setCodeList(code) + setNoList(no) + + } else { + Taro.showToast({ title: '获取路线失败', icon: 'error' }) + } + }) + } + + const handleCheckChange = (value, key) => { + let nextValue = { + ...checked, + [key]: value + } + + let name = [] + let code = [] + let no = [] + let data = road?.filter(d => (nextValue?.routeName ? nextValue?.routeName == d?.routeName : true) + && (nextValue?.routeCode ? nextValue?.routeCode == d?.routeCode : true) + && (nextValue?.sectionNo ? nextValue?.sectionNo == d?.sectionNo : true)) + + data.forEach(v => { + if (v.routeName && !name.includes(v.routeName)) { + name.push(v.routeName) + } + if (v.routeCode && !code.includes(v.routeCode)) { + code.push(v.routeCode) + } + if (v.sectionNo && !no.includes(v.sectionNo)) { + no.push(v.sectionNo) + } + }); + setNameList(name) + setCodeList(code) + setNoList(no) + + if (nextValue.routeName && nextValue.routeCode && nextValue.sectionNo) { + nextValue.startingPlaceName = data[0]?.startingPlaceName + nextValue.stopPlaceName = data[0]?.stopPlaceName + } else { + nextValue.startingPlaceName = '' + nextValue.stopPlaceName = '' + } + setChecked(nextValue) + } + + const handleSubmit = () => { + if (!checked.routeName || !checked.routeCode || !checked.sectionNo) { + Taro.showToast({ title: '请选择路线', icon: 'error' }) + return + } + let data = road.find(d => checked.routeName == d?.routeName + && checked.routeCode == d.routeCode + && checked.sectionNo == d.sectionNo + ) + Taro.showLoading({ title: '调整中...' }) + request.post(`${roadSpotChange()}`, { + previewId: spotItem.id, + originRoadId: detailItem.road?.id, + changeRoadId: data.id, + }).then(res => { + Taro.hideLoading() + if (res.statusCode === 204) { + Taro.showToast({ title: '调整成功', icon: 'success' }) + setTimeout(() => { + Taro.navigateBack() + }, 1500) + } else { + Taro.showToast({ title: '调整失败', icon: 'error' }) + } + }) + } + + return ( + + + 道路类型 + {roadLevel} + + + *路线名称 + + handleCheckChange(nameList[e.detail.value], 'routeName')} + > + + {checked.routeName || '请选择'} + + + + handleCheckChange('', 'routeName')} + /> + + + + *路线代码 + + handleCheckChange(codeList[e.detail.value], 'routeCode')} + > + + {checked.routeCode || '请选择'} + + + + handleCheckChange('', 'routeCode')} + /> + + + + *路段序号 + + handleCheckChange(noList[e.detail.value], 'sectionNo')} + > + + {checked.sectionNo || '请选择'} + + + + handleCheckChange('', 'sectionNo')} + /> + + + + 起点地名 + {checked.startingPlaceName} + + + 止点地名 + {checked.stopPlaceName} + + + 确定 + + ) +} + +export default Index \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotChange/index.scss b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.scss new file mode 100644 index 00000000..c10777ff --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotChange/index.scss @@ -0,0 +1,54 @@ +.page { + height: 100vh; + background-color: #fff; + // font-size: 28px; + + .cell { + padding: 24px 0px; + margin: 0 32px; + display: flex; + justify-content: space-between; + border-bottom: rgb(223, 237, 243) 1px solid; + + .title { + display: inline-block; + width: 192px; + margin-right: 16px; + + .star { + color: #ff0000; + margin-right: 8px; + } + } + + .content { + width: calc(100% - 192px - 16px); + display: flex; + justify-content: flex-end; + + .picker { + width: 400px; + display: flex; + justify-content: flex-end; + align-items: center; + + .arrow { + margin: 0 32px; + } + } + } + } + + .list-item { + width: calc(100% - 60px); + } + + .list-clear { + margin-right: 20px; + } + + .btn { + width: 70%; + margin: 100px auto 0; + } +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.config.js b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.config.js new file mode 100644 index 00000000..07643f0c --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.config.js @@ -0,0 +1,3 @@ +export default { + navigationBarTitleText: '抽查详情' +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx new file mode 100644 index 00000000..71e050ab --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.jsx @@ -0,0 +1,73 @@ +import React, { useEffect, useState } from 'react' +import Taro, { useRouter, useDidShow } from '@tarojs/taro' +import { View } from '@tarojs/components' +import { AtButton, AtSearchBar } from 'taro-ui' +import { NoData } from '@/components/index' +import moment from 'moment' +import request from '@/services/request' +import { getRoadSpotDetail } from '@/services/api' +import './index.scss' + +function Index() { + const { item } = useRouter().params + const spotItem = item ? JSON.parse(decodeURIComponent(item)) : null + + const [keyword, setKeyword] = useState('') + const [roadDetailList, setRoadDetailList] = useState([]) + + useDidShow(() => { + getDetail() + }) + + const getDetail = () => { + if (spotItem) { + Taro.showLoading({ title: '加载中' }) + request.get(`${getRoadSpotDetail()}?previewId=${spotItem.id}&keyword=${keyword}`).then(res => { + Taro.hideLoading() + if (res.statusCode === 200) { + setRoadDetailList(res.data) + } else { + Taro.showToast({ title: '获取详情失败', icon: 'error' }) + } + }) + } + } + + return ( + setKeyword(v)} + onActionClick={getDetail} + /> + 抽查日期:{moment(spotItem.date).format('YYYY-MM-DD')} + + {roadDetailList.length ? roadDetailList.map(item => + 道路类型:{item.road?.level ? (item.road?.level + '道') : '--'} + 路线名称:{item.road?.routeName || '--'} + + 路线代码:{item.road?.routeCode || '--'} + 路段序号:{item.road?.sectionNo || '--'} + + + 起点地名:{item.road?.startingPlaceName || '--'} + 止点地名:{item.road?.stopPlaceName || '--'} + + 里程:{item.road?.chainageMileage || '--'} + + 养护次数(次):{item.maintenanceCount} + + Taro.navigateTo({ url: `/packages/maintenanceSpotCheck/spotChange/index?detail=${encodeURIComponent(JSON.stringify(item))}&spot=${encodeURIComponent(JSON.stringify(spotItem))}` })} + >调整 + + + ) : } + ) +} + +export default Index \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.scss b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.scss new file mode 100644 index 00000000..0583420e --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoadDetail/index.scss @@ -0,0 +1,29 @@ +.page { + background-color: #fff; + height: 100vh; + font-size: 28px; + padding-bottom: 40px; + + .top { + height: 90px; + } + + .card { + padding: 20px; + border: gainsboro 1px solid; + border-radius: 10px; + background-color: #fff; + box-shadow: 10px 10px 5px rgb(219, 218, 218); + margin: 0 0 20px 20px; + width: calc(100% - 40px); + box-sizing: border-box; + + .item { + padding: 10px 0; + + .edit-btn { + width: 100px; + } + } + } +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.config.js b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.config.js new file mode 100644 index 00000000..9715ac34 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.config.js @@ -0,0 +1,3 @@ +export default { + navigationBarTitleText: '开始抽查' +} \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx new file mode 100644 index 00000000..939b4f85 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx @@ -0,0 +1,85 @@ +import React, { useState } from 'react' +import Taro from '@tarojs/taro' +import { View, Picker } from '@tarojs/components' +import { AtButton, AtIcon, } from 'taro-ui' +import request from '@/services/request' +import { roadSpotPrepare, roadSpotConfirm } from '@/services/api' +import './index.scss' + +function Index() { + const rateArr = ['50%', '75%']; + const [rate, setRate] = useState('50%') + const [prepare, setPrepare] = useState({ + previewId: null, + spotCountyRoadCount: null, + spotTownRoadCount: null, + spotVillageRoadCount: null, + }) + + const startSpotCheck = () => { + request.post(roadSpotPrepare(), { countyPercentage: rate === '50%' ? 50 : 75 }).then(res => { + if (res.statusCode === 200 || res.statusCode === 204) { + Taro.showToast({ title: '抽取成功', icon: 'success' }) + setPrepare(res.data) + } else { + Taro.showToast({ title: '抽取失败', icon: 'error' }) + console.log(res.errMsg) + } + }) + } + + const onSubmit = () => { + if (!prepare.previewId) { + Taro.showToast({ title: '请先抽取道路' }) + return + } + request.post(roadSpotConfirm(), { previewId: prepare.previewId }).then(res => { + if (res.statusCode === 204) { + Taro.showToast({ title: '提交成功', icon: 'success' }) + setTimeout(() => { + Taro.navigateBack() + }, 1500) + } else { + Taro.showToast({ title: '提交失败', icon: 'error' }) + console.log(res.errMsg) + } + }) + } + + return ( + + + 默认抽查乡道比例为25%,村道比例为10% + + 抽查县道比例(%): + setRate(rateArr[e.detail.value])} + > + + {rate || '请选择'} + + + + + 开始抽取 + + 抽查县道(条): + {prepare.spotCountyRoadCount} + + + 抽查乡道(条): + {prepare.spotTownRoadCount} + + + 抽查村道(条): + {prepare.spotVillageRoadCount} + + 提交 + + + ) +} +export default Index \ No newline at end of file diff --git a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss new file mode 100644 index 00000000..1f0760f8 --- /dev/null +++ b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss @@ -0,0 +1,43 @@ +.page { + background-color: #fff; + height: 100vh; + padding: 60px; + box-sizing: border-box; + + .content { + margin: 0 auto; + width: 100%; + min-height: 60%; + + .item { + margin-top: 30px; + + + .title {} + + .input { + margin-top: 10px; + border: 1px solid #ccc; + border-radius: 10px; + padding: 10px 20px; + display: flex; + justify-content: space-between; + height: 42px; + } + + .disabled { + background-color: #eee; + } + } + + .start-btn { + width: 150px; + margin: 30px auto; + } + + .submit-btn { + width: 70%; + margin: 100px auto 0; + } + } +} \ No newline at end of file diff --git a/weapp/src/pages/home/index.jsx b/weapp/src/pages/home/index.jsx index 20d012ad..0065fc3b 100644 --- a/weapp/src/pages/home/index.jsx +++ b/weapp/src/pages/home/index.jsx @@ -26,6 +26,10 @@ const Index = () => { } }, []) + const navigateTo = (url) => { + Taro.navigateTo({ url }) + } + function toPatrol(kind) { Taro.navigateTo({ url: `/packages/patrol/index?type=edit&kind=${kind}` @@ -107,7 +111,18 @@ const Index = () => { 待 办 事 项 toPatrolView('wait') + () => toPatrolView('wait') + }> + 查看 + + : '' + } + { + judgeRight('MAINTENANCESPOTCHECK') ? + + 养护抽查 + navigateTo('/packages/maintenanceSpotCheck/index') }> 查看 diff --git a/weapp/src/services/api.js b/weapp/src/services/api.js index bc56d782..bc97e84e 100644 --- a/weapp/src/services/api.js +++ b/weapp/src/services/api.js @@ -67,13 +67,32 @@ export const postHandle = reportId => { return `/report/${reportId}/handle`; }; +// 道路抽查列表 +export const getRoadSpotList = () => { + return `/road/spot/list`; +}; +// 道路抽查详情 +export const getRoadSpotDetail = () => { + return `/road/spot/detail`; +}; +// 获取道路 +export const roadUrl = () => { + return `/road`; +}; +// 调整已抽查的道路 +export const roadSpotChange = () => { + return `/road/spot/change`; +}; +// 开始抽取 +export const roadSpotPrepare = () => { + return `/road/spot/prepare`; +}; - - - - - +// 提交抽查 +export const roadSpotConfirm = () => { + return `/road/spot/confirm`; +}; \ No newline at end of file