<template>
	<view>
		<div v-for="(item,index) in data" :key="index">
			<div>
				<table>
					<tr>
						<td>工&emsp;&emsp;单：</td><td>{{item.pwoCode}}</td>
					</tr>
					<tr>
						<td>物料编码：</td><td>{{item.ptNoTar}}</td>
					</tr>
					<tr>
						<td>物料名称：</td><td>{{item.ptTitleTar}}</td>
					</tr>
					<tr>
						<td>物料规格：</td><td>{{item.specification1}}</td>
					</tr>
					<tr>
						<td>物料图号：</td><td></td>
					</tr>
					<tr>
						<td>客户名称：</td><td></td>
					</tr>
					<tr>
						<td>是否冲孔：</td><td></td>
					</tr>
					<tr>
						<td>总&thinsp;数&thinsp;量&nbsp;</td><td>{{item.num}}</td>
					</tr>
				</table>
			</div>
			<div>
				<u-button class="uButton" @click="clickButton(item)">入库</u-button>
			</div>
		</div>
	</view>
</template>

<script>
	import {
		getPwoByCode,
		getDetailData
	} from "@/api/mes/pwoIn.js";
	export default {
		data() {
			return {
				data:{}
			}
		},
		beforeMount() {
			//把查询页面查询到的数据放入进来
			this.data =this.$store.state.pwo.data
			//接收完后清空vuex里面的数据清空
			this.$store.commit('updatData',{})
		},
		methods: {
			/**
			 * 入库按钮点击事件
			 * @param {Object} item 当前点击按钮的数据
			 */
			async clickButton(item){
				const {pwoCode,id} = item
				const obj = {
					delStatus : "0",
					genRedraw : true,
					pwoCode,
					pwoI : id,
					status : '0',
					type : "3"
				}
				const res = await Promise.all([getPwoByCode(pwoCode),getDetailData(obj)])
				this.$store.commit("updatData",{body:res[0].data,list:res[1].data})
				uni.navigateTo({
					url:"/pages/mes/jobCv/transfer/from"
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	$fontSize : 14px ;
	page {
		background-color: #ffffff;
		padding-top: 1vw;
		view > div {
			position: relative;
			width: 95%;
			border-width: 1px 2px;
			border-style: solid;
			border: 2px solid #e0fff9;
			margin:  1px 2.5% 2px 2.5%;
			display: flex;
			div:first-child {
				width: 85%;
				margin-right:2%
			};
			div:last-child {
				margin-right: auto;
				width: 13%;
				& > .uButton{
					height: 1.65 * 8 * $fontSize;
				}
			}
		}
	}
</style>