<!-- 列表页右上角按钮组 -->
<script lang="ts" setup name="ButtonBox">
import type { PropType } from 'vue'
import { ref } from 'vue'
import type { IMenu } from './buttonBox'

const props = defineProps({
  active: String,
  menu: {
    type: Array as PropType<IMenu[]>,
  },
})
const emits = defineEmits(['changeCurrentButton'])

const current = ref('') // 选中的按钮
watch(current, (newValue) => {
  if (newValue) {
    emits('changeCurrentButton', newValue)
  }
})
watch(() => props.active, (newValue) => {
  current.value = newValue!
})
</script>

<template>
  <div class="container">
    <div class="btns">
      <el-radio-group v-model="current">
        <el-radio-button v-for="item in menu" :key="item.id" :label="item.id">
          {{ item.name }}
        </el-radio-button>
      </el-radio-group>
    </div>
  </div>
</template>

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

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

