<template>
	<gui-page :custom-header="true" :header-class="['gui-theme-background-color']">
		<template #gHeader>
			<view style="height:44px;" class="gui-flex gui-nowrap gui-rows gui-align-items-center">
				<!-- 使用组件实现返回按钮及返回首页按钮 -->
				<text style="font-size:44rpx;" class="gui-header-leader-btns gui-color-white font-icons"
					@tap="goBack">&#xe6c5;</text>
				<!-- 导航文本此处也可以是其他自定义内容 -->
				<text
					class="gui-h4 gui-blod gui-flex1 gui-text-center gui-ellipsis gui-color-white gui-primary-text">工单明细</text>
				<!-- 此处加一个右侧展位元素与左侧同宽，实现标题居中 -->
				<!-- 实际宽度请根据自己情况设置 -->
				<view style="width:40px;" />
				<!-- 如果右侧有其他内容可以利用条件编译和定位来实现-->
			</view>
		</template>
		<template #gBody>
			<view class="oqc-checkout">
				<view class="card-list-flexbox">
					<text class="card-list-title" :style="[isPad?'font-size: 18px':'font-size: 14px']">详细信息</text>
					<view class="card-list-item">
						<text>生产订单号</text>
						<text>{{ ProcessParams.erpWorkOrderNo }}</text>
					</view>
					<view class="card-list-item">
						<text>产品编号</text>
						<text>{{ ProcessParams.materialNo }}</text>
					</view>
					<view class="card-list-item">
						<text>产品名称</text>
						<text>{{ ProcessParams.materialName }}</text>
					</view>
					<view class="card-list-item">
						<text>计划数量</text>
						<text>{{ ProcessParams.planningQty }} {{ ProcessParams.unitName }}</text>
					</view>
					<view class="card-list-item">
						<text>包装量</text>
						<text>{{ ProcessParams.numberOfPieces }} {{ ProcessParams.unitName }}</text>
					</view>
					<view class="card-list-item">
						<text>生产工序</text>
						<text>{{ ProcessParams.processName }}</text>
					</view>
					<view class="card-list-item">
						<text>计划号</text>
						<text>{{ ProcessParams.erpWorkOrderNo }}</text>
					</view>
					<view class="card-list-item">
						<text>需求日期</text>
						<text>{{ $parseTime(ProcessParams.needTime) }}</text>
					</view>
					<view class="card-list-item">
						<text>单据日期</text>
						<text>{{ $parseTime(ProcessParams.createTime) }}</text>
					</view>
				</view>
				<view class="table-title" style="margin-top: 16px;">
					<span>工艺路线</span>
				</view>
				<view class="custom-table2">
					<uni-table border stripe empty-text="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr class="custom-table-head">
							<uni-th align="center" width="140px">工序</uni-th>
							<uni-th align="center" width="140px">机器</uni-th>
							<uni-th align="center" width="140px">模具</uni-th>
							<uni-th align="center" width="140px">备注</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr>
							<uni-td align="center">{{ ProcessParams.processName }}</uni-td>
							<uni-td align="center" />
							<uni-td align="center">{{ ProcessParams.tooling }}</uni-td>
							<uni-td align="center">{{ ProcessParams.remark }}</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="table-title">
					<span>物料清单</span>
				</view>
				<view class="custom-table">
					<uni-table border stripe empty-text="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr class="custom-table-head">
							<uni-th align="center" width="55px">序号</uni-th>
							<uni-th align="center" width="110px">物料编码</uni-th>
							<uni-th align="center" width="160px">物料名称</uni-th>
							<uni-th align="center" width="100px">规格</uni-th>
							<uni-th align="center" width="100px">单位</uni-th>
							<uni-th align="center" width="100px">需求数量</uni-th>
							<uni-th align="center" width="100px">实发数量</uni-th>
							<uni-th align="center" width="100px">是否主材</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item, key) in ProcessParams.materialList" :key="key">
							<uni-td align="center" width="120px">{{ ++key }}</uni-td>

							<uni-td align="center">{{ item.materialNo }}</uni-td>
							<uni-td align="center">{{ item.materialName }}</uni-td>
							<uni-td align="center">{{ item.materialModels }}</uni-td>
							<uni-td align="center">{{ item.unitCode }}</uni-td>
							<uni-td align="center">{{ item.needNum }}</uni-td>
							<uni-td align="center">{{ item.realityNum }}</uni-td>
							<uni-td align="center">{{ item.keyMaterial === 'Y'? '是': '否' }}</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="table-title">
					<span>执行情况</span>
				</view>
				<view class="custom-table" style="margin-bottom: 80px;">
					<uni-table border stripe empty-text="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr class="custom-table-head">
							<uni-th align="center" width="55px">序号</uni-th>
							<uni-th align="center" width="100px">标签补打</uni-th>
							<uni-th align="center" width="140px">标签名称</uni-th>
							<uni-th align="center" width="80px">单位</uni-th>
							<uni-th align="center" width="80px">数量</uni-th>
							<uni-th align="center" width="80px">状态</uni-th>
							<uni-th align="center" width="80px">备注</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item, key) in ProcessParams.executeResultFlatKnifeDOList" :key="key">
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ ++key }}</uni-td>

							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">
								<button v-if="item.status * 1 === 2" size="mini" type="primary"
									@tap="handlePatchWork(item)">补打</button>
							</uni-td>
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.labelName }}</uni-td>
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.unitName }}</uni-td>
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.qty }}</uni-td>
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.status === 1? '未打印': '已打印' }}</uni-td>
							<uni-td align="center"
								:style="item.status * 1 === 2? 'background-color: rgba(109, 205, 50, 1);color: white;': ''">{{ item.remark }}</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="table-title">
					<span>卸料情况</span>
				</view>
				<view class="custom-table" style="margin-bottom: 80px;">
					<uni-table border stripe empty-text="暂无更多数据">
						<!-- 表头行 -->
						<uni-tr class="custom-table-head">
							<uni-th align="center" width="55px">序号</uni-th>
							<uni-th align="center" width="100px">标签补打</uni-th>
							<uni-th align="center" width="140px">物料名称</uni-th>
							<uni-th align="center" width="120px">卸料数量(m²)</uni-th>
						</uni-tr>
						<!-- 表格数据行 -->
						<uni-tr v-for="(item, key) in unLoadList" :key="key">
							<uni-td align="center">{{ ++key }}</uni-td>

							<uni-td align="center">
								<button size="mini" type="primary" @tap="handleUnloadPrintLabel(item)">补打</button>
							</uni-td>
							<uni-td align="center">{{ item.materialName }}</uni-td>
							<uni-td align="center">{{ item.unloadNumber }}</uni-td>
						</uni-tr>
					</uni-table>
				</view>
				<view class="operationBtn">
					<button v-if="ProcessParams.processName !== '全检'" type="primary"
						style="width: calc(100% - 8px);margin: 0 4px;"
						@click="handleSubmitApprovalModal('前段')">工序执行</button>
					<button v-else type="primary" style="width: calc(100% - 8px);margin: 0 4px;"
						@click="handleSubmitApprovalModal('后段')">后段执行</button>
				</view>
			</view>
			<uni-popup ref="errorTip" type="dialog">
				<uni-popup-dialog type="error" cancel-text="关闭" confirm-text="确认" title="提示" :content="errorTipMessage"
					@confirm="handleCloseErrorTipsModal" @close="handleCloseErrorTipsModal" />
			</uni-popup>
		</template>
	</gui-page>
