<template>
  <Dialog
    :title="title"
    :visible="dialogVisible"
    width="70%"
    @change-visible="changeVisible"
  >
    <DialogTabs
      :tabList="tabList"
      :currentTab="currentTabNow"
      @change="(val) => changeTab(val)"
      v-if="tabName == 'ZLPD'"
    ></DialogTabs>
    <component :is="currentTabNow" :data="data" :tabnamenow="tabName"></component>
  </Dialog>
</template>
<script>
import ZLPD from "./ZLJCPD.vue";
import ZLJC from "./ZLJC.vue";
import sgqx from "./SGQX.vue";
export default {
  name: "GCZLIndex",
  components: { ZLPD, ZLJC, sgqx },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    data: {
      type: Object,
      default: () => {
        return {};
      },
    },
    tabList: {
      type: Array,
      default: () => {
        return [];
      },
    },
    tabName:{
      type: String,
      default: ''
    },
    title:{
      type: String,
      default: ''
    }
  },
  data() {
    return {
      // tabList: [
      //   { name: "ZLPD", label: "质量评定" },
      //   { name: "ZLJC", label: "质量检测" },
      // ],
      currentTabNow: "",
    };
  },
  computed: {
    dialogVisible: {
      get() {
        return this.visible;
      },
      set(val) {
        this.$emit("change-visible", val);
      },
    },
  },
  methods: {
    changeTab(e) {
      this.currentTabNow = e;
    },
    changeVisible(val) {
      this.dialogVisible = val;
    },
  },
  mounted() {
    this.$eventBus.$on("switchTabGC", (type) => {
      this.$nextTick(() => {
        this.currentTabNow = type;
      });
    });
  },
  watch: {
    dialogVisible(val) {
      if (val) {
        this.currentTabNow = this.tabName;
      } else {
        this.currentTabNow = "";
      }
    },
  },
};
</script>
  <style lang="less" scoped>
</style>