<template>
  <div class="default-main ba-table-box">
    <el-alert class="ba-table-alert" v-if="baTable.table.remark" :title="baTable.table.remark" type="info"
              show-icon />
    <el-row>
      <el-col :span="24">
        <!-- 表格顶部菜单 -->
        <TableHeader :buttons="['refresh', 'add', 'edit', 'delete', 'comSearch']"
                     quick-search-placeholder="通过标题模糊搜索"
                     @action="baTable.onTableHeaderAction" />
        <!-- 表格 -->
        <!-- 要使用`el-table`组件原有的属性，直接加在Table标签上即可 -->
        <Table @action="baTable.onTableAction" />

      </el-col>
    </el-row>


  </div>
</template>

<script setup lang="ts">
import { ref, onMounted, provide } from "vue";
import { couponHistory } from "/@/api/controllerUrls";
import Table from "/@/components/table/index.vue";
import TableHeader from "/@/components/table/header/index.vue";
import { defaultOptButtons } from "/@/components/table";
import { baTableApi } from "/@/api/common";
import baTableClass from "/@/utils/baTable";


const tableRef = ref();
const baTable = new baTableClass(
  new baTableApi(couponHistory),
  {
    dblClickNotEditColumn: [undefined, "status"],
    column: [
      { type: "selection", align: "center", operator: false },
      { label: "优惠卷", prop: "couponName", align: "center", operator: "LIKE" },
      { label: "商品", prop: "goodsName", align: "center", operator: "LIKE" },
      { label: "用户", prop: "memberName", align: "center", operator: "LIKE" },
      { label: "头像", prop: "headPortrait", align: "center", render: "image", operator: false },
      { label: "订单编号", prop: "usedOrderId", align: "center", operator: "LIKE" },
      { label: "实际支付金额", prop: "actualAmount", align: "center", operator: false },
      { label: "优惠金额", prop: "discountAmount", align: "center", operator: false },
      { label: "使用时间", prop: "usedTime", align: "center", operator: "LIKE" }

    ]
  },
  {
    defaultItems: {}
  },
  {
    // 获得编辑数据后
    requestEdit: () => {
      if (baTable.form.items && !baTable.form.items.icon) baTable.form.items.icon = "el-icon-Minus";
    }
  }
);

provide("baTable", baTable);

onMounted(() => {
  baTable.mount();
  baTable.getIndex();
});
</script>


<style scoped lang="scss"></style>
