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

This commit is contained in:
Zxuyoubin 2024-04-08 18:11:13 +08:00
parent 2ee240ea35
commit 3da82cb55a
4 changed files with 247 additions and 30 deletions

View File

@ -66,6 +66,7 @@ const EquipMent = () => {
setDataList(res.data.list) setDataList(res.data.list)
}) })
} }
const [selectedMenuId, setSelectedMenuId] = useState(0)
useEffect(()=>{ useEffect(()=>{
getDeviceInfoCard({}).then(res=>{ getDeviceInfoCard({}).then(res=>{
console.log(res,'获取基地'); console.log(res,'获取基地');
@ -76,11 +77,11 @@ const EquipMent = () => {
})).reverse()) })).reverse())
console.log('基地id', res.data.list[0].id); console.log('基地id', res.data.list[0].id);
let time=fn(date) let time=fn(date)
setSelectedMenuId(res.data.list[0].id)
getdevice2(res.data.list[0].id,time) getdevice2(res.data.list[0].id,time)
}) })
},[]) },[])
const [selectedMenuId, setSelectedMenuId] = useState('all')
const [refreshTrigger, setRefreshTrigger] = useState(false) const [refreshTrigger, setRefreshTrigger] = useState(false)
function handleDateChange(e) { function handleDateChange(e) {
const value = e.detail.value const value = e.detail.value
@ -88,14 +89,40 @@ const EquipMent = () => {
let a3= fn(value) let a3= fn(value)
setDate(value) setDate(value)
getdevice2(topMenus[0].id,a3) 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() })
} }
let [id,setId]=useState(0)
const tabCli=(val)=>{
setSelectedMenuId(val.id)
setId(val.id2)
let time=fn(date)
getdevice2(val.id2,time)
}
return ( return (
<View className="px-1 h-full" style={{position:'relative',}}> <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> <View className="flex px-2 py-1">
{
topMenus.map((item,index)=>{
return(
<View className="flex px-2 py-1" key={item.id}>
<View
className={`p-1 px-3 ${selectedMenuId === item.id ? 'border-b-4 border-lime-800' : ''}`}
key={item.id}
style={{ color: 'white' }}
onClick={() => tabCli(item)}
>
{item.title}
</View>
</View>
)
})
}
</View>
<View className="pb-2" style={{ height: 'calc(100% - 2.4rem)', width: '100%' }}> <View className="pb-2" style={{ height: 'calc(100% - 2.4rem)', width: '100%' }}>
<ScrollView <ScrollView
className="w-full h-full" className="w-full h-full"
@ -142,7 +169,7 @@ const EquipMent = () => {
onClick={() => { onClick={() => {
console.log(item,'设备'); 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}` })
}} }}
></View> ></View>
</View> </View>

View File

@ -13,6 +13,8 @@ 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
console.log('基地',baseId);
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 date2=Taro.getCurrentInstance().router?.params.time
const name=Taro.getCurrentInstance().router?.params.name const name=Taro.getCurrentInstance().router?.params.name
@ -42,10 +44,15 @@ const EquipMent = () => {
}, },
]) ])
//获取数据 //获取数据
useEffect(()=>{
Taro.useDidShow(() => {
getList('0') 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){ function fn(data){
let a2=data.substring(0,4) let a2=data.substring(0,4)
let b2 =data.substring(5,7) let b2 =data.substring(5,7)
@ -53,6 +60,8 @@ const EquipMent = () => {
return `${a2}-${b2}-${c2}` return `${a2}-${b2}-${c2}`
} }
const getList=(id)=>{ const getList=(id)=>{
console.log('ID', id);
getCheckDeviceBySomet({pageNo:1,pageSize:10,base:baseId,createTime:fn(date),deviceStatus: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)
@ -73,7 +82,7 @@ const EquipMent = () => {
setDate(value) setDate(value)
} }
return ( return (
<PageWrapper title={name}> <PageWrapper title={name} style={{position:'relative'}}>
<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">
@ -99,7 +108,7 @@ const EquipMent = () => {
> >
<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>
<View className="text-sm px-4" style={{ color: '#00000090' }}> {item.inspectionTime}</View> <View className="text-sm px-4" style={{ color: '#00000090' }}> { new Date().toLocaleDateString(item.inspectionTime)}</View>
<View className="w-full px-4 flex justify-between items-start py-2 space-x-1"> <View className="w-full px-4 flex justify-between items-start py-2 space-x-1">
<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"
@ -108,17 +117,17 @@ const EquipMent = () => {
Taro.navigateTo({ url: '/inspectionManager/inspectionLog/index?id=' + item.equNum}) 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',display:item.inspectionState=='1'?'none':'', }}
onClick={() => { onClick={() => {
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}`})
}} }}
></View> ></View>
</View> </View>
<View <View
className="absolute left-0 top-0 text-white p-1 text-sm px-2" className="absolute left-0 top-0 text-white p-1 text-sm px-2"
style={{ backgroundColor: '#0FC87C', color: 'white', borderRadius: '.3rem 0 .3rem 0' }} style={{ backgroundColor: '#0FC87C', color: 'white', borderRadius: '.3rem 0 .3rem 0' }}
> >
{ item.inspectionState=='1'?'在线':'离线'} { item.inspectionState=='1'?'在线':'离线'}
</View> </View>

