<template>
	<view class="zd_container">
		<nav-bar title="原辅料收料"></nav-bar>
		<view class="zd_content">
			<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>
							</tr>
						</thead>
						<tbody>
							<tr v-for="(e, i) in dataList" :key="i" :class="{'checked': e.checked}">
								<td><span class="iconfont icon_unchecked" :class="{'icon_checked': e.checked}" @tap="toCheck(e)">&#xe66b;</span></td>
								<td>{{e.device_code}}</td>
								<td @tap="toJump(e)">{{e.device_name}}</td>
								<td>{{e.status_name}}</td>
								<td>{{e.plan_start_date}}</td>
							</tr>
						</tbody>
					</table>
				</view>
			</view>
		</view>
		<view class="submit-bar">
			<button class="submit-button" :class="{'btn-disabled': !pkId}" :disabled="disabled" @tap="toSure1">确认入库</button>
		</view>
	</view>
</template>

<script>
	import NavBar from '@/components/NavBar.vue'
	import SearchBox from '@/components/SearchBox.vue'
	import {coolIOQuery, confirmInstor, statusList} from '@/utils/getData2.js'
	export default {
		components: {
			NavBar,
			SearchBox
		},
		data() {
			return {
				dataList: [],
				checkArr: [],
				disabled: false
			};
		},
		created () {
		},
		methods: {
			/** 下拉框查询 */
			async _statusList () {
				let res = await statusList()
				this.options = [...res.data]
			},
			/** grid查询 */
			async _empOutgetIvt (e) {
				let res = await empOutgetIvt(e)
				res.data.map(el => {
					this.$set(el, 'checked', false)
				})
				this.dataList = [...res.data]	
			},
			/** 确认 */
			async _confirmInstor () {
				this.disabled = true
				if (!this.val1 || !this.pkId || !this.index) {
					this.disabled = false
					return
				}
				try {
					let res = await confirmInstor(this.pkObj, this.val1, this.index)
					this.disabled = false
					this.pkId = ''
					this.pkObj = {}
					this.searchList()
					uni.showToast({
						title: res.message,
						icon: 'none'
					})
				} catch (e) {
					this.disabled = false
				}
			},
			toCheck (e) {
				e.checked = !e.checked
				this.checkArr = this.dataList.filter(i => { return i.checked === true })
			},
			toJump (e) {
				this.$store.dispatch('setPublicObj', e)
				uni.navigateTo({
					url: '/pages/warehouse/WarehouseReceiptDetails'
				})
			}
		}
	}
</script>

<style lang="stylus">
</style>
