<template>
	<view class="cu-card article ">
		<uni-row>
			<uni-col :span="6">
				<u-button type="success" @click="restore">还原</u-button>
			</uni-col>
		</uni-row>
		<view class="cu-item shadow borderBottom" v-for="(item,index) in wmsOpTransferOutStockList" :key="index">
			<view class="content">
				<view class="desc">
					<view class="text-content" style="font-size: 15px;">
						<view><strong>物料编码</strong> : {{item.materialCode}}</view>
						<view><strong>物料名称</strong> : {{item.materialName}}</view>
						<view><strong>批号</strong> : {{item.batchNo}}</view>
						<view><strong>件号</strong> : {{item.pieceNo}}</view>
						<view><strong>库位</strong> : {{item.storageLocationCode}}</view>
						<view><uni-row>
								<uni-col :span="3">
									<strong>数量</strong> :
								</uni-col>
								<uni-col :span="21"> <u-number-box v-model="item.num" @change="valChange"
										inputWidth="120"></u-number-box></uni-col>
							</uni-row>
						</view>
						<view><strong>单位</strong> : {{item.unitId}}</view>
						<uni-row>
							<uni-col :span="18">
								<view><strong>备注</strong> : {{item.remark}}</view>
							</uni-col>
							<uni-col :span="6">
								<u-button size="small" type="error" icon="trash"
									@click="deleteList(index)">删除</u-button></uni-col>
						</uni-row>
					</view>
				</view>
			</view>
		</view>
		<u-button type="primary" @click="submit">提交</u-button>
	</view>
</template>

<script>
	import {
		customizeConvert
	} from "@/api/mes/pwoIn.js";
	export default {
		onLoad: function(option) {
			console.log(option);
			this.wmsOpTransferOutStockList = JSON.parse(decodeURIComponent(
				option.wmsOpTransferOutStockList));
			this.formerWmsOpTransferOutStockList = JSON.parse(decodeURIComponent(
				option.wmsOpTransferOutStockList));
		},
		data() {
			return {
				wmsOpTransferOutStockList: [],
				formerWmsOpTransferOutStockList: []
			}
		},
		methods: {
			deleteList(i) {
				this.formerWmsOpTransferOutStockList = [...this.formerWmsOpTransferOutStockList];
				this.wmsOpTransferOutStockList.splice(i, 1);
				console.log(this.wmsOpTransferOutStockList);
			},
			restore() {
				this.wmsOpTransferOutStockList = this.formerWmsOpTransferOutStockList;
			},
			submit() {
				const _this = this;
				uni.showModal({
					title: '提示',
					content: '您确定核销吗？',
					success: function(res) {
						if (res.confirm) {
							let requestData = {
								wmsOpTransferOutStockList: _this.wmsOpTransferOutStockList
							}
							console.log(_this.wmsOpTransferOutStockList);
							_this.$modal.loading('提交中')
							customizeConvert(requestData).then((response) => {
								_this.$modal.closeLoading();
								_this.$modal.msgSuccess("核销成功！");
								setTimeout(() => {
									_this.$tab.navigateBack();
								}, 500);
							});
						} else if (res.cancel) {
							console.log('用户点击取消');
						}
					}
				});
			}
		},
	}
</script>

<style>
	.cu-card.article>.cu-item .content .text-content {
		height: 100% !important;
	}
</style>