<template>
	<view class="p-content1">
		<view class="p-head" v-if="detailData">
			<view>
				<view>
					<text>店内调出单号：</text>
					<text style="color: crimson;">{{detailData.storeCallOutNo}}</text>
				</view>
			</view>
			<view>
				<view>
					<text>调往对象名称：</text>
					<view>
						{{
						  (detailData.putPersonType == 'EMPLOYEE'
							? detailData.putPersonName
							: detailData.customerNameCurrent == detailData.putPersonName
							  ? detailData.customerNameCurrent
							  : detailData.customerNameCurrent + '（' + detailData.putPersonName + '）') || '--'
						}}
					</view>
				</view>
			</view>
			<view>
				<view>
					<text>调拨类型：</text>
					<view>
						{{detailData.callOutTypeName||'--'}}
					</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.productCode}}</uni-td>
					<uni-td width="30%" align="center">{{item.productName}}</uni-td>
					<uni-td width="20%" align="center">{{item.outQty}}</uni-td>
					<uni-td width="20%" align="center"><u--text mode="price" :text="item.totalOutCost"></u--text></uni-td>
				</uni-tr>
			</uni-table>
		</view>
	</view>
</template>

<script>
	import { storeCallOutDetail, storeCallOutDetailCount, storeCallOutDetailList } from '@/config/api.js'
	export default {
		data() {
			return {
				loading: false,
				detailData: null,
				productTotal: null,
				detailList:[],
				storeCallOutSn: null,
			};
		},
		onLoad(opts) {
		  this.storeCallOutSn = opts.storeCallOutSn
		  
		  this.getDetail()
		  this.getCount()
		  this.getDetailList()
		},
		methods: {
			// 详情
			getDetail(){
				storeCallOutDetail({sn: this.storeCallOutSn}).then(res => {
					if(res.status == 200){
						this.detailData = res.data
					}
				})
			},
			// 合计
			getCount(){
				storeCallOutDetailCount({storeCallOutSn: this.storeCallOutSn}).then(res => {
					if(res.status == 200){
						this.productTotal = res.data
					}
				})
			},
			// 产品明细列表
			getDetailList(){
				storeCallOutDetailList({pageNo:1,pageSize:1000,storeCallOutSn:this.storeCallOutSn}).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>
