<template>
  <div style="margin-top: 10px;">
    <el-table :data="props.list" border style="width: 100%">
      <el-table-column prop="date" align="center" label="Date" />
      <el-table-column prop="name" align="center" label="Name">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;">
            <el-image style="width: 40px; height: 40px" :src="scope.row.headImg" fit="contain" />
            {{ scope.row.nickName }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="status" align="center" label="状态">
        <template #default="scope">
          <el-tag :type="scope.row.status === 1 ? 'success' : 'danger'">{{ scope.row.status === 1 ? '上架' : '下架'
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="address" align="center" label="Address" />
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-button size="small" type="primary" link icon="Edit" @click="handleEdit(scope.row)">编辑</el-button>
          <el-button size="small" type="danger" link icon="Delete" style="color: #f89797;"
            @click="handleDelete(scope.$index, scope.row)"> 删除 </el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script setup>
const emit = defineEmits(['handleDelete', 'handleEdit'])
const props = defineProps({
  list: {
    type: Array,
    default: () => []
  }
})

function handleEdit(row) {
  emit('handleEdit', row)
}
function handleDelete(index, row) {
  emit('handleDelete', row.id)
}

</script>
