<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.auditDepart}}</text>
						<text v-if="v.applicantStatus ==='1' || v.applicantStatus ==='5'" class="over">意见：{{v.reason}}</text>
					</view>
					<text class="type" :style="{'--bg':({1:'#EE263A',2:'#FFCB69',3:'#FFCB69',4:'#FFCB69',5:'rgb(16, 193, 118)'})[v.applicantStatus]}">{{({1:"审核未通过",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,
				baseId:this.$store.state.baseInfo.id,
				// 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/purchasePageList",{
					method:"post",
					body:this.searchVal
				})
				if(res.statu){
					this.list=this.list.concat(res.data.realRecords)
					this.total=res.data.page.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>