<template>
  <a-card :bordered="false">
    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline" @keyup.enter.native="searchQuery">
        <a-row :gutter="24">
          <a-col :span="6">
            <a-form-item label="事件名称">
              <j-input
                placeholder="事件名称"
                v-model="queryParam.name"
                style="width: 200px"
              ></j-input>
            </a-form-item>
          </a-col>
          <a-col :md="6" :sm="8">
            <span
              style="float: left; overflow: hidden"
              class="table-page-search-submitButtons"
            >
              <a-button type="primary" @click="searchQuery" icon="search"
                >查询</a-button
              >
              <a-button
                type="primary"
                @click="searchReset"
                icon="reload"
                style="margin-left: 8px"
                >重置</a-button
              >
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!-- 查询区域-END -->

    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
      <a-dropdown v-if="selectedRowKeys.length > 0">
        <a-button style="margin-left: 8px">
          批量操作 <a-icon type="down"
        /></a-button>
      </a-dropdown>
    </div>

    <!-- table区域-begin -->
    <div>
      <!-- <div class="ant-alert ant-alert-info" style="margin-bottom: 16px">
        <i class="anticon anticon-info-circle ant-alert-icon"></i> 已选择
        <a style="font-weight: 600">{{ selectedRowKeys.length }}</a
        >项
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div> -->

      <a-table
        ref="table"
        size="middle"
        :scroll="{ x: true }"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{
          selectedRowKeys: selectedRowKeys,
          onChange: onSelectChange,
        }"
        class="j-table-force-nowrap"
        @change="handleTableChange"
      >
        <template slot="timeslot" slot-scope="text, record, index">
          {{ record.startTime + "~" + record.endTime }}
        </template>
        <template slot="stateslot" slot-scope="text, record, index">
          {{ record.state == 1 ? "启用" : "禁用" }}
        </template>
        <span slot="action" slot-scope="text, record">
          <a @click="handleConfig(record)">配置</a>
          <a-divider type="vertical" />
          <a @click="handleEdit(record)">编辑</a>

          <a-divider type="vertical" />
          <a-dropdown>
            <a class="ant-dropdown-link">更多 <a-icon type="down" /></a>
            <a-menu slot="overlay">
              <a-menu-item>
                <a @click="handleDetail(record)">详情</a>
              </a-menu-item>
              <a-menu-item>
                <a-popconfirm
                  title="确定删除吗?"
                  @confirm="() => handleDelete(record.id)"
                >
                  <a>删除</a>
                </a-popconfirm>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </a-table>
    </div>
    <bus-market-coupons-event-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></bus-market-coupons-event-modal>
    <bus-market-coupons-event-detail-list-modal
      :eventId="eventId"
      ref="modalCouponsEventDetailList"
    ></bus-market-coupons-event-detail-list-modal>
  </a-card>
</template>
  
  <script>
import { JeecgListMixin } from "@/mixins/JeecgListMixin";
import BusMarketCouponsEventModal from "./modules/BusMarketCouponsEventModal";
import BusMarketCouponsEventDetailListModal from "./modules/BusMarketCouponsEventDetailListModal";
import { filterObj } from "@/utils/util";
import { getAction } from "@/api/manage";
export default {
  name: "marketRechargeList",
  mixins: [JeecgListMixin],
  components: {
    BusMarketCouponsEventModal,
    BusMarketCouponsEventDetailListModal,
  },
  data() {
    return {
      queryParam: {},
      // 分页参数
      ipagination: {
        current: 1,
        pageSize: 10,
        pageSizeOptions: ["10", "20", "30"],
        showTotal: (total, range) => {
          return range[0] + "-" + range[1] + " 共" + total + "条";
        },
        showQuickJumper: true,
        showSizeChanger: true,
        total: 0,
      },
      // 表头
      columns: [
        {
          title: "商家",
          align: "center",
          dataIndex: "hotelName",
        },
        {
          title: "事件名称",
          align: "center",
          dataIndex: "name",
        },
        {
          title: "事件类型",
          align: "center",
          dataIndex: "typeName",
        },
        {
          title: "有效期",
          align: "center",
          dataIndex: "startTime",
          scopedSlots: { customRender: "timeslot" },
        },
        {
          title: "状态",
          align: "center",
          dataIndex: "remarks",
          scopedSlots: { customRender: "stateslot" },
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: "action" },
        },
      ],
      url: {
        list: "/business/busMarketCouponsEvent/list",
        delete: "/business/busMarketCouponsEvent/delete",
        deleteBatch: "/business/busMarketCouponsEvent/deleteBatch",
        exportXlsUrl: "/business/busMarketCouponsEvent/exportXls",
        importExcelUrl: "/business/busMarketCouponsEvent/importExcel",
      },
      dictOptions: {},
      superFieldList: [],
      selectedRowKeys: [],
      isorter: {
        column: "createTime",
        order: "desc",
      },
      eventId: "",
    };
  },
  created() {},
  methods: {
    handleConfig(item) {
      this.eventId = item.id;
      this.$refs.modalCouponsEventDetailList.eventId = item.id;
      this.$refs.modalCouponsEventDetailList.visible = true;
      this.$refs.modalCouponsEventDetailList.title = "赠送明细";
      this.$refs.modalCouponsEventDetailList.add(item.id);
    },
  },
};
</script>
  <style scoped>
@import "~@assets/less/common.less";
</style>