<template>
	<view class="manageQrcode">
		<view class="dtl" v-if="isScanCode">
			<view class="">
				二维码编号：{{dtlData.qrCode}}
			</view>
			<view class="">
				物料编码：{{dtlData.materialCode}}
			</view>
			<view class="">
				物料名称：{{dtlData.materialName}}
			</view>
			<view class="">
				绑定数量：{{dtlData.quantity}}
			</view>
			<view class="">
				绑定时间：{{dtlData.createTime}}
			</view>
			<view class="">
				供应商：{{dtlData.supplierName || '空'}}
			</view>
			<view class="">
				合同编号：{{dtlData.purchaseBillNo}} <span style="margin-left: 20rpx;">批次号：{{dtlData.batchNo}}</span>
			</view>
		</view>
		<view class="" style="font-size: 24rpx;padding-bottom:200rpx;">
			<view style="border-bottom:1rpx solid #dcdcdc;padding: 20rpx 40rpx;" v-for="i in waterDetailData">
				<view class="">
					时间：{{i.createTime}} <span style="margin-left: 40rpx;">{{typeList[i.stockChangeType]}}</span>
				</view>
				<view class="">
					操作人：{{i.nickName}}
				</view>
			</view>
		</view>
		<view class="submit-box">
			<button @click="scanCode()" style="background: #0066CC;color:#fff;margin-bottom: 30rpx;">重新扫描</button>
		</view>
	</view>
</template>

<script>
	import {
		getInfo
	} from "@/util/api.js";
	import {dateFormat,getTime} from '../../util/uitl.js'
	export default {
		data() {
			return {
				listData: [],
				req: {
					keyword: null,
					materialId: null
				},
				isScanCode:false,
				dtlData:{},
				waterDetailData:[],
				typeList:{
					6:'库存初始化',10:'入库',11:'盘盈',12:'数量添加修正',13:'补入库',14:'标签损坏入库',15:'归还入库',16:'现场回仓',17:'调仓入库',20:'出库',21:'盘亏',22:'数量减少修正',23:'补出库',24:'绑定错误',25:'标签损坏出库',26:'退货出库',27:'报废出库',28:'调仓出库'
				}
			}
		},
		onLoad(option) {
			this.scanCode()
		},
		methods: {
			scanCode(){
				const v = this
				uni.scanCode({
					onlyFromCamera: true,
					success: function (res) {
						uni.showToast({
							icon: "loading",
							title: '加载中',
							duration: 1500
						});
						v.$post('/wx/selectQrcode/getWaterDetail',{qrCode:res.result}).then(res=>{
							for (var i = 0; i < res.data.length; i++) {
								// res.data[i].createTime = dateFormat(res.data[i].createTime)
								
							}
							v.waterDetailData = res.data
						})
						v.$post('/wx/common/gerMaterialInfoByQrcode',{qrCode:res.result}).then(res=>{
							// res.data.createTime = dateFormat(res.data.createTime)
							v.dtlData = res.data
							v.isScanCode = true
						})
					},fail() {
						wx.navigateBack()
					}
				});
			},
			getData(){
				
			},
		},
	}
</script>

<style lang="less">
	.manageQrcode{
		.dtl {
			padding: 30rpx;
			border-bottom: 1rpx solid #dcdcdc;
			font-size: 26rpx;
			line-height: 40rpx;
		}
		.submit-box {
			position: fixed;
			left: 0;
			right: 0;
			bottom: 0;
			padding: 0 30rpx;
		}
	}
</style>
