cultivationApp/pages/record/record.vue

462 lines
11 KiB
Vue
Raw Normal View History

2023-12-21 16:29:58 +08:00
<template>
<view style="position: relative;">
<view class="top">
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav-con">
<view class="left"></view>
<view class="title" @click="navBack">
2023-12-25 14:36:19 +08:00
<u-icon name="arrow-left" color="#fff" size="40rpx" style="margin-right: 10rpx;"></u-icon> <text
2023-12-21 16:29:58 +08:00
style="padding-bottom: 5rpx;">档案管理</text>
</view>
<view class="btn" style="margin-top: -5rpx;">
2023-12-25 14:36:19 +08:00
<u-icon name="plus" color="#fff" size="40rpx" style="margin-right: 20rpx;"
2023-12-21 16:29:58 +08:00
@click="show=true"></u-icon>
<Myindex url='/pages/index/index' />
2023-12-21 16:29:58 +08:00
</view>
</view>
</view>
<view class="" style="height:var(--status-bar-height) ;">
</view>
<view class="nav-con">
</view>
<view class="content">
<view class="serch">
<u-search bgColor="white" :show-action="false" placeholder="请输入耳号" v-model="searchKey" shape="round"
2024-01-30 18:31:10 +08:00
:clearabled='false'></u-search>
2023-12-21 16:29:58 +08:00
<view class="ser-text" @click="search">
搜索
</view>
</view>
<view class="tits">
档案信息
</view>
<view class="">
<block class="" v-if="dataList.length>0">
<view class="thing-card" v-for="(item,index) in dataList" :key="index">
<view class="card_body">
<view class="left">
2024-01-31 14:17:10 +08:00
<u--image @click="perviewFn(item.pic[0])" radius='10' :src="item.pic[0]" width="250rpx"
2023-12-21 16:29:58 +08:00
height="250rpx"></u--image>
2024-02-01 18:01:18 +08:00
<u---image class="qr-code" @click="showBarCode(item)" src="/static/main/house/su_yuan_ma_btn.png" width="60rpx" height="60rpx"></u---image>
2023-12-21 16:29:58 +08:00
</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="navTo(`/pages/plantAdmin/breedDetail?id=${item.id}&house_id=${item.fence_house_id}`)"></u--image>
<view class="right" style="color: #7B7B7B;" @click="navTo(`/pages/plantAdmin/breedDetail?id=${item.id}&house_id=${item.fence_house_id}`)">
<view class="name">{{item.sn}}</view>
2023-12-21 16:29:58 +08:00
<view class="r-item">
<view class="item-title">品类:</view>
2024-01-30 18:31:10 +08:00
<view>{{getAnimalType(item.animal_type)}}</view>
2023-12-21 16:29:58 +08:00
</view>
<view class="r-item">
<view class="item-title">品种:</view>
2024-01-30 18:31:10 +08:00
<view>{{item.brand}}</view>
2023-12-21 16:29:58 +08:00
</view>
<view class="r-item">
<view class="item-title">性别:</view>
2024-01-30 18:31:10 +08:00
<view>{{item.gender? '公':'母'}}</view>
2023-12-21 16:29:58 +08:00
</view>
<view class="r-item">
<view class="item-title">栏舍:</view>
2024-01-30 18:31:10 +08:00
<view v-if="item.fenceHouseAttr">{{item.fenceHouseAttr.fence_house_name}}</view>
2023-12-21 16:29:58 +08:00
</view>
<view class="r-item">
<view class="item-title">来源:</view>
2024-01-30 18:31:10 +08:00
<view>{{item.animal_source==1 ? '购买': '自繁'}}</view>
2023-12-21 16:29:58 +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>
</view>
<u-action-sheet :show="show" keyName="name" closeOnClickOverlay :actions="selectList" title="请选择"
@close="show = false" @select="selectOne">
</u-action-sheet>
2024-02-01 18:01:18 +08:00
<uni-popup ref="codeRef">
<view class="bar-code">
<view class="title">{{options.code.split('d_')[1]}}</view>
<w-qrcode ref="qrCode" :options="options"></w-qrcode>
<view @click="saveCode" class="btn">保存图片</view>
</view>
</uni-popup>
2023-12-21 16:29:58 +08:00
</view>
</template>
<script setup>
import {
onLoad,
onShow,
onReachBottom,
onPullDownRefresh
} from "@dcloudio/uni-app"
import {
ref,
reactive,
onMounted
} from "vue"
2024-01-30 18:31:10 +08:00
import {
animalInfoList
} from "@/api/manage.js"
import {
animalTypeLists
} from "@/api/dict.js"
2023-12-21 16:29:58 +08:00
import Myindex from '@/components/return/index.vue';
2024-02-01 18:01:18 +08:00
const options = ref({
code: '',// 生成二维码的值
size: 460,// 460代表生成的二维码的宽高均为460rpx
})
const qrCode = ref('');
const saveCode = async ()=>{//保存二维码图片
const img = await qrCode.value.GetCodeImg()
uni.saveImageToPhotosAlbum({
filePath: img.tempFilePath,
success(res) {
uni.showToast({
title: '保存成功',
icon: 'success',
duration: 2000
});
},
fail(err) {
uni.showToast({
title: '保存失败',
icon: 'none',
duration: 2000
});
}
});
}
const codeRef = ref(null);
const showBarCode = (e)=>{
options.value.code = 'd_' + e.sn;
codeRef.value.open();
}
2023-12-21 16:29:58 +08:00
const searchKey = ref('');
2024-01-30 18:31:10 +08:00
const dataList = reactive([])
2023-12-21 16:29:58 +08:00
const show = ref(false);
const selectList = ref([
{name: '购买'},
{name: '自繁'},
]);
const selectOne = (e)=>{
navTo(`/pages/plantAdmin/addBreed?name=${e.name}&type=${e.name=='购买'?1:2}`)
}
//跳转
const navTo = (url) => {
uni.navigateTo({
url
})
}
2023-12-25 14:36:19 +08:00
const navBack = () => {
uni.navigateBack()
}
2023-12-21 16:29:58 +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)
}
2024-01-30 18:31:10 +08:00
const where = ref({
page_no: 1,
page_size: 10
})
const getlist = () => {
animalInfoList({
keyword: searchKey.value,
page_no: where.value.page_no,
page_size: where.value.page_size
}).then((res) => {
if (res.code == 1) {
2024-01-31 14:17:10 +08:00
res.data.lists = res.data.lists.map(item => {
item.showCode = false;
item.pic = JSON.parse(item.pic||'[]');
return item
2024-01-30 18:31:10 +08:00
})
2024-03-06 17:40:26 +08:00
res.data.lists.forEach(item=>{
dataList.push(item)
})
2024-01-30 18:31:10 +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 || ''
}
// 搜索
const search = ()=>{
where.value.page_no = 1;
dataList.value = [];
getlist();
}
onLoad(() => {
getlist();
});
onReachBottom(()=>{
where.value.page_no++;
getlist();
})
2023-12-21 16:29:58 +08:00
</script>
<style lang="scss">
page {
background-color: $theme-bg-color;
}
.top {
background-color: #feb048;
position: fixed;
z-index: 999999;
width: 750rpx;
}
.nav-con {
width: 100vw;
height: 44px;
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 20rpx;
padding-bottom: 10rpx;
color: #fff;
.title {
display: flex;
align-items: center;
margin-left: 20rpx;
}
.btn {
flex: 1;
display: flex;
align-items: center;
justify-content: flex-end;
}
}
.tits {
position: relative;
padding-left: 20rpx;
font-weight: bold;
margin-bottom: 20rpx;
}
.tits::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 3px;
/* 左边框的宽度 */
height: 30rpx;
background-color: #FFB049;
}
.content {
position: relative;
padding: 0 28rpx;
.serch {
box-shadow: 1rpx 1rpx 10rpx 1rpx rgba(0, 0, 0, 0.1);
border-radius: 200rpx;
position: relative;
color: #feb048;
font-size: 28rpx;
margin-top: 20rpx;
margin-bottom: 20rpx;
.ser-text {
position: absolute;
padding-left: 20rpx;
top: 50%;
transform: translateY(-50%);
right: 40rpx;
}
.ser-text::before {
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
left: 0;
width: 2px;
/* 左边框的宽度 */
height: 20rpx;
background-color: #FFB049;
}
}
}
.thing-card {
width: 694;
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;
/* 设置为需要显示的行数 */
}
}
}
}
}
2024-01-30 18:31:10 +08:00
.coneng-detail {
width: 478rpx;
height: 341rpx;
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: 300rpx auto;
image {
width: 280rpx;
height: 142rpx;
margin-bottom: 20rpx;
}
}
2024-02-01 18:01:18 +08:00
.bar-code{
padding: 28rpx;
background-color: #fff;
border-radius: 24rpx;
display: flex;
align-items: center;
flex-direction: column;
justify-content: center;
.title{
font-size: 32rpx;
font-weight: bold;
margin-bottom: 15rpx;
}
.btn{
background-color: rgba(#999, 0.2);
font-size: 24rpx;
padding: 5rpx 20rpx;
border-radius: 50rpx;
margin-top: 30rpx;
}
}
2023-12-21 16:29:58 +08:00
</style>