<template>
	<uni-popup ref="popup">
		<view class="maskbox" @tap="maskClick"></view>
		<view class="uni-flex uni-column center"
			style="background-color: white;width: 200px; height:auto;padding: 20rpx;z-index: 99;position: relative;">
			<view class="uni-flex space-between u-col-center" style="width: 100%;">
					<view class="" style="font-size: 32rpx;">
						只看当天
					</view>
					
				<u-switch v-model="checkedToday" active-color="#4DD865" inactive-color="#eee" size="35" @change="switchChangeToday"></u-switch>	
			</view>
			<view class="uni-flex space-between u-col-center" style="width: 100%;margin-top: 30rpx;">
				
				<view class="" style="font-size: 32rpx;">
					只看待处理
				</view>
				<u-switch v-model="checkedWaitTask" active-color="#4DD865" inactive-color="#eee" size="35" @change="switchChangeWait"></u-switch>	
			</view>
			<view class="">
				<view class="uni-flex u-row-center" style="margin-top: 30rpx;" v-if="isShowAsn">
					<button class="filter_button" hover-class="filter_button_after"
						@click="scanOtherClick">扫描ASN单号</button>
				</view>
				<view class="uni-flex u-row-center" style="margin-top: 30rpx;">
					<button class="filter_button" hover-class="filter_button_after"
						@click="scanNumberClick">扫描任务编号</button>
				</view>
			</view>
		</view>
	</uni-popup>
	<win-scan-job-number ref="scanNumber" title="任务编号" @getScanCode='getScanNumber'></win-scan-job-number>
	<win-scan-asn-number ref="scanAsnNumber" :title="otherTitle" @getScanCode='getScanAsNumber'></win-scan-asn-number>
</template>

<script>
	import {
		getTodayDate
	} from '@/common/basic.js';

	import winScanJobNumber from "@/mycomponents/scan/winScanJobNumber.vue"
	import winScanAsnNumber from "@/mycomponents/scan/winScanAsnNumber.vue"

	export default {
		emits: ["switchChangeToday", "switchChangeWait", "onScanNumber", "onScanAsnNumber"],
		components: {
			winScanJobNumber,
			winScanAsnNumber
		},
		data() {
			return {
				dataContent: {},
			}
		},
		props: {
			checkedToday: {
				type: Boolean,
				default: false
			},
			checkedWaitTask: {
				type: Boolean,
				default: false
			},
			otherTitle: {
				type: String,
				default: ""
			},
			isShowAsn:{
				type: Boolean,
				default: false
			}
		},
		watch: {
		},
		mounted() {
			
		},
		methods: {
			// 点击遮罩
			maskClick() {
				// 如果不允许点击遮罩，直接返回
				this.closeScanPopup();
			},
			openFilter() {
				this.$refs['popup'].open("right");
			},
			closeScanPopup() {
				this.$refs.popup.close()
			},
			switchChangeToday(isOn) {
				
				let creationTime = '';
				if (isOn) {
					creationTime = getTodayDate();
				}
				
				this.$emit("switchChangeToday", isOn, creationTime)
				this.closeScanPopup()
			},
			switchChangeWait(isOn) {
				let status = "1,2";
				if(isOn){
					status="1"
				}
				this.$emit("switchChangeWait", isOn, status)
				this.closeScanPopup()
			},

			scanNumberClick() {
				this.$refs.scanNumber.openScanPopup();
			},

			scanOtherClick() {
				this.$refs.scanAsnNumber.openScanPopup();
			},

			getScanAsNumber(val) {
				this.$emit("onScanAsnNumber", val)
				this.$refs.scanAsnNumber.closeScanPopup();
				this.closeScanPopup();
			},
			getScanNumber(val) {
				this.$emit("onScanNumber", val)
				this.$refs.scanNumber.closeScanPopup();
				this.closeScanPopup();
			},
		}
	}
</script>
<style lang="scss">
	.maskbox {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		height: 100vh;
		z-index: 0;
	}
</style>
