<template>
	<view class="page-wraper">
		<view class="page-header flex"
			style="font-size: 32rpx; padding-left: 10rpx; padding-top: 10rpx; flex-direction: column;">

		</view>
		<view class="page-main">
			<scroll-view scroll-y="true" class="page-main-scroll">
				<view style="padding-bottom: 80rpx;width: 100%;">

					<view class="uni-flex uni-column " style="margin: 10rpx;">
						<uni-section title="扫描" subTitle="扫码" subTitleFontSize="26rpx" titleFontSize="35rpx"
							type="line">
						</uni-section>

						<view class="uni-flex space-between">
							<view class="" style="width: 90%;  ">
								<uni-easyinput style="margin-left: 10rpx; margin-right: 10rpx;" trim="all"
									v-model="scanCode" @clear="clearCode"
									:focus="true"
									@confirm="onConfirm"></uni-easyinput>
							</view>
						</view>
						<view class="" v-if="scanCode!=''">
							<uni-table border stripe >
								<!-- 表头行 -->
								<!-- <uni-tr>
									<uni-th align="center">日期</uni-th>
									<uni-th align="center">姓名</uni-th>
									<uni-th align="left">地址</uni-th>
								</uni-tr> -->
								<!-- 表格数据行 -->
								<uni-tr>
									<uni-td >箱码</uni-td>
									<uni-td>1234</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td>批次</uni-td>
									<uni-td>20240508</uni-td>
								</uni-tr>
								<uni-tr>
									<uni-td>库位</uni-td>
									<uni-td>103</uni-td>
								</uni-tr>
							
							</uni-table>
						</view>
						

					</view>
					

				</view>
			</scroll-view>
		</view>
		<view class="page-footer">
			<view class="uni-flex u-col-center space-between padding_10"
				style="background-color:ghostwhite; width: 100%; ">
				<view class="">
					<!-- <button class="btn_single_reset" hover-class="btn_single_after" @click="reset">重置</button> -->
				</view>
				<view class=" uni-flex uni-row">
					<button class="btn_single_commit" hover-class="btn_commit_after" @click="submit">提交</button>
				</view>
			</view>
		</view>

	</view>


</template>
<script module="render" lang="renderjs">
	export default {
		methods: {
			_inputFocus(event) {
				document.querySelector('#inputSelect input').select()
			}
		}
	}
</script>
<script>
	import {
		downLickSubmit,
		getFoamScanUpLinkInfo
	} from '@/api/request2.js';
	import {
		showConfirmMsg
	} from "@/common/utils.js"

	import {
		getCurrDateTime,
	} from "@/common/basic.js"
	import selectClickList from "@/mycomponents/popup/selectClickList.vue"

	export default {
		components: {
			selectClickList
		},
		data() {
			return {
				dateTime: "",
				dataList: [],
				userForm: {
					names: [],
					values: [],
					origin: []
				},
				materialList: [],
				planList: [],
				scanCode: "",
				scanCheckCode:"",


			}
		},
		computed: {},
		onLoad() {},
		onUnload() {},
		onReady() {

		},

		methods: {
			submit() {
				if (this.scanCode == "") {
					this.scanCheckCode=""
					this.showMessage("请先扫描")
					return
				}
				uni.showLoading({
					title: "加载中",
					mask: true
				})
				var param = {
					id: this.$store.state.user.id,
					createTime: getCurrDateTime(),
				}
				console.log("提交", JSON.stringify(param))

				downLickSubmit(param).then(res => {
					uni.hideLoading()
					this.showMessage("提交成功")
					this.resetData()
				}).catch(error => {
					uni.hideLoading()
					this.showMessage(error)
				})
			},
			showMessage(hint) {
				showConfirmMsg("提示", hint, false, callBack => {

				})
			},
			resetData() {
				this.scanCode == ""
				this.scanCheckCode=""
			},
			clearCode() {
				this.scanCode == ""
				this.scanCheckCode=""
			},
			onConfirm(data) {
				if(data==undefined||data==""){
					this.showMessage("扫描数据为空,请先输入")
					return;
				}
				uni.showLoading({
					title: "加载中",
					mask: true
				})
				getFoamScanUpLinkInfo(data).then(res => {
					uni.hideLoading()
					this.scanCode = data;
					this.scanCheckCode = data;
					console.log(data)
				}).catch(error => {
					this.scanCode = "";
					this.scanCheckCode = "";
					uni.hideLoading()
					this.showMessage("扫描["+data+"]"+error)
				})
			},



			openScanPopup() {
				this.$refs.scanPopup.openScanPopup();
			},

			closeScanPopup() {
				this.$refs.scanPopup.closeScanPopup();
			},

		}
	}
</script>

<style lang="scss">
	.example {
		padding: 15px;
		background-color: #fff;
	}

	.segmented-control {
		margin-bottom: 15px;
	}

	.button-group {
		margin-top: 15px;
		display: flex;
		justify-content: space-around;
	}

	.form-item {
		display: flex;
		align-items: center;
		flex: 1;
	}

	.button {
		display: flex;
		align-items: center;
		height: 35px;
		line-height: 35px;
		margin-left: 10px;
	}

	.input {
		padding: 10rpx;
		height: 65rpx;
		text-align: left;
		margin: 5rpx;
		font-size: 28rpx;
		color: #333;
		overflow: hidden;
		text-overflow: ellipsis;
		outline: none;
		border-radius: 10rpx;
		border: 1rpx solid lightgrey;
	}
</style>