<style lang="scss">
	.container{
		height:100%;
		background:#f6f6f6;

		scroll-view{
			flex-grow: 1;
			height: 1rpx;

			.card{
				margin-top:0;
				.head{
					border-bottom:1px solid #D8D8D8;
					display:flex;
					align-items: center;
					padding-bottom:20rpx;
					margin-bottom:10rpx;
					text{
						flex-shrink: 0;
						&:first-child{
							color:#10C176;
						}
						&:nth-child(2){
							margin:0 auto 0 15rpx;
							flex-shrink: 1;
							font-weight: bold;
						}
					}
				}
				.item{
					display:flex;
					height:50rpx;
					align-items: center;
					color:#777;
					text{
						&:first-child{
							margin-right:auto;
						}
					}
				}
				.foot{
					background:rgba(223, 225, 224, 0.3);
					min-height:88rpx;
					margin:0 -30rpx -30rpx;
					color:#999;
					display:flex;
					align-items: center;
					justify-content: space-between;
					padding:20rpx 30rpx;
					.examine{
						flex-grow: 1;
						width:1rpx;
						display:flex;
						justify-content: space-evenly;
						flex-direction: column;
					}
					.type{
						flex-shrink: 0;
						margin-left:40rpx;
						font-size:24rpx;
						color:#fff;
						background:var(--bg,#FFCB69);
						border-radius: 6rpx;
						height:48rpx;
						line-height: 48rpx;
						min-width: 94rpx;
						padding:0 8rpx;
						text-align: center;
					}
				}
			}
		}
	}
</style>
<template>
	<view class="container flex">
		<d-search v-model="searchVal.goodsName" @search="clean();search()"/>

		<scroll-view scroll-y @scrolltolower="search">
			<view class="card" v-for="(v,k) in list" :key="k" @click="$u.route({url:'pages/purchase/detail',params:{id:v.id,date:v.applicantTime}})">
				<view class="head">
					<text class="plant-edifice"/>
					<text>{{v.baseName}}</text>
					<text>{{v.applicantName}}</text>
				</view>
				<view class="item">
					<text>申请日期</text>
					<text>{{v.applicantTime}}</text>
				</view>
				<view class="item">
					<text>种类</text>
					<text>{{v.goodsSpecificationNum}}种</text>
					<text class="plant-youbian"/>
				</view>
				<view class="foot">
					<view class="examine">
						<text v-if="true">审核人:xxx</text>
						<text v-if="true" class="over">原因:此处是原因此处是原因此处是处是原因此处是原因此处是</text>
					</view>
					<text class="type" :style="{'--bg':({2:'#FFCB69',3:'#10C176',4:'#EE263A',5:'#2196f3'})[v.applicantStatus]}">{{({2:"审核中",3:"通过",4:"未通过",5:"农资入库"})[v.applicantStatus]}}</text>
				</view>
			</view>
			<u-empty :show="list.length<=0" text="为查询到相关信息" width="70%" icon="/static/noData.png"/>
		</scroll-view>
	</view>
</template>
<script>
import request from '@/common/request'
export default {
	data(){
		return{
			searchVal:{
				goodsName:"",
				roleCode:this.$store.getters['userInfo'].roleCode,
				pageNo:1,
				pageSize:6,
				companyId:this.$store.getters['userInfo'].companyId
			},
			total:0,
			list:[],
		}
	},
	onLoad(){
		this.search()
	},
	methods:{
		clean(){
			this.list=[]
			this.total=0
			this.searchVal.pageNo=1
		},
		async search(){
			if(this.total==0||this.list.length<this.total){
				var res = await request("/api/purchase/purchaseList",{
					params:this.searchVal
				})
				if(res.statu){
					this.list=this.list.concat(res.data.records)
					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>