Browse Source

(*) 小程序-纳入下次抽查功能

dev^2
liujiangyong 9 months ago
parent
commit
6eb759894f
  1. 63
      weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.jsx
  2. 4
      weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss
  3. 5
      weapp/src/services/api.js

63
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 => <View key={item.id} className='card'>
<View className='item'>道路类型{item.road?.level ? (item.road?.level + '道') : '--'}</View>
@ -52,9 +62,11 @@ function Index() {
<View className='at-col-6'>起点地名{item.road?.startingPlaceName || '--'}</View>
<View className='at-col-6'>止点地名{item.road?.stopPlaceName || '--'}</View>
</View>
<View className='item'>里程{item.road?.chainageMileage || '--'}</View>
<View className='item at-row'>
<View className='at-col-6'>里程{item.road?.chainageMileage || '--'}</View>
<View className='at-col-6'>养护次数{item.maintenanceCount}</View>
</View>
<View className='item at-row'>
<View className='at-col-3'>
<AtButton
className='edit-btn'
@ -75,6 +87,47 @@ function Index() {
}
>调整</AtButton>
</View>
<View className='at-col-6'>
<AtButton
className='next-btn'
type='primary'
size='small'
onClick={() => {
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)
)
}
>纳入下次抽查</AtButton>
</View>
</View>
</View>) : <Skeleton length={3} />
}

4
weapp/src/packages/maintenanceSpotCheck/spotCheckRoad/index.scss

@ -24,6 +24,10 @@
.edit-btn {
width: 100px;
}
.next-btn {
width: 200px;
}
}
}
}

5
weapp/src/services/api.js

@ -100,4 +100,9 @@ export const roadSpotConfirm = () => {
// 获取抽查城镇
export const getTownUrl = () => {
return `/town`;
};
// 纳入下次抽查
export const roadSpotNextUrl = () => {
return `/road/spot/next`;
};
Loading…
Cancel
Save