<template>
	<view class="zd_container">
		<!-- 库存查询 -->
		<nav-bar :title="title" :inner="true"></nav-bar>
		<view class="zd_content">
			<view class="zd_wrapper">
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">查询类型</span>
					</view>
					<view class="zd-col-18 filter_select">
						<uni-data-select v-model="index1" :localdata="options1"></uni-data-select>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">点位</span>
					</view>
					<view class="zd-col-18">
						<search-box v-model="val1"/>
					</view>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">物料编码</span>
					</view>
					<view class="zd-col-13">
						<!-- <search-box v-model="materialData.material_code"/> -->
						<input type="text" class="filter_input" v-model="materialData.material_code" disabled>
					</view>
					<button class="mini-btn" type="primary" @tap="toJump('mater-save?title=物料维护')">查询</button>
				</view>
				<view class="zd-row border-bottom">
					<view class="zd-col-6">
						<span class="filter_label">批号</span>
					</view>
					<view class="zd-col-13">
						<input type="text" class="filter_input" v-model="val2">
					</view>
					<button class="mini-btn" type="primary" @tap="_queryIvt">查询</button>
				</view>
			</view>
			<view class="zd_wrapper grid-wraper">
				<view class="slide_new">
					<table>
						<thead>
							<tr>
								<th>序号</th>
								<th>点位</th>
								<th>物料编码</th>
								<th>物料名称</th>
								<th>批号</th>
								<th>数量</th>
								<th>单位</th>
								<th>类别</th>
								<th>规格</th>
								<th>型号</th>
								<th>入库时间</th>
								<th>载具</th>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(e, i) in dataList" :key="i">
								<td>{{i+1}}</td>
								<td>{{e.struct_code}}</td>
								<td>{{e.material_code}}</td>
								<td>{{e.material_name}}</td>
								<td>{{e.pcsn}}</td>
								<td>{{e.canuse_qty}}</td>
								<td>{{e.qty_unit_name}}</td>
								<td>{{e.class_name}}</td>
								<td>{{e.material_spec}}</td>
								<td>{{e.material_model}}</td>
								<td>{{e.insert_time}}</td>
								<td>{{e.storagevehicle_code}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {queryIvt} from '@/utils/getData3.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				title: '',
				// options1: [],
				materialData: {},
				options1: [{text:'原料', value: 'WYL01'}, {text:'辅料', value: 'WFL01'}, {text:'批料室', value: 'PZC01'}, {text:'中间站', value: 'ZZC01'}, {text:'内包材', value: 'NBC01'}, {text:'外包材', value: 'WBC01'}],
				index1: 'WYL01',
				val1: '',
				val2: '',
				dataList: []
			};
		},
		onLoad (options) {
			this.title = options.title
		},
		onShow () {
			if (this.$store.getters.publicObj !== '') {
				this.materialData = this.$store.getters.publicObj
				this.$store.dispatch('setPublicObj', '')
			}
		},
		methods: {
			toEmpty () {
				this.val1 = ''
				this.dataList = []
				this.disabled = false
			},
			toJump (name) {
				uni.navigateTo({
					url: `/pages/hdyy/tygn/${name}`
				})
			},
			async _queryIvt () {
				try {
					let res = await queryIvt(this.index1, this.val1, this.materialData.material_code, this.val2)
					if (res && res.data) {
						this.dataList = [...res.data]
					} else {
						this.dataList = []
						uni.showToast({
							title: res.message,
							icon: 'none'
						})
					}
				} catch (e) {
					this.dataList = []
				}
			}
		}
	}
</script>

<style scoped>
.filter_picker {
	text-align: center
}
</style>