You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

200 lines
4.3 KiB

<style lang="scss">
.transaction{
height:100%;
display:flex;
flex-direction: column;
&>.dateRange{
flex-shrink: 0;
display: flex;
align-items: center;
margin:30rpx;
text{
&.plant-youbian{
display: flex;
align-items: center;
flex-direction: row-reverse;
justify-content: space-between;
background:#fff;
height:48rpx;
font-size:24rpx;
color:#333;
border-radius: 8rpx;
padding:0 10rpx;
min-width:226rpx;
box-sizing: border-box;
&:before{
transform: rotate(90deg);
}
&.noDate{
color:#999;
}
}
&:nth-child(2){
color:#999;
padding:0 28rpx;
}
}
}
scroll-view{
flex-grow: 1;
height:1rpx;
.card{
margin-top:0;
display: flex;
.u-transition{
margin-right:20rpx;
}
&>.info{
flex-grow: 1;
width:1rpx;
.title{
font-weight: bold;
margin-bottom:6rpx;
2 years ago
}
.spec,.total{
font-size:24rpx;
color:#999;
margin-top:10rpx;
display:flex;
align-items: center;
text:first-child{
min-width:180rpx;
}
}
.total{
text:first-child{
2 years ago
color:#10C176;
font-weight: bold;
&:after{
content:"("attr(data-unit)")";
font-weight: normal;
}
}
}
}
}
}
.u-popup{
flex:0;
}
}
</style>
<template>
<view class="transaction">
<d-dateRange @date="searchVal.startTime=$event[0];searchVal.endTime=$event[1];reSearch()"/>
<scroll-view scroll-y @scrolltolower="search">
<view class="card" v-for="(v,k) in list" :key="k">
<u-image radius="20rpx" width="130rpx" height="118rpx" mode="aspectFill" :src="`${host}/${v.images[0]}`">
<text slot="error" style="font-size:45rpx;" class="plant-xiaopangchetupianjiazaishibai"/>
</u-image>
<view class="info">
<view class="title">{{v.productName}}</view>
<view class="spec">
<text>规格{{v.specification}}</text>
<text class="over">{{v.buyerName}}</text>
</view>
<view class="total">
<text :data-unit="`${(parseFloat(v.tradeNum)||0)*(parseFloat(v.specification)||0)}${v.weightUnit}`">{{v.tradeNum}}{{v.packUnit_dictText}}</text>
<text>交易日期{{v.tradeTime}}</text>
</view>
</view>
</view>
<u-empty v-if="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
</scroll-view>
<u-datetime-picker
:show="show"
mode="date"
closeOnClickOverlay
@close="show=false"
@cancel="show=false"
:minDate="dateType=='endTime'&&searchVal.startTime?new Date(searchVal.startTime).getTime():new Date().set('y',-15).getTime()"
:maxDate="dateType=='startTime'&&searchVal.endTime?new Date(searchVal.endTime).getTime():new Date().set('y',15).getTime()"
:value="searchVal[dateType] || new Date().format('yyyy-MM-dd')"
@confirm="searchVal[dateType]=new Date($event.value).format('yyyy-MM-dd');show=false"/>
</view>
</template>
<script>
import request,{host} from '@/common/request'
export default {
props:{
plotId:{
type:String,
default:""
},
recoveryId:{
type:String,
default:""
}
},
data(){
return{
show:false,
host:host('imgUrl'),
searchVal:{
startTime:"",
endTime:"",
pageNo:1,
pageSize:5,
},
list:[],
total:0,
dateType:"startTime",
}
},
computed:{
date(){
return [this.searchVal.startTime, this.searchVal.endTime]
},
},
watch:{
date(n){
if(n[0] && n[1]){
this.clean()
this.search()
}
}
},
created(){
this.search()
},
methods:{
clean(){
this.list=[]
this.total=0
this.searchVal.pageNo=1
},
reSearch(){
this.clean()
this.search()
},
async search(){
if(this.total==0||this.list.length<this.total){
var res=await request("/api/plantTrade/list",{
method:"post",
body: {
...this.searchVal,
harvestId:this.recoveryId,
plotId: this.plotId,
}
})
if(res.statu){
this.list=this.list.concat(res.data.records.map(v=>({...v,images:v.images.split(",").filter(v=>v)})))
this.total=res.data.total
this.searchVal.pageNo++
if(this.list.length==this.total)uni.showToast({title:"加载完成!",icon:"none"})
}else{
uni.showModal({
title:"提示",
content:res.msg||"获取交易记录失败!",
showCancel:false,
})
}
}
},
}
}
</script>