<template>
  <a-card :bordered="false">
    <!-- 操作按钮区域 -->
    <div class="table-operator">
      <a-button @click="handleAdd" type="primary" icon="plus">新增</a-button>
    </div>

    <!-- table区域-begin -->
    <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="typeSlot" slot-scope="text, record">
          {{  record.type==1?'优惠券':'免房券'}}
        </template>
        <template slot="imgSlot" slot-scope="text, record">
          <span v-if="!text" style="font-size: 12px; font-style: italic"
            >无图片</span
          >
          <img
            v-else
            :src="getImgView(text)"
            :preview="record.id"
            height="25px"
            alt=""
            style="max-width: 80px; font-size: 12px; font-style: italic"
          />
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px; font-style: italic"
            >无文件</span
          >
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)"
          >
            下载
          </a-button>
        </template>

        <span slot="action" slot-scope="text, record">
          <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-detail-modal
      ref="modalForm"
      @ok="modalFormOk"
    ></bus-market-coupons-event-detail-modal>
  </a-card>
</template>

<script>
import "@/assets/less/TableExpand.less";
import { mixinDevice } from "@/utils/mixin";
import { JeecgListMixin } from "@/mixins/JeecgListMixin";
import BusMarketCouponsEventDetailModal from "./BusMarketCouponsEventDetailModal";

export default {
  name: "BusMarketCouponsEventDetailList",
  mixins: [JeecgListMixin, mixinDevice],
  components: {
    BusMarketCouponsEventDetailModal,
  },
  props: {
    eventId: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      description: "bus_market_coupons_event_detail_info管理页面",
      // 表头
      columns: [
        {
          title: "门店",
          align: "center",
          dataIndex: "hotelName",
        },
        {
          title: "会员等级",
          align: "center",
          dataIndex: "levelName",
        },
        {
          title: "券类型",
          align: "center",
          dataIndex: "type",
          scopedSlots: { customRender: "typeSlot" },
        },
        {
          title: "券名称",
          align: "center",
          dataIndex: "couponsName",
        },
        {
          title: "数量",
          align: "center",
          dataIndex: "count",
        },
        {
          title: "操作",
          dataIndex: "action",
          align: "center",
          fixed: "right",
          width: 147,
          scopedSlots: { customRender: "action" },
        },
      ],
      url: {
        list: "/business/busMarketCouponsEventDetail/list?eventId=" + this.eventId,
        delete: "/business/busMarketCouponsEventDetail/delete",
        deleteBatch: "/business/busMarketCouponsEventDetail/deleteBatch",
        exportXlsUrl: "/business/busMarketCouponsEventDetail/exportXls",
        importExcelUrl: "business/busMarketCouponsEventDetail/importExcel",
      },
      dictOptions: {},
      superFieldList: [],
      // eventId: "",
    };
  },
  created(e) {
    // this.getSuperFieldList();

  },
  computed: {
    importExcelUrl: function () {
      return `${window._CONFIG["domianURL"]}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    add(eventId) {
      // this.eventId = eventId;

      // this.loadData();
    },
    handleAdd() {
      console.log("eventId", this.eventId);
      this.$refs.modalForm.add(this.eventId);
      this.$refs.modalForm.title = "新增";
      this.$refs.modalForm.disableSubmit = false;
    },
    initDictConfig() {},
    getSuperFieldList() {
      let fieldList = [];
      fieldList.push({ type: "string", value: "tenantId", text: "关联租户" });
      fieldList.push({ type: "string", value: "hotelId", text: "关联酒店" });
      fieldList.push({ type: "string", value: "eventId", text: "关联事件" });
      fieldList.push({ type: "string", value: "levelId", text: "关联会员" });
      fieldList.push({
        type: "string",
        value: "couponsCashId",
        text: "关联卷",
      });
      fieldList.push({
        type: "int",
        value: "type",
        text: "类型（1-优惠卷；3-免房卷）",
      });
      fieldList.push({ type: "int", value: "count", text: "赠送数量" });
      this.superFieldList = fieldList;
    },
  },
};
</script>
<style scoped>
@import "~@assets/less/common.less";
</style>