mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 21:59:12 +08:00
优化加入选择房屋功能
This commit is contained in:
parent
a6f194ddb3
commit
448c1fae3a
@ -66,5 +66,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<vc:create path="common/document"></vc:create>
|
||||
<vc:create path="property/roomTree"></vc:create>
|
||||
<vc:create path="frame/viewMenuUser"></vc:create>
|
||||
</div>
|
||||
18
public/components/property/roomTree/roomTree.html
Executable file
18
public/components/property/roomTree/roomTree.html
Executable file
@ -0,0 +1,18 @@
|
||||
<!-- 弹出层 modal -->
|
||||
<div>
|
||||
<div class="modal right fade" id="roomTreeModal" tabindex="-1" role="dialog" aria-labelledby="roomTreeLabel"
|
||||
aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h4 class="modal-title">请选择房屋</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div id="jstree_floorUnitRoom">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- end 弹出层 moda -->
|
||||
</div>
|
||||
201
public/components/property/roomTree/roomTree.js
Executable file
201
public/components/property/roomTree/roomTree.js
Executable file
@ -0,0 +1,201 @@
|
||||
(function(vc){
|
||||
let DEFAULT_PAGE = 1;
|
||||
let DEFAULT_ROW = 10;
|
||||
vc.extends({
|
||||
data:{
|
||||
roomTreeInfo: {
|
||||
units:[],
|
||||
callName:''
|
||||
}
|
||||
},
|
||||
_initMethod:function(){
|
||||
},
|
||||
_initEvent:function(){
|
||||
vc.on('roomTree','openRoomTree',function(_param){
|
||||
$that.roomTreeInfo.callName = _param.callName;
|
||||
$('#roomTreeModal').modal('show');
|
||||
$that._loadRoomTreeFloorAndUnits();
|
||||
});
|
||||
},
|
||||
methods:{
|
||||
_loadRoomTreeFloorAndUnits: function() {
|
||||
|
||||
let param = {
|
||||
params: {
|
||||
communityId: vc.getCurrentCommunity().communityId
|
||||
}
|
||||
};
|
||||
//发送get请求
|
||||
vc.http.apiGet('/unit.queryUnits',
|
||||
param,
|
||||
function(json) {
|
||||
let _unitInfo = JSON.parse(json);
|
||||
$that.roomTreeInfo.units = _unitInfo;
|
||||
$that._initJsTreeRoomTreeFloorUnit();
|
||||
},
|
||||
function() {
|
||||
console.log('请求失败处理');
|
||||
});
|
||||
},
|
||||
_initJsTreeRoomTreeFloorUnit: function() {
|
||||
|
||||
let _data = $that._doJsTreeRoomTreeData();
|
||||
|
||||
_data = _data.sort(function(a, b) {
|
||||
return a.floorNum - b.floorNum
|
||||
})
|
||||
$.jstree.destroy()
|
||||
$("#jstree_floorUnitRoom").jstree({
|
||||
"checkbox": {
|
||||
"keep_selected_style": false
|
||||
},
|
||||
'state': { //一些初始化状态
|
||||
"opened": true,
|
||||
},
|
||||
'core': {
|
||||
"check_callback": true,
|
||||
'data': _data
|
||||
}
|
||||
});
|
||||
$("#jstree_floorUnitRoom").on("ready.jstree", function(e, data) {
|
||||
//data.instance.open_all();//打开所有节点
|
||||
$('#jstree_floorUnitRoom').jstree('select_node', _data[0].children[0].id /* , true */ );
|
||||
|
||||
});
|
||||
|
||||
$('#jstree_floorUnitRoom').on("changed.jstree", function(e, data) {
|
||||
if (data.action == 'model' || data.action == 'ready') {
|
||||
//默认合并
|
||||
//$("#jstree_floorUnit").jstree("close_all");
|
||||
return;
|
||||
}
|
||||
let _selected = data.selected[0];
|
||||
|
||||
if (_selected.startsWith('f_')) {
|
||||
return;
|
||||
}
|
||||
|
||||
//console.log(_selected, data.node.original.unitId)
|
||||
if (_selected.startsWith('u_')) {
|
||||
$that._roomTreeLoadRoom(data.node.original.unitId,data);
|
||||
}
|
||||
|
||||
if(_selected.startsWith('r_')){
|
||||
$('#roomTreeModal').modal('hide');
|
||||
vc.emit($that.roomTreeInfo.callName, 'selectRoom', {
|
||||
roomName: data.node.original.roomName,
|
||||
roomId:data.node.original.roomId
|
||||
})
|
||||
}
|
||||
});
|
||||
},
|
||||
_roomTreeLoadRoom:function(_unitId,data){
|
||||
//获取选中的节点
|
||||
let node = data.instance.get_node(data.selected[0]);
|
||||
//遍历选中节点的子节点
|
||||
let childNodes = data.instance.get_children_dom(node);
|
||||
if(childNodes && childNodes.length>0){
|
||||
for(var childIndex = 0; childIndex<childNodes.length;childIndex++){
|
||||
$('#jstree_floorUnitRoom').jstree('delete_node', childNodes[childIndex]);
|
||||
}
|
||||
}
|
||||
let param = {
|
||||
params:{
|
||||
page:1,
|
||||
row:1000,
|
||||
unitId:_unitId,
|
||||
communityId:vc.getCurrentCommunity().communityId
|
||||
}
|
||||
}
|
||||
//发送get请求
|
||||
vc.http.apiGet('/room.queryRooms',
|
||||
param,
|
||||
function(json, res) {
|
||||
let listRoomData = JSON.parse(json);
|
||||
if(listRoomData.total< 1){
|
||||
return ;
|
||||
}
|
||||
listRoomData.rooms.forEach(_room =>{
|
||||
let _data = {
|
||||
id: 'r_' + _room.roomId,
|
||||
roomId: _room.roomId,
|
||||
roomName:_room.floorNum+"-"+_room.unitNum+"-"+_room.roomNum,
|
||||
text: _room.roomNum,
|
||||
icon: "/img/unit.png",
|
||||
};
|
||||
|
||||
$('#jstree_floorUnitRoom').jstree('create_node', $('#u_'+_unitId), _data, "last", false, false);
|
||||
|
||||
})
|
||||
$('#jstree_floorUnitRoom').jstree('open_node', $('#u_'+_unitId));
|
||||
},
|
||||
function(errInfo, error) {
|
||||
console.log('请求失败处理');
|
||||
}
|
||||
);
|
||||
},
|
||||
_doJsTreeRoomTreeData: function() {
|
||||
let _mFloorTree = [];
|
||||
|
||||
let _units = $that.roomTreeInfo.units;
|
||||
|
||||
//构建 第一层菜单组
|
||||
_units.forEach(pItem => {
|
||||
let _includeFloor = false;
|
||||
for (let _mgIndex = 0; _mgIndex < _mFloorTree.length; _mgIndex++) {
|
||||
if (pItem.floorId == _mFloorTree[_mgIndex].floorId) {
|
||||
_includeFloor = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!_includeFloor) {
|
||||
let _floorItem = {
|
||||
id: 'f_' + pItem.floorId,
|
||||
floorId: pItem.floorId,
|
||||
floorNum: pItem.floorNum,
|
||||
icon: "/img/floor.png",
|
||||
text: pItem.floorNum + "栋",
|
||||
state: {
|
||||
opened: false
|
||||
},
|
||||
children: []
|
||||
};
|
||||
$that._doJsTreeRoomTreeMenuData(_floorItem);
|
||||
_mFloorTree.push(_floorItem);
|
||||
}
|
||||
});
|
||||
return _mFloorTree;
|
||||
},
|
||||
_doJsTreeRoomTreeMenuData: function(_floorItem) {
|
||||
let _units = $that.roomTreeInfo.units;
|
||||
//构建菜单
|
||||
let _children = _floorItem.children;
|
||||
for (let _pIndex = 0; _pIndex < _units.length; _pIndex++) {
|
||||
if (_floorItem.floorId == _units[_pIndex].floorId) {
|
||||
let _includeMenu = false;
|
||||
for (let _mgIndex = 0; _mgIndex < _children.length; _mgIndex++) {
|
||||
if (_units[_pIndex].unitId == _children[_mgIndex].unitId) {
|
||||
_includeMenu = true;
|
||||
}
|
||||
}
|
||||
if (!_includeMenu) {
|
||||
let _menuItem = {
|
||||
id: 'u_' + _units[_pIndex].unitId,
|
||||
unitId: _units[_pIndex].unitId,
|
||||
text: _units[_pIndex].unitNum + "单元",
|
||||
icon: "/img/unit.png",
|
||||
state: {
|
||||
opened: true
|
||||
},
|
||||
children: []
|
||||
};
|
||||
_children.push(_menuItem);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
});
|
||||
})(window.vc);
|
||||
@ -23,7 +23,10 @@
|
||||
<div class="col-lg-1 padding-lr-0 margin-left-sm">
|
||||
<button type="button" class="form-control btn btn-primary" @click="_doSearch()">查询</button>
|
||||
</div>
|
||||
<div class="col-lg-3">
|
||||
<div class="col-lg-1 padding-lr-0 margin-left-sm" v-if="simplifyAcceptanceInfo.searchType == '1'">
|
||||
<button type="button" class="form-control btn btn-white" @click="_simplifyAcceptanceChooseRoom()">选择房屋</button>
|
||||
</div>
|
||||
<div class="col-lg-2">
|
||||
</div>
|
||||
</div>
|
||||
<div class="vc-line"></div>
|
||||
|
||||
@ -58,6 +58,12 @@
|
||||
$that.simplifyAcceptanceInfo.roomName = _room.floorNum + '栋' + _room.unitNum + '单元' + _room.roomNum;
|
||||
vc.emit('simplifyRoomFee', 'switch', $that.simplifyAcceptanceInfo)
|
||||
});
|
||||
vc.on('simplifyAcceptance','selectRoom',function(_param){
|
||||
$that.simplifyAcceptanceInfo.searchType ='1';
|
||||
$that.simplifyAcceptanceInfo.searchValue = _param.roomName;
|
||||
$that.simplifyAcceptanceInfo.searchPlaceholder = "请输入房屋编号 楼栋-单元-房屋 如1-1-1";
|
||||
$that._doSearch();
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
_changeSearchType: function () {
|
||||
@ -206,6 +212,11 @@
|
||||
roomArea:'',
|
||||
roomRent:''
|
||||
}
|
||||
},
|
||||
_simplifyAcceptanceChooseRoom:function(){
|
||||
vc.emit('roomTree','openRoomTree',{
|
||||
callName:'simplifyAcceptance'
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Loading…
Reference in New Issue
Block a user