<template>
  <div>
    <el-form-item label="权限管理：">
      <input class="fadeDom" v-model="form.permission" />
      <el-tree
        show-checkbox
        :default-expand-all="true"
        :default-checked-keys="form.resources"
        node-key="id"
        @check="handleCheck"
        @check-change="handleCheckChange"
        :data="form.permission"
        :props="defaultProps"
        @node-click="handleNodeClick"
      >
      </el-tree>
    </el-form-item>
  </div>
</template>

<script>
export default {
  props: ["data", "rule"],
  data() {
    let tmp = [];
    this.data.permission.forEach((item) => {
      if (item.authority) {
        tmp.push(item.id)
      }
    });

    this.data.resources = tmp;

    console.log(this.data.resources, 111111);

    return {
      form: this.data,
      defaultProps: {
        children: "children",
        label: "name",
      },
    };
  },
  methods: {
    handleCheckChange() {
      // console.log(data,data1,data2);
      // this.form.content = data
    },
    handleNodeClick() {},
    handleCheck(data, data1) {
      console.log(data1);
      this.form.resources = data1.checkedKeys;
    },
  },
  mounted() {},
};
</script>
