From 28d7cfd800430ed09c0c5cae7b66714b65dffab3 Mon Sep 17 00:00:00 2001 From: Zxuyoubin Date: Sun, 7 Apr 2024 17:51:19 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E6=AD=A6=E9=9A=86=E9=B2=81?= =?UTF-8?q?=E6=B8=9D=E5=8D=8F=E4=BD=9C=E7=A4=BA=E8=8C=83=E6=9D=91=E6=95=B0?= =?UTF-8?q?=E5=AD=97=E5=8C=96=E8=B5=8B=E8=83=BD=20app=E7=A0=94=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/basePage/equipment/index.tsx | 43 ++++++++++++++----- src/inspectionManager/inspection/index.tsx | 43 +++++++++++++------ src/inspectionManager/inspectionLog/index.tsx | 21 +++++++++ 3 files changed, 84 insertions(+), 23 deletions(-) diff --git a/src/basePage/equipment/index.tsx b/src/basePage/equipment/index.tsx index 9830517..05337b0 100644 --- a/src/basePage/equipment/index.tsx +++ b/src/basePage/equipment/index.tsx @@ -1,4 +1,4 @@ -import { View } from "@tarojs/components" +import { View,Picker } from "@tarojs/components" import { useEffect, useState } from "react" import Taro from "@tarojs/taro" import TabWrapper from "../../components/customized/tabWrapper" @@ -50,13 +50,22 @@ const EquipMent = () => { id: '3', }, ]) - const getdevice2=(id)=>{ - getdevice({pageNo:1,pageSize:10,baseId:id}).then(res=>{ + let a=new Date().getFullYear() + 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,'获取数据'); setDataList(res.data.list) }) } - useEffect(()=>{ getDeviceInfoCard({}).then(res=>{ console.log(res,'获取基地'); @@ -65,21 +74,26 @@ const EquipMent = () => { id:index, id2:item.id })).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 [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 => { return new Promise((resolve, reject) => { resolve() }) } return ( - + @@ -126,7 +140,9 @@ const EquipMent = () => { className="rounded-xl w-20 bg-green-500 text-center py-1" style={{ color: 'white' }} 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}` }) }} >去巡检 @@ -136,6 +152,11 @@ const EquipMent = () => { + + + 当前选择:{date} + + ) } diff --git a/src/inspectionManager/inspection/index.tsx b/src/inspectionManager/inspection/index.tsx index 0ecfb53..c59fc96 100644 --- a/src/inspectionManager/inspection/index.tsx +++ b/src/inspectionManager/inspection/index.tsx @@ -1,4 +1,4 @@ -import { View, Image } from "@tarojs/components" +import { View, Image,Picker } from "@tarojs/components" import { useEffect, useState } from "react" import Taro from "@tarojs/taro" import PageWrapper from "../../components/customized/pageWrapper" @@ -14,8 +14,9 @@ const getCheckDeviceBySomet=(data)=>{ const EquipMent = () => { const baseId = Taro.getCurrentInstance().router?.params.id || 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 topMenus = [ @@ -44,8 +45,15 @@ const EquipMent = () => { useEffect(()=>{ 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)=>{ - 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'); setDataList(res.data.list) }) @@ -55,13 +63,19 @@ const EquipMent = () => { console.log(id,'tab id'); if(id=='1'){ - getList('0') - }else{ getList('1') + }else{ + getList('0') } } + + + function handleDateChange(e) { + const value = e.detail.value + setDate(value) + } return ( - + @@ -82,25 +96,25 @@ const EquipMent = () => { { dataList.map(item => { return ( - {item.equName} 上次巡检 {item.inspectionTime} - { - Taro.navigateTo({ url: '/iotManager/weatherStation/index?id=' + item.id}) + Taro.navigateTo({ url: '/inspectionManager/inspectionLog/index?id=' + item.equNum}) }} >巡检日志 { - Taro.navigateTo({ url: '/iotManager/weatherStation/index?id=' + item.id}) + Taro.navigateTo({ url: '/inspectionManager/inspectionContent/index?id=' + item.id}) }} >去巡检 @@ -117,6 +131,11 @@ const EquipMent = () => { + + + 当前选择:{date} + + ) diff --git a/src/inspectionManager/inspectionLog/index.tsx b/src/inspectionManager/inspectionLog/index.tsx index 325dc2b..91a865c 100644 --- a/src/inspectionManager/inspectionLog/index.tsx +++ b/src/inspectionManager/inspectionLog/index.tsx @@ -1,7 +1,28 @@ import { Input, View } from "@tarojs/components" 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 baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id + //获取数据 + useEffect(()=>{ + getPageByCondition({pageNo:1,pageSize:100,equNum:baseId,inspectionState:'1'}).then(res=>{ + console.log(res,'获取数据'); + + }) + },[]) return (