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)
})
}
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<void> => {
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 (
<View className="px-1 h-full" style={{position:'relative',}}>
<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%' }}>
<ScrollView
className="w-full h-full"
@ -142,7 +169,7 @@ const EquipMent = () => {
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}` })
}}
></View>
</View>

View File

@ -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 (
<PageWrapper title={name}>
<PageWrapper title={name} style={{position:'relative'}}>
<View className="p-1 h-full">
<View className="h-full flex flex-col">
<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>
<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="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})
}}
></View>
<View
<View
className="rounded-xl w-20 bg-green-500 text-center py-1"
style={{ color: 'white' }}
style={{ color: 'white',display:item.inspectionState=='1'?'none':'', }}
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
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'?'在线':'离线'}
</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 Taro from "@tarojs/taro";
import { useEffect, useState } from "react";
import { request } from "../../config/axios"
const FormItem = ({ children, label = '' }) => {
return (
<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 = () => {
//获取巡检人
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 (
<PageWrapper title="巡检内容">
<View className="h-[3rem] flex items-center px-7 border" style={{ color: 'white' }}>1--1NKWFDS1AW27</View>
<PageWrapper title="巡检内容" style={{position:'relative'}}>
<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)'}}>
<FormItem label="巡检结果">
<RadioGroup>
<RadioGroup onChange={onReaio}>
<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 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>
{isError4 && <View style={{ color: 'red' }}></View>}
</RadioGroup>
</FormItem>
<View className="flex items-start border-b border-slate-400 p-3">
<View className="w-[5rem]"></View>
<Textarea placeholder="请输入巡检内容" className="h-[3rem] pl-3"></Textarea>
<View className="w-[5rem]"></View>
<Textarea placeholder="请输入巡检内容" onInput={handleTextarea} value={textareaVal} className="h-[3rem] pl-3"></Textarea>
{isError1 && <View style={{ color: 'red' }}></View>}
</View>
<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 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>
<View className="p-3">
<View className="w-[5rem]"></View>
@ -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])
}
})
}}
></View>
{isError5 && <View style={{ color: 'red' }}></View>}
<Image src={img} style={{width:'200px',height:'200px'}}></Image>
</View>
<View className="absolute bottom-3 left-0 p-4 w-full">
<Button
className="rounded-full border flex justify-center items-center"
style={{ background: 'linear-gradient(to right, #19b3c3, #10c87e);', color: 'white' }}
onClick={() =>add()}
></Button>
</View>
</View>
</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 { 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 = () => {
<View
className="bg-white rounded-2xl p-6 relative overflow-auto"
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>
)
}