<script setup>
defineProps({
  action: String,
  info: Object
})

const tab = ref('locator')
const tabs = ref([
  {value: 'locator', text: 'Locator'},
  {value: 'replenish', text: 'Replenish'},
  {value: 'accounting', text: 'Accounting'},
])

const openTab = async (val) => {
  if(tab.value !== val) {
    tab.value = val
    sessionStorage.setItem('warehouse_detail_record', tab.value)
  }
}
onMounted(() => {
  const getSessionStorageTab = sessionStorage.getItem('warehouse_detail_record')
  if(getSessionStorageTab) {
    openTab(getSessionStorageTab)
  }
})
</script>

<template>
  <div class="bt-2px_dashed_hexe2e2e2">
    <DetailRecordTab v-model="tab" :tabs="tabs" @handler="(val) => openTab(val.value)" />
    <MaterialsWarehouseDetailRecordLocator v-if="tab === 'locator'" :action="action" :info="info" />
    <MaterialsWarehouseDetailRecordReplenish v-else-if="tab === 'replenish'" :action="action" :info="info" />
    <MaterialsWarehouseDetailRecordAccounting v-else-if="tab === 'accounting'" :action="action" :info="info" />
  </div>
</template>