Blame view

public/components/frame/orgTreeShow/orgTreeShow.js 2.94 KB
809d9ffa   wuxw   流程设计页面组件没法和vue兼容只...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
  /**
   入驻小区
   **/
  (function (vc) {
      vc.extends({
          propTypes: {
              callBackListener: vc.propTypes.string, //父组件名称
          },
          data: {
              orgTreeShowInfo: {
                  orgs: [],
                  orgId: '',
                  curOrg: {}
              }
          },
          _initMethod: function () {
              $that._loadOrgsShow();
          },
          _initEvent: function() {
              vc.on('orgTreeShow', 'refreshTree', function() {
                  $that._loadOrgsShow();
              })
          },
          methods: {
              _loadOrgsShow: function () {
                  let param = {
                      params: {
                          communityId: vc.getCurrentCommunity().communityId
                      }
                  };
                  //发送get请求
                  vc.http.apiGet('/org.listOrgTree',
                      param,
                      function (json) {
                          let _orgs = JSON.parse(json).data;
                          $that.orgTreeShowInfo.orgs = _orgs;
                          $that._initJsTreeOrgShow();
                      },
                      function () {
                          console.log('请求失败处理');
                      });
              },
              _initJsTreeOrgShow: function () {
                  let _data = $that.orgTreeShowInfo.orgs;
                  if ($.jstree) {
                      $.jstree.destroy()
                  }
  
                  $("#jstree_org_show").jstree({
                      "checkbox": {
                          "keep_selected_style": false
                      },
                      'state': { //一些初始化状态
                          "opened": true,
                      },
                      // 'plugins': ['contextmenu'],
                      'core': {
                          'data': _data
                      },
                  });
                  $("#jstree_org_show").on("ready.jstree", function (e, data) {
                      data.instance.open_all(); //打开所有节点
                  });
                  $('#jstree_org_show').on("changed.jstree", function (e, data) {
                      if (data.action == 'model' || data.action == 'ready') {
                          //默认合并
                          //$("#jstree_org").jstree("close_all");
                          return;
                      }
                      $that.orgTreeShowInfo.curOrg = data.node.original;
                      $that.orgTreeShowInfo.curOrg.orgId = $that.orgTreeShowInfo.curOrg.id;
                      vc.emit($props.callBackListener, 'switchOrg', {
                          orgId: data.node.original.id,
                          orgName: $that.orgTreeShowInfo.curOrg.text
                      })
                  });
                  // $('#jstree_org')
                  //     .on('click', '.jstree-anchor', function(e) {
                  //         $(this).jstree(true).toggle_node(e.target);
                  //     })
              },
          }
      });
  })(window.vc);