<template>
	<div>
		
		<view class="ul">
			<view class="li" v-for="i in dataList" :key="i.id">
				<view class="line">
					物料编码：{{i.materialCode}}
				</view>
				<view class="line">
					物料名称：{{i.materialName}}
				</view>
				<view class="line">
					出库时间：{{i.submitTime}}
					<view class="span">
						数量：<span style="color:red">{{i.quantity}}</span>
					</view>
				</view>
				<view class="line">
					接收人员：{{i.receiveUserName}}
				</view>
				<view class="btn-warp">
					<button @click="operation(4,i.id)">退回</button>
					<button @click="operation(3,i.id)">确认接收</button>
				</view>
			</view>
		</view>
		<button class="footer-btn" @click="operation('all')">
			批量接受物料
		</button>
	</div>
</template>

<script>
	export default{
		name:"xx",
		data(){
			return{
				userInfo:null,
				dataList:[],
			}
		},
		created(){
			setTimeout(()=>{
				this.getList()
			},100)
		},
		methods:{
			operation(_type,_id){
				const v = this 
				var idList = []
				var operation = ''
				if(_type == 'all'){
					
					operation = 3
					for (var i = 0; i < this.dataList.length; i++) {
						idList.push(this.dataList[i].id)
					}
					
					
				}else{
					operation = _type
					idList = [_id]
				}
				console.log(idList,operation)
				v.$post('/materialReceiving/operation',{
					idList: idList,
					operation:operation,
				}).then(res=>{
					console.log(res)
					v.getList()
					if(res.data.code == 200){
						v.$msg.showToast('操作成功！')
						
					}
				})
			},
			getList(){
				const v = this
				uni.getStorage({
					key: 'Authorization',
					success: function (res) {
						v.$post('/materialReceiving/list',{
							receiveUserAccount:res.data.account
						}).then(res=>{
							console.log(res)
							v.dataList = res.data
						})
					}
				});
				
			},
		},
	}
</script>

<style scoped lang="less">
	.ul{
		padding-bottom: 200rpx;
	}
	.li{
		background-color: #fff;
		margin: 20rpx 20rpx 0;
		padding: 20rpx;
		list-style: none;
		.line{
			
			line-height: 70rpx;
			border: none;
			display: flex;
			padding: 0 20rpx;
			.span{
				margin-left: 50rpx;
			}
		}
	}
	.btn-warp{
		display: flex;
		button{
			width: 48%;
		}
	}
	.footer-btn{
		position: fixed;
		bottom: 10rpx;
		left: 10rpx;
		right: 10rpx;
		background-color: red;
		color: #fff;
	}
</style>