<template>
  <div style="margin-top: 10px;">
    <el-table :data="props.list" border style="width: 100%">
      <el-table-column prop="name" align="center" label="用户名">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;justify-content: 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="name" align="center" label="酒品名">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;justify-content: center;">
            <el-image style="width: 40px; height: 40px" :src="scope.row.imgUrl" fit="contain" />
            {{ scope.row.name }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="name" align="center" label="数量">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;justify-content: center;">
            {{ scope.row.num }} {{ scope.row.unit }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="savTime" align="center" label="存酒时间" />
      <el-table-column prop="expTime" align="center" label="到期时间" />
      <el-table-column label="状态" align="center" prop="status">
        <template #default="scope">
          <el-tag type="info">{{
            scope.row.status == 0 ? '已取完' : scope.row.status === 1 ? '未取完' : '已过期'
          }}</el-tag>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-button size="small" type="primary" link @click="handleEdit(scope.row)">查看记录</el-button>
          <el-button size="small" :type="scope.row.status == 1 ? 'primary' : 'info'" link
            @click="handleDelete(scope.row)">{{ scope.row.status == 0 ? '已取完'
              : scope.row.status === 1 ? '取酒' : '已过期' }}</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(row) {
  if (row.status == 1) {
    emit('handleDelete', row)
  }
}

</script>
