<template>
	<view>
		<view class="list-ul">
			<view class="list-li" v-for="(item, index) in region_list" :key="index" @click="changeData(item)">
				<view class="name">{{ item.storageLocationName }}</view>
				<view class="other-info">
					<text class="label">库位编码</text>
					{{ item.storageLocationCode }}
				</view>
				<view class="other-info">
					<text class="label">所属库区</text>
					{{ item.areaName }}
				</view>
			</view>
			<u-loadmore :status="load_status" />
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			load_status: 'nomore',
			basicGoodsId: '',
			skuId: '',
			warehouseId: '',
			region_list: []
		};
	},
	onLoad(options) {
		if (options.basicGoodsId) {
			this.basicGoodsId = options.basicGoodsId;
			this.skuId = options.skuId;
			this.warehouseId = options.warehouseId;
		}
		this.getAreaDateBySkuId();
	},
	onPullDownRefresh() {
		this.getAreaDateBySkuId();
	},
	methods: {
		changeData(item) {
			// 选择返回上一页
			this._prePage().areaBysku = item;
			uni.navigateBack();
		},
		// 库位
		getAreaDateBySkuId() {
			this.$u.api
				.getAreaDateBySkuId({
					basicGoodsId: this.basicGoodsId,
					skuId: this.skuId,
					warehouseId: this.warehouseId
				})
				.then(res => {
					if (res.data.length) {
						this.region_list = res.data[0].areaDate;
					}
				});
		}
	}
};
</script>

<style lang="scss" scoped>
.list-ul {
	.list-li {
		width: 710rpx;
		margin: 20rpx auto;
		border-radius: 10rpx;
		background-color: #ffffff;
		padding: 24rpx;
		.name {
			padding-bottom: 10rpx;
			font-weight: bold;
		}
		.other-info {
			padding-top: 10rpx;
			font-size: 24rpx;
			.label {
				color: #879bba;
				margin-right: 20rpx;
			}
		}
	}
}
</style>