mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-06-15 03:08:44 +08:00
优化代码
This commit is contained in:
parent
46e5fd6c73
commit
39c1e11fbf
@ -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;
|
||||
|
||||
@ -86,6 +86,10 @@
|
||||
})
|
||||
}
|
||||
});
|
||||
$('#jstree_floorUnitRoom')
|
||||
.on('click', '.jstree-anchor', function(e) {
|
||||
$(this).jstree(true).toggle_node(e.target);
|
||||
})
|
||||
},
|
||||
_roomTreeLoadRoom: function(_unitId, data) {
|
||||
//获取选中的节点
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user