<!--
 * @Author: chris
 * @Date: 2025-08-08 16:17:54
 * @LastEditors: chris
 * @LastEditTime: 2025-12-08 16:37:07
-->
<template>
  <el-table
    v-loading="loading"
    :data="list"
    @selection-change="handleSelectionChange"
    border
    highlight-current-row
    style="width: 100%"
  >
    <el-table-column type="selection" width="50" align="center" />
    <el-table-column label="标题" align="center" prop="title" v-if="columns[0].visible" :show-overflow-tooltip="true" />
    <el-table-column label="类型" align="center" prop="type" v-if="columns[1].visible">
      <template #default="scope">
        <span>{{ selectDictLabel(props.types, scope.row.type) }}</span>
      </template>
    </el-table-column>
    <el-table-column label="内容" align="center" prop="content" :show-overflow-tooltip="true" v-if="columns[2].visible" />
    <el-table-column label="创建时间" align="center" prop="createTime" v-if="columns[3].visible">
      <template #default="scope">
        <span>{{ parseTime(scope.row.createTime) }}</span>
      </template>
    </el-table-column>
    <el-table-column label="操作" align="center" fixed="right">
      <template #default="scope">
        <!-- <el-tooltip content="查看" placement="top">
          <el-button link type="primary" icon="Eye" @click="handleView(scope.row)" v-hasPermi="['business:orchard:query']"></el-button>
        </el-tooltip> -->
        <el-tooltip content="修改" placement="top">
          <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['business:orchard:edit']"></el-button>
        </el-tooltip>
        <el-tooltip content="删除" placement="top">
          <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['business:orchard:remove']"></el-button>
        </el-tooltip>
      </template>
    </el-table-column>
  </el-table>
</template>

<script setup>
import { parseTime, selectDictLabel } from '@/utils/ruoyi'
import { statusColorMap } from '../config'

const props = defineProps({
  list: { type: Array, required: true },
  loading: { type: Boolean, required: true },
  columns: { type: Array, required: true },
  types: { type: Array, required: true }
})

const emits = defineEmits(['selection-change', 'view', 'update', 'delete'])

function handleSelectionChange(selection) {
  emits('selection-change', selection)
}

function handleUpdate(row) {
  emits('update', row)
}

function handleDelete(row) {
  emits('delete', row)
}
</script>