<template>
  <el-select v-model="roleId" filterable @change="handleChangeRole" style="width: 150px">
    <el-option v-for="item in options" :key="item.id" :label="item.name" :value="item.id" />
  </el-select>
</template>

<script setup name="RoleSelect">
import { useUserStore } from '@/store/modules/user'
import { getInfo } from '@/api/login/index'

const userStore = useUserStore()

const options = computed(() => {
  return userStore.getRoles
})
const roleId = ref(userStore.getUser.currentRole)

function handleChangeRole(val) {
  getInfo({ roleId: val }).then(() => {
    userStore.refresh()
  })
}
</script>

<style lang="scss" scoped></style>
