<template>
	<view class="warp">
		<view class="content1">
			<u-search placeholder="输入车牌号" :show-action="false" v-model="inputKeyword"></u-search>
		</view>
		<view class="content2" v-if="!inputKeyword">
			<view class="title">编号{{contractNo}}可选车牌号如下：</view>
			<view class="item-contnet">
				<view class="item-list" v-for="(item,index) in newList" :key="index" @click="confirm(item)">
					{{item.carNo}}({{item.tranCarNo}})
				</view>
			</view>
		</view>
		<view class="content3" v-if="inputKeyword">
			<view class="search-item-list" v-for="(item,index) in filterNewList" :key="index" @click="confirm(item)">
				{{item.carNo}}
			</view>
		</view>
	</view>
</template>

<script>
	 import helper from '@/common/helper.js'; 
	export default {
		data() {
			return {
				inputKeyword: '',
				newList: [],
				filterNewList: [],
				compId: '',
				contractNo:''
			}
		},
		onShow() {
			this.newList = uni.getStorageSync('erpContractNo').tranCarInfoList
			this.contractNo = uni.getStorageSync('erpContractNo').contractNo
		},
		onLoad(options) {
			
		},
		watch: {
			inputKeyword(val) {
				this.filterNewList = this.newList.filter(function(item) {
					if (item.carNo.indexOf(val) > -1) {
						return item
					}
				})
			}
		},
		methods: {
			confirm(item){
				uni.setStorageSync('erpcarNo', item);
				uni.navigateBack({})
			},
		}
	}
</script>

<style scoped lang="scss">
	.content1 {
		background: white;
		padding: 20rpx;
		border-radius: 0 0 20rpx 20rpx;
	}

	.content2 {
		background: white;
		margin-top: 20rpx;
		padding: 20rpx;
		border-radius: 20rpx 20rpx 0 0;

		.title {
			font-size: 28rpx;
			font-weight: 400;
			color: #AFB3BF;
		}

		.item-contnet {
			display: flex;
			flex-wrap: wrap;
			justify-content: space-between;
		}

		.item-list {
			width: 45%;
			background: #F5F6F9;
			margin: 20rpx 0;
			padding: 10rpx 15rpx;
			border-radius: 30rpx;
			text-align: center;
		}
	}

	.content3 {
		height: calc(100vh - 192rpx);
		background: white;
		padding: 20rpx;
		box-sizing: border-box;
	}

	.search-item-list {
		margin: 20rpx;
		border-bottom: 1px solid #EEEEEE;
		padding-bottom: 20rpx;
	}
</style>
