<template>
	<view class="wrap">
		<view class="dropdown content1">
			<view class="left" @click='show1=true'>
				<view>{{warehouseName}}</view>
				<u-icon name="arrow-right"></u-icon>
				<u-picker @confirm="warehousechange" range-key='warehouseName' mode="selector" v-model="show1"
					:range="warehouseList"></u-picker>
			</view>
			<view class="right" @click='show2=true'>
				<view>{{binNumber}}仓位</view>
				<u-icon name="arrow-right"></u-icon>
				<u-picker @confirm="warehouseCWchange" range-key='binNumber' mode="selector" v-model="show2"
					:range="warehouseCWList"></u-picker>
			</view>
		</view>
		<view class="content2">
			<view class="content2-item" v-for="(item,index) in dataList" @click="goDetail(item)">
				<view class="item-style">{{item.contractNo}}</view>
				<view class="item-style">{{item.carNo}}</view>
				<view class="item-style">{{item.updateDate}}</view>
				<view class="item-style">{{item.backOffice}}</view>
			</view>
		</view>
	</view>
</template>

<script>
	import helper from '@/common/helper.js';
	export default {
		data() {
			return {
				show1: false,
				show2: false,
				currentPage: 1,
				pageSize: 10,
				positionId: "",
				binNumber: "",
				binNumber: "",
				warehouseName: '',
				warehouseList: [],
				warehouseCWList:[],
				dataList: []
			}
		},
		onLoad() {
			this.positionId = helper.erpWarehouse.positionId
			this.warehouseId = helper.erpWarehouse.warehouseId
			this.getList()
		},
		onShow() {
			this.positionId = helper.erpWarehouse.positionId
			this.warehouseId = helper.erpWarehouse.warehouseId
			let _data = helper.erpWarehouse
			this.positionId = _data.positionId
			this.warehouseId = _data.warehouseId
			this.warehouseList = _data.allWarehouse
			this.warehouseCWList = _data.warehouseCWList
			this.warehouseName = _data.warehouseName
			this.binNumber = _data.binNumber
		},
		methods: {
			getList() {
				this.$api.doRequest('get', '/warehouseInOutInfo/selectWarehouseInOutInfo', {
					positionId:this.positionId,
					baseId: this.warehouseId,
					currentPage: this.currentPage,
					pageSize: this.pageSize,
					inOutFlag:1
				}).then(res => {
					if (res.data.code == 200) {
						this.dataList = res.data.data.records
					}
				})
			},
			warehousechange(e) {
				 this.warehouseName = this.warehouseList[e[0]].warehouseName
				 this.warehouseId =this.warehouseList[e[0]].id
				 this.warehouseCWList = this.warehouseList[e[0]].positionInfos
				 this.warehouseCWchange([0])
			},
			warehouseCWchange(e) {
				 this.binNumber = this.warehouseCWList[e[0]].binNumber
				 this.warehouseId = this.warehouseCWList[e[0]].baseId
				 this.positionId = this.warehouseCWList[e[0]].id
				 helper.erpWarehouse.binNumber = this.binNumber
				  helper.erpWarehouse.warehouseName = this.warehouseName
				 helper.erpWarehouse.positionId =  this.positionId
				 helper.erpWarehouse.warehouseId = this.warehouseId 
				 this.getList()
			},
			goDetail(val) {
				uni.navigateTo({
					url: '/pages/erp/improvedExWaehousing/improvedExWaehousingDetail?data=' + JSON.stringify(val),
				})
			}

		}
	}
</script>

<style scoped lang="scss">
	.dropdown {
		display: flex;
		margin: 20rpx 0;
		justify-content: space-between;

		.left,
		.right {
			display: flex;
		}
	}

	.content1 {
		padding: 40rpx 20rpx;
		margin: 20rpx;
		border-radius: 10rpx;
		background: #FFFFFF;
	}

	.content2 {
		// padding: 20rpx;
		margin: 20rpx;
		// border-bottom: 1px solid #ccc;
		background: #FFFFFF;
		border-radius: 10rpx;

		.content2-item {
			padding: 20rpx;
			margin-bottom: 10rpx;
			border-bottom: 1px solid #ccc;
			// padding-bottom: 10px;
		}

		.item-style {
			display: inline-block;
			width: 50%;
		}
	}
</style>
