<script setup lang="ts">
	import { ref } from 'vue';

	const onClickLeft = () => {
		history.back()
	}

	const h5ScanCode = ref(false);
	function scanCode() {
		// #ifdef H5
		h5ScanCode.value = true;
		// #endif
		// #ifndef H5
		uni.scanCode({
			success: (res) => {
				uni.showToast({
					icon: "none",
					title: res.result,
				});
			},
			faile: (err) => {
				console.log("err", err);
			},
		});
		// #endif
	}
	function handleSuccess(res : any) {
		h5ScanCode.value = false;
	}
	function handleFail(err : any) {
		uni.showModal({
			title: err.errName,
			content: err.errMsg,
			complete: () => {
				h5ScanCode.value = false;
			},
		});
	}

	function handleClose() {
		h5ScanCode.value = false;
	}
	
	const showDialog = ref(false)
	const form = ref({} as any)
	
	const submit = () =>{
		
	}
</script>

<template>
	<view class="flex">
		<van-nav-bar title="扫描暂存" left-text="返回" left-arrow @click-left="onClickLeft" />
		<h3 style="text-align: center;">请扫描面料编码</h3>
		<view style="text-align: center;margin-top: 100rpx;">
			<van-image width="100" height="100" src="../../static/zhaoxiangji.png" @click="scanCode" />
		</view>
	</view>
	<cshaptx4869-scancode v-if="h5ScanCode" @success="handleSuccess" @fail="handleFail"
		@close="handleClose"></cshaptx4869-scancode>
		
		<van-dialog v-model:show="showDialog">
			<view style="margin: 10rpx 5rpx;">
				<van-field label="质检时间" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="质检人员" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="供应商名" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="面料名称" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="面料编号" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="面料米数" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="入库人" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="白胚等级" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="面料状态" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
				<van-field label="入库时间" label-width="5.5em" colon label-align="right" v-model="form.zjsj" readonly/>
			</view>
			<template #footer>
				<view class="footer-button">
					<van-button size="small" style="width: 25vw;" @click="showDialog=false">
						取消
					</van-button>
					<van-button size="small" type="success" style="width: 25vw;" @click="submit">
						暂存
					</van-button>
				</view>
			</template>
		</van-dialog>
</template>

<style lang="scss" scoped>
	.flex {
		display: flex;
		flex-direction: column;
		height: 100vh;
		width: 100vw;
	}
	.footer-button {
		margin: 20px;
		display: flex;
		justify-content: space-around;
	}
</style>