TraceabilityAPP/components/poultry/detailCard.vue

197 lines
4.2 KiB
Vue
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<view class="" v-if="props.showImg">
<view class="" v-if="animal_detail?.pic_detail?.pic">
<imgCard :imgUrl='animal_detail.pic_detail.pic'></imgCard>
</view>
<view class="bad-info">
<view class="" style="display: flex;align-items: center;">
<u--image src="/static/img/sj.png')" style="margin: 0 5rpx;" width="28.04rpx"
height="28.04rpx"></u--image>
<text>刷新时间:{{dateFn()}}</text>
</view>
<view style="display: flex;" @click="navgo(`/pages/poultry/histroyFeed?id=${props.id}`)">
查看历史条件 <u--image src="/static/img/CKGD.png" style="margin-left: 5rpx;" width="31.54rpx"
height="31.54rpx"></u--image>
</view>
</view>
<view class="up-plant-btn" @click="updateImgFn">
上传新的种植情况
</view>
</view>
<view class="card">
<view class="tit">
<view class="">
溯源码: {{animal_detail.code}}
</view>
</view>
<view class="card-li">
<view class="">
养殖品种: {{animal_detail.kind}}
</view>
<view class="">
年龄: {{animal_detail.age}}
</view>
</view>
<view class="card-li">
<view class="">
养殖类型: {{animal_detail.breed}}
</view>
<view class="">
体重:{{animal_detail.weight}}
</view>
</view>
</view>
<view class="card">
<view class="card-li">
<view class="" style="display: flex;align-items: center;">
<u--image src="/static/img/GG.png" style="margin: 0 21rpx;" width="80rpx" height="80rpx"></u--image>
当前养殖状态
</view>
<view class="" style="color: #00A15E;" v-if='animal_detail.status==1'>
健康
</view>
<view class="" style="color: #FFD736;" v-if='animal_detail.status==2'>
怀孕中
</view>
<view class="" style="color: #3274F9;" v-if='animal_detail.status==4'>
可出栏
</view>
<view class="" style="color: #F84221;" v-if='animal_detail.status==3'>
生病隔离中
</view>
</view>
</view>
</template>
<script setup>
import imgCard from "@/components/imgCard.vue"
import uplodeImg from "@/utils/uplodeImg.js"
import {
animalInfoAPI,
addAnimalPicAPI
} from "@/api/chick.js"
import {
ref,
reactive,
watch
} from "vue"
import {
onShow
} from "@dcloudio/uni-app"
const dateFn = () => {
var today = new Date();
// 获取年、月、日
var year = today.getFullYear();
var month = today.getMonth() + 1; // 月份从0开始需要加1
var day = today.getDate();
// 构建日期字符串
var dateStr = year + '-' + month + '-' + day;
return dateStr
// 输出日期字符串
}
const navgo = (url) => {
uni.navigateTo({
url
})
}
// 详情猪
const objFn = (res, data) => {
for (let key in res) {
data[key] = res[key]
}
}
const animal_detail = reactive({})
const props = defineProps({
id: String,
showImg: Boolean
})
watch(props, (newValue, oldVlaue) => {
// console.log("dfhsdfgsdjk")
if (props?.id) {
animalInfoAPI({
poultry_id: Number(props.id)
}).then(res => {
objFn(res.data, animal_detail)
})
}
}, {
// 页面加载会先执行一次
immediate: true
})
onShow(() => {
if (props?.id) {
animalInfoAPI({
poultry_id: Number(props.id)
}).then(res => {
objFn(res.data, animal_detail)
})
}
})
const updateImgFn = () => {
uplodeImg().then(res => {
animal_detail.pic_detail.pic = res.data.image
// img.value = res.data.image
addAnimalPicAPI({
poultry_id: Number(props.id),
pic: res.data.image
})
})
}
</script>
<style lang="scss" scoped>
.card {
margin-bottom: 20rpx;
.tit {
display: flex;
justify-content: space-between;
padding-bottom: 20rpx;
border-bottom: 1px solid #EBF1EF;
}
.card-li {
margin-top: 20rpx;
display: flex;
justify-content: space-between;
align-items: center;
}
}
.bad-info {
display: flex;
// background-color: red;
justify-content: space-between;
align-items: center;
margin: 20rpx 0;
color: #737373;
width: 693.93rpx;
font-size: 26.29rpx;
.tit-b {
color: red;
}
}
.up-plant-btn {
width: 371.5rpx;
height: 66.59rpx;
color: #00A15E;
margin: 40rpx auto;
border: 1px solid #00A15E;
font-weight: bold;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
display: flex;
align-items: center;
justify-content: center;
}
</style>