cultivationApp/pages/plantAdmin/breedDetail.vue

489 lines
12 KiB
Vue
Raw Permalink Normal View History

2023-12-20 18:13:01 +08:00
<template>
<view class="box">
<view class="content">
<view class="" style="display: flex;justify-content: space-between;margin-bottom: 20rpx;">
<view class="tit" style="margin-bottom: 0;">
2024-01-31 17:25:29 +08:00
动物数据
2023-12-20 18:13:01 +08:00
</view>
<view class="" style="display: flex;align-items: center;">
<u-icon name="clock" style="margin-right: 10rpx;"></u-icon>
<text style="color: #ACACAC;font-size: 25rpx;">刷新时间: {{getNowTimeFn()}} </text>
</view>
</view>
2024-01-31 17:25:29 +08:00
<view class="video" @click="perviewFn(dataobj.pic[0])">
2024-01-31 11:16:49 +08:00
<u--image v-if="dataobj&&dataobj.pic" :src="dataobj.pic[0]" width="100%"
2023-12-20 18:13:01 +08:00
height="300rpx"></u--image>
</view>
2024-02-21 18:23:37 +08:00
<breedInfo :info='dataobj' @getFenceHouseDetail="getFenceHouseDetail"></breedInfo>
2023-12-20 18:13:01 +08:00
<view class="add-btn">
2024-01-30 18:31:10 +08:00
<view class="add-thing" style="width: 694rpx;" @click="addshowPicke(2)">
2023-12-20 18:13:01 +08:00
新增喂养
</view>
</view>
<view class="">
<view class="tit tit-more" style="margin: 20rpx 0;">
<view>喂养信息</view>
2024-01-30 18:31:10 +08:00
<view class="more" @click="navTo(`/pages/plantAdmin/moreFeed?id=${typeID}&house_id=${houseID}`)">查看更多 <u-icon name="arrow-right"></u-icon> </view>
2023-12-20 18:13:01 +08:00
</view>
2024-01-30 18:31:10 +08:00
<block class="" v-if="feedList.length>0" v-for="(item, index) in feedList" :key="index">
<view class="thing-card" v-if="item != null">
2024-01-31 14:17:10 +08:00
<view class="card_body" v-if="item">
2023-12-20 18:13:01 +08:00
<view class="left">
2024-01-30 18:31:10 +08:00
<u--image v-if="item&&item.pic" @click="perviewFn(item.pic[0])" radius='10' :src="item.pic[0]" width="200rpx"
2023-12-20 18:13:01 +08:00
height="200rpx"></u--image>
</view>
2024-01-30 18:31:10 +08:00
<u--image src="/static/main/house/xia_yi_ji_btn.png" class="next" width="38rpx" height="38rpx" @click="navFeed(item, index)"></u--image>
<view class="right" style="color: #7B7B7B;" @click="navFeed(item, index)">
2023-12-20 18:13:01 +08:00
<view class="r-item">
<view class="item-title">操作类型:</view>
2024-02-01 18:01:18 +08:00
<view>{{item.type_text}}</view>
2023-12-20 18:13:01 +08:00
</view>
<view class="r-item">
<view class="item-title">操作人员:</view>
2024-01-30 18:31:10 +08:00
<view>{{item.operator}}</view>
2023-12-20 18:13:01 +08:00
</view>
<view class="r-item">
<view class="item-title">操作日期:</view>
2024-01-30 18:31:10 +08:00
<view>{{item.create_time}}</view>
2023-12-20 18:13:01 +08:00
</view>
<view class="r-item" style="height: 80rpx;">
<view class="item-title">备注:</view>
2024-01-30 18:31:10 +08:00
<view class="row2">{{item.remark}}</view>
2023-12-20 18:13:01 +08:00
</view>
</view>
</view>
</view>
</block>
<view class="coneng-detail" v-else>
<view class="">
<image src="@/static/img/zw.png" mode="aspectFit"></image>
<view class="">
暂无数据
</view>
</view>
</view>
</view>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="selectList" title="请选择"
@close="show = false" @select="selectOne">
</u-action-sheet>
</view>
</view>
</template>
<script setup>
import breedInfo from "@/components/plant/breedInfo.vue"
import {
ref,
reactive
} from "vue"
import {
plantlist,
landdetail
} from '@/api/api.js'
2024-01-29 18:12:35 +08:00
import {
2024-01-30 18:31:10 +08:00
fenceHouseDetail,
animalInfoList,
operationLogIndex,
animalInfoDetail
} from "@/api/manage.js"
2023-12-20 18:13:01 +08:00
import {
onLoad,
onShow
} from "@dcloudio/uni-app"
2024-01-30 18:31:10 +08:00
import {
animalTypeLists
} from "@/api/dict.js"
const dataList = reactive([])
2023-12-20 18:13:01 +08:00
const dataobj = reactive({})
const typeID = ref('')
const columns = reactive([
[{
label: '种植',
route: "/pages/husbandryForm/sow"
}, {
label: '施肥',
route: "/pages/husbandryForm/fertilize"
}, {
label: '除草',
route: "/pages/husbandryForm/weeding"
}, {
label: '灌溉',
route: "/pages/husbandryForm/irrigate"
}, {
label: '除虫',
route: "/pages/husbandryForm/Pest"
}, {
label: '收获',
route: "/pages/husbandryForm/harvest"
}]
]);
2024-01-30 18:31:10 +08:00
2024-01-29 18:12:35 +08:00
const animal_type_lists = ref([]);
const initAnimalTypeLists = ()=>{
animalTypeLists().then(res=>{
animal_type_lists.value = res.data;
})
}
initAnimalTypeLists();
const getAnimalType = (value)=>{
return animal_type_lists.value.find(item=>item.value==value)?.name || ''
}
2024-01-30 18:31:10 +08:00
const feedList = ref([])
const initOperationLogIndex = ()=>{
operationLogIndex({
2024-02-03 10:46:08 +08:00
fence_house_id: houseID.value,
animal_info_id: typeID.value
2024-01-30 18:31:10 +08:00
}).then(res=>{
res.data = res.data.map(item=>{
2024-02-01 18:01:18 +08:00
item = {
...item.detail,
create_time: item.create_time,
2024-02-03 16:18:17 +08:00
type_text: item.type_text,
type: item.type
2024-02-01 18:01:18 +08:00
};
2024-01-30 18:31:10 +08:00
if(item) item.pic = JSON.parse(item.pic||'[]');
return item ?? null;
})
feedList.value = res.data;
})
}
const houseID = ref('');
2023-12-20 18:13:01 +08:00
onLoad((option) => {
typeID.value = option.id;
2024-01-30 18:31:10 +08:00
houseID.value = option.house_id;
getFenceHouseDetail();
2023-12-20 18:13:01 +08:00
});
onShow(() => {
2024-01-30 18:31:10 +08:00
getlist();
initOperationLogIndex();
2023-12-20 18:13:01 +08:00
})
2024-01-30 18:31:10 +08:00
const getFenceHouseDetail = () => {
animalInfoDetail({
id: typeID.value,
2023-12-20 18:13:01 +08:00
}).then((res) => {
if (res.code == 1) {
2024-01-31 11:16:49 +08:00
res.data.pic = JSON.parse(res.data.pic||'[]');
2023-12-20 18:13:01 +08:00
Object.assign(dataobj, res.data);
}
});
};
const getlist = () => {
2024-01-30 18:31:10 +08:00
animalInfoList({
fence_house_id: typeID.value,
page_no: 1,
page_size: 3
2023-12-20 18:13:01 +08:00
}).then((res) => {
if (res.code == 1) {
2024-01-30 18:31:10 +08:00
dataList.splice(0, dataList.length, ...res.data.lists);
2023-12-20 18:13:01 +08:00
dataList.forEach(item => {
item.showCode = false
})
2024-01-30 18:31:10 +08:00
// console.log(dataList)
2023-12-20 18:13:01 +08:00
}
});
};
const show = ref(false);
const selectList = ref([]);
const navType = ref(1);
2024-01-30 18:31:10 +08:00
2023-12-20 18:13:01 +08:00
const addshowPicke = (type=1) => {
if(type==1){
selectList.value = [
{name: '购买'},
{name: '自繁'},
];
}else {
selectList.value = [
{name: '喂食'},
{name: '喂水'},
{name: '消毒'},
{name: '疫苗'},
{name: '驱虫'},
];
}
navType.value = type;
show.value = true;
}
const selectOne = (e)=>{
if(navType.value==1){
2024-01-30 18:31:10 +08:00
navTo(`/pages/plantAdmin/addBreed?name=${e.name}&type=${e.name=='购买'?1:2}&id=${dataobj.id}&fence_house_name=${dataobj.fence_house_name}`)
2023-12-21 16:29:58 +08:00
}else {
2024-01-30 18:31:10 +08:00
if(e.name=='喂食') return navTo(`/pages/feed/feed?id=${typeID.value}&house_id=${houseID.value}`);
if(e.name=='喂水') return navTo(`/pages/feed/water?id=${typeID.value}&house_id=${houseID.value}`);
if(e.name=='消毒') return navTo(`/pages/feed/sterilize?id=${typeID.value}&house_id=${houseID.value}`);
if(e.name=='疫苗') return navTo(`/pages/feed/vaccine?id=${typeID.value}&house_id=${houseID.value}`);
if(e.name=='驱虫') return navTo(`/pages/feed/expelling?id=${typeID.value}&house_id=${houseID.value}`);
2023-12-20 18:13:01 +08:00
}
}
//跳转
const navTo = (url) => {
uni.navigateTo({
url
})
}
2024-01-31 14:17:10 +08:00
const navFeed = (item, index)=>{
2024-02-03 16:18:17 +08:00
if(item.type==3) uni.navigateTo({
2024-01-31 14:17:10 +08:00
url: `/pages/feedDetail/feedDetail`,
success: (res) => {
res.eventChannel.emit('setDatasItem', item);
}
})
2024-02-03 16:18:17 +08:00
if(item.type==5) uni.navigateTo({
2024-01-31 14:17:10 +08:00
url: `/pages/feedDetail/waterDetail`,
success: (res) => {
res.eventChannel.emit('setDatasItem', item);
}
})
2024-02-03 16:18:17 +08:00
if(item.type==1) uni.navigateTo({
2024-01-31 14:17:10 +08:00
url: `/pages/feedDetail/sterilizeDetail`,
success: (res) => {
res.eventChannel.emit('setDatasItem', item);
}
})
2024-02-03 16:18:17 +08:00
if(item.type==4) uni.navigateTo({
2024-01-31 14:17:10 +08:00
url: `/pages/feedDetail/vaccineDetail`,
success: (res) => {
res.eventChannel.emit('setDatasItem', item);
}
})
2024-02-03 16:18:17 +08:00
if(item.type==2) uni.navigateTo({
2024-01-31 14:17:10 +08:00
url: `/pages/feedDetail/expellingDetail`,
success: (res) => {
res.eventChannel.emit('setDatasItem', item);
}
})
2023-12-20 18:13:01 +08:00
}
const getNowTimeFn = () => {
const now = new Date();
const hour = now.getHours();
const minute = now.getMinutes();
const formattedHour = hour < 10 ? '0' + hour : hour;
const formattedMinute = minute < 10 ? '0' + minute : minute;
const currentTime = formattedHour + ':' + formattedMinute;
return currentTime
}
//查看
const perviewFn = (url) => {
uni.previewImage({
urls: [url]
})
}
let img = ''
let codeImg = ''
const showCodeFn = (i) => {
// dataList[i].showCode != dataList[i].showCode
dataList[i].showCode = !dataList[i].showCode
console.log(dataList[i].showCode)
}
</script>
<style lang="scss" scoped>
2024-01-30 18:31:10 +08:00
page{
background-color: $theme-bg-color;
}
2023-12-20 18:13:01 +08:00
.box {
width: 750rpx;
background-color: $theme-bg-color;
padding: 0;
.content {
width: 693.93rpx;
margin: auto;
padding-top: 20rpx;
.add-btn {
display: flex;
justify-content: space-between;
}
.add-thing {
height: 90rpx;
width: 335rpx;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
line-height: 90rpx;
text-align: center;
color: white;
background-color: $theme-main-color;
}
}
// padding: 20rpx;
.time {
display: flex;
font-size: 26.29rpx;
color: #737373;
margin-top: 10rpx;
}
.video {
// margin-top: 10rpx;
border-radius: 14rpx;
overflow: hidden;
}
}
.coneng-detail {
width: 478rpx;
height: 341rpx;
// background: #FFFFFF;
border-radius: 6px 6px 6px 6px;
opacity: 1;
font-size: 25rpx;
font-family: PingFang SC, PingFang SC;
font-weight: 400;
color: #737373;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
margin: 70rpx auto;
image {
width: 280rpx;
height: 142rpx;
margin-bottom: 20rpx;
}
}
.thing-card {
width: 693.93rpx;
box-sizing: border-box;
background-color: #fff;
border-radius: 20rpx;
overflow: hidden;
margin-bottom: 30rpx;
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
.head {
height: 90rpx;
border-radius: 20rpx 20rpx 0 0;
background-color: $theme-main-color;
display: flex;
justify-content: space-between;
line-height: 90rpx;
color: white;
padding: 0 30rpx;
}
.card_body {
padding: 20rpx;
display: flex;
position: relative;
.next {
position: absolute;
top: 50%;
transform: translateY(-50%);
right: 20rpx;
}
.left {
flex-shrink: 0;
position: relative;
.qr-code{
position: absolute;
right: 10rpx;
bottom: 10rpx;
}
}
.right {
flex: 1;
display: flex;
justify-content: space-between;
flex-direction: column;
margin-left: 20rpx;
.name {
font-weight: bold;
color: #333;
}
.r-item {
font-size: 28rpx;
display: flex;
.item-title {
color: #333;
flex-shrink: 0;
margin-right: 10rpx;
}
.row2 {
display: -webkit-box;
-webkit-box-orient: vertical;
overflow: hidden;
-webkit-line-clamp: 2;
/* 设置为需要显示的行数 */
}
}
}
}
}
.tit {
position: relative;
padding-left: 20rpx;
font-weight: bold;
margin-bottom: 20rpx;
}
.tit-more {
display: flex;
justify-content: space-between;
align-items: center;
.more {
display: flex;
font-size: 28rpx;
font-weight: 400;
}
}
.tit::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 3px;
/* 左边框的宽度 */
height: 30rpx;
background-color: #FFB049;
}
.code-btn {
border: 1px solid $theme-main-color;
border-radius: 30rpx;
padding: 3rpx 20rpx;
color: $theme-main-color;
position: absolute;
right: 20rpx;
}
.actBtn {
background: linear-gradient(to right, #FEFFFF 0%, #E8FAF2 100%);
}
</style>