View File

@ -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 PageWrapper from "../../components/customized/pageWrapper";
import Taro from "@tarojs/taro"; import Taro from "@tarojs/taro";
import { useEffect, useState } from "react";
import { request } from "../../config/axios"
const FormItem = ({ children, label = '' }) => { const FormItem = ({ children, label = '' }) => {
return ( return (
<View className="flex items-center border-b border-slate-400 p-3"> <View className="flex items-center border-b border-slate-400 p-3">
@ -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 = () => { 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 ( return (
<PageWrapper title="巡检内容"> <PageWrapper title="巡检内容" style={{position:'relative'}}>
<View className="h-[3rem] flex items-center px-7 border" style={{ color: 'white' }}>1--1NKWFDS1AW27</View> <View className="h-[3rem] flex items-center px-7 border" style={{ color: 'white' }}>{device}{deviceCode}</View>
<View className="bg-white rounded-2xl p-6 relative" style={{ height: 'calc(100% - 3rem)'}}> <View className="bg-white rounded-2xl p-6 relative" style={{ height: 'calc(100% - 3rem)'}}>
<FormItem label="巡检结果"> <FormItem label="巡检结果">
<RadioGroup> <RadioGroup onChange={onReaio}>
<Label className='radio-list__label' for={'0'} key={0}> <Label className='radio-list__label' for={'0'} key={0}>
<Radio className='radio-list__radio' value={'0'} checked={false}></Radio> <Radio className='radio-list__radio' value='正常' checked={false}></Radio>
</Label> </Label>
<Label className='radio-list__label ml-4' for={'1'} key={1}> <Label className='radio-list__label ml-4' for={'1'} key={1}>
<Radio className='radio-list__radio' value={'0'} checked={false}></Radio> <Radio className='radio-list__radio' value='异常' checked={false}></Radio>
</Label> </Label>
{isError4 && <View style={{ color: 'red' }}></View>}
</RadioGroup> </RadioGroup>
</FormItem> </FormItem>
<View className="flex items-start border-b border-slate-400 p-3"> <View className="flex items-start border-b border-slate-400 p-3">
<View className="w-[5rem]"></View> <View className="w-[5rem]"></View>
<Textarea placeholder="请输入巡检内容" className="h-[3rem] pl-3"></Textarea> <Textarea placeholder="请输入巡检内容" onInput={handleTextarea} value={textareaVal} className="h-[3rem] pl-3"></Textarea>
{isError1 && <View style={{ color: 'red' }}></View>}
</View> </View>
<FormItem label="巡检人"> <FormItem label="巡检人">
<Input placeholder="请输入巡检人"></Input> <PickerView style='width: 100%; height: 50px;' value={inputVal} onChange={onChange}>
<PickerViewColumn>
{dataList.map(item => {
return (
<View>{item.deptName}</View>
)
})}
</PickerViewColumn>
</PickerView>
</FormItem> </FormItem>
<FormItem label="巡检时间"> <FormItem label="巡检时间">
<Input placeholder="请输入巡检时间"></Input> <Picker mode='date' onChange={onTimeChange} style={{width:'45%'}}>
<View className='picker'>
:{years}
</View>
</Picker>
<Picker mode='time' onChange={onTimeChange2} style={{width:'35%'}}>
<View className='picker'>
:{times}
</View>
</Picker>
<Input placeholder='请输入秒' value={seconds} onInput={onSeconds} ></Input>
{isError3 && <View style={{ color: 'red' }}></View>}
</FormItem> </FormItem>
<View className="p-3"> <View className="p-3">
<View className="w-[5rem]"></View> <View className="w-[5rem]"></View>
@ -48,20 +210,25 @@ const InspectionContent = () => {
fail: () => { fail: () => {
console.log('fail'); console.log('fail');
}, },
success: () => { success: (e) => {
console.log('success'); console.log(e.tempFilePaths[0],'success');
setImg(e.tempFilePaths[0])
} }
}) })
}} }}
></View> ></View>
{isError5 && <View style={{ color: 'red' }}></View>}
<Image src={img} style={{width:'200px',height:'200px'}}></Image>
</View> </View>
<View className="absolute bottom-3 left-0 p-4 w-full"> <View className="absolute bottom-3 left-0 p-4 w-full">
<Button <Button
className="rounded-full border flex justify-center items-center" className="rounded-full border flex justify-center items-center"
style={{ background: 'linear-gradient(to right, #19b3c3, #10c87e);', color: 'white' }} style={{ background: 'linear-gradient(to right, #19b3c3, #10c87e);', color: 'white' }}
onClick={() =>add()}
></Button> ></Button>
</View> </View>
</View> </View>
</PageWrapper> </PageWrapper>
) )
} }

View File

@ -1,7 +1,7 @@
import { Input, View } from "@tarojs/components" import { Input, View,Button } from "@tarojs/components"
import PageWrapper from "../../components/customized/pageWrapper"; import PageWrapper from "../../components/customized/pageWrapper";
import { request } from "../../config/axios" import { request } from "../../config/axios"
import { useEffect } from "react"; import { useEffect, useState } from "react";
import Taro from "@tarojs/taro" import Taro from "@tarojs/taro"
@ -15,12 +15,13 @@ const getPageByCondition=(data)=>{
} }
const InspectionLog = () => { const InspectionLog = () => {
let [dataList,setDataList]=useState([])
const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id const baseId = Taro.getCurrentInstance().router?.params.id || 0; // 基地id
//获取数据 //获取数据
useEffect(()=>{ useEffect(()=>{
getPageByCondition({pageNo:1,pageSize:100,equNum:baseId,inspectionState:'1'}).then(res=>{ getPageByCondition({pageNo:1,pageSize:100,equNum:baseId,inspectionState:'1'}).then(res=>{
console.log(res,'获取数据'); console.log(res,'获取数据');
setDataList(res.data.list)
}) })
},[]) },[])
return ( return (
@ -33,7 +34,20 @@ const InspectionLog = () => {
<View <View
className="bg-white rounded-2xl p-6 relative overflow-auto" className="bg-white rounded-2xl p-6 relative overflow-auto"
style={{ height: 'calc(100% - 3rem)'}} style={{ height: 'calc(100% - 3rem)'}}
></View> >
{
dataList.map(item=>{
return (
<View className="flex px-2 py-1" style={{justifyContent:'spaceBetween',alignItems:'center',width:'100%'}}>
<View style={{marginRight:'20px'}}>{new Date().toLocaleDateString(item.inspectionTime)}</View>
<View style={{marginRight:'20px'}}>{item.inspectionResults}</View>
<View style={{marginRight:'20px'}}>{item.inspector}</View>
<Button style={{backgroundColor:'#0fc67b',borderRadius:'25px',color:'#fff'}}></Button>
</View>
)
})
}
</View>
</PageWrapper> </PageWrapper>
) )
} }