<template>
	<view>
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" title="出库登记详情" @clickLeft="onBack">
		</uni-nav-bar>
		<view style="padding-bottom: 110rpx;" v-if="'worksheetInfo'">
			<uni-collapse ref="collapse" :typeOpen="1" title="基本信息">
				<view class="bg">
					<CellInfo label="出库单号" :value="worksheetInfo.code"></CellInfo>
					<CellInfo label="状态" :value="worksheetInfo.status?'已出库':'未出库'"></CellInfo>
					<CellInfo label="来源单号" :value="worksheetInfo.sourceBill"></CellInfo>
					<CellInfo label="申请时间" :value="worksheetInfo.applyDate"></CellInfo>
					<CellInfo label="领取时间" :value="worksheetInfo.getDate"></CellInfo>
					<CellInfo label="创建人" :value="worksheetInfo.creator?worksheetInfo.creator.name:''"></CellInfo>
					<CellInfo label="部门" :value="worksheetInfo.dept"></CellInfo>
					<CellInfo label="备注" :value="worksheetInfo.remark"></CellInfo>
				</view>
				</uni-collapse-item>
			</uni-collapse>
			<!-- 选择归还区域 -->
			<template>
				<CellTip title="库存信息"> </CellTip>
				<view class="" v-for="(item,index) in worksheetInfo.spareparts" :key="index">
					<OrderList lable1="编码:" :value1="item.code" lable2="名称:" :value2="item.name" lable3="规格:"
						:value3="item.spec" lable4="型号:" :value4="item.model" lable5="库存:" :value5="item.stock"
						lable6="单位:" :value6="item.unit">

					</OrderList>
				</view>

				<!-- <Cell cellType="more" title="选择仓库">

				</Cell>
				<Cell cellType="more" title="选择库区">

				</Cell> -->
			</template>


		</view>
	</view>
</template>

<script>
	import Cell from '@/components/Cell.vue'
	import CellTip from '@/components/CellTip.vue'
	import CellInfo from '@/components/CellInfo.vue'
	import OrderDeatil from '../components/OrderDeatil.vue'
	import OrderList from '../components/OrderList.vue'
	import {
		get
	} from "@/utils/api.js"
	export default {
		components: {
			Cell,
			OrderDeatil,
			CellTip,
			CellInfo,
			OrderList
		},
		data() {
			return {
				worksheetInfo: {},
				pageId: ""
			}
		},
		onLoad(options) {
			this.pageId = options.id;
			this.getInfo();
		},
		onShow() {
			if (this.worksheetInfo) {
				this.getInfo();
			}
		},
		methods: {
			getInfo() {
				get(this.apiUrl + "/feature/book/sparepartsExport/info?code=" + this.pageId).then(res => {
					if (res.success) {
						this.worksheetInfo = res.data
					}
				})
			},
			onBack() {
				uni.redirectTo({
					url: "/pages/outbound/order/index"
				})
			},
			goSparepart(id) {
				uni.navigateTo({
					url: '../sparepart/sparepart?id=' + id
				})
			},

		}
	}
</script>

<style lang="scss" scoped>
	.btn-main-box {
		padding: 20rpx 0;

		.btn-primary {
			margin: 20rpx auto;
			width: 80rpx;
			text-align: center;
		}
	}
</style>
