<template >
  <div class="common-box">
    <funTree
      ref="funtree"
      :defaultMenu="[]"
      @commitMenu="commitMenu"
    />
  </div>
</template>

<script>
import { setFun, setButton } from "@/api/system/function";
import FunTree from "@/views/page/system/function/compontents/funTree";

export default {
  components: {
    FunTree,
  },
  data() {
    return {};
  },
  created() {},
  methods: {
    commitMenu(temp, type, statue) {
      if (type === "create") {
        if (statue == "menu") {
          setFun(temp).then((response) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            this.$refs.funtree.dialogFormVisible = false;
            this.$refs.funtree.getMenuData();
          });
        } else {
          setButton(temp).then((response) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            this.$refs.funtree.dialogFormVisible = false;
            this.$refs.funtree.getMenuData();
          });
        }
      } else {
        if (statue == "menu") {
          setFun(temp).then((response) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            this.$refs.funtree.dialogFormVisible = false;
            this.$refs.funtree.getMenuData();
          });
        } else {
          setButton(temp).then((response) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            this.$refs.funtree.dialogFormVisible = false;
            this.$refs.funtree.getMenuData();
          });
        }
      }
    },
  },
};
</script>

<style scoped>
</style>
