/** 入驻小区 **/ (function (vc) { vc.extends({ propTypes: { callBackListener: vc.propTypes.string, //父组件名称 }, data: { storeOrgTreeInfo: { orgs: [], orgId: '', curOrg: {} } }, _initMethod: function () { $that._loadOrgsShow(); }, _initEvent: function() { vc.on('storeOrgTree', 'refreshTree', function() { $that._loadOrgsShow(); }) }, methods: { _loadOrgsShow: function () { let param = { params: { hc:1.8 } }; //发送get请求 vc.http.apiGet('/org.queryAdminOrgTree', param, function (json) { let _orgs = JSON.parse(json).data; $that.storeOrgTreeInfo.orgs = _orgs; $that._initJsTreeOrgShow(); }, function () { console.log('请求失败处理'); }); }, _initJsTreeOrgShow: function () { let _data = $that.storeOrgTreeInfo.orgs; if ($.jstree) { $.jstree.destroy() } $("#jstree_storeOrgTree").jstree({ "checkbox": { "keep_selected_style": false }, 'state': { //一些初始化状态 "opened": true, }, // 'plugins': ['contextmenu'], 'core': { 'data': _data }, }); $("#jstree_storeOrgTree").on("ready.jstree", function (e, data) { //data.instance.open_all(); //打开所有节点 }); $('#jstree_storeOrgTree').on("changed.jstree", function (e, data) { if (data.action == 'model' || data.action == 'ready') { //默认合并 //$("#jstree_org").jstree("close_all"); return; } $that.storeOrgTreeInfo.curOrg = data.node.original; $that.storeOrgTreeInfo.curOrg.orgId = $that.storeOrgTreeInfo.curOrg.id; vc.emit($props.callBackListener, 'switchOrg', { orgId: data.node.original.id, orgName: $that.storeOrgTreeInfo.curOrg.text }) }); }, } }); })(window.vc);