<template>
	<view>
		<uni-easyinput suffixIcon="scan" placeholder="请输入件号" @iconClick="scanBar" v-model="pieceNo" type="text"
			@confirm="getList" />
		<view class="cu-card article ">
			<view class="cu-item shadow borderBottom" v-for="(item,index) in OpTranInOptions" :key="index">
				<view class="content">
					<view class="desc">
						<view class="text-content" style="font-size: 15px;">
							<view><strong>生产工单作业编码</strong> : {{item.code}}</view>
							<view><strong>生产工单</strong> : {{item.pwoCode}}</view>
							<view><strong>制程序号</strong> : {{item.opNo}}</view>
							<view><strong>制程编码</strong> : {{item.opCode}}</view>
							<view><strong>制程名称</strong> : {{item.opTitle}}</view>
							<view><strong>目标产品编码</strong> : {{item.ptNoTar}}</view>
							<view><strong>目标产品名称</strong> : {{item.ptTitleTar}}</view>
							<view><strong>生产批号</strong> : {{item.batchNo}}</view>
							<view><strong>转入时间</strong> : {{parseTime(item.pieceTransferInTime)}}</view>
							<view><strong>完成时间</strong> : {{parseTime(item.pieceFinishTime)}}</view>
							<view><strong>加工设备</strong> : {{item.eqpCode}}</view>
							<view><strong>加工人员</strong> : {{item.pieceEmpName}}</view>
							<view><strong>刀具SN号</strong> : {{item.pieceCutterPieceNo}}</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getPieceNoJob
	} from "@/api/retrospect/retrospect.js";


	export default {
		mounted() {},
		data() {
			return {
				OpTranInOptions: {},
				pieceNo: null,
			}
		},
		methods: {
			getList() {
				getPieceNoJob(this.pieceNo).then(response => {
					this.OpTranInOptions = response.data;
					console.log(this.OpTranInOptions)
				})
			},

			scanBar() {
				const _this = this;
				uni.scanCode({
					scanType: ['qrCode', 'barCode'],
					success: function(res) {
						_this.pieceNo = res.result;
						_this.getList();
					}
				});
			},
			//转换时间格式
			parseTime(time) {
				if (time === null) {
					return ''; // 或者返回其他默认值
				}
				const originalDate = new Date(time);
				const formattedDate = originalDate.toISOString().replace(/T/, ' ').replace(/\..+/, '');
				return formattedDate;
			}
		}
	}
</script>

<style>
	// 搜索框
	.search-bar {
		width: 100%;
		height: 100rpx;
		margin-top: 2%;
	}

	.search-bar-box {
		display: flex;
		margin: 0 auto;
		width: 620rpx;
		height: 74rpx;
		border: 5rpx solid #00a8cc;
		border-radius: 50rpx;
	}

	.search-text {
		width: 100%;
		margin-top: 10rpx;
		margin-left: 20rpx;
		font-size: 30rpx;
		color: #7f7f81;
	}

	.search-btn {
		background-color: #00a8cc;
		/* Green */
		color: white;
		text-align: center;
		display: inline-block;
		font-size: 35rpx;
		width: 240rpx;
		height: 70rpx;
		line-height: 65rpx;
		border-radius: 30rpx;
		letter-spacing: 3rpx;
	}

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