<template>
	<view class="mainBox">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="物料入库单" @clickLeft="back"></uni-nav-bar>
		
		<u-cell-group>
			<u-cell title="单号" :value="contData.code"></u-cell>
			<u-cell title="状态">
				<view slot="value" class="u-slot-value"><u--text type="primary" :text="contData.status.name" v-if="contData.status"></u--text></view>
			</u-cell>
			<u-cell title="创建时间" :value="contData.createTime"></u-cell>
		</u-cell-group>
		
		<uni-section title="基本信息" type="line">
		    <u-cell title="仓库" :value="contData.warehouse.name" v-if="contData.warehouse"></u-cell>
			<u-cell title="负责人" :value="contData.creator.name" v-if="contData.creator"></u-cell>
			<u-cell title="来源单据" :value="contData.sourceBill?contData.sourceBill:'无'"></u-cell>
			<u-cell title="入库登记人" :value="contData.executor.name"  v-if="contData.executor"></u-cell>
			<u-cell title="送货人" :value="contData.sendName"></u-cell>
			<u-cell title="送货人联系方式" :value="contData.sendPhone"></u-cell>
		</uni-section>
		
		<u-collapse class="cLine" >	 
		    <u-collapse-item title="附件" name="">
		      	<view class="picList">
					<u--image :showLoading="true" :src="item.src" width="50px" height="50px" @click="viewImage(item.src)" v-for="(item,index) in contData.attaments" :key="index"></u--image>
				</view>
		    </u-collapse-item>
			
			<u-collapse-item title="描述" name="">
			  <text class="u-collapse-content">{{contData.remark}}</text>
			</u-collapse-item>
			
			<u-collapse-item title="明细" name="detail">
				
		      <view class="listBox" v-for="(item, index) in contData.pieceDetails" :key="index" >
		      	<view class="listTit">
		      	   <view style="display:inline-block;"><u-tag text="按量" size="mini" shape="circle" type="primary"></u-tag></view> 
		      	   <view class="name">{{item.material.name}}</view>	
		      	   <view class="weight">{{item.num}}{{item.unit}}</view>
		      	   <view class="delete">{{item.trueNum}}{{item.unit}}</view>
		      	</view>
		      	<view class="listCont">
		      		<view class="item"><text>编码：</text>{{item.material.id}}</view>
		      		<view class="item"><text>批次号：</text>{{item.batchNo}}</view>
		      		<view class="item" v-if="item.type"><text>物料类型：</text>{{item.type.name}}</view>
		      		<view class="item"><text>包装单位：</text>{{item.pkgUnit}}</view>
		      		<view class="item" v-if="item.storeArea"><text>库区：</text>{{item.storeArea.name}}</view>
					<view class="item" v-if="item.storeSpace"><text>库位：</text>{{item.storeSpace.name}}</view>
					<view class="item"><text>层级：</text>{{item.level}}</view>
		      	</view>
		      </view>
			  
			</u-collapse-item>
			
		  </u-collapse>
		
		<view class="footBox">
			<view class="reg" style="width:100%;" @click="getAddDetails"><uni-icons custom-prefix="iconfont" type="icon-shixiangxinzeng" size="20" color="#fff"></uni-icons> 入库登记</view>
		</view>
		
		
	</view>
</template>

<script>
	import { post,get } from "@/utils/api.js";
	export default {
		data() {
			return {
				id:'',
				code:'',
				contData:{},
			}
		},
		onLoad(params){
			this.id = params.id;
			this.code = params.code;
			this.getDetails(params.id,params.code);
		},

		methods: {
			//获取信息
			getDetails(id,code){
				let data = {
					id:id,
					code:code
				}
				get(this.apiWebUrl + "/wms/enter/material/info", data).then(res=>{
					this.contData = res.data;
				}).catch((res)=>{
								
				})
			},
			//查看附件
			viewImage(src){
				uni.previewImage({
					current:0,
					urls: [src],
				});
			},
			//入库登记
			getAddDetails(){
				uni.navigateTo({
					url: '/pages/warehouse/material/addMaterial'
				});
			},		
		}
	}
</script>

<style  lang="scss" scoped>
	.mainBox{
		padding-bottom: 120rpx;
	}
	.picList{
		display: flex;
		align-items: center;
		justify-items: flex-start;
		flex-wrap: wrap;
	}
	/deep/.picList .u-image{
		margin-right:10rpx;
		margin-bottom: 10rpx;
	}
	
	/deep/.cLine .u-line:nth-child(1){
		border-bottom: none !important;
	}
	.footBox{
		position: fixed;
		left:0px;
		bottom: 0px;
		height: 100rpx;
		width: 100%;
		display: flex;
		align-items: center;
		justify-content: space-between;
		view{
			width:50%;
			height: 100%;
			text-align: center;
			color: #fff;
			display: flex;
			align-items: center;
			justify-content: center;
		}
		.reg{
			background: $u-success-dark;
		}
		.uni-icons{margin-right: 8rpx !important;}
	}
	
	.listBox{
		 padding: 20rpx 0;
		 border-bottom:1px #f2f2f2 solid;
		.listTit{
			display: flex;
			align-items: center;
			.name{
				margin-left: 10px;
			}
			.weight {
				font-size: $uni-font-size-base;
				margin-left: auto;
				margin-right: 60rpx;
				position: relative;
			}
			.weight::after{
				 position: absolute;
				 right:-30rpx;
				 top:50%;
				 content: '';
				 background: #eee;
				 width: 1px;
				 height: 28rpx;
				 margin-top: -14rpx;
			}
			.delete{
				color: #999;
			}
		}
		.listCont{
			display: flex;
			align-items: center;
			flex-wrap: wrap;
			margin-top: 15px;
			.item{
				width:50%;
				font-size: $uni-font-size-sm;
				line-height: 48rpx;
				overflow: hidden;
				white-space: nowrap;
				text-overflow: ellipsis;
	            -o-text-overflow:ellipsis;
				color: #000;
			}
			.item text{color: #666;}
		}
	 }
	 .listBox:last-child{
		border:none !important;
	 }
</style>
