mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-06-15 19:23:26 +08:00
84 lines
3.3 KiB
JavaScript
84 lines
3.3 KiB
JavaScript
(function (vc) {
|
|
let DEFAULT_PAGE = 1;
|
|
let DEFAULT_ROW = 10;
|
|
vc.extends({
|
|
data: {
|
|
communityFloorTreeInfo: {
|
|
units: [],
|
|
callName: ''
|
|
}
|
|
},
|
|
_initMethod: function () {
|
|
},
|
|
_initEvent: function () {
|
|
vc.on('communityFloorTree', 'initCommunityFloorTree', function (_param) {
|
|
$that.communityFloorTreeInfo.callName = _param.callName;
|
|
$that._loadCommunityFloorTree();
|
|
});
|
|
},
|
|
methods: {
|
|
_loadCommunityFloorTree: function () {
|
|
let param = {
|
|
params: {
|
|
hc:1.8
|
|
}
|
|
};
|
|
//发送get请求
|
|
vc.http.apiGet('/community.queryCommunityFloorTree',
|
|
param,
|
|
function (json) {
|
|
let _json = JSON.parse(json);
|
|
$that.communityFloorTreeInfo.units = _json.data;
|
|
$that._initJsTreeCommunityFloorTree();
|
|
},
|
|
function () {
|
|
console.log('请求失败处理');
|
|
});
|
|
},
|
|
_initJsTreeCommunityFloorTree: function () {
|
|
let _data = $that.communityFloorTreeInfo.units;
|
|
$.jstree.destroy()
|
|
$("#jstree_communityFloorTreeDiv").jstree({
|
|
"checkbox": {
|
|
"keep_selected_style": false
|
|
},
|
|
'state': { //一些初始化状态
|
|
"opened": true,
|
|
},
|
|
'core': {
|
|
"check_callback": true,
|
|
'data': _data
|
|
}
|
|
});
|
|
$("#jstree_communityFloorTreeDiv").on("ready.jstree", function (e, data) {
|
|
$('#jstree_communityFloorTreeDiv').jstree('select_node', _data[0].children[0].id /* , true */);
|
|
});
|
|
$('#jstree_communityFloorTreeDiv').on("changed.jstree", function (e, data) {
|
|
if (data.action == 'model' || data.action == 'ready') {
|
|
return;
|
|
}
|
|
let _selected = data.selected[0];
|
|
if (_selected.startsWith('c_')) {
|
|
vc.emit($that.communityFloorTreeInfo.callName, 'selectCommunity', {
|
|
communityName: data.node.original.communityName,
|
|
communityId: data.node.original.communityId
|
|
})
|
|
return;
|
|
}
|
|
if (_selected.startsWith('f_')) {
|
|
vc.emit($that.communityFloorTreeInfo.callName, 'selectFloor', {
|
|
floorNum: data.node.original.floorNum,
|
|
floorId: data.node.original.floorId
|
|
})
|
|
return;
|
|
}
|
|
|
|
});
|
|
$('#jstree_communityFloorTreeDiv')
|
|
.on('click', '.jstree-anchor', function (e) {
|
|
$(this).jstree(true).toggle_node(e.target);
|
|
})
|
|
},
|
|
}
|
|
});
|
|
})(window.vc); |