<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="row">
					<view class="left">合同编号</view>
					<view>{{item.contractNo}}</view>
				</view>
				<view class="row">
					<view class="left">车牌号</view>
					<view>{{item.carNo}}</view>
				</view>
				<view class="row">
					<view class="left">暂存时间</view>
					<view>{{item.updateDate}}</view>
				</view>
				<view class="row no-boder">
					<view class="left">提交人</view>
					<view>{{item.backOffice}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import helper from '@/common/helper.js';
	export default {
		data() {
			return {
				show1: false,
				show2: false,
				currentPage: 1,
				pageSize: 9999,
				positionId: "",
				binNumber: "",
				warehouseName: '',
				positionName: '',
				warehouseList: [],
				warehouseCWList: [],
				dataList: [],
				allWarehouse: [],
				showTime: ''
			}
		},
		onLoad() {
			this.positionId = helper.erpWarehouse.positionId
			this.warehouseId = helper.erpWarehouse.warehouseId
		},
		onShow() {
			let _data = helper.erpWarehouse
			this.warehouseName = _data.warehouseName
			this.warehouseList = _data.allWarehouse
			this.warehouseCWList = _data.warehouseCWList
			this.binNumber = _data.binNumber
			this.positionId = _data.positionId
			this.warehouseId = _data.warehouseId
			this.getList()
		},
		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
				helper.erpWarehouse.warehouseCWList = this.warehouseCWList//保存仓位列表，用于解决待完善出入库返回该页面仓库与仓位不匹配问题
				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;
			align-items: center;
		}
	}

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

	.content2 {
		.row {
			display: flex;
			justify-content: space-between;
			border-bottom: 1px solid #EEEEEE;
			padding: 21rpx 0;

			.right,
			input {
				font-size: 28rpx;
				color: #333333;
			}
		}

		.row-bottom {
			.right-bottom {
				width: 300rpx;
				text-align: right;
			}
		}
	}

	.content2-item {
		background: white;
		margin: 0 20rpx 20rpx 20rpx;
		padding: 10rpx;
		border-radius: 15rpx;
	}

	.no-boder {
		border-bottom: none !important;
	}
</style>
