<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { get } from '@/api/request'
import { ElMessage, ElMessageBox } from 'element-plus'

const loading = ref(false)
const list = ref<any[]>([])

async function fetchData() {
  loading.value = true
  try {
    const res = await get('/api/dictionaries')
    list.value = Array.isArray(res) ? res : []
  } catch { list.value = [] } finally { loading.value = false }
}

onMounted(() => fetchData())
</script>

<template>
  <div>
    <h2 style="margin-bottom:16px">字典管理</h2>
    <el-card>
      <el-table :data="list" v-loading="loading" stripe>
        <el-table-column prop="id" label="ID" width="80" />
        <el-table-column prop="type" label="字典类型" width="160" />
        <el-table-column prop="code" label="编码" width="160" />
        <el-table-column prop="name" label="字典名称" width="160" />
        <el-table-column prop="value" label="值" />
      </el-table>
    </el-card>
  </div>
</template>
