<template>
	<furniture-reception-impl :incomingTab="incomingTab" :receptionPrefill="receptionPrefill" />
</template>

<script>
import FurnitureReceptionImpl from './furniture_reception-impl.vue';

/** 与 CustomerList 写入的 key 一致：客户管理「准备接待」预填开始接待表单 */
const RECEPTION_FORM_PREFILL_KEY = 'workbench-reception-form-prefill';

export default {
	name: 'FurnitureReceptionEntry',
	components: {
		FurnitureReceptionImpl,
	},
	data() {
		return {
			incomingTab: '',
			receptionPrefill: null,
		};
	},
	onLoad(options = {}) {
		const allowed = ['status', 'reception', 'tag'];
		const raw = options.tab != null ? String(options.tab) : '';
		this.incomingTab = allowed.includes(raw) ? raw : 'reception';
		try {
			const rawPrefill = uni.getStorageSync(RECEPTION_FORM_PREFILL_KEY);
			if (!rawPrefill) {
				return;
			}
			try {
				const parsed = typeof rawPrefill === 'string' ? JSON.parse(rawPrefill) : rawPrefill;
				if (parsed && typeof parsed === 'object') {
					this.receptionPrefill = parsed;
				}
			} catch (parseErr) {
				console.warn('[FurnitureReceptionEntry] 接待表单预填 JSON 无效:', parseErr);
			} finally {
				uni.removeStorageSync(RECEPTION_FORM_PREFILL_KEY);
			}
		} catch (e) {
			console.warn('[FurnitureReceptionEntry] 读取接待表单预填失败:', e);
		}
	},
};
</script>
