<template>
	<view class="selectQrcode">
		<uni-search-bar @confirm="getData" v-model="req.keyword" @cancel="reload">
		</uni-search-bar>
		<view class="dtl">
			<view class="">
				物料编码：{{option.code}}
			</view>
			<view class="">
				物料名称：{{option.name}}
			</view>
			<view class="" style="color:#C280FF">
				{{option.count}} 个入库单
			</view>
		</view>
		<view class="addQrcode-list" v-for="(i,index) in listData" :key="i.materialId"  @click="toRouter(index)">
			<view class="fl" >
				<view class="code">
					<view class="">
						供应商:{{i.supplierName}}
					</view>
					<view class="">
						合同编号:{{i.purchaseBillNo}}
					</view>
					<view class="">
						<span style="color:#02A7F0">待入库:{{i.notArrivalQty}} </span>
						<span style="margin-left:40rpx;color:#D9001B">已生成:{{i.arrivalQty}}</span>
					</view>
				</view>
			</view>
			<view class="fr">
				<uni-icons type="forward" size="30"></uni-icons>
			</view>
		</view>
	</view>
</template>

<script>
	import {
	    getInfo
	} from "@/util/api.js";
	export default {
		data() {
			return {
				listData:[],
				req:{
					keyword:null,
					materialId:null
				},
				option:{},
			}
		},
		onLoad(option) {
			const v = this
			v.option = JSON.parse(decodeURIComponent(option.data))
			console.log(v.option)
			v.req.materialId = v.option.materialId
			v.getData()
			
		},
		methods: {
			reload(){
				this.req.keyword = null
				this.getData()
			},
			getData(){
				const v = this
				v.$post('/wx/createQrcode/getPurchaseByMaterialIdList',v.req).then(res=>{
					v.listData = res.data
					
				})
			},
			toRouter(i){
				const v = this
				console.log(i)
				v.option = Object.assign(v.option,v.listData[i])
				uni.navigateTo({
					url: '/pages/addQrcode/addBatch?data=' + encodeURIComponent(JSON.stringify(v.option))
				})
				// uni.navigateTo({
				// 	url: '/pages/addQrcode/selectQrcode?id=' + i.materialId
				// })
			},
		},
	}
</script>

<style lang="less">
	.selectQrcode {
		font-size: 28rpx;
		.dtl{
			padding: 30rpx;
			border-bottom: 1rpx solid #dcdcdc;
		}
		.addQrcode-list {
			height: 120rpx;
			display: flex;
			justify-content: space-between;
			padding: 15rpx;
			border-bottom: 1rpx solid #dcdcdc;
		
			.fl {
				display: flex;
				padding-left: 20rpx;
				.code {
					margin-right: 20rpx;
				}
			}
		
			.fr {
				line-height: 120rpx;
			}
		}
	}
</style>
