<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" 
						 :isShowHistory="false"
						 headerType=""
						 >
						</win-com-scan>
					</view>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

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

		},

		created() {

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

<style>
</style>
