TraceabilityAPP/pages/feedIng/addPoultry.vue

335 lines
7.4 KiB
Vue
Raw Normal View History

2023-10-21 18:02:06 +08:00
<template>
2023-10-25 19:55:18 +08:00
<view class="content">
2023-10-21 18:02:06 +08:00
2023-10-25 19:55:18 +08:00
<view class="head" v-if="addList.length">
已添加{{addList.length}}条畜生
2023-10-21 18:02:06 +08:00
</view>
<view class="card">
<view class="card-li">
<view class="card-li-tit">
养殖品种
</view>
<view class="">
2023-10-25 19:55:18 +08:00
<up-input placeholder="请输入品种" border="surround" v-model="formData.kind"></up-input>
</view>
</view>
2023-10-28 18:28:10 +08:00
<view class="card-li">
<view class="card-li-tit">
动物编码
</view>
<view class="">
<up-input placeholder="请输入品种" border="surround" v-model="formData.code"></up-input>
</view>
</view>
2023-10-25 19:55:18 +08:00
<view class="card-li">
<view class="card-li-tit">
具体品类
</view>
<view class="">
<up-input placeholder="请输入品种" border="surround" v-model="formData.breed"></up-input>
2023-10-21 18:02:06 +08:00
</view>
</view>
<view class="card-li">
<view class="card-li-tit">
年龄
</view>
<view class="">
2023-10-25 19:55:18 +08:00
<up-input placeholder="请输入年龄" border="surround" v-model="formData.age"></up-input>
2023-10-21 18:02:06 +08:00
</view>
</view>
<view class="card-li">
2023-10-23 17:57:19 +08:00
<view class="select">
2023-10-28 18:28:10 +08:00
养殖类型: <up-input @click="selectFoucsFn" placeholder="请选择" style="margin-top: 20rpx;"
2023-10-25 19:55:18 +08:00
border="surround" v-model="gender">
2023-10-23 17:57:19 +08:00
</up-input>
<view class="JT" :class="{actJT:selectAct}">
<u--image src="/static/img/XLJT.png" width="24.53rpx" height="24.53rpx"></u--image>
</view>
<view class="selectvalue" v-show="selectAct">
<view class="select-li" v-for="(item,index) in selectList" :key="index"
@click="changSelectfn(index)" :style="{color:indexs==index?'black':'#B3B3B3'}">
{{item}}
<view class="" v-show='indexs==index'>
<u--image src="/static/img/XLZZ.png" width="24.53rpx" height="24.53rpx"></u--image>
</view>
</view>
</view>
2023-10-21 18:02:06 +08:00
</view>
2023-10-23 17:57:19 +08:00
2023-10-21 18:02:06 +08:00
</view>
<view class="card-li">
2023-10-23 17:57:19 +08:00
<view class="select">
2023-10-25 19:55:18 +08:00
状态: <up-input placeholder="请选择" style="margin-top: 20rpx;" border="surround" @click="selectFoucsFn1"
v-model="status">
2023-10-23 17:57:19 +08:00
</up-input>
<view class="JT" :class="{actJT:selectAct1}">
<u--image src="/static/img/XLJT.png" width="24.53rpx" height="24.53rpx"></u--image>
</view>
<view class="selectvalue" v-show="selectAct1" style="bottom:-250rpx">
<view class="select-li" v-for="(item,index) in selectList1" :key="index"
2023-10-25 19:55:18 +08:00
@click="changSelectfn1(index)" :style="{color:indexs1==index?'black':'#B3B3B3'}">
2023-10-23 17:57:19 +08:00
{{item}}
2023-10-25 19:55:18 +08:00
<view class="" v-show='indexs1==index'>
2023-10-23 17:57:19 +08:00
<u--image src="/static/img/XLZZ.png" width="24.53rpx" height="24.53rpx"></u--image>
</view>
</view>
</view>
2023-10-21 18:02:06 +08:00
</view>
</view>
<view class="card-li">
<view class="card-li-tit">
体重
</view>
<view class="">
2023-10-25 19:55:18 +08:00
<up-input placeholder="请输入品种" border="surround" v-model="formData.weight"></up-input>
2023-10-21 18:02:06 +08:00
</view>
</view>
2023-10-23 17:57:19 +08:00
<view class="code-img">
<view class="carime-icon" @click="updateImgFn">
2023-10-25 19:55:18 +08:00
<view class="" v-if="formData.pic">
<u--image :src="formData.pic" width="637.85rpx" height='196.26rpx'></u--image>
</view>
<view class="carime-icon" v-else>
<u--image src="/static/img/DJSC.png" width="91.12rpx" height="91.12rpx"></u--image>
<view class="">
上传
</view>
2023-10-23 17:57:19 +08:00
</view>
2023-10-25 19:55:18 +08:00
2023-10-23 17:57:19 +08:00
</view>
2023-10-21 18:02:06 +08:00
</view>
</view>
2023-10-25 19:55:18 +08:00
<view class="next-btn" @click="nextFn">
2023-10-21 18:02:06 +08:00
下一个
</view>
2023-10-25 19:55:18 +08:00
<view class="ripe-btn" @click='navgo'>
2023-10-21 18:02:06 +08:00
完成添加
</view>
</view>
</template>
2023-10-23 17:57:19 +08:00
<script setup>
import {
reactive,
ref
} from "vue"
2023-10-25 19:55:18 +08:00
import uplodeImg from "@/utils/uplodeImg.js"
import {
addAnimalAPI,
2023-10-28 18:28:10 +08:00
} from "@/api/animal.js"
2023-10-25 19:55:18 +08:00
const navgo = () => {
uni.navigateTo({
url: "/pages/index/index"
})
}
const updateImgFn = () => {
uplodeImg().then(res => {
formData.pic = res.data.image
})
}
2023-10-23 17:57:19 +08:00
const off = () => {
selectAct.value = false
selectAct1.value = false
}
const selectList = reactive([
2023-10-25 19:55:18 +08:00
"公猪", "母猪"
2023-10-23 17:57:19 +08:00
])
2023-10-25 19:55:18 +08:00
const gender = ref("")
const status = ref("")
2023-10-23 17:57:19 +08:00
const selectList1 = reactive([
"健康", "怀孕中", "生病隔离中", "可出栏"
])
const value = ref("")
2023-10-25 19:55:18 +08:00
const value1 = ref("")
2023-10-23 17:57:19 +08:00
const selectAct = ref(false)
const selectAct1 = ref(false)
const selectFoucsFn = (e) => {
selectAct.value = true
2023-10-25 19:55:18 +08:00
selectAct1.value = false
2023-10-23 17:57:19 +08:00
}
const selectFoucsFn1 = (e) => {
selectAct1.value = true
2023-10-25 19:55:18 +08:00
selectAct.value = false
2023-10-23 17:57:19 +08:00
}
const indexs = ref(0)
2023-10-25 19:55:18 +08:00
const indexs1 = ref(0)
2023-10-23 17:57:19 +08:00
const changSelectfn = (index) => {
indexs.value = index
value.value = selectList[index]
2023-10-25 19:55:18 +08:00
formData.gender = index + 1
gender.value = selectList[index]
selectAct.value = false
selectAct1.value = false
2023-10-23 17:57:19 +08:00
}
2023-10-25 19:55:18 +08:00
const changSelectfn1 = (index) => {
indexs1.value = index
value1.value = selectList[index]
formData.status = index + 1
status.value = selectList1[index]
selectAct.value = false
selectAct1.value = false
}
const baseFormData = reactive({
user_id: 307,
kind: "",
breed: "",
gender: 1,
age: "",
status: 1,
weight: "",
2023-10-28 18:28:10 +08:00
pic: "",
code: ""
2023-10-25 19:55:18 +08:00
})
const objFn = (res, obj) => {
for (let key in res) {
obj[key] = res[key]
}
}
const formData = reactive({})
objFn(baseFormData, formData)
const nextFn = () => {
addAnimalAPI({
...formData
}).then(res => {
status.value = ''
gender.value = ''
addList.push(1)
objFn(baseFormData, formData)
uni.showToast({
title: '添加成功',
icon: 'success',
duration: 1000,
})
2023-10-23 17:57:19 +08:00
})
}
2023-10-21 18:02:06 +08:00
2023-10-25 19:55:18 +08:00
const addList = reactive([])
</script>
2023-10-21 18:02:06 +08:00
<style lang="scss">
.card-tit {
display: flex;
justify-content: space-between;
border-bottom: 1px solid #F4F4F4;
padding-bottom: 20rpx;
margin-bottom: 20rpx;
}
.card-cont {
display: flex;
justify-content: space-between;
.card-l {
display: flex;
flex-direction: column;
justify-content: space-between;
}
.card-r {
overflow: hidden;
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
width: 353.97rpx;
height: 210.28rpx;
}
}
.card-li-tit {
margin-bottom: 20rpx;
}
.uplode {
height: 350.47rpx;
background-color: red;
}
.next-btn {
width: 196.26rpx;
height: 66.59rpx;
border: 1px solid #00A15E;
color: #00A15E;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
margin: 0 auto;
text-align: center;
line-height: 66rpx;
}
.ripe-btn {
width: 588.79rpx;
height: 84.11rpx;
background-color: #00A15E;
color: white;
display: flex;
justify-content: center;
align-items: center;
margin: 85rpx auto;
border-radius: 42.06rpx 42.06rpx 42.06rpx 42.06rpx;
background: linear-gradient(to right, #00A15E, #4CC593);
}
2023-10-23 17:57:19 +08:00
.select {
position: relative;
.JT {
position: absolute;
right: 20rpx;
top: 60%;
2023-10-25 19:55:18 +08:00
z-index: 9;
2023-10-23 17:57:19 +08:00
transition: .2s;
}
.actJT {
transition: .2s;
transform: rotate(180deg);
}
.selectvalue {
position: absolute;
width: 608.53rpx;
background-color: white;
z-index: 99;
font-size: 26.29rpx;
left: 0rpx;
2023-10-25 19:55:18 +08:00
bottom: -130rpx;
2023-10-23 17:57:19 +08:00
border-radius: 21.03rpx 21.03rpx 21.03rpx 21.03rpx;
padding: 0 20rpx;
border: 1px solid #F4F4F4;
.select-li {
margin: 20rpx 0;
display: flex;
justify-content: space-between;
align-items: center;
}
}
}
.code-img {
background-color: #F4F4F4;
height: 196.26rpx;
position: relative;
.carime-icon {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
display: flex;
flex-direction: column;
align-items: center;
}
}
2023-10-25 19:55:18 +08:00
.head {
text-align: center;
margin-bottom: 10rpx;
}
2023-10-21 18:02:06 +08:00
</style>