From 6eb759894fa112e02cf5228c5d33fa8b20f98b7b Mon Sep 17 00:00:00 2001 From: liujiangyong Date: Tue, 23 Jan 2024 17:30:12 +0800 Subject: [PATCH] =?UTF-8?q?(*)=20=E5=B0=8F=E7=A8=8B=E5=BA=8F-=E7=BA=B3?= =?UTF-8?q?=E5=85=A5=E4=B8=8B=E6=AC=A1=E6=8A=BD=E6=9F=A5=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../spotCheckRoad/index.jsx | 63 +++++++++++++++++-- .../spotCheckRoad/index.scss | 4 ++ weapp/src/services/api.js | 5 ++ 3 files changed, 67 insertions(+), 5 deletions(-) diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.jsx b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.jsx index 50bb6527..a11d60fc 100644 --- a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.jsx +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.jsx @@ -6,7 +6,7 @@ import { NoData } from '@/components/index' import Skeleton from '../components/skeleton' import moment from 'moment' import request from '@/services/request' -import { getRoadSpotDetail } from '@/services/api' +import { getRoadSpotDetail, roadSpotNextUrl, getRoadSpotList } from '@/services/api' import './index.scss' function Index() { @@ -16,16 +16,17 @@ function Index() { const [keyword, setKeyword] = useState('') const [roadDetailList, setRoadDetailList] = useState([]) const [isNoData, setIsNoData] = useState(false) + const [nextAbstract, setNextAbstract] = useState(spotItem.nextAbstract) useDidShow(() => { getDetail() }) - const getDetail = () => { + const getDetail = (showLoading = true) => { if (spotItem) { - Taro.showLoading({ title: '加载中' }) + showLoading && Taro.showLoading({ title: '加载中' }) request.get(`${getRoadSpotDetail()}?previewId=${spotItem.id}&keyword=${keyword}`).then(res => { - Taro.hideLoading() + showLoading && Taro.hideLoading() if (res.statusCode === 200) { setRoadDetailList(res.data) } else { @@ -40,6 +41,15 @@ function Index() { } } + const getSpotList = () => { + request.get(`${getRoadSpotList()}`) + .then(res => { + if (res.statusCode === 200) { + setNextAbstract(res.data[0].nextAbstract) + } + }) + } + const renderList = () => { return roadDetailList.length ? roadDetailList.map(item => 道路类型:{item.road?.level ? (item.road?.level + '道') : '--'} @@ -52,9 +62,11 @@ function Index() { 起点地名:{item.road?.startingPlaceName || '--'} 止点地名:{item.road?.stopPlaceName || '--'} - 里程:{item.road?.chainageMileage || '--'} + 里程:{item.road?.chainageMileage || '--'} 养护次数(次):{item.maintenanceCount} + + 调整 + + { + Taro.showModal({ + title: '提示', + content: '确认纳入下次抽查?', + success: function (res) { + if (res.confirm) { + request.post(roadSpotNextUrl(), { + previewId: spotItem?.id, + level: item.road?.level, + roadId: item.roadId + }).then(res => { + Taro.showLoading() + if (res.statusCode === 200 || res.statusCode === 204) { + Taro.hideLoading() + Taro.showToast({ title: '纳入下次抽查成功', icon: 'success' }) + getSpotList() + getDetail(false) + } else { + Taro.showToast({ title: '纳入下次抽查失败', icon: 'error' }) + } + }) + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + }} + disabled={ + isOld === 'true' || ( + nextAbstract?.town?.includes(item.roadId) + || nextAbstract?.village?.includes(item.roadId) + || nextAbstract?.county?.includes(item.roadId) + ) + } + >纳入下次抽查 + ) : } diff --git a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss index 0583420e..6fa6b3de 100644 --- a/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss +++ b/weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss @@ -24,6 +24,10 @@ .edit-btn { width: 100px; } + + .next-btn { + width: 200px; + } } } } \ No newline at end of file diff --git a/weapp/src/services/api.js b/weapp/src/services/api.js index a7da84db..6bdeefdf 100644 --- a/weapp/src/services/api.js +++ b/weapp/src/services/api.js @@ -100,4 +100,9 @@ export const roadSpotConfirm = () => { // 获取抽查城镇 export const getTownUrl = () => { return `/town`; +}; + +// 纳入下次抽查 +export const roadSpotNextUrl = () => { + return `/road/spot/next`; }; \ No newline at end of file