<template>
  <MegaSplitPanes class="factory-page">
    <MegaSplitPane size="18">
      <a-tree
        v-if="treeData.length"
        :tree-data="treeData"
        :default-expand-all="true"
        :replace-fields="{
          children: 'children',
          key: 'id',
          value: 'id',
          title: 'label',
        }"
      />
      <div v-else>
        {{ $t("NO_DATA") }}
      </div>
    </MegaSplitPane>
    <MegaSplitPane size="82">
      <slot name="page-table" />
    </MegaSplitPane>
  </MegaSplitPanes>
</template>

<script>
import { SplitPanes as MegaSplitPanes } from "@mega-design/ui-vue";
import ApiConstant from "@/api/ApiConstant";

export default {
  name: "Factorypage",
  components: {
    MegaSplitPanes,
    MegaSplitPane: MegaSplitPanes.Pane,
  },
  data() {
    return {
      treeData: [],
    };
  },
  mounted() {
    this.getTreeData();
  },
  methods: {
    // 获取返回数据
    getTreeData() {
      this.$axios
        .get(`${ApiConstant.PREFIX_CORE}/api/mdm/fac-model/tree`)
        .then((res) => {
          this.treeData = res.data.data;
        });
    },
  },
};
</script>

<style lang="less">
.factory-page {
  position: absolute;
}
</style>
