<!-- 设备借用处理 -->
<script lang="ts" setup name="borrowApply">
import list from './components/handleList.vue'
export interface menuType {
  name: string
  comp: any
}
const menu = shallowRef<menuType[]>([
  { name: '待借用', comp: list },
  { name: '已借用', comp: list },
  { name: '已归还', comp: list },
])
const current = ref('待借用')
const currentComp = shallowRef(list)
watch(current, (newValue) => {
  currentComp.value = menu.value.filter(item => item.name === newValue)[0].comp
})
onUnmounted(() => {
  sessionStorage.setItem('deviceBorrowHandler', current.value)
})
onMounted(() => {
  current.value = sessionStorage.getItem('deviceBorrowHandler') || '待借用'
  sessionStorage.getItem('deviceBorrowHandler') ? sessionStorage.removeItem('deviceBorrowHandler') : ''
})
</script>

<template>
  <div class="container">
    <div class="btns">
      <!-- 三级菜单 -->
      <el-radio-group v-model="current">
        <el-radio-button v-for="item in menu" :key="item.name" :label="item.name">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
    </div>
    <!-- 展示区域 -->
    <component :is="currentComp" :status="current" />
  </div>
</template>

<style lang="scss" scoped>
.container {
  position: relative;

  .btns {
    position: fixed;
    top: 67px;
    right: 15px;
    z-index: 999;
  }
}
</style>