</template>
<script>
	import {
		computed,
		defineComponent,
		ref,
		onBeforeMount
	} from 'vue'
	import tsc from '@/unit/CHITEN_SDK_APP/tsc.js'
	export default defineComponent({
		onLoad() {
			// // #ifdef APP-PLUS
			// plus.screen.lockOrientation('default');
			// // #endif
		},
		onUnload() {
			// // #ifdef APP-PLUS
			// plus.screen.lockOrientation('portrait-primary');
			// // #endif
		},
		onResize() {
			if ([90, -90].includes(plus.navigator.getOrientation())) {
				this.isLandscapeScreen = true
			} else {
				this.isLandscapeScreen = false
			}
		},
		setup(options) {
			const popup = ref()
			const bluetooth = ref()
			const isLandscapeScreen = ref(false)
			const parentRow = uni.getStorageSync('HotPressInfo') ?? {}
			const unLoadList = ref([])
			const errorState = ref(0)
			const errorTip = ref('')
			const errorTipMessage = ref('')
			// 工单信息
			const ProcessParams = ref({
				id: '',
				erpWorkOrderNo: '',
				materialNo: '',
				materialName: '',
				planningQty: '',
				numberOfPieces: '',
				processName: '',
				createTime: '',
				materialList: [], // 物料清单
				executeResultFlatKnifeDOList: [] // 执行情况
			})
			const blueConfig = ref({
				loopBuffer: 0,
				currentTime: 1,
				lastData: 0,
				onBufferSize: 20,
				printerNum: 1,
				currentPrint: 1,
				isLabelSend: false
			})

			// 卸料列表
			const getUnloadList = function() {
				uni.$reqGet('getUnLoadList', {
						hotPressId: ProcessParams.value.id
					})
					.then(({
						code,
						data,
						msg
					}) => {
						if (code === 0) {
							unLoadList.value = data ?? []
						} else {
							uni.showToast({
								title: msg,
								duration: 2000,
								icon: 'none'
							})
						}
					})
			}

			onBeforeMount(() => {
				Object.assign(ProcessParams.value, JSON.parse(parentRow))
				// #ifdef APP-PLUS
				const bluetoothConfig = uni.getStorageSync('bluetoothConfig')
				if ([null, '', undefined].includes(bluetoothConfig)) {
					bluetooth.value = {
						'isOpenBle': false,
						'deviceId': '',
						'serviceId': '',
						'writeId': '',
						'notifyId': ''
					}
					setTimeout(() => {
						// #ifdef APP-PLUS
						plus.device.beep(2)
						// #endif
						errorTipMessage.value = '蓝牙打印机未连接'
						errorState.value = -1
						errorTip.value.open()
					}, 800)
				} else {
					bluetooth.value = JSON.parse(bluetoothConfig)
				}
				// #endif
				getUnloadList()
			})

			const goBack = function() {
				uni.$goBack('/pages/workbranch/production/processExecution/processList')
			}

			const handleSubmitApprovalModal = function(state) {
				if (state === '前段') {
					uni.navigateTo({
						url: `/pages/workbranch/production/processExecution/processExecution`
					})
				} else {
					uni.navigateTo({
						url: `/pages/workbranch/production/processExecution/processPosteriorSegment?hotPressId=${ProcessParams.value.id}`
					})
				}
			}

			const Send = function(buff) {
				var currentTime = blueConfig.value.currentTime
				var loopBuffer = blueConfig.value.loopBuffer
				var lastData = blueConfig.value.lastData
				var onBufferSize = blueConfig.value.onBufferSize
				var printNum = blueConfig.value.printerNum
				var currentPrint = blueConfig.value.currentPrint
				var buf
				var dataView
				if (currentTime < loopBuffer) {
					buf = new ArrayBuffer(onBufferSize)
					dataView = new DataView(buf)
					for (let i = 0; i < onBufferSize; ++i) {
						dataView.setUint8(i, buff[(currentTime - 1) * onBufferSize + i])
					}
				} else {
					buf = new ArrayBuffer(lastData)
					dataView = new DataView(buf)
					for (let i = 0; i < lastData; ++i) {
						dataView.setUint8(i, buff[(currentTime - 1) * onBufferSize + i])
					}
				}
				plus.bluetooth.writeBLECharacteristicValue({
					deviceId: bluetooth.value.deviceId,
					serviceId: bluetooth.value.serviceId,
					characteristicId: bluetooth.value.writeId,
					value: buf,
					success: function(res) {
						if (currentPrint <= printNum) {
							wx.showToast({
								title: '数据打印中',
								icon: 'loading'
							})
						}
						// 将complete中处理数据的代码挪过来，增加30ms延迟, 解决蓝牙打印数据传输10007问题
						setTimeout(() => {
							currentTime += 1
							if (currentTime <= loopBuffer) {
								blueConfig.value.isLabelSend = true
								blueConfig.value.currentTime = currentTime
								Send(buff)
							}
							// end
							if (currentTime === loopBuffer) {
								blueConfig.value.currentPrint += 1
								blueConfig.value.isLabelSend = false
							}
						}, 10)
					},
					fail: function(e) {
						wx.showToast({
							title: '打印第' + currentPrint + '张失败' + 'error: code ' + e
								?.code + ', message ' + e?.message,
							icon: 'none',
							duration: 4000
						})
					},
					complete: function() {}
				})
			}

			const prepareSend = function(buff) {
				var time = blueConfig.value.onBufferSize
				var loopBuffer = parseInt(buff.length / time)
				var lastData = parseInt(buff.length % time)
				blueConfig.value.loopBuffer = loopBuffer + 1
				blueConfig.value.lastData = lastData
				blueConfig.value.currentTime = 1
				Send(buff)
			}

			const labelTest = function(ret) {
				var command = tsc.dlabelPrinter.createNew()
				command.setBackFeed(6)
				// (480 * 200)dots
				command.setSize(60, 25)
				command.setCls()
				command.setGap(6)
				command.setBox(0, 0, 475, 200, 1)
				// 1
				command.setBar(108, 0, 2, 40)
				command.setBar(108, 40, 2, 40)
				command.setBar(108, 80, 2, 40)
				command.setBar(108, 120, 2, 40)
				command.setBar(108, 160, 2, 40)
				command.setBar(108, 200, 2, 40)
				// 竖
				command.setBar(210, 80, 2, 40)
				command.setBar(210, 120, 2, 40)
				command.setBar(210, 160, 2, 40)
				command.setBar(210, 200, 2, 40)
				// 横
				command.setBar(0, 40, 480, 2)
				command.setBar(0, 80, 320, 2)
				command.setBar(0, 120, 210, 2)
				command.setBar(0, 160, 210, 2)
				// 横
				command.setBar(320, 80, 480, 2)
				command.setBar(320, 120, 480, 2)
				command.setBar(320, 160, 480, 2)
				// 竖
				command.setBar(322, 40, 2, 40)
				command.setBar(322, 80, 2, 40)
				command.setBar(322, 120, 2, 40)
				command.setBar(322, 160, 2, 40)
				// 竖
				command.setBar(378, 40, 2, 40)
				command.setBar(378, 80, 2, 40)
				command.setBar(378, 120, 2, 40)
				command.setBar(378, 160, 2, 40)

				// row1
				command.setText(4, 8, 'TSS24.BF2', 0, 1, 1, '料号')
				command.setText(112, 10, '2', 0, 1, 1, ret.materialName)
				// row2
				command.setText(4, 48, 'TSS24.BF2', 0, 1, 1, '工令单')
				command.setText(112, 50, '2', 0, 1, 1, ret.wordOrderNo)
				command.setText(328, 48, 'TSS24.BF2', 0, 1, 1, '数量')
				command.setText(384, 50, '2', 0, 1, 1, ret.qty)
				// row3
				command.setText(4, 88, 'TSS24.BF2', 0, 1, 1, '生产日期')
				command.setText(110, 90, '1', 0, 1, 1, ret.dateOfManufacture)
				command.setText(328, 88, 'TSS24.BF2', 0, 1, 1, '库位')
				command.setText(384, 90, '1', 0, 1, 1, ret.storageLocation)
				// row4
				command.setText(4, 128, 'TSS24.BF2', 0, 1, 1, '供应商')
				command.setText(112, 130, '3', 0, 1, 1, ret.vendor)
				command.setText(328, 128, 'TSS24.BF2', 0, 1, 1, '后制')
				command.setText(384, 130, '1', 0, 1, 1, ret.postProduction)
				// row5
				command.setText(4, 168, 'TSS24.BF2', 0, 1, 1, '包装')
				command.setText(112, 170, '1', 0, 1, 1, ret.packaging)
				command.setText(328, 168, 'TSS24.BF2', 0, 1, 1, 'QC')
				command.setText(384, 170, '1', 0, 1, 1, ret.qc)

				command.setQrcode(214, 88, 'L', 5, 'A', ret.qrCode)
				command.setPagePrint()
				prepareSend(command.getData())
			}

			const cuttingPrint = function(ret) {
				var command = tsc.dlabelPrinter.createNew()
				command.setBackFeed(6)
				// (640 * 320)dots
				command.setSize(80, 40)
				command.setCls()
				command.setGap(8)
				command.setBox(0, 0, 635, 315, 1)
				command.setBar(0, 40, 640, 2)
				command.setBar(0, 80, 640, 2)
				command.setBar(0, 120, 640, 2)
				command.setBar(0, 160, 640, 2)
				command.setBar(0, 200, 366, 2)
				command.setBar(0, 240, 366, 2)
				command.setBar(0, 280, 640, 2)
				// 1
				command.setBar(115, 0, 2, 40)
				command.setBar(115, 40, 2, 40)
				command.setBar(115, 80, 2, 40)
				command.setBar(115, 120, 2, 40)
				command.setBar(115, 160, 2, 40)
				command.setBar(115, 200, 2, 40)
				command.setBar(115, 240, 2, 40)
				command.setBar(115, 280, 2, 40)
				// 2
				command.setBar(360, 40, 2, 40)
				command.setBar(360, 80, 2, 40)
				command.setBar(360, 120, 2, 40)
				command.setBar(360, 160, 2, 40)
				command.setBar(360, 200, 2, 40)
				command.setBar(360, 240, 2, 40)
				command.setBar(360, 280, 2, 40)
				// 3
				command.setBar(475, 40, 2, 40)
				command.setBar(475, 80, 2, 40)
				command.setBar(475, 120, 2, 40)
				command.setBar(475, 280, 2, 40)

				command.setText(10, 6, 'TSS24.BF2', 0, 1, 1, '物料名称')
				command.setText(126, 6, 'TSS24.BF2', 0, 1, 1, ret.materialName)
				// row2
				command.setText(10, 46, 'TSS24.BF2', 0, 1, 1, '物料编码')
				command.setText(126, 46, 'TSS24.BF2', 0, 1, 1, ret.materialNo)
				command.setText(366, 46, 'TSS24.BF2', 0, 1, 1, '供应商')
				command.setText(481, 46, 'TSS24.BF2', 0, 1, 1, ret.supplierName)
				// row3
				command.setText(10, 86, 'TSS24.BF2', 0, 1, 1, '物料规格')
				command.setText(126, 86, 'TSS24.BF2', 0, 1, 1, ret.size)
				command.setText(366, 86, 'TSS24.BF2', 0, 1, 1, '分切日期')
				command.setText(481, 86, 'TSS24.BF2', 0, 1, 1, ret.createTime)
				// row4
				command.setText(10, 126, 'TSS24.BF2', 0, 1, 1, 'Lot no.')
				command.setText(126, 126, '1', 0, 1, 1, ret.materialLots)
				command.setText(366, 126, 'TSS24.BF2', 0, 1, 1, '储位')
				command.setText(481, 126, 'TSS24.BF2', 0, 1, 1, ret.wmsStockLocationName)
				// row5
				command.setText(10, 166, 'TSS24.BF2', 0, 1, 1, '有效期')
				command.setText(126, 166, 'TSS24.BF2', 0, 1, 1, ret.validityDate)
				// row6
				command.setText(10, 206, 'TSS24.BF2', 0, 1, 1, '检测日期')
				command.setText(126, 206, 'TSS24.BF2', 0, 1, 1, ret.inspectTime)
				// row7
				command.setText(10, 246, 'TSS24.BF2', 0, 1, 1, '存储条件')
				const strList = ret.storageEnvironment?.split(' ')
				const strText = strList[0] + ' ' + strList[1]
				command.setText(126, 246, 'TSS24.BF2', 0, 1, 1, strText)
				// row8
				command.setText(10, 286, 'TSS24.BF2', 0, 1, 1, '分切单号')
				command.setText(126, 286, 'TSS24.BF2', 0, 1, 1, ret.slittingOrderNo)
				command.setText(366, 286, 'TSS24.BF2', 0, 1, 1, '生产日期')
				command.setText(481, 286, 'TSS24.BF2', 0, 1, 1, ret.produceDate)

				command.setText(480, 216, '2', 0, 1, 1, ret.qty)
				command.setQrcode(366, 166, 'L', 4, 'A', ret.batchNumber)
				command.setPagePrint()
				prepareSend(command.getData())
			}

			const handlePatchWork = function(item) {
				let list = []
				uni.request({
					method: 'GET',
					url: uni.$baseUrl + '/report/print/getPrintDataFeol',
					data: {
						executeResultId: item?.id
					}
				}).then(async ({
					data: {
						code,
						data,
						msg
					}
				}) => {
					if (code === 0) {
						uni.showToast({
							title: '标签打印中，请勿操作',
							duration: 10000,
							icon: 'none'
						})
						list = data
						if (list.length > 0) {
							blueConfig.value.currentPrint = 1
							blueConfig.value.printNum = list.length

							const timer = setInterval(async () => {
								const currentPrint = blueConfig.value.currentPrint - 1
								if (blueConfig.value.isLabelSend === false &&
									currentPrint <
									blueConfig.value.printNum) {
									const paramsObj = {
										pn: list[currentPrint]
											.pn ?? '',
										wordOrderNo: list[currentPrint]
											.wordOrderNo ??
											'',
										qty: list[currentPrint]
											.qty ??
											'',
										dateOfManufacture: list[currentPrint]
											.dateOfManufacture ??
											'',
										storageLocation: list[currentPrint]
											.storageLocation ??
											'',
										postProduction: list[currentPrint]
											.postProduction ??
											'',
										vendor: list[currentPrint]
											.vendor ??
											'',
										packaging: list[currentPrint]
											.packaging ??
											'',
										qc: list[currentPrint]
											.qc ??
											'',
										qrCode: list[currentPrint]
											.qrCode ??
											''
									}
									await labelTest(paramsObj)
								}
								if (currentPrint === blueConfig.value.printNum) {
									await clearInterval(timer)
								}
							}, 3000)
						}
					} else {
						uni.showToast({
							title: msg,
							duration: 2000,
							icon: 'none'
						})
					}
				})
			}

			const handleUnloadPrintLabel = function(item) {
				let list = []
				uni.request({
					url: uni.$baseUrl + '/report/print/slittingPrintData',
					data: {
						id: item.labelMasterId
					}
				}).then(async ({
					data: {
						data
					}
				}) => {
					if (data?.length > 0) {
						uni.showToast({
							title: '标签打印中，请勿进行操作',
							duration: 10000,
							icon: 'none'
						})
						list = data
						if (list.length > 0) {
							blueConfig.value.currentPrint = 1
							blueConfig.value.printNum = list.length

							const timer = setInterval(async () => {
								const currentPrint = blueConfig.value.currentPrint - 1
								if (blueConfig.value.isLabelSend === false &&
									currentPrint <
									blueConfig.value.printNum) {
									const paramsObj = {
										materialName: list[currentPrint]
											.materialName ?? '',
										materialNo: list[currentPrint]
											.materialNo ??
											'',
										supplierName: list[currentPrint]
											.supplierName ??
											'',
										size: list[currentPrint]
											.size ??
											'',
										createTime: list[currentPrint]
											.createTime ??
											'',
										materialLots: list[currentPrint]
											.materialLots ??
											'',
										wmsStockLocationName: list[currentPrint]
											.wmsStockLocationName ??
											'',
										validityDate: list[currentPrint]
											.validityDate ??
											'',
										inspectTime: list[currentPrint]
											.inspectTime ??
											'',
										storageEnvironment: list[currentPrint]
											.storageEnvironment ??
											'',
										slittingOrderNo: list[currentPrint]
											.slittingOrderNo ??
											'',
										produceDate: list[currentPrint]
											.produceDate ??
											'',
										batchNumber: list[currentPrint]
											.batchNumber ??
											'',
										qty: list[currentPrint]
											.qty ??
											''
									}
									await cuttingPrint(paramsObj)
								}
								if (currentPrint === blueConfig.value.printNum) {
									await clearInterval(timer)
								}
							}, 3000)
						}
					} else {
						uni.showToast({
							title: '打印数据错误',
							icon: 'none',
							duration: 2000
						})
					}
				})
			}

			// 关闭错误信息弹窗
			const handleCloseErrorTipsModal = async function() {
				errorTip.value.close()
			}

			return {
				popup,
				goBack,
				unLoadList,
				errorTip,
				errorState,
				errorTipMessage,
				isLandscapeScreen,
				ProcessParams,
				handlePatchWork,
				handleUnloadPrintLabel,
				handleCloseErrorTipsModal,
				handleSubmitApprovalModal
			}
		}
	})
</script>

<style lang="scss" scoped>
	.gui-header-leader-btns {
		color: black;
		font-size: 24px !important;
		margin-left: 24rpx;
	}

	.gui-sbody {
		background-color: rgba(234, 239, 242, 1);
	}

	.gui-relative {
		overflow: visible;
		height: 100vh;

		.oqc-checkout {
			width: 100vw;
			height: calc(100vh - 75px);
			position: absolute;
			top: 95px;
			overflow-y: scroll;
		}
	}

	.card-list-flexbox {
		width: calc(100vw - 24px);
		height: 345px;
		margin: 0 12px;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		overflow-y: scroll;

		.card-list-title {
			width: 100%;
			height: 35px;
			line-height: 35px;
			margin: 0 4px 0 4px;
			border-radius: 4px 4px 0 0;
			text-align: center;
			color: white;
			background-color: rgba(0, 160, 233, 1.0);
		}

		.card-list-item,
		.card-list-item-operation {
			width: 100%;
			height: 35px;
			margin: 0 4px 3rpx 4px;
			border-radius: 4px;
			display: flex;
			flex-direction: row;
			align-items: center;
			justify-content: space-between;
			background-color: #fff;

			uni-text {
				font-size: 14px;
				height: 50rpx;
				text-align: left;
				padding: 0 8px;
				display: flex;
				flex-direction: row;
				align-items: center;
			}

			.text-1 {
				flex: 1;
				height: 35px;
				justify-content: flex-start;
			}

			.text-2 {
				flex: 3;
				height: 35px;
				justify-content: flex-end;
				margin-right: 4px;
				padding: 2px 6px;
			}

		}

	}

	.popup-content {
		width: 100vw;
		height: 55vh;
		overflow-y: scroll;
	}

	.card-list-flexbox-popup {
		width: 100vw;
		display: flex;
		flex-direction: row;
		align-items: center;
		flex-wrap: wrap;

		.card-list-item,
		.card-list-item-input {
			width: 100vw;
			height: 100%;
			min-height: 40px;
			display: flex;
			flex-direction: row;
			align-items: center;
			background-color: #fff;

			uni-text {
				font-size: 14px;
				height: 50rpx;
				text-align: left;
				padding: 0 12px;
				display: flex;
				flex-direction: row;
				align-items: center;
			}

			uni-image {
				width: calc(100vw / 2 - 4px);
				height: calc(100vw / 3.2 - 2px);
				pointer-events: none;
			}

			uni-image::after {
				content: "×";
				width: 22px;
				height: 22px;
				position: absolute;
				top: 5px;
				right: 5px;
				display: flex;
				justify-content: center;
				align-items: center;
				color: rgba(255, 255, 255, 0.9);
				background-color: rgba(0, 0, 0, 0.5);
				border-radius: 50%;
				font-size: 24px;
				/*给伪元素开启鼠标事件，将事件冒泡到父元素的点击事件中*/
				pointer-events: auto;
			}

			.text-1 {
				flex: 1;
				height: 40px;
				justify-content: flex-start;
			}

			.text-2 {
				flex: 3;
				height: 40px;
				justify-content: flex-end;
				margin-right: 4px;
				padding: 2px 6px;
			}

			.text-3 {
				width: calc(100% - 15%);
				min-height: 35px;
				justify-content: flex-end;
				padding: 2px 6px;
			}

			.text-3::before {}

			.btn-mg {
				margin: 0 5px;
			}
		}

		.card-list-item {
			justify-content: center;
		}

		.card-list-item-input {
			margin: 10px 0 10px 2%;
			display: flex;
			flex-direction: column;

			uni-view {
				width: 100%;
				height: 100%;
				display: flex;

				uni-textarea {
					flex: 8;
				}

				uni-view {
					flex: 1;
				}

				.operation-icon,
				.operation-icon-2 {
					height: auto;

					uni-text {
						width: 22px;
						height: 100%;
						padding: 0 !important;
						text-align: center;
						display: flex;
						justify-content: center;
						align-items: center;
						border-top-right-radius: 4px;
						border-bottom-right-radius: 4px;
						color: white;
						background-color: #80b7ff;
					}
				}

				.operation-icon-2 {
					uni-text {
						background-color: #ff5962;
					}
				}

			}
		}

		.grid-image {
			/* 设置容器布局为grid布局 */
			display: grid;
			/* 指定每一行的宽度 每个宽度中间用空格隔开 */
			grid-template-rows: repeat(auto-fill, 1fr);
			/* 指定每一列的宽度 每个宽度中间用空格隔开 */
			grid-template-columns: repeat(2, 1fr);
			padding: 0 4px;
		}

		.card-list-item:nth-of-type(1) {

			.text-1 {
				flex: 9;
				font-weight: bold;
				color: black !important;
			}

			.text-1::before {
				content: "";
				width: 4px;
				height: 20px;
				border-radius: 4px;
				margin-right: 4px;
				background-color: skyblue;
			}

			.text-2 {
				flex: 4;
				display: flex;
				flex-direction: row;
				justify-content: flex-end;
				align-items: center;
				color: limegreen !important;
			}
		}

	}

	.table-title {
		height: 40px;
		line-height: 40px;
		margin: 4px 0 -3px 0;
		padding: 0 12px;
		font-size: 16px;
		font-weight: bold;
		background-color: white;
	}

	.custom-table {
		height: 24vh;
		min-height: 230px;
		margin: 5px 0;
		// min-height: 600px;
		overflow-y: scroll;
	}

	.custom-table2 {
		height: 100px;
		margin: 5px 0;
		overflow-y: scroll;
	}

	.uni-list-cell {
		width: 100vw;
		height: 35px;
		margin: 4px 0;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: space-between;
		border-bottom: 2px solid #eaeff2;
		background-color: #fff;

		view {
			font-size: 14px;
			height: 50rpx;
			text-align: left;
			padding: 0 8px;
			display: flex;
			flex-direction: row;
			align-items: center;
		}

		.uni-list-cell-left {
			flex: 1;
			height: 35px;
			justify-content: flex-start;
		}

		.uni-list-cell-db {
			flex: 3;
			height: 35px;
			justify-content: flex-end;
			margin-right: 4px;
			padding: 2px 6px;

			uni-picker {
				width: 100%;
				display: flex;
				flex-direction: row;
				justify-content: center;
			}
		}
	}

	.modal-btns {
		height: 100rpx;
		line-height: 100rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.line {
		margin-top: 10rpx;
		height: 80rpx;
		width: 1rpx;
		background-color: #dcdcdc;
	}

	.operationBtn {
		position: fixed;
		width: 100%;
		bottom: 0;
		padding: 12px 0;
	}
</style>