2023-10-25 19:55:18 +08:00
|
|
|
<template>
|
|
|
|
<view class="content">
|
|
|
|
|
|
|
|
<view class="head" v-if="addList.length">
|
|
|
|
已添加{{addList.length}}条畜生
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view class="card">
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="card-li-tit">
|
|
|
|
养殖品种
|
|
|
|
</view>
|
|
|
|
<view class="">
|
|
|
|
<up-input placeholder="请输入品种" border="surround" v-model="formData.kind"></up-input>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="card-li-tit">
|
|
|
|
具体品类
|
|
|
|
</view>
|
|
|
|
<view class="">
|
|
|
|
<up-input placeholder="请输入品种" border="surround" v-model="formData.breed"></up-input>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="card-li-tit">
|
|
|
|
年龄
|
|
|
|
</view>
|
|
|
|
<view class="">
|
|
|
|
<up-input placeholder="请输入年龄" border="surround" v-model="formData.age"></up-input>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="select">
|
|
|
|
养殖类型: <up-input @tap="selectFoucsFn" readonly placeholder="请选择" style="margin-top: 20rpx;"
|
|
|
|
border="surround" v-model="gender">
|
|
|
|
</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>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="select">
|
|
|
|
状态: <up-input placeholder="请选择" style="margin-top: 20rpx;" border="surround" @click="selectFoucsFn1"
|
|
|
|
v-model="status">
|
|
|
|
</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"
|
|
|
|
@click="changSelectfn1(index)" :style="{color:indexs1==index?'black':'#B3B3B3'}">
|
|
|
|
{{item}}
|
|
|
|
<view class="" v-show='indexs1==index'>
|
|
|
|
<u--image src="/static/img/XLZZ.png" width="24.53rpx" height="24.53rpx"></u--image>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="card-li">
|
|
|
|
<view class="card-li-tit">
|
|
|
|
体重
|
|
|
|
</view>
|
|
|
|
<view class="">
|
|
|
|
<up-input placeholder="请输入品种" border="surround" v-model="formData.weight"></up-input>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view class="code-img">
|
|
|
|
<view class="carime-icon" @click="updateImgFn">
|
|
|
|
<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>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view class="next-btn" @click="nextFn">
|
|
|
|
下一个
|
|
|
|
</view>
|
|
|
|
<view class="ripe-btn" @click='navgo'>
|
|
|
|
完成添加
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script setup>
|
|
|
|
import {
|
|
|
|
reactive,
|
|
|
|
ref
|
|
|
|
} from "vue"
|
|
|
|
import uplodeImg from "@/utils/uplodeImg.js"
|
|
|
|
import {
|
|
|
|
addAnimalAPI,
|
|
|
|
|
2023-10-26 19:02:26 +08:00
|
|
|
} from "@/api/chick.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
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
const off = () => {
|
|
|
|
selectAct.value = false
|
|
|
|
selectAct1.value = false
|
|
|
|
}
|
|
|
|
|
|
|
|
const selectList = reactive([
|
|
|
|
"公猪", "母猪"
|
|
|
|
])
|
|
|
|
const gender = ref("")
|
|
|
|
const status = ref("")
|
|
|
|
const selectList1 = reactive([
|
|
|
|
"健康", "怀孕中", "生病隔离中", "可出栏"
|
|
|
|
])
|
|
|
|
const value = ref("")
|
|
|
|
const value1 = ref("")
|
|
|
|
const selectAct = ref(false)
|
|
|
|
const selectAct1 = ref(false)
|
|
|
|
const selectFoucsFn = (e) => {
|
|
|
|
selectAct.value = true
|
|
|
|
selectAct1.value = false
|
|
|
|
}
|
|
|
|
const selectFoucsFn1 = (e) => {
|
|
|
|
selectAct1.value = true
|
|
|
|
selectAct.value = false
|
|
|
|
}
|
|
|
|
const indexs = ref(0)
|
|
|
|
const indexs1 = ref(0)
|
|
|
|
const changSelectfn = (index) => {
|
|
|
|
indexs.value = index
|
|
|
|
value.value = selectList[index]
|
|
|
|
formData.gender = index + 1
|
|
|
|
gender.value = selectList[index]
|
|
|
|
selectAct.value = false
|
|
|
|
selectAct1.value = false
|
|
|
|
}
|
|
|
|
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: "",
|
|
|
|
pic: ""
|
|
|
|
})
|
|
|
|
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,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
const addList = reactive([])
|
|
|
|
</script>
|
|
|
|
<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);
|
|
|
|
}
|
|
|
|
|
|
|
|
.select {
|
|
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
|
|
.JT {
|
|
|
|
position: absolute;
|
|
|
|
right: 20rpx;
|
|
|
|
top: 60%;
|
|
|
|
z-index: 9;
|
|
|
|
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;
|
|
|
|
bottom: -130rpx;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.head {
|
|
|
|
text-align: center;
|
|
|
|
margin-bottom: 10rpx;
|
|
|
|
}
|
|
|
|
</style>
|