<template>
	<view class="container" >
		<xinsoft-form-input :itemDefine='itemDefine1' :bindSource.sync="dataItem1" @toSearch='searchinventory'></xinsoft-form-input>
	<!-- //搜索仓库列表 -->
	<chooseInventorySingle :showsearch.sync="show_search_inventory"
				:itemInfo_.sync="search_value_inventory"></chooseInventorySingle>
		<view class="bottom_btn"><view class="btn" @click="toSubmit">执行盘点</view></view>
	<view class="goHome" @click='goMain()'>
		<img src="@/static/img/gohome.png">
	</view>
	</view>
</template>

<script>
	import xinsoftFormInput from '@/components/xinsoft-form-input/xinsoft-form-input.vue'
	//搜索仓库列表
	import chooseInventorySingle from '@/components/xinsoft-search-list/chooseInventorySingle.vue'
	
	export default {
		components: {
			xinsoftFormInput,chooseInventorySingle
		},
		data() {
			return { 
				query:false,
				
				itemDefine1:{
						title: "请选择盘点方案",
						fieldName: "valueName",
						type: "kd-vlookup-edit",
						required: true,
						disabled: true,
						placeholder: "",
						canClear:false,//是否带清空按钮
				},
				dataItem1:{
					valueName: "",
				},
			
				show_search_inventory:false,//显示仓库搜索列表
					search_value_inventory:[],//选择的仓库信息
					inventoryInfo:{},//选的盘点信息，
				}
				
			},
			mounted() {
			},
			
			methods:{
				//点击显示仓库列表
				searchinventory(){
					this.show_search_inventory=true;
				},
			
				//获取当前时间
				getCurrentTime(){
					   let date = new Date();
					    let y = date.getFullYear();
					    let MM = date.getMonth() + 1;
					    MM = MM < 10 ? ('0' + MM) : MM;
					    let d = date.getDate();
					    d = d < 10 ? ('0' + d) : d;
					    let h = date.getHours();
					    h = h < 10 ? ('0' + h) : h;
					    let m = date.getMinutes();
					    m = m < 10 ? ('0' + m) : m;
					    let s = date.getSeconds();
					    s = s < 10 ? ('0' + s) : s;
					    return y + '-' + MM + '-' + d + ' ' + h + ':' + m + ':' + s;
				},
				toSubmit(){
					if(!this.inventoryInfo.id){
						uni.showToast({
						    title:'请先选择盘点方案',
							icon:"none",
						    duration: 2000
						});
						return
					}
					uni.navigateTo({
						url: "add?code="+encodeURIComponent(this.inventoryInfo.code)+"&id="+encodeURIComponent(this.inventoryInfo.id)+"&warehouseName="+encodeURIComponent(this.inventoryInfo.warehouseName)+"&warehouse="+encodeURIComponent(this.inventoryInfo.warehouse)
					});
				},
			},
			watch:{
					search_value_inventory(newv){
						this.inventoryInfo={
							code:newv.code,
							id:newv.id,
							warehouse:newv.warehouse,
							warehouseName:newv.warehouseName,
						}
						this.dataItem1.valueName=newv.code
						},
					}
		}
</script>

<style scoped>
	
	.container{
		position: relative;
		min-height: 100%;
		background-color: #fff;
	}
	>>>.name_{
		width: 40%;
	}
	>>>.input_out{
		width: 60%;
	}
.bottom_btn {
	position: absolute;
	bottom: 0;
	left: 0;
	width: 100%;
	height: 50px;
	display: flex;
	justify-content: space-around;
	align-items: center;
}
.btn {
	position: relative;
	width: 95%;
	height: 40px;
	line-height: 40px;
	background-color: #007aff;
	text-align: center;
	color: #fff;
	font-size: 18px;
	letter-spacing: 5px;
}
</style>
