<template>
	<dialog-base class="dialog-body" ref="baseDialog" title="批次详情">
		<view style="overflow: auto;">
			<view class='middle'>
				<view class='segment'></view>
				<uni-icons type="paperclip" size="30" style="margin-left: 16rpx;"></uni-icons>
				<view class="lotTitle">批次信息</view>
				<view class='segment'></view>
			</view>
			<view class="item-info uni-row">
				<text class="label">批次号</text>
				<text class="label right">{{ lotData['lotCode'] }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">产品描述</text>
				<text
					class="label right">{{ store.planDetails['productDescription'] ? store.planDetails['productDescription'] : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">箱号</text>
				<text class="label right">{{ lotData['carrierName'] ? lotData['carrierName'] : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">投入数</text>
				<text
					class="label right">{{lotData['processQualifiedNum'] == 0 ? lotData['productionQuantity'] : lotData['processQualifiedNum']}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">已完成工序</text>
				<text class="label right">{{ lotData.prevProcess ? lotData['prevProcess'].processAlias : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">待加工工序</text>
				<text
					class="label right">{{ lotData.currentProcess ? lotData['currentProcess'].processAlias : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">下道工序</text>
				<text class="label right">{{ lotData.nextDeptProcess ? lotData['nextDeptProcess'] : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">所在区域</text>
				<text class="label right">{{ getPlaceText(lotData)}}</text>
			</view>
			<view class='middle'>
				<view class='segment'></view>
				<uni-icons type="paperclip" size="30" style="margin-left: 16rpx;"></uni-icons>
				<view class="lotTitle">领料信息</view>
				<view class='segment'></view>
			</view>
			<view class="item-info uni-row">
				<text class="label">炉号</text>
				<text id="manufacturer"
					class="label right">{{ furnaceNoInfo.furnaceNumber ? furnaceNoInfo.furnaceNumber : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">计划单号</text>
				<text id="manufacturer"
					class="label right">{{ furnaceNoInfo.productionPlanNo ? furnaceNoInfo.productionPlanNo : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">序号</text>
				<text class="label right">{{ furnaceNoInfo.lineNumber ? furnaceNoInfo.lineNumber : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">厂家</text>
				<text class="label right">{{ furnaceNoInfo.factory ? furnaceNoInfo.factory : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">牌号</text>
				<text class="label right">{{ furnaceNoInfo.brandNumber ? furnaceNoInfo.brandNumber : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">规格</text>
				<text class="label right">{{ furnaceNoInfo.spec ? furnaceNoInfo.spec : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">形状</text>
				<text class="label right">{{ furnaceNoInfo.shape ? furnaceNoInfo.shape : '-'}}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">材料直径</text>
				<text class="label right">{{ furnaceNoInfo.diameter ? furnaceNoInfo.diameter : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">原料编码</text>
				<text
					class="label right">{{ furnaceNoInfo.rawMaterialCode ? furnaceNoInfo.rawMaterialCode : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">来料日期</text>
				<text class="label right">{{ furnaceNoInfo.incomingDate ? furnaceNoInfo.incomingDate : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">技术要求1</text>
				<text
					class="label right">{{ furnaceNoInfo.firstTechnicalRequirement ? furnaceNoInfo.firstTechnicalRequirement : '-' }}</text>
			</view>
			<view class="item-info uni-row">
				<text class="label">技术要求2</text>
				<text
					class="label right">{{ furnaceNoInfo.secondTechnicalRequirement ? furnaceNoInfo.secondTechnicalRequirement : '-' }}</text>
			</view>
		</view>

	</dialog-base>
</template>

<script setup>
	import {
		ref,
		getCurrentInstance
	} from 'vue'
	import {
		store
	} from '../../store';
	import {
		getFurnaceNoInfoByDayworkId
	} from '@/api/business/furnaceNoInfo.js'

	const baseDialog = ref(null)
	const lotData = ref(null)
	const furnaceNoInfo = ref(null)

	function open() {
		lotData.value = store.dayworkInfo;
		getFurnaceNoInfoByDayworkId({
			dayworkId: store.dayworkInfo.id
		}).then(res => {
			if (res.code == 200) {
				furnaceNoInfo.value = res.rows.length == 0 ? [{}] : res.rows[0];
				baseDialog.value.open();
			} else {
				uni.showToast({
					icon: 'none',
					title: '炉号信息获取异常,请稍后重试'
				})
			}
		})
	}

	function getPlaceText(item) {
		let place = item.dayworkItemList[0].place == "" ? item.dayworkItemList[0].turnoverArea == "" ?
			'-' : item.dayworkItemList[0].turnoverArea : item.dayworkItemList[0].place
		let deptName = item.dayworkItemList[0].deptName
		return place == "-" ? deptName + "-" : deptName + "-" + place
	}

	function close() {
		baseDialog.value.close()
	}

	defineExpose({
		open
	})
</script>

<style lang="scss">
	.dialog-body {
		// height: 60%;
		// margin: auto auto;
		overflow: auto;
	}

	.item-info {
		margin: 8rpx;

		.label {
			font-size: 28rpx;
			width: 220rpx;
			color: #808080;

			&.right {
				flex: 1;
				color: #000000;
			}
		}
	}

	.status-btn {
		justify-content: flex-end;
		align-items: center;

		.turnover-tag {
			padding-right: 12rpx;
			padding-left: 12rpx;
			border-radius: 8rpx;
			border: 1rpx solid #FF7901;
			background-color: #FF7901;
			font-size: 28rpx;
			color: #FFFFFF;

		}

		.reporting-tag {
			padding-right: 12rpx;
			padding-left: 12rpx;
			border-radius: 8rpx;
			margin-left: 16rpx;
			border: 1rpx solid #1684fc;
			background-color: #1684fc;
			font-size: 28rpx;
			color: #FFFFFF;

		}
	}

	.middle {
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center
	}

	.segment {
		width: 80rpx;
		background-color: rgba(213, 213, 213, 1);
		border: 1rpx solid rgba(213, 213, 213, 1);
	}

	.lotTitle {
		margin: 16rpx 16rpx 16rpx 0;
	}
</style>