deptTreeP.vue 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <template>
  2. <div class="treebox">
  3. <el-tree ref="tree" @node-expand="handleNodeClick" @node-click="handleCheckChange" :data="treeList" node-key="o"
  4. :default-checked-keys="defaultListc" :default-expanded-keys="defaultList"></el-tree>
  5. </div>
  6. </template>
  7. <script>
  8. export default {
  9. props: ["defaultList","type"],
  10. data() {
  11. return {
  12. treeList: [],
  13. opt: [],
  14. defaultProps: {
  15. children: 'children',
  16. label: 'label'
  17. },
  18. defaultListc:[]
  19. };
  20. },
  21. methods: {
  22. getTree(v) {
  23. this.$http({
  24. url: "/sysmgr/csysdept/queryAllList",
  25. method: "post",
  26. headers: {
  27. "Content-Type": "application/json",
  28. },
  29. data: {
  30. parentorgid: v
  31. },
  32. }).then((res) => {
  33. this.treeList = res.data;
  34. });
  35. },
  36. handleCheckChange(v) {
  37. let opt = [{
  38. id:v.id,
  39. o:v.o,
  40. ou:v.ou,
  41. displayname:v.displayname
  42. }];
  43. this.$emit("treeCheck",opt)
  44. },
  45. },
  46. mounted() {},
  47. created() {
  48. this.getTree();
  49. this.defaultListc = this.defaultList;
  50. },
  51. watch:{
  52. type(){
  53. this.defaultListc = this.defaultList;
  54. }
  55. }
  56. };
  57. </script>
  58. <style scoped lang="scss">
  59. .treebox {
  60. border: 1px solid #ddd;
  61. }
  62. </style>