<template>
  <j-modal
    :title="title"
    :width="width"
    :visible="visible"
    switchFullscreen
    @ok="handleOk"
    :okButtonProps="{ class: { 'jee-hidden': disableSubmit } }"
    @cancel="handleCancel"
    cancelText="关闭"
  >
    <a-card :bordered="false">
      <a-tabs default-active-key="1" @tabClick="tabClick">
        <a-tab-pane key="1">
          <span slot="tab"> 会员 </span>
          <bus-member-card-list
            :couponsId="couponsId"
            :couponsType="couponsType"
            ref="busMemberCardList"
            @ok="submitCallback"
          ></bus-member-card-list>
        </a-tab-pane>
        <a-tab-pane key="2">
          <span slot="tab"> 非会员 </span>
          <mobile-form
            :couponsId="couponsId"
            :couponsType="couponsType"
            ref="mobileForm"
            @ok="submitCallback"
          ></mobile-form>
        </a-tab-pane>
      </a-tabs>
    </a-card>
  </j-modal>
</template>

<script>
import BusMemberCardList from "./BusMemberCardList";
import MobileForm from "./MobileForm";
export default {
  components: {
    BusMemberCardList,
    MobileForm,
  },
  props: {
    couponsId: {
      type: String,
      default: "",
    },
    couponsType: {
      type: Number,
      default: 1,
    },
  },
  data() {
    return { title: "", width: 1200, visible: false, disableSubmit: false };
  },
  methods: {
    tabClick(e) {
      this.disableSubmit = e !== '2';
    },
    close() {
      this.$emit("close");
      this.visible = false;
    },
    handleOk() {
      this.$refs.mobileForm.submitForm();
    },
    submitCallback() {
      console.log("submitCallback");
      this.$emit("ok");
      this.visible = false;
    },
    handleCancel() {
      this.close();
    },
  },
};
</script>

<style scoped>
</style>
