diff --git a/src/basePage/equipment/index.tsx b/src/basePage/equipment/index.tsx index 05337b0..3e60a5d 100644 --- a/src/basePage/equipment/index.tsx +++ b/src/basePage/equipment/index.tsx @@ -66,6 +66,7 @@ const EquipMent = () => { setDataList(res.data.list) }) } + const [selectedMenuId, setSelectedMenuId] = useState(0) useEffect(()=>{ getDeviceInfoCard({}).then(res=>{ console.log(res,'获取基地'); @@ -76,11 +77,11 @@ const EquipMent = () => { })).reverse()) console.log('基地id', res.data.list[0].id); let time=fn(date) + setSelectedMenuId(res.data.list[0].id) 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 @@ -88,14 +89,40 @@ const EquipMent = () => { let a3= fn(value) setDate(value) getdevice2(topMenus[0].id,a3) + } const refreshFunc = (): Promise => { return new Promise((resolve, reject) => { resolve() }) } + let [id,setId]=useState(0) + const tabCli=(val)=>{ + setSelectedMenuId(val.id) + setId(val.id2) + let time=fn(date) + getdevice2(val.id2,time) + } return ( - + + { + topMenus.map((item,index)=>{ + return( + + tabCli(item)} + > + {item.title} + + + ) + }) + } + + { onClick={() => { console.log(item,'设备'); - Taro.navigateTo({ url: `/inspectionManager/inspection/index?id=${topMenus[2].id2}&categoryId=${item.categoryId}&time=${fn(date)}&name=${item.categoryName}` }) + Taro.navigateTo({ url: `/inspectionManager/inspection/index?id=${id}&categoryId=${item.categoryId}&time=${fn(date)}&name=${item.categoryName}` }) }} >去巡检 diff --git a/src/inspectionManager/inspection/index.tsx b/src/inspectionManager/inspection/index.tsx index 4ee8795..8dd0cb4 100644 --- a/src/inspectionManager/inspection/index.tsx +++ b/src/inspectionManager/inspection/index.tsx @@ -13,6 +13,8 @@ const getCheckDeviceBySomet=(data)=>{ } const EquipMent = () => { const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id + console.log('基地',baseId); + const categoryId2 = Taro.getCurrentInstance().router?.params.categoryId || 0; // 基地id const date2=Taro.getCurrentInstance().router?.params.time const name=Taro.getCurrentInstance().router?.params.name @@ -42,10 +44,15 @@ const EquipMent = () => { }, ]) //获取数据 - useEffect(()=>{ + + Taro.useDidShow(() => { getList('0') - },[]) - const [date, setDate] = useState(date2) + }) + + 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(date2||a+'-'+b+'-'+c) function fn(data){ let a2=data.substring(0,4) let b2 =data.substring(5,7) @@ -53,6 +60,8 @@ const EquipMent = () => { return `${a2}-${b2}-${c2}` } const getList=(id)=>{ + console.log('ID', id); + getCheckDeviceBySomet({pageNo:1,pageSize:10,base:baseId,createTime:fn(date),deviceStatus:categoryId2,inspectionState:id }).then(res=>{ console.log(res,'huoqushuju'); setDataList(res.data.list) @@ -73,7 +82,7 @@ const EquipMent = () => { setDate(value) } return ( - + @@ -99,7 +108,7 @@ const EquipMent = () => { > {item.equName} - 上次巡检 {item.inspectionTime} + 上次巡检 { new Date().toLocaleDateString(item.inspectionTime)} { Taro.navigateTo({ url: '/inspectionManager/inspectionLog/index?id=' + item.equNum}) }} >巡检日志 - { - Taro.navigateTo({ url: '/inspectionManager/inspectionContent/index?id=' + item.id}) + Taro.navigateTo({ url: `/inspectionManager/inspectionContent/index?time=${date2}&device=${item.equName}&deviceCode=${item.equNum}&base=${item.base}&massif=${item.massif}`}) }} >去巡检 - { item.inspectionState=='1'?'在线':'离线'} diff --git a/src/inspectionManager/inspectionContent/index.tsx b/src/inspectionManager/inspectionContent/index.tsx index 234cdaa..a400e3e 100644 --- a/src/inspectionManager/inspectionContent/index.tsx +++ b/src/inspectionManager/inspectionContent/index.tsx @@ -1,7 +1,8 @@ -import { Label, Radio, RadioGroup, Input, View, Textarea, Button } from "@tarojs/components" +import { Label, Radio, RadioGroup, Input, View, Textarea, Button,Image,PickerView,PickerViewColumn,Picker } from "@tarojs/components" import PageWrapper from "../../components/customized/pageWrapper"; import Taro from "@tarojs/taro"; - +import { useEffect, useState } from "react"; +import { request } from "../../config/axios" const FormItem = ({ children, label = '' }) => { return ( @@ -11,30 +12,191 @@ const FormItem = ({ children, label = '' }) => { ) } +//获取巡检人 +const page=()=>{ + return request({ + url:'/system/user/page?pageNo=1&pageSize=10', + method:'GET', + }) +} +//添加巡检 +const getCreateCheck=(data)=>{ + return request({ + url:'/agriculture/check-logs/createCheck', + method:'POST', + data + }) +} const InspectionContent = () => { + //获取巡检人 + let [dataList,setDataList]=useState([]) + useEffect(()=>{ + page().then(res=>{ + console.log(res.data.list,'huoqurenkou'); + setDataList(res.data.list) + }) + },[]) + const time = Taro.getCurrentInstance().router?.params.time ; // 时间 + //设备名称 + let device=Taro.getCurrentInstance().router?.params.device + //设备编号 + let deviceCode=Taro.getCurrentInstance().router?.params.deviceCode + //所属地块 + let massif=Taro.getCurrentInstance().router?.params.massif + //所属基地 + let base = Taro.getCurrentInstance().router?.params.base + console.log(time,device,deviceCode,massif,base); + let pages =Taro.getCurrentPages(); + console.log(pages,'pagessss'); + const page2=pages[pages.length-2] + console.log(page2,'222'); + + + //巡检内容 + const [textareaVal,setTextareaVal]=useState('') + //巡检人 + const [inputVal,setInputVal]=useState('') + //巡检图片 + let [img,setImg]=useState('') + //年月日 + let [years,setYears]=useState('') + //时分 + let [times,setTimes]=useState('') + //秒 + let [seconds,setSeconds]=useState('') + //巡检状态 + let [readio,setReadio]=useState('') + let [isError1,setIsError1]=useState(false) + let [isError3,setIsError3]=useState(false) + let [isError4,setIsError4]=useState(false) + let [isError5,setIsError5]=useState(false) + const add=()=>{ + if(!readio){ + setIsError4(true) + return + } + if (!textareaVal) { + setIsError1(true) // 如果输入框为空,设置错误状态 + return + } + if(!years){ + setIsError3(true) // 如果输入框为空,设置错误状态 + return + } + if(!times){ + setIsError3(true) // 如果输入框为空,设置错误状态 + return + } + if(!seconds){ + setIsError3(true) // 如果输入框为空,设置错误状态 + return + } + if(!img){ + setIsError5(true) // 如果输入框为空,设置错误状态 + return + } + let data={ + inspectionState:'1', + inspectionResults:readio, + equNum:deviceCode, + equName:device, + massif:massif, + base:base, + createTime:time, + content:textareaVal, + inspectionImage:img, + inspectionTime:years+times+':'+seconds, + inspectorId:inputVal?inputVal:dataList[0].id + } + getCreateCheck(data).then(res=>{ + console.log(res,'成功与否'); + if(res.data){ + Taro.navigateBack({ + delta: 1 + }) + } + + }) + + } + //巡检内容 + const handleTextarea=(e)=>{ + setTextareaVal(e.target.value) + setIsError1(false) + } + //巡检结果 + const onReaio=(e)=>{ + setIsError4(false) + setReadio(e.target.value) + } + //巡检人 + const onChange=(e)=>{ + console.log(e.target.value,'uuuuu') + setInputVal(dataList[e.target.value].id) + } + //选择年月日 + const onTimeChange=(e)=>{ + console.log(e,'shijian'); + setYears(e.detail.value) + setIsError3(false) + } + //选择时间 + const onTimeChange2=(e)=>{ + console.log(e,'shijian'); + setIsError3(false) + setTimes(e.detail.value) + } + //秒 + const onSeconds=(e)=>{ + // console.log(e.target.value); + setIsError3(false) + setSeconds(e.target.value) + + } return ( - - 基地1-气象站-设备1(NKWFDS1AW27) + + {device}({deviceCode}) - + + {isError4 && 巡检结果不能为空} - 巡检结果 - + 巡检内容 + + {isError1 && 巡检内容不能为空} - + + + {dataList.map(item => { + return ( + {item.deptName} + ) + })} + + - + + + 年:{years} + + + + + 时:{times} + + + + {isError3 && 巡检时间不能为空} 影像 @@ -48,20 +210,25 @@ const InspectionContent = () => { fail: () => { console.log('fail'); }, - success: () => { - console.log('success'); + success: (e) => { + console.log(e.tempFilePaths[0],'success'); + setImg(e.tempFilePaths[0]) } }) }} >选择图片 + {isError5 && 巡检内容不能为空} + + ) } diff --git a/src/inspectionManager/inspectionLog/index.tsx b/src/inspectionManager/inspectionLog/index.tsx index 91a865c..9ea607e 100644 --- a/src/inspectionManager/inspectionLog/index.tsx +++ b/src/inspectionManager/inspectionLog/index.tsx @@ -1,7 +1,7 @@ -import { Input, View } from "@tarojs/components" +import { Input, View,Button } from "@tarojs/components" import PageWrapper from "../../components/customized/pageWrapper"; import { request } from "../../config/axios" -import { useEffect } from "react"; +import { useEffect, useState } from "react"; import Taro from "@tarojs/taro" @@ -15,12 +15,13 @@ const getPageByCondition=(data)=>{ } const InspectionLog = () => { + let [dataList,setDataList]=useState([]) const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id //获取数据 useEffect(()=>{ getPageByCondition({pageNo:1,pageSize:100,equNum:baseId,inspectionState:'1'}).then(res=>{ console.log(res,'获取数据'); - + setDataList(res.data.list) }) },[]) return ( @@ -33,7 +34,20 @@ const InspectionLog = () => { + > + { + dataList.map(item=>{ + return ( + + {new Date().toLocaleDateString(item.inspectionTime)} + {item.inspectionResults} + {item.inspector} + + + ) + }) + } + ) }