<template>
	<view class="stockDetail-wrap">
		<!-- 查询结果 -->
		<view class="stockDetail-info" v-if="productData">
			<view class="info-item flex align_center justify_between">
				<view class="info-name">产品编码</view>
				<view style="width:70%;">{{productData && productData.dealerProductEntity.code || '--'}} <copyText :text="productData.dealerProductEntity.code" label="产品编码"></copyText></view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">产品名称</view>
				<view style="width:70%;">{{productData && productData.dealerProductEntity.name || '--'}} <copyText :text="productData.dealerProductEntity.name" label="产品名称"></copyText></view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">原厂编码</view>
				<view style="width:70%;">{{productData && productData.dealerProductEntity.origCode || '--'}} <copyText :text="productData.dealerProductEntity.origCode" label="原厂编码"></copyText></view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">条形码</view>
				<view style="width:70%;">{{productData && productData.dealerProductEntity.qrCode || '--'}} <copyText :text="productData.dealerProductEntity.qrCode" label="条形码"></copyText></view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">可用库存</view>
				<view style="width:70%;">{{productData.currentQty||0}}</view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">冻结库存</view>
				<view style="width:70%;">{{productData.freezeQty||0}}</view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">仓库/仓位</view>
				<view style="width:70%;">{{productData && productData.warehouseName || '--'}}>{{productData && productData.warehouseLocationName || '--'}}</view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">产品分类</view>
				<view style="width:70%;">{{productData.dealerProductEntity.productTypeName1 }} > {{productData.dealerProductEntity.productTypeName2 }} > {{productData.dealerProductEntity.productTypeName3 }} </view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">单位</view>
				<view style="width:70%;">{{productData && productData.dealerProductEntity.unit || '--'}}</view>
			</view>
			<view class="info-item flex align_center justify_between">
				<view class="info-name">产品图片</view>
				<view style="width:70%;" @click="viewImgs()">
					<u-image :src="productData.productMainImage?productData.productMainImage:`../../static/def_img@2x.png`" width="80" height="80" border-radius="10"></u-image>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import { toThousands } from '@/libs/tools'
	import { stockfindGroupPage } from '@/config/api'
	import copyText from '@/pages/common/copyText.vue'
	export default{
		components: { copyText },
		data(){
			return {
				productData: null,
				theme: '',
				toThousands
			}
		},
		onLoad(option) {
			this.getData()
		},
		methods: {
			getData(){
				const data = this.$store.state.vuex_tempData
				const params = {
				     "productSn":data.productSn,
					 "warehouseSn":data.warehouseSn,
					 "warehouseLocationSn":data.warehouseLocationSn,
					 "minCurrentQty":1
				}
				stockfindGroupPage(params).then(res => {
					console.log(res.data)
					if(res.status == 200){
						this.productData = res.data
					}
				})
			},
			viewImgs(){
				const imgUrls = []
				this.productData.productPicList && this.productData.productPicList.map(item => {
					imgUrls.push(item.imageUrl)
				})
				if(imgUrls.length){
					uni.previewImage({
						urls: imgUrls
					})
				}
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f8f8f8;
	}
	.stockDetail-wrap{
		padding: 30upx;
		.panel-box {
			background-color: #ffffff;
			padding: 20upx 20upx;
			border-radius: 20upx;
			box-shadow: 3upx 2upx 6upx #eee;
			margin-bottom: 30upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			.info-con{
				margin-left: 20upx;
				.padding_7{
					padding: 14upx 0 0;
					font-size: 14px;
				}
			}
		}
		.stockDetail-info{
			background-color: #ffffff;
			padding: 10upx 20upx 20upx;
			border-radius: 20upx;
			box-shadow: 3upx 2upx 6upx #eee;
			.info-item{
				border-bottom: 1px dashed #e4e7ed;
				padding: 20upx 0;
				.info-name{
					color: #464646;
				}
			}
		}
	}
</style>
