<template>
	<view class="">
		<uni-popup ref="popup" @change="change">
			<view class="popup_box">
				<view class="pop_title uni-flex space-between">
					<view class="">
						扫描{{title}}
					</view>
					<view class="">
						<image class=" icons_scan_close" src="@/static/icons/icons_scan_close.svg"
							@click="closeScanPopup()"></image>
					</view>
				</view>
				<view class="">
					<view class="">
						<win-com-scan ref="scan" @getResult="getScanResult" :placeholder='title' :clearResult="false">
						</win-com-scan>
					</view>
				</view>

			</view>
		</uni-popup>

	</view>

</template>

<script>
	import winComScan from '@/mycomponents/scan/winComScan.vue'
	export default {
		name: 'winScanItem',
		components: {
			winComScan
		},
		emits: ["getScanCode",'getScanResult'],
		props: {
			title: {
				type: String,
				default: ''
			},
			isShowRecord: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				code: '',
				result: {},
				isShow: false,
				expand: false,
				scanList: [],
				expendIcon: 'arrow-down'
			}

		},

		created() {

		},
		methods: {
			openScanPopup() {
				this.$refs.popup.open('bottom')
			},
			closeScanPopup() {
				this.$refs.popup.close()
			},
			getfocus() {
				if (this.isShow) {
					this.$refs.scan.getfocus()
				}
			},
			scanClick() {
				this.$refs.scan.clickScanMsg();
			},
			cancelClick() {
				this.$refs.scan.clearScanValue();
			},
			getScanResult(result) {
				this.result = result;
				if (result.label.barType == "QRCode") {
					this.code = result.label.itemCode;
				} else if (result.label.barType == "BarCode") {
					this.code = result.label.code;
				}
				this.callBack();
			},
			callBack() {
				this.$refs.scan.clear();
				this.$emit("getScanCode", this.code);
				this.$emit("getScanResult", this.code, this.result);
			},
			change(e) {
				this.isShow = e.show
			}
		}
	}
</script>

<style>
</style>
