<template>
  <div class="tag-management">
    <div class="action-bar">
      <el-button type="primary" @click="showCreateDialog">+ 新增标签</el-button>
      <el-input 
        v-model="searchKeyword" 
        placeholder="搜索标签..."
        style="width: 300px"
        clearable
      />
    </div>

    <el-table :data="tags" style="width: 100%">
      <el-table-column prop="name" label="标签名称" min-width="150" />
      <el-table-column prop="category" label="标签分类" width="120" />
      <el-table-column prop="color" label="颜色" width="100">
        <template #default="{ row }">
          <div class="color-preview" :style="{ background: row.color }"></div>
        </template>
      </el-table-column>
      <el-table-column prop="usageCount" label="使用次数" width="100" />
      <el-table-column prop="createDate" label="创建时间" width="150" />
      <el-table-column label="操作" width="180" fixed="right">
        <template #default="{ row }">
          <el-button size="small" @click="editTag(row)">编辑</el-button>
          <el-button size="small" type="danger" @click="deleteTag(row)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { ElButton, ElInput, ElTable, ElTableColumn, ElMessage } from 'element-plus';

const searchKeyword = ref('');
const tags = ref<any[]>([]);

onMounted(() => {
  loadTags();
});

function loadTags() {
  // TODO: 加载标签数据
}

function showCreateDialog() {
  // TODO: 显示创建标签对话框
}

function editTag(row: any) {
  // TODO: 编辑标签
}

function deleteTag(row: any) {
  // TODO: 删除标签
  ElMessage.success('删除成功');
}
</script>

<style lang="scss" scoped>
.tag-management {
  padding: 20px;
}

.action-bar {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
  align-items: center;
}

.color-preview {
  width: 40px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
}
</style>

