|
@ -1,5 +1,5 @@ |
|
|
import React, { useState, useEffect } from 'react' |
|
|
import React, { useState, useEffect } from 'react' |
|
|
import Taro, { useDidShow } from '@tarojs/taro' |
|
|
import Taro, { useDidShow, useRouter } from '@tarojs/taro' |
|
|
import { View, Picker, Input, Image } from '@tarojs/components' |
|
|
import { View, Picker, Input, Image } from '@tarojs/components' |
|
|
import moment from 'moment' |
|
|
import moment from 'moment' |
|
|
import './index.scss' |
|
|
import './index.scss' |
|
@ -15,6 +15,10 @@ import conserveIcon from '../../static/img/patrolView/conserve.svg' |
|
|
import conserveActiveIcon from '../../static/img/patrolView/conserve-active.svg' |
|
|
import conserveActiveIcon from '../../static/img/patrolView/conserve-active.svg' |
|
|
|
|
|
|
|
|
function Index() { |
|
|
function Index() { |
|
|
|
|
|
const userInfo = Taro.getStorageSync('userInfo') || {}; |
|
|
|
|
|
const router = useRouter() |
|
|
|
|
|
const { params: { limit } } = router |
|
|
|
|
|
|
|
|
const [isPatrol, setIsPatrol] = useState(true) |
|
|
const [isPatrol, setIsPatrol] = useState(true) |
|
|
const [datePicker, setDatePicker] = useState(moment().format('YYYY-MM-DD')) |
|
|
const [datePicker, setDatePicker] = useState(moment().format('YYYY-MM-DD')) |
|
|
const [listData, setListData] = useState([]) |
|
|
const [listData, setListData] = useState([]) |
|
@ -42,14 +46,17 @@ function Index() { |
|
|
Taro.showLoading({ title: '加载中' }) |
|
|
Taro.showLoading({ title: '加载中' }) |
|
|
request.get( |
|
|
request.get( |
|
|
getReportList(), |
|
|
getReportList(), |
|
|
{ startTime: datePicker + ' 00:00:00', endTime: datePicker + ' 23:59:59' }, |
|
|
{ startTime: datePicker + ' 00:00:00', endTime: datePicker + ' 23:59:59' } |
|
|
{ hideErrorToast: true, hideLoading: true } |
|
|
|
|
|
).then(res => { |
|
|
).then(res => { |
|
|
Taro.hideLoading() |
|
|
Taro.hideLoading() |
|
|
if (res.statusCode == 200) { |
|
|
if (res.statusCode == 200) { |
|
|
setListData(res.data) |
|
|
let { data } = res |
|
|
setShowListData(res.data.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve')) |
|
|
if (limit === 'my') { |
|
|
return res.data; |
|
|
data = data.filter(item => item.user.name === userInfo.name) |
|
|
|
|
|
} |
|
|
|
|
|
setListData(data) |
|
|
|
|
|
setShowListData(data.filter(item => isPatrol ? item.reportType === 'patrol' : item.reportType === 'conserve')) |
|
|
|
|
|
return data; |
|
|
} else { |
|
|
} else { |
|
|
dealError(res.data.message || '请求出错'); |
|
|
dealError(res.data.message || '请求出错'); |
|
|
} |
|
|
} |
|
|