<template>
	<dialog-base ref="baseDialog" title="请选择序检批次">
		<view>
			<uni-section title="批次" type="line">
				<uni-data-select v-model="selectedLot" :localdata="lotList" :clear="false"
					@change="handleLotChange"></uni-data-select>
			</uni-section>
		</view>

		<view class="add-btn-container uni-row">
			<button type="primary" class="btn" @click="handleStart">确定</button>
		</view>
	</dialog-base>
</template>

<script setup>
	import {
		ref
	} from 'vue'
	import {
		onLoad
	} from '@dcloudio/uni-app'
	import {
		store
	} from '@/store/index.js'

	const baseDialog = ref(null)
	const selectedLot = ref("")
	const lotList = ref([])
	const emit = defineEmits(['handleSelectProcessInspection'])


	// onLoad(() => {

	// })

	function open(data) {
		lotList.value = data.map(v => ({
			text: v.lotCode,
			value: v.lotCode,
		}))

		baseDialog.value.open();
	}

	function handleLotChange() {
		console.log("选中", selectedLot.value);
	}

	function handleStart() {
		emit('handleSelectProcessInspection', selectedLot.value);
		close()
	}

	function close() {
		baseDialog.value.close()
	}

	defineExpose({
		open
	})
</script>

<style lang="scss">
	.dialog-body {
		.equipment-container {
			height: 300rpx;
			overflow: auto;
			flex-wrap: wrap;
			justify-content: flex-start;
			margin: 24rpx 0 0 7%;

			.item {
				width: 236rpx;
				height: 60rpx;
				text-align: center;
				line-height: 60rpx;
				border-radius: 6rpx;
				margin: 16rpx;
				flex: 0 0 40%;
				border: 1px solid #000000;
			}

			.selected {
				background-color: #1684fc;
				color: #FFF;
			}
		}

		.add-btn-container {
			margin-top: 32rpx;

			.btn {
				flex: 1;
			}
		}

		.switch {
			font-size: 26rpx;
			align-items: center;
			justify-content: space-between;
			margin: 16rpx;
		}

		.userList {
			border: 1rpx solid #1684fc;
			border-radius: 8rpx;
			max-height: 300rpx;
			overflow: auto;
			width: 100%;

			.showUser {
				justify-content: flex-start;
				flex-wrap: wrap;

				.user {
					border: 1rpx solid #999;
					border-radius: 8rpx;
					width: 150rpx;
					height: 50rpx;
					text-align: center;
					line-height: 50rpx;
					margin: 10rpx;
					overflow: auto;
				}
			}
		}

		.selectedUserList {
			width: 100%;
			justify-content: flex-start;
			flex-wrap: wrap;

			.selectedUser {
				border: 1rpx solid #999;
				border-radius: 8rpx;
				width: 150rpx;
				height: 50rpx;
				text-align: center;
				line-height: 50rpx;
				margin: 20rpx 20rpx 0 0;
				justify-content: space-around;

			}
		}
	}
</style>