diff --git a/weapp/src/packages/maintenanceSpotCheck/index.jsx b/weapp/src/packages/maintenanceSpotCheck/index.jsx
index 2d861e71..ae7047f3 100644
--- a/weapp/src/packages/maintenanceSpotCheck/index.jsx
+++ b/weapp/src/packages/maintenanceSpotCheck/index.jsx
@@ -87,24 +87,31 @@ function Index() {
enhanced
pagingEnabled
>
- {roadSpotList.length ? roadSpotList.map((item, index) => navigateTo(`/packages/maintenanceSpotCheck/spotCheckRoad/index?item=${encodeURIComponent(JSON.stringify(item))}&isOld=${index !== 0}`
- )}
- >
- 抽查县道比例(%):{item.countyPercentage}
- 抽查县道(公里):{item.countryMil?.toFixed(3)}
- 抽查乡道(公里):{item.townMil?.toFixed(3)}
- 抽查村道(公里):{item.villageMil?.toFixed(3)}
- 抽查日期:{moment(item.date).format('YYYY-MM-DD')}
- ) : }
+ {roadSpotList.length
+ ? roadSpotList.map((item, index) => navigateTo(`/packages/maintenanceSpotCheck/spotCheckRoad/index?item=${encodeURIComponent(JSON.stringify(item))}&isOld=${index !== 0}`)}
+ >
+ 抽查县道比例(%):{item.countyPercentage}
+ 抽查县道(公里):{item.countryMil?.toFixed(3)}
+ 抽查乡道(公里):{item.townMil?.toFixed(3)}
+ 抽查村道(公里):{item.villageMil?.toFixed(3)}
+ 抽查日期:{moment(item.date).format('YYYY-MM-DD')}
+ )
+ : }
- navigateTo('/packages/maintenanceSpotCheck/startSpotCheck/index')}
- >发起抽查
+ {roadSpotList.length && !roadSpotList[0].abstractFinish
+ ? navigateTo(`/packages/maintenanceSpotCheck/startSpotCheck/index?item=${encodeURIComponent(JSON.stringify(roadSpotList[0]))}`)}
+ >继续抽查
+ : navigateTo('/packages/maintenanceSpotCheck/startSpotCheck/index')}
+ >发起抽查}
)
}
diff --git a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx
index eb0f84f3..e201a826 100644
--- a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx
+++ b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.jsx
@@ -1,94 +1,211 @@
-import React, { useState } from 'react'
-import Taro from '@tarojs/taro'
-import { View, Picker } from '@tarojs/components'
+import React, { useState, useEffect } from 'react'
+import Taro, { useRouter } from '@tarojs/taro'
+import { View, Picker, Input } from '@tarojs/components'
import { AtButton, AtIcon, } from 'taro-ui'
import request from '@/services/request'
-import { roadSpotPrepare, roadSpotConfirm } from '@/services/api'
+import { roadSpotPrepare, roadSpotConfirm, getTownUrl } from '@/services/api'
+import dayjs from 'dayjs'
import './index.scss'
function Index() {
+ const { item } = useRouter().params
+ const spotItem = item ? JSON.parse(decodeURIComponent(item)) : null
+
const rateArr = ['50%', '75%'];
const [rate, setRate] = useState('50%')
- const [prepare, setPrepare] = useState({
- previewId: null,
- spotCountyRoadCount: null,
- spotTownRoadCount: null,
- spotVillageRoadCount: null,
+ const [town, setTown] = useState([])
+ const [formValue, setFormValue] = useState({
+ countyRoad: {
+ drawPeople: '', // 抽查人
+ countyPresent: null, // 县道实际抽取(公里)
+ countyDifferenceValue: null, // 县道比计划多(公里)
+ abstractTime: null, // 抽取时间
+ },
})
- const startSpotCheck = () => {
- Taro.showLoading({ title: '抽取中' })
- request.post(roadSpotPrepare(), { countyPercentage: rate === '50%' ? 50 : 75 }).then(res => {
- Taro.hideLoading()
- 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)
+ useEffect(() => {
+ getTown()
+ if (spotItem) {
+ setFormValue(spotItem.gather)
+ setRate(spotItem.countyPercentage === 50 ? '50%' : '75%')
+ }
+ }, [])
+
+ const getTown = () => {
+ request.get(getTownUrl()).then(res => {
+ if (res.statusCode === 200) {
+ setTown(res.data?.filter(d => d.code != '360121205000'))
}
})
}
- const onSubmit = () => {
- if (!prepare.previewId) {
- Taro.showToast({ title: '请先抽取道路' })
+ const startSpotCheck = (code) => {
+ if (!formValue[code]?.drawPeople) {
+ Taro.showToast({ title: '请输入抽取人', icon: 'none' })
return
}
- Taro.showLoading({ title: '提交中' })
- request.post(roadSpotConfirm(), { previewId: prepare.previewId }).then(res => {
+ let body = {}
+ if (code === 'countyRoad') {
+ body = {
+ level: '县',
+ countyPercentage: rate === '50%' ? 50 : 75,
+ drawPeople: formValue[code].drawPeople
+ }
+ } else {
+ body = {
+ code,
+ countyPercentage: rate === '50%' ? 50 : 75,
+ drawPeople: formValue[code].drawPeople
+ }
+ }
+ Taro.showLoading({ title: '抽取中' })
+ request.post(roadSpotPrepare(), body).then(res => {
Taro.hideLoading()
- if (res.statusCode === 204) {
- Taro.showToast({ title: '提交成功', icon: 'success' })
- setTimeout(() => {
- Taro.navigateBack()
- }, 1500)
+ if (res.statusCode === 200 || res.statusCode === 204) {
+ Taro.showToast({ title: '抽取成功', icon: 'success' })
+ setFormValue(res.data.gather)
+ setRate(res.data.countyPercentage === 50 ? '50%' : '75%')
} else {
- Taro.showToast({ title: '提交失败', icon: 'error' })
+ Taro.showToast({ title: '抽取失败', icon: 'error' })
console.log(res.errMsg)
}
})
}
+ // const onSubmit = () => {
+ // if (!prepare.previewId) {
+ // Taro.showToast({ title: '请先抽取道路' })
+ // return
+ // }
+ // Taro.showLoading({ title: '提交中' })
+ // request.post(roadSpotConfirm(), { previewId: prepare.previewId }).then(res => {
+ // Taro.hideLoading()
+ // if (res.statusCode === 204) {
+ // Taro.showToast({ title: '提交成功', icon: 'success' })
+ // setTimeout(() => {
+ // Taro.navigateBack()
+ // }, 1500)
+ // } else {
+ // Taro.showToast({ title: '提交失败', icon: 'error' })
+ // console.log(res.errMsg)
+ // }
+ // })
+ // }
+
return (
-
- 抽查县道比例(%):
-
+ 抽查县道比例(%):
+ setRate(rateArr[e.detail.value])}
+ style={{ marginLeft: 10 }}
+ disabled={formValue.countyRoad.abstractTime}
+ className={formValue.countyRoad.abstractTime ? 'disabled' : ''}
>
{rate || '请选择'}
+ { startSpotCheck('countyRoad') }}
+ disabled={formValue.countyRoad.abstractTime}
+ >开始抽取
-
- 抽查乡道比例(%):
- {rate === '50%' ? '25%' : '50%'}
+
+ 抽查人:
+ setFormValue({
+ ...formValue,
+ countyRoad: { ...formValue.countyRoad, drawPeople: e.detail.value }
+ })}
+ />
-
- 抽查村道比例(%):
- {rate === '50%' ? '10%' : '20%'}
+
+ 县道实际抽取(公里):
+ {formValue.countyRoad.countyPresent?.toFixed(4)}
- 开始抽取
-
- 抽查县道(公里):
- {prepare.countryMil}
+
+ 县道比计划多(公里):
+ {formValue.countyRoad.countyDifferenceValue?.toFixed(4)}
-
- 抽查乡道(公里):
- {prepare.townMil}
+
+ 抽查时间:
+ {
+ formValue.countyRoad.abstractTime
+ ? dayjs(formValue.countyRoad.abstractTime).format('YYYY-MM-DD HH:mm:ss')
+ : ''
+ }
-
- 抽查村道(公里):
- {prepare.villageMil}
+
+
+ 抽查乡道比例(%):
+ {rate === '50%' ? '25%' : '50%'}
+
+
+ 抽查村道比例(%):
+ {rate === '50%' ? '10%' : '20%'}
- 提交
+
+ {
+ formValue.countyRoad.abstractTime && town.map(t => {
+ return
+
+ {t.name}
+ { startSpotCheck(t.code) }}
+ disabled={formValue[t.code]?.abstractTime}
+ >开始抽取
+
+
+ 抽查人:
+ {
+ setFormValue({
+ ...formValue,
+ [t.code]: { ...formValue[t.code], drawPeople: e.detail.value }
+ })
+ }}
+ />
+
+
+ 乡道实际抽取(公里):
+ {formValue[t.code]?.townshipPresent?.toFixed(4)}
+
+
+ 乡道比计划多(公里):
+ {formValue[t.code]?.townshipDifferenceValue?.toFixed(4)}
+
+
+ 村道实际抽取(公里):
+ {formValue[t.code]?.villagePresent?.toFixed(4)}
+
+
+ 村道比计划多(公里):
+ {formValue[t.code]?.villageDifferenceValue?.toFixed(4)}
+
+
+ 抽查时间:
+ {
+ formValue[t.code]?.abstractTime
+ ? dayjs(formValue[t.code].abstractTime).format('YYYY-MM-DD HH:mm:ss')
+ : ''
+ }
+
+
+ })
+ }
+
+ {/* 提交 */}
)
diff --git a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss
index 1f0760f8..b7e90f65 100644
--- a/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss
+++ b/weapp/src/packages/maintenanceSpotCheck/startSpotCheck/index.scss
@@ -1,7 +1,7 @@
.page {
background-color: #fff;
- height: 100vh;
- padding: 60px;
+ height: 100%;
+ padding: 10px 30px 40px;
box-sizing: border-box;
.content {
@@ -9,25 +9,39 @@
width: 100%;
min-height: 60%;
- .item {
- margin-top: 30px;
-
-
- .title {}
+ .card {
+ border: 1px solid #ccc;
+ border-radius: 10px;
+ padding: 10px 20px;
+ margin-top: 10px;
- .input {
- margin-top: 10px;
- border: 1px solid #ccc;
- border-radius: 10px;
- padding: 10px 20px;
+ .card-item {
display: flex;
- justify-content: space-between;
- height: 42px;
+ align-items: center;
+ justify-content: flex-start;
+ height: 80px;
}
+ }
- .disabled {
- background-color: #eee;
- }
+ .item {
+ width: 100%;
+ height: 80px;
+ margin-top: 20px;
+ }
+
+ .input {
+ min-width: 100px;
+ 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 {
@@ -37,7 +51,7 @@
.submit-btn {
width: 70%;
- margin: 100px auto 0;
+ margin: 30px auto 0;
}
}
}
\ No newline at end of file
diff --git a/weapp/src/services/api.js b/weapp/src/services/api.js
index bc97e84e..a7da84db 100644
--- a/weapp/src/services/api.js
+++ b/weapp/src/services/api.js
@@ -95,4 +95,9 @@ export const roadSpotPrepare = () => {
// 提交抽查
export const roadSpotConfirm = () => {
return `/road/spot/confirm`;
+};
+
+// 获取抽查城镇
+export const getTownUrl = () => {
+ return `/town`;
};
\ No newline at end of file