<template>
	<view>
		<uni-popup ref="popup" @change="change" @maskClick="closeScanPopup()">
			<view class="popup_box">
				<view class="pop_title">
					扫描工位码
					<text class="fr" @click="closeScanPopup()">关闭</text>
				</view>
				<view class="pop_tab">
					<view class="tab_info">
						<win-com-scan ref="comscan" @getScanResult="getScanResult" placeholder="工位码"
							:clearResult="true"></win-com-scan>
						<view class="uni-flex">
							<button class="clean_scan_btn" @click="cancelClick()">清空</button>
							<button class="scan_btn" @click="scanClick()">扫描</button>
						</view>
					</view>
				</view>
			</view>
		</uni-popup>
		<com-message ref="comMessage" @afterClose="getfocus"></com-message>
	</view>
</template>

<script>
	import winComScan from '@/mycomponents/wincom/winComScan.vue'
	import comMessage from '@/mycomponents/common/comMessage.vue'
	import {
		getPositionCodeInfo
	} from '@/api/index.js';
	import {
		getPositionCodeName
	} from '@/common/basic.js';
	

	export default {
		name: 'winScanByPack',
		components: {
			winComScan,
			comMessage
		},
		props: {
			title: {
				type: String,
				default: ''
			},
			codeType: {
				type: String,
				default: ""
			}
		},
		data() {
			return {
				scanResult: {},
				show: false,
			}
		},
		created() {

		},
		methods: {
			openScanPopup(content) {
				this.$refs.popup.open('bottom');
			},

			closeScanPopup(content) {
				this.$refs.popup.close();
				this.$emit("close", '');
			},

			scanClick() {
				this.$refs.comscan.handelScanMsg();
			},
			cancelClick() {
				this.$refs.comscan.clearScanValue();
			},

			getScanResult(result) {
				console.log("扫描",result.data.code)
				this.scanResult =result.data.code
				this.callBack()
				this.closeScanPopup()
			},


			callBack() {
				this.$refs.comscan.clear();
				this.$emit("getScanResult", this.scanResult);
			},
			getfocus() {
				if (this.$refs.comscan != undefined) {
					this.$refs.comscan.getfocus();
				}
			},
			losefocus() {
				if (this.$refs.comscan != undefined) {
					this.$refs.comscan.losefocus();
				}
			},
			showMessage(message) {
				this.$refs.comMessage.showMessage(message);
			},
			change(e) {
				this.show = e.show
			}
		}
	}
</script>

<style>
</style>
