<template>
	<view class="p-content1">
		<view class="p-head" v-if="detailData">
			<view>
				<view>
					<text>连锁调出单号:</text>
					<text style="color: crimson;">{{detailData.allocationLinkageOutNo}}</text>
				</view>
			</view>
			<view>
				<view>
					<text>调往对象:</text>
					<view>
						{{detailData.putTenantName||'--'}}
					</view>
				</view>
			</view>
			<view>
				<view>
					<text>调拨类型:</text>
					<view>
						{{detailData.allocationTypeDictValue||'--'}}
					</view>
				</view>
			</view>
			<view>
				<view>
					<text>业务状态:</text>
					<view>
						 {{detailData.stateDictValue||'--'}}
					</view>
				</view>
			</view>
			<view>
				<view>
					<text>财务状态:</text>
					<view>
						 {{detailData.settleStateDictValue||'--'}}
					</view>
				</view>
			</view>
			<view>
				<view>
					<text>备注:</text>
					<view>
						 {{detailData.remark||'--'}}
					</view>
				</view>
			</view>
			<view v-if="productTotal" style="justify-content: flex-start;flex-wrap: wrap;">
				<view>总款数:{{productTotal.productTotalCategory||0}}</view>
				<view>总数量:{{productTotal.productTotalQty||0}}</view>
				<view>总成本:¥{{productTotal.productTotalCost||0}}</view>
			</view>
		</view>
		<view class="p-body">
			<uni-table style="width: 100%;" border emptyText="暂无数据" :loading="loading" >
				<!-- 表头行 -->
				<uni-tr>
					<uni-td align="center">产品编码</uni-td>
					<uni-td align="center">产品名称</uni-td>
					<uni-td align="center">调出数量</uni-td>
					<uni-td align="center">成本价</uni-td>
				</uni-tr>
				<!-- 表格数据行 -->
				<uni-tr v-for="item in detailList" :key="item.id">
					<uni-td width="30%" align="center">{{item.dealerProductEntity.code}}</uni-td>
					<uni-td width="30%" align="center">{{item.dealerProductEntity.name}}</uni-td>
					<uni-td width="20%" align="center">{{item.outQty}}</uni-td>
					<uni-td width="20%" align="center"><u--text mode="price" :text="item.outCost"></u--text></uni-td>
				</uni-tr>
			</uni-table>
		</view>
	</view>
</template>

<script>
	import { allocLinkageOutDetail, allocLinkageOutDetailCount, allocLinkageOutDetailList } from '@/config/api.js'
	export default {
		data() {
			return {
				loading: false,
				detailData: null,
				productTotal: null,
				detailList:[],
				code:'',
				allocationLinkageOutSn: null,
			};
		},
		onLoad(opts) {
		  this.allocationLinkageOutSn = opts.allocationLinkageOutSn
		  
		  this.getDetail()
		  this.getCount()
		  this.getDetailList()
		},
		methods: {
			// 详情
			getDetail(){
				allocLinkageOutDetail({sn: this.allocationLinkageOutSn}).then(res => {
					if(res.status == 200){
						this.detailData = res.data
					}
				})
			},
			// 合计
			getCount(){
				allocLinkageOutDetailCount({allocationLinkageOutSn: this.allocationLinkageOutSn}).then(res => {
					if(res.status == 200){
						this.productTotal = res.data
					}
				})
			},
			// 产品明细列表
			getDetailList(){
				allocLinkageOutDetailList({pageNo:1,pageSize:1000,allocationLinkageOutSn:this.allocationLinkageOutSn}).then(res => {
					if(res.status == 200){
						this.detailList = res.data.list
					}
				})
			},
		},
	}
</script>

<style lang="scss">
	.p-content1{
		.p-head{
			font-size: 32upx;
			color: $uni-text-color;
			>view{
				display: flex;
				align-items: center;
				padding: 10upx 20upx;
				border-bottom: 1px solid #eee;
				> view{
					display: flex;
					padding: 0 10upx;
					align-items: center;
				}
			}
		}
		.p-body{
			overflow: auto;
		}
		.p-footer{
			padding:20upx 30upx;
			display: flex;
			> button{
				width: 30%;
			}
		}
	}
</style>