import { getRoleAll } from '@/api/system/role/index'
import { ref, reactive } from 'vue'
const rolesOptions = ref([])

export const search = reactive({
  search: [
    {
      label: '用户账号',
      key: 'username',
      props: {
        placeholder: '请输入用户账号'
      }
    },
    {
      label: '用户姓名',
      key: 'realname',
      props: {
        placeholder: '请输入用户姓名'
      }
    },
    {
      label: '用户角色',
      type: 'select',
      key: 'roleId',
      props: {
        placeholder: '请选择用户角色',
        options: rolesOptions
      }
    }
  ]
})

export const fetchRolesOption = async function() {
  const res = await getRoleAll()
  rolesOptions.value = res.data.map((item) => { return { key: item.id, label: item.name } })
}
