<template>
	<view class="content-box">
		<uni-nav-bar fixed="true" statusBar="true" left-icon="back" :title="title" background-color="#157A2C"
			color="#fff" @clickLeft="back"></uni-nav-bar>


		<view class="top-wrapper cx">
			<stepsNav  v-if='info.taskId && stepsList.length' :stepsList="stepsList" :taskId="info.taskId"></stepsNav>

			<view class="tab_box rx-sc">
				<view class="tab_item" :class="{active: tabType == 1}" @click="handTab(1)">基本信息</view>
				<view class="tab_item" :class="{active: tabType == 2}" @click="handTab(2)">生产明细</view>
			</view>

		</view>

		<view class="list_box">

			<u-list @scrolltolower="scrolltolower" key="info" v-if="tabType == 1">
				<view class="item_list rx-bc">
					<text class="lable">生产工单号</text>
					<text>{{ info.code }}</text>
				</view>

				<view class="item_list rx-bc">
					<text class="lable">计划编号</text>
					<text>{{ info.productionPlanCode }}</text>
				</view>

				<view class="item_list rx-bc">
					<text class="lable">工艺路线版本</text>
					<text>{{ info.routingVersion }}</text>
				</view>

				<view class="item_list rx-bc">
					<text class="lable">产品编码</text>
					<text> {{ info.productCode }}</text>
				</view>


				<view class="item_list rx-bc">
					<text class="lable">产品名称</text>
					<text>{{ info.productName }}</text>
				</view>


				<view class="item_list rx-bc">
					<text class="lable">牌号</text>
					<text>{{ info.brandNo }}</text>
				</view>


				<view class="item_list rx-bc">
					<text class="lable">型号</text>
					<text>{{info.model}}</text>
				</view>


				<view class="item_list rx-bc">
					<text class="lable">要求成型数量</text>
					<text>{{info.formingNum }} </text>
				</view>



				<view class="item_list rx-bc">
					<text class="lable">要求成型重量</text>
					<text>{{ info.formingWeight }} KG</text>
				</view>

				<view class="item_list rx-bc">
					<text class="lable">已完成生产数量</text>
					<text></text>
				</view>


				<view class="item_list rx-bc">
					<text class="lable">已完成生产重量</text>
					<text></text>
				</view>

				<view class="item_list rx-bc">
					<text class="lable">计划开始时间</text>
					<text>{{ info.planStartTime }}</text>
				</view>



			</u-list>

			<u-list @scrolltolower="scrolltolower" key="detail" v-if="tabType == 2">
			
				<view v-for="(item,index) in produceList" :key="index" class="detail-list">
					<view class="name">{{item.taskName}}</view>
					<view class="list rx-bc" >
						<view class="title rx-sc">
							<image  class="icon" src="~@/static/pda/layers.svg"></image>
							待投料数量
						</view>

						<view class="rx-ec">
						{{item.waitFeedNum}}
						<image  class="arrow_right2" src="~@/static/pda/arrow_right2.svg"></image>
						</view>
					</view>
					
					<view class="list rx-bc" >
						<view class="title rx-sc">
							<image  class="icon" src="~@/static/pda/check-square.svg"></image>
							生产中数量
						</view>
					
						<view class="rx-ec">
						 0
						<image  class="arrow_right2" src="~@/static/pda/arrow_right2.svg"></image>
						</view>
					</view>
					
					
					<view class="list rx-bc" >
						<view class="title rx-sc">
						
							<image  class="icon" src="~@/static/pda/target.svg"></image>
					
							待投料数量
						</view>
					
						<view class="rx-ec">
						{{item.waitFeedNum}}
						<image  class="arrow_right2" src="~@/static/pda/arrow_right2.svg"></image>
						</view>
					</view>
				</view>
			</u-list>

		</view>

		<view class="bottom-wrapper">
			<bottomOperate state='1' @operate='operate'></bottomOperate>
		</view>

	</view>
</template>

<script>
	import bottomOperate from '../../components/bottomOperate.vue'
	import stepsNav from '../../components/stepsNav.vue'
	
		import { getTaskInstanceList, workorderInfo, produceDetail } from '@/api/pda/workOrder.js'
	export default {
		components: {
			bottomOperate,
			stepsNav
		},
		data() {
			return {
				title: '',
				tabType: 1,
				id: null,
				
				stepsList: [],
				info: {},
				taskId: null,
				
				produceList: [],
			}
		},

		onLoad(options) {
			this.title = options.title
			this.id = options.id
			
			uni.showLoading({
				title: '加载中'
			});
			


		},
		
		onShow() {
			this.getSteps()
			this.getInfo()
			
			this.produce()
		},

		methods: {
			scrolltolower() {},

			handTab(type) {
				if (type != this.tabType) {
					this.tabType = type
				}
			},
			
			getSteps() {
				getTaskInstanceList(this.id).then(res => {
					this.stepsList = res
				
				})
			},
			
			getInfo() {
				workorderInfo(this.id).then(res => {
					this.info = res
					uni.hideLoading();
				}).catch(() => {
					uni.hideLoading();
				})
			},
			
			operate(type) {
				let url  
				if(type == 'picking') {
				url = '/pages/pda/picking/details'
				let _arr = JSON.stringify([ this.info.id ])
				url += `?arr=${encodeURIComponent(_arr)}&taskId=${this.info.taskId}`
				uni.navigateTo({
					url
				})
				} else if(type == 'feeding') {
					url = '/pages/pda/feeding/details'
					let _arr = JSON.stringify([ this.info.id ])
					url += `?arr=${encodeURIComponent(_arr)}&taskName=${this.info.taskName}`
					uni.navigateTo({
						url
					})
				}
	
			},
			
			
			produce() {
				produceDetail(this.id).then(res => {
					this.produceList = res.produceDetail
				
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.content-box {
		height: 100vh;
		overflow: hidden;
		display: flex;
		flex-direction: column;
		background-color: $page-bg;
	}

	.top-wrapper {
		background-color: #fff;
		display: flex;
		width: 750rpx;
		background: #fff;
		align-items: center;
	}

	.tab_box {
		width: 100%;
		height: 68rpx;


		.tab_item {
			height: 68rpx;
			line-height: 68rpx;
			padding: 0 20rpx;
			font-size: 32rpx;
			color: #979C9E;

		}

		.active {
			box-sizing: border-box;
			border-bottom: 6rpx solid $theme-color;
			color: $theme-color;
		}


	}

	.list_box {
		flex: 1;
		overflow: hidden;
		padding: 4rpx 0;

		.u-list {
			height: 100% !important;
		}

		.item_list {

			width: 100%;
			height: 80rpx;
			box-sizing: border-box;
			padding: 0 32rpx;
			font-size: 32rpx;
			color: #979C9E;
			font-weight: 400;
			border-bottom: 1rpx solid #E3E5E5;



			.lable {
				color: #090A0A;
				font-weight: 500;
			}
		}


		.detail-list {
			line-height: 80rpx;

			.name {
				color: #090A0A;
				font-size: 32rpx;
				font-weight: 600;
				padding: 0 32rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #E3E5E5;
			}

			.list {
				padding: 0 32rpx;
				box-sizing: border-box;
				border-bottom: 1rpx solid #E3E5E5;

				.title {
					font-weight: 400;
					color: #090A0A;

				}

				.icon {
					width: 36rpx;
					height: 36rpx;
					margin-right: 8rpx;
				}
				
				.arrow_right2{
					width: 12rpx;
					height: 24rpx;
					margin-left: 8rpx;
				}
			}

		}
	}


	.bottom-wrapper {}
</style>