<template>
  <div style="margin-top: 10px;">
    <el-table :data="props.list" border style="width: 100%">
      <el-table-column prop="orderNo" align="center" label="订单编号" />
      <el-table-column prop="nickName" align="center" label="用户名">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;">
            <el-image style="width: 40px; height: 40px" :src="scope.row.avatarUrl" fit="contain" />
            {{ scope.row.nickName }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="pointsGoodsName" align="center" label="商品">
        <template v-slot="scope">
          <div style="display: flex;align-items: center;">
            <el-image style="width: 40px; height: 40px" :src="scope.row.goodsImageUrl" fit="contain" />
            {{ scope.row.pointsGoodsName }}
          </div>
        </template>
      </el-table-column>
      <el-table-column prop="spendPoints" align="center" label="消耗积分" />
      <el-table-column prop="extraPaymentAmount" align="center" label="支付金额" />
      <el-table-column prop="payMethod" align="center" label="支付方式" />
      <el-table-column prop="payTime" align="center" label="实际支付时间" />
      <el-table-column prop="createTime" align="center" label="下单时间" />
      <el-table-column prop="name" align="center" label="领取方式">
        <template v-slot="scope">
          <el-tag type="success" effect="plain" disable-transitions v-if="scope.row.pickupMethod == 'self'">自取</el-tag>
          <el-tag type="info" effect="plain" disable-transitions v-if="scope.row.pickupMethod == 'post'">邮寄
          </el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="status" align="center" label="状态">
        <template v-slot="scope">
          <el-tag type="warning" disable-transitions v-if="scope.row.status == 'waiting'">待自取</el-tag>
          <el-tag type="success" disable-transitions v-if="scope.row.status == 'done'">已完成</el-tag>
          <el-tag type="warning" disable-transitions v-if="scope.row.status == 'unpaid'">待支付</el-tag>
          <el-tag type="info" disable-transitions v-if="scope.row.status == 'cancel'">已取消</el-tag>
        </template>
      </el-table-column>
      <el-table-column prop="cancelOrRefundReason" align="center" label="取消/退款" />
      <el-table-column label="操作" align="center">
        <template #default="scope">
          <el-button size="small" type="primary" link icon="Finished" @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.couponCode)
}

</script>
