From 39c1e11fbf6445bc0673b88008e0aaa49f66d661 Mon Sep 17 00:00:00 2001 From: java110 <928255095@qq.com> Date: Tue, 12 Jul 2022 11:03:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../property/floorUnitTree/floorUnitTree.js | 48 +++++++++-------- .../components/property/roomTree/roomTree.js | 4 ++ .../property/roomTreeDiv/roomTreeDiv.js | 53 ++++++++++--------- 3 files changed, 58 insertions(+), 47 deletions(-) diff --git a/public/components/property/floorUnitTree/floorUnitTree.js b/public/components/property/floorUnitTree/floorUnitTree.js index 862fd8bd9..b808ff68e 100644 --- a/public/components/property/floorUnitTree/floorUnitTree.js +++ b/public/components/property/floorUnitTree/floorUnitTree.js @@ -1,7 +1,7 @@ /** 入驻小区 **/ -(function (vc) { +(function(vc) { vc.extends({ propTypes: { callBackListener: vc.propTypes.string, //父组件名称 @@ -9,16 +9,16 @@ data: { floorUnitTreeInfo: { units: [], - floorId:'' + floorId: '' } }, - _initMethod: function () { + _initMethod: function() { $that._loadFloorAndUnits(); }, - _initEvent: function () { - vc.on('floorUnitTree','refreshTree',function(_param){ - if(_param){ + _initEvent: function() { + vc.on('floorUnitTree', 'refreshTree', function(_param) { + if (_param) { $that.floorUnitTreeInfo.floorId = _param.floorId; } $that._loadFloorAndUnits(); @@ -26,7 +26,7 @@ }, methods: { - _loadFloorAndUnits: function () { + _loadFloorAndUnits: function() { let param = { params: { @@ -36,28 +36,28 @@ //发送get请求 vc.http.apiGet('/floor.queryFloorAndUnits', param, - function (json) { + function(json) { let _unitInfo = JSON.parse(json); $that.floorUnitTreeInfo.units = _unitInfo; $that._initJsTreeFloorUnit(); }, - function () { + function() { console.log('请求失败处理'); }); }, - _initJsTreeFloorUnit: function () { + _initJsTreeFloorUnit: function() { let _data = $that._doJsTreeData(); let _unitId = ''; - $that.floorUnitTreeInfo.units.forEach(item=>{ - if($that.floorUnitTreeInfo.floorId && item.floorId == $that.floorUnitTreeInfo.floorId){ + $that.floorUnitTreeInfo.units.forEach(item => { + if ($that.floorUnitTreeInfo.floorId && item.floorId == $that.floorUnitTreeInfo.floorId) { _unitId = item.unitId; } }) - _data = _data.sort(function (a, b) { + _data = _data.sort(function(a, b) { return a.floorNum - b.floorNum }); @@ -81,23 +81,23 @@ // "action": function (data) { // var inst = $.jstree.reference(data.reference), // obj = inst.get_node(data.reference); - + // } // }, // }, // } }); - $("#jstree_floorUnit").on("ready.jstree", function (e, data) { + $("#jstree_floorUnit").on("ready.jstree", function(e, data) { //data.instance.open_all();//打开所有节点 - if(_unitId){ - $('#jstree_floorUnit').jstree('select_node', 'u_'+_unitId /* , true */); - return ; + if (_unitId) { + $('#jstree_floorUnit').jstree('select_node', 'u_' + _unitId /* , true */ ); + return; } - $('#jstree_floorUnit').jstree('select_node', _data[0].children[0].id /* , true */); + $('#jstree_floorUnit').jstree('select_node', _data[0].children[0].id /* , true */ ); }); - $('#jstree_floorUnit').on("changed.jstree", function (e, data) { + $('#jstree_floorUnit').on("changed.jstree", function(e, data) { if (data.action == 'model' || data.action == 'ready') { //默认合并 //$("#jstree_floorUnit").jstree("close_all"); @@ -117,10 +117,14 @@ unitId: data.node.original.unitId }) }); + $('#jstree_floorUnit') + .on('click', '.jstree-anchor', function(e) { + $(this).jstree(true).toggle_node(e.target); + }) }, - _doJsTreeData: function () { + _doJsTreeData: function() { let _mFloorTree = []; let _units = $that.floorUnitTreeInfo.units; @@ -152,7 +156,7 @@ }); return _mFloorTree; }, - _doJsTreeMenuData: function (_floorItem) { + _doJsTreeMenuData: function(_floorItem) { let _units = $that.floorUnitTreeInfo.units; //构建菜单 let _children = _floorItem.children; diff --git a/public/components/property/roomTree/roomTree.js b/public/components/property/roomTree/roomTree.js index 064b61c72..7597f2c32 100755 --- a/public/components/property/roomTree/roomTree.js +++ b/public/components/property/roomTree/roomTree.js @@ -86,6 +86,10 @@ }) } }); + $('#jstree_floorUnitRoom') + .on('click', '.jstree-anchor', function(e) { + $(this).jstree(true).toggle_node(e.target); + }) }, _roomTreeLoadRoom: function(_unitId, data) { //获取选中的节点 diff --git a/public/components/property/roomTreeDiv/roomTreeDiv.js b/public/components/property/roomTreeDiv/roomTreeDiv.js index 0e353a012..a4c94f7fa 100644 --- a/public/components/property/roomTreeDiv/roomTreeDiv.js +++ b/public/components/property/roomTreeDiv/roomTreeDiv.js @@ -1,4 +1,4 @@ -(function (vc) { +(function(vc) { let DEFAULT_PAGE = 1; let DEFAULT_ROW = 10; vc.extends({ @@ -8,16 +8,15 @@ callName: '' } }, - _initMethod: function () { - }, - _initEvent: function () { - vc.on('roomTreeDiv', 'initRoomTreeDiv', function (_param) { + _initMethod: function() {}, + _initEvent: function() { + vc.on('roomTreeDiv', 'initRoomTreeDiv', function(_param) { $that.roomTreeDivInfo.callName = _param.callName; $that._loadRoomTreeDivFloorAndUnits(); }); }, methods: { - _loadRoomTreeDivFloorAndUnits: function () { + _loadRoomTreeDivFloorAndUnits: function() { let param = { params: { communityId: vc.getCurrentCommunity().communityId @@ -26,18 +25,18 @@ //发送get请求 vc.http.apiGet('/unit.queryUnits', param, - function (json) { + function(json) { let _unitInfo = JSON.parse(json); $that.roomTreeDivInfo.units = _unitInfo; $that._initJsTreeRoomTreeDivFloorUnit(); }, - function () { + function() { console.log('请求失败处理'); }); }, - _initJsTreeRoomTreeDivFloorUnit: function () { + _initJsTreeRoomTreeDivFloorUnit: function() { let _data = $that._doJsTreeRoomTreeDivData(); - _data = _data.sort(function (a, b) { + _data = _data.sort(function(a, b) { return a.floorNum - b.floorNum }) $.jstree.destroy() @@ -53,12 +52,12 @@ 'data': _data } }); - $("#jstree_floorUnitRoomDiv").on("ready.jstree", function (e, data) { + $("#jstree_floorUnitRoomDiv").on("ready.jstree", function(e, data) { //data.instance.open_all();//打开所有节点 - $('#jstree_floorUnitRoomDiv').jstree('select_node', _data[0].children[0].id /* , true */); + $('#jstree_floorUnitRoomDiv').jstree('select_node', _data[0].children[0].id /* , true */ ); }); - $('#jstree_floorUnitRoomDiv').on("changed.jstree", function (e, data) { + $('#jstree_floorUnitRoomDiv').on("changed.jstree", function(e, data) { if (data.action == 'model' || data.action == 'ready') { //默认合并 //$("#jstree_floorUnit").jstree("close_all"); @@ -79,8 +78,12 @@ }) } }); + $('#jstree_floorUnitRoomDiv') + .on('click', '.jstree-anchor', function(e) { + $(this).jstree(true).toggle_node(e.target); + }) }, - _roomTreeDivLoadRoom: function (_unitId, data) { + _roomTreeDivLoadRoom: function(_unitId, data) { //获取选中的节点 let node = data.instance.get_node(data.selected[0]); //遍历选中节点的子节点 @@ -91,17 +94,17 @@ } } let param = { - params: { - page: 1, - row: 1000, - unitId: _unitId, - communityId: vc.getCurrentCommunity().communityId + params: { + page: 1, + row: 1000, + unitId: _unitId, + communityId: vc.getCurrentCommunity().communityId + } } - } - //发送get请求 + //发送get请求 vc.http.apiGet('/room.queryRooms', param, - function (json, res) { + function(json, res) { let listRoomData = JSON.parse(json); if (listRoomData.total < 1) { return; @@ -128,12 +131,12 @@ }) } }, - function (errInfo, error) { + function(errInfo, error) { console.log('请求失败处理'); } ); }, - _doJsTreeRoomTreeDivData: function () { + _doJsTreeRoomTreeDivData: function() { let _mFloorTree = []; let _units = $that.roomTreeDivInfo.units; //构建 第一层菜单组 @@ -162,7 +165,7 @@ }); return _mFloorTree; }, - _doJsTreeRoomTreeDivMenuData: function (_floorItem) { + _doJsTreeRoomTreeDivMenuData: function(_floorItem) { let _units = $that.roomTreeDivInfo.units; //构建菜单 let _children = _floorItem.children;