<template>
	<uni-popup ref="popup" type="top">
		<uni-list>
			<uni-list-item :title="type==='in'?'入库人员':'出库人员'" :rightText="viewData.accountName"></uni-list-item>
			<uni-list-item  v-if="type==='in'" title="入库时间" :rightText="viewData.inboundTime"></uni-list-item>
			<uni-list-item v-if="type==='out'" title="出库时间" :rightText="viewData.outboundTime"></uni-list-item>
			<uni-list-item v-if="type==='in'" title="入库类型" :rightText="inboundTypeFormat(viewData.inboundType)"></uni-list-item>
			<uni-list-item v-if="type==='out'" title="出库类型" :rightText="outboundTypeFormat(viewData.outboundType)"></uni-list-item>
			<uni-list-item title="物资分类" :rightText="viewData.goodsCatTitle"></uni-list-item>
			<uni-list-item :title="type==='in'?'入库数量':'出库数量'" :rightText="viewData.qty"></uni-list-item>
			<uni-list-item v-if="type==='in'" title="入库地址" :rightText="viewData.inboundLocation"></uni-list-item>
			<uni-list-item v-if="type==='out'" title="出库地址" :rightText="viewData.outboundLocation"></uni-list-item>
			<uni-list-item title="物资编号" :rightText="viewData.goodsNo"></uni-list-item>
			<uni-list-item title="物资名称" :rightText="viewData.goodsTitle"></uni-list-item>
			<uni-list-item title="生产日期" :rightText="viewData.goodsPdDate"></uni-list-item>
			<uni-list-item title="过期日期" :rightText="viewData.goodsExpDate"></uni-list-item>
			<uni-list-item title="物资说明" :rightText="viewData.goodsDesc"></uni-list-item>
			<uni-list-item title="备注" :rightText="viewData.remark"></uni-list-item>
		</uni-list>
	</uni-popup>
</template>

<script>
	import goodsApi from '@/api/goods.js'	
	export default{
		name:"Inbound",
		data(){
			return{
				type:undefined,
				viewData:{
					groupId: 0,
					groupName: '',
					inboundId: 0,
					inboundType: 1,
					inboundTime: '',
					inboundLocation: '',
					accountId: 0,
					accountName: '',
					goodsType: 1,
					goodsCatId: 0,
					goodsCatTitle: '',
					qty: 0,
					goodsNo: '',
					goodsTitle: '',
					goodsPdDate: '',
					goodsExpDate: '',
					goodsDesc: '',
					remark: '',
					//outbound
					outboundId: 0,
					outboundType: 1,
					outboundTime: '',
					outboundLocation: ''
				},
			}
		},
		methods:{
			inboundTypeFormat(idx){
				  const enums = [ '未知','正常入库', '报溢',]
				  return enums[idx]||'未知'
			},
			outboundTypeFormat(idx){
				  const enums = [ '未知','正常入库', '报损','过期']
				  return enums[idx]||'未知'
			},
			show(type,id){
				this.type=type;
				this.$refs.popup.open('bottom')
				this.getData(id)
			},
			getData(id){
				const getDataById=this.type==='in'?goodsApi.getInboundById:goodsApi.getOutboundById;
				getDataById(id).then((res)=>{
					this.viewData=res.data
				})							
			},
			close(){
				this.$refs.popup.close()
			}
		}
	}
</script>

<style>
</style>