<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.entryType?worksheetInfo.entryType.name:''"></CellInfo>
					<CellInfo label="入库时间" :value="worksheetInfo.entryTime"></CellInfo>
					<CellInfo label="登记时间" :value="worksheetInfo.registrationTime"></CellInfo>
					<CellInfo label="登记人" :value="worksheetInfo.registrant?worksheetInfo.registrant.name:''"></CellInfo>
					<CellInfo label="部门" :value="worksheetInfo.registrationDept"></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/sparepartsEntry/info?code=" + this.pageId).then(res => {
					if (res.success) {
						this.worksheetInfo = res.data
					}
				})
			},
			onBack() {
				uni.redirectTo({
					url: "/pages/put_storage/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>
