<template>
  <div>
    <el-tabs
      v-model="activeName"
      @tab-click="handleClick"
      style="margin-bottom: 20px"
    >
      <el-tab-pane label="堤防基本信息" name="basePage" :lazy="true">
        <basePage ref="basePage" :baseData="baseData" />
      </el-tab-pane>
      <el-tab-pane
        label="工程管理"
        name="projectManagement"
        :disabled="!routeList[1].isEdit"
        :lazy="true"
      >
        <projectManagement
          ref="projectManagement"
          :projectManagementData="projectManagementData"
        />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>
<script>
import basePage from "./basePage.vue";
import projectManagement from "./projectManagement.vue";
export default {
  components: {
    basePage,
    projectManagement,
  },
  props: ["baseData", "projectManagementData"],
  inject: ["granParentEle"],
  data() {
    return {
      activeName: "basePage",
      routeList: [],
      formData: {},
    };
  },
  created() {
    console.log("this.baseData in compare", this.baseData);
    this.routeList = JSON.parse(this.$store.state.basePageData.routeList);
    // this.getList();
  },
  watch: {
    baseData: function (n, o) {
      this.baseData = n;
    },
  },
  methods: {
    goCompare() {
      this.$router.push({
        path:
          "/sluice/engineeringCondition/sluiceCompare?embankmentCode=" +
          this.$refs.basePage.copyForm.embankmentCode,
      });
    },
    goBack() {
      this.$router.back();
    },
    // getList() {
    //   const id = this.$route.query.baseDataId;
    //   getSluiceInfo(id).then((response) => {
    //     this.formData = response.data;
    //     // console.log("this.formData", this.formData);
    //   });
    // },
    // 切换标签页
    handleClick(tab, event) {
      const childrenEles = Object.keys(this.granParentEle);
      for (let index = 0; index < childrenEles.length; index++) {
        // console.log(33333333, childrenEles[index]);
        this.granParentEle[childrenEles[index]].activeName = tab.name;
      }
      // this.getList();
      // console.log("切换标签页", tab, event);
      // console.log("切换标签页", this.routeList[1].routeName);
      this.routeList[1].routeName = tab.label;
      // console.log(
      //   "this.$refs.basePage.copyForm.embankmentCode",
      //   this.$refs.basePage.copyForm.embankmentCode
      // );
    },
  },
};
</script>
<style lang="scss" scoped>
// .app-container {
//   border: 1px solid #000;
// }
</style>
