feat:武隆鲁渝协作示范村数字化赋能 app研发

This commit is contained in:
Zxuyoubin 2024-04-07 17:51:19 +08:00
parent 2669fbe488
commit 28d7cfd800
3 changed files with 84 additions and 23 deletions

View File

@ -1,4 +1,4 @@
import { View } from "@tarojs/components" import { View,Picker } from "@tarojs/components"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import Taro from "@tarojs/taro" import Taro from "@tarojs/taro"
import TabWrapper from "../../components/customized/tabWrapper" import TabWrapper from "../../components/customized/tabWrapper"
@ -50,13 +50,22 @@ const EquipMent = () => {
id: '3', id: '3',
}, },
]) ])
const getdevice2=(id)=>{ let a=new Date().getFullYear()
getdevice({pageNo:1,pageSize:10,baseId:id}).then(res=>{ let b=(new Date().getMonth()+1).toString().length>=2?new Date().getMonth()+1:0+(new Date().getMonth()+1).toString()
let c=(new Date().getDate()).toString().length>=2?new Date().getDate():0+(new Date().getDate()).toString()
const [date, setDate] = useState(a+'-'+b+'-'+c)
function fn(data){
let a2=data.substring(0,4)
let b2 =data.substring(5,7)
let c2= data.substring(8)
return `${a2}-${b2}-${c2}`
}
const getdevice2=(id,time)=>{
getdevice({pageNo:1,pageSize:10,baseId:id,createTime:time}).then(res=>{
console.log(res,'获取数据'); console.log(res,'获取数据');
setDataList(res.data.list) setDataList(res.data.list)
}) })
} }
useEffect(()=>{ useEffect(()=>{
getDeviceInfoCard({}).then(res=>{ getDeviceInfoCard({}).then(res=>{
console.log(res,'获取基地'); console.log(res,'获取基地');
@ -65,21 +74,26 @@ const EquipMent = () => {
id:index, id:index,
id2:item.id id2:item.id
})).reverse()) })).reverse())
getdevice2(res.data.list.reverse()[1].id) console.log('基地id', res.data.list[0].id);
let time=fn(date)
getdevice2(res.data.list[0].id,time)
}) })
},[]) },[])
const [selectedMenuId, setSelectedMenuId] = useState('all') const [selectedMenuId, setSelectedMenuId] = useState('all')
const [refreshTrigger, setRefreshTrigger] = useState(false) const [refreshTrigger, setRefreshTrigger] = useState(false)
function handleDateChange(e) {
const value = e.detail.value
console.log(value,'value');
let a3= fn(value)
setDate(value)
getdevice2(topMenus[0].id,a3)
}
const refreshFunc = (): Promise<void> => { const refreshFunc = (): Promise<void> => {
return new Promise((resolve, reject) => { resolve() }) return new Promise((resolve, reject) => { resolve() })
} }
return ( return (
<View className="px-1 h-full"> <View className="px-1 h-full" style={{position:'relative',}}>
<View className="h-full flex flex-col justify-start"> <View className="h-full flex flex-col justify-start">
<TabWrapper options={topMenus} selectedId={selectedMenuId} callback={setSelectedMenuId}></TabWrapper> <TabWrapper options={topMenus} selectedId={selectedMenuId} callback={setSelectedMenuId}></TabWrapper>
<View className="pb-2" style={{ height: 'calc(100% - 2.4rem)', width: '100%' }}> <View className="pb-2" style={{ height: 'calc(100% - 2.4rem)', width: '100%' }}>
@ -126,7 +140,9 @@ const EquipMent = () => {
className="rounded-xl w-20 bg-green-500 text-center py-1" className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }} style={{ color: 'white' }}
onClick={() => { onClick={() => {
Taro.navigateTo({ url: `/inspectionManager/inspection/index?id=${topMenus[1].id2}&categoryId=${item.categoryId}` }) console.log(item,'设备');
Taro.navigateTo({ url: `/inspectionManager/inspection/index?id=${topMenus[2].id2}&categoryId=${item.categoryId}&time=${fn(date)}&name=${item.categoryName}` })
}} }}
></View> ></View>
</View> </View>
@ -136,6 +152,11 @@ const EquipMent = () => {
</ScrollView> </ScrollView>
</View> </View>
</View> </View>
<Picker mode="date" value={date} onChange={handleDateChange} style={{ position:"absolute",right:'5px',top:'20px',color:'#c1c1c1',padding:'5px' }}>
<View className="picker">
{date}
</View>
</Picker>
</View> </View>
) )
} }

View File

@ -1,4 +1,4 @@
import { View, Image } from "@tarojs/components" import { View, Image,Picker } from "@tarojs/components"
import { useEffect, useState } from "react" import { useEffect, useState } from "react"
import Taro from "@tarojs/taro" import Taro from "@tarojs/taro"
import PageWrapper from "../../components/customized/pageWrapper" import PageWrapper from "../../components/customized/pageWrapper"
@ -14,8 +14,9 @@ const getCheckDeviceBySomet=(data)=>{
const EquipMent = () => { const EquipMent = () => {
const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id
const categoryId2 = Taro.getCurrentInstance().router?.params.categoryId || 0; // 基地id const categoryId2 = Taro.getCurrentInstance().router?.params.categoryId || 0; // 基地id
const date2=Taro.getCurrentInstance().router?.params.time
const name=Taro.getCurrentInstance().router?.params.name
console.log(date2,'shijian');
const [selectedMenuId, setSelectedMenuId] = useState('all') const [selectedMenuId, setSelectedMenuId] = useState('all')
const topMenus = [ const topMenus = [
@ -44,8 +45,15 @@ const EquipMent = () => {
useEffect(()=>{ useEffect(()=>{
getList('0') getList('0')
},[]) },[])
const [date, setDate] = useState(date2)
function fn(data){
let a2=data.substring(0,4)
let b2 =data.substring(5,7)
let c2= data.substring(8)
return `${a2}-${b2}-${c2}`
}
const getList=(id)=>{ const getList=(id)=>{
getCheckDeviceBySomet({pageNo:1,pageSize:10,base:baseId,categoryId:categoryId2,inspectionState:id }).then(res=>{ getCheckDeviceBySomet({pageNo:1,pageSize:10,base:baseId,createTime:fn(date),deviceStatus:categoryId2,inspectionState:id }).then(res=>{
console.log(res,'huoqushuju'); console.log(res,'huoqushuju');
setDataList(res.data.list) setDataList(res.data.list)
}) })
@ -55,13 +63,19 @@ const EquipMent = () => {
console.log(id,'tab id'); console.log(id,'tab id');
if(id=='1'){ if(id=='1'){
getList('0')
}else{
getList('1') getList('1')
}else{
getList('0')
} }
} }
function handleDateChange(e) {
const value = e.detail.value
setDate(value)
}
return ( return (
<PageWrapper title="气象站"> <PageWrapper title={name}>
<View className="p-1 h-full"> <View className="p-1 h-full">
<View className="h-full flex flex-col"> <View className="h-full flex flex-col">
<View className="flex px-2 py-1"> <View className="flex px-2 py-1">
@ -83,7 +97,7 @@ const EquipMent = () => {
dataList.map(item => { dataList.map(item => {
return ( return (
<View <View
className="py-2 pt-0 rounded-md shadow-xl bg-white relative" className='py-2 pt-0 rounded-md shadow-xl bg-white relative'
> >
<Image src={'https://picx.zhimg.com/70/v2-76efadc2e5b562f6f727521aedbb31ef_1440w.image?source=172ae18b&biz_tag=Post'} className="w-full h-[6rem] rounded-md"></Image> <Image src={'https://picx.zhimg.com/70/v2-76efadc2e5b562f6f727521aedbb31ef_1440w.image?source=172ae18b&biz_tag=Post'} className="w-full h-[6rem] rounded-md"></Image>
<View className="text-lg px-4 text-bold">{item.equName}</View> <View className="text-lg px-4 text-bold">{item.equName}</View>
@ -93,14 +107,14 @@ const EquipMent = () => {
className="rounded-xl w-20 bg-green-500 text-center py-1" className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }} style={{ color: 'white' }}
onClick={() => { onClick={() => {
Taro.navigateTo({ url: '/iotManager/weatherStation/index?id=' + item.id}) Taro.navigateTo({ url: '/inspectionManager/inspectionLog/index?id=' + item.equNum})
}} }}
></View> ></View>
<View <View
className="rounded-xl w-20 bg-green-500 text-center py-1" className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }} style={{ color: 'white' }}
onClick={() => { onClick={() => {
Taro.navigateTo({ url: '/iotManager/weatherStation/index?id=' + item.id}) Taro.navigateTo({ url: '/inspectionManager/inspectionContent/index?id=' + item.id})
}} }}
></View> ></View>
</View> </View>
@ -117,6 +131,11 @@ const EquipMent = () => {
</View> </View>
</View> </View>
</View> </View>
<Picker mode="date" value={date} onChange={handleDateChange} style={{ position:"absolute",right:'20px',top:'50px',color:'#c1c1c1',padding:'5px' }}>
<View className="picker">
{date}
</View>
</Picker>
</PageWrapper> </PageWrapper>
) )

View File

@ -1,7 +1,28 @@
import { Input, View } from "@tarojs/components" import { Input, View } from "@tarojs/components"
import PageWrapper from "../../components/customized/pageWrapper"; import PageWrapper from "../../components/customized/pageWrapper";
import { request } from "../../config/axios"
import { useEffect } from "react";
import Taro from "@tarojs/taro"
//获取数据
const getPageByCondition=(data)=>{
return request({
url:'/agriculture/check-logs/pageByCondition',
method:'GET',
data
})
}
const InspectionLog = () => { const InspectionLog = () => {
const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id
//获取数据
useEffect(()=>{
getPageByCondition({pageNo:1,pageSize:100,equNum:baseId,inspectionState:'1'}).then(res=>{
console.log(res,'获取数据');
})
},[])
return ( return (
<PageWrapper title="巡检日志"> <PageWrapper title="巡检日志">
<View className="h-[3rem] flex items-center px-7" style={{ color: 'white' }}> <View className="h-[3rem] flex items-center px-7" style={{ color: 'white' }}>