353 lines
15 KiB
HTML
353 lines
15 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<base href="/population/">
|
|
<meta charset="utf-8">
|
|
<meta name="renderer" content="webkit">
|
|
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
|
|
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
|
|
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
|
|
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
|
|
<link rel="stylesheet" href="assets/js/vendor/zTree3/css/metroStyle/metroStyle.css"/>
|
|
</head>
|
|
<body>
|
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
|
<div class="layui-row layui-col-space15">
|
|
<div class="layui-col-md2">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body left-tree-wrap">
|
|
<div id="leftTreeWrap">
|
|
<ul id="leftTree" class="ztree"></ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-md10">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body">
|
|
<blockquote class="layui-elem-quote" id="houseAddrStr">未选择楼栋单元或区域</blockquote>
|
|
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
|
|
<div class="layui-inline">
|
|
<input type="text" id="keywords" class="layui-input search-item" style="height: 38px;width: 220px" placeholder="房屋名称|房主姓名|房主联系方式">
|
|
</div>
|
|
<div class="layui-inline">
|
|
<div id="buildingGroupBox" class="layui-form layui-form-item" style="margin-bottom: 0px; width: 140px;">
|
|
<select id="houseStatus">
|
|
<option value="">选择房屋状态</option>
|
|
<option value="自住">自住</option>
|
|
<option value="出租">出租</option>
|
|
<option value="闲置">闲置</option>
|
|
<option value="其他">其他</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<button type="button" id="search" class="layui-btn layui-btn-sm">
|
|
<i class="fa fa-lg fa-search"></i> 搜索
|
|
</button>
|
|
</div>
|
|
<table class="layui-hide" id="dataTable" lay-filter="dataTable"></table>
|
|
<!-- 表头按钮组 -->
|
|
<script type="text/html" id="headerToolBar">
|
|
<div class="layui-btn-group">
|
|
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
|
|
<i class="fa fa-lg fa-plus"></i> 新增
|
|
</button>
|
|
<button type="button" class="layui-btn layui-btn-normal layui-btn-sm" lay-event="updateEvent">
|
|
<i class="fa fa-lg fa-edit"></i> 编辑
|
|
</button>
|
|
<button type="button" class="layui-btn layui-btn-danger layui-btn-sm" lay-event="removeEvent">
|
|
<i class="fa fa-lg fa-trash"></i> 删除
|
|
</button>
|
|
</div>
|
|
</script>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
|
<script>
|
|
layui.config({
|
|
base: 'assets/layuiadmin/'
|
|
}).extend({
|
|
index: 'lib/index'
|
|
}).use(['index', 'table', 'ztree'], function() {
|
|
var $ = layui.$;
|
|
var $win = $(window);
|
|
var table = layui.table;
|
|
var admin = layui.admin;
|
|
var tableUrl = 'api/buildinghouse/list-page';
|
|
var cityBuildingId = '';
|
|
|
|
function init(){
|
|
$('#leftTreeWrap').css({
|
|
height: $win.height() - 30,
|
|
overflow: 'auto'
|
|
});
|
|
$('#listContentWrap').css({
|
|
height: $win.height() - 50,
|
|
});
|
|
initThree();
|
|
initTable();
|
|
}
|
|
init();
|
|
|
|
// 初始化树
|
|
function initThree() {
|
|
var setting = {
|
|
data: {
|
|
simpleData: {
|
|
enable: true,
|
|
idKey: "id",
|
|
pIdKey: "pId",
|
|
rootPId: 0
|
|
}
|
|
},
|
|
callback: {
|
|
onClick: function (event, treeId, treeNode){
|
|
if(treeNode.level == 3){
|
|
// 初始化列表
|
|
cityBuildingId = treeNode.id;
|
|
initTable();
|
|
loadHouseAddr(cityBuildingId);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var treeNodes = [];
|
|
top.restAjax.get(top.restAjax.path('app/sys-basic-info/release/list-area-community-district-building-tree', []), {}, null, function (code, data) {
|
|
$.fn.zTree.init($("#leftTree"), setting, data);
|
|
}, function (code, data) {
|
|
top.dialog.msg("街道社区小区楼栋加载失败!");
|
|
treeNodes = [];
|
|
$.fn.zTree.init($("#leftTree"), setting, treeNodes);
|
|
});
|
|
}
|
|
|
|
// 加载房屋地址坐标信息
|
|
function loadHouseAddr(id){
|
|
top.restAjax.get(top.restAjax.path('api/buildinghouse/get-house-addr', []), {cityBuildingId : id}, null, function (code, data) {
|
|
var str = '';
|
|
str += data.areaName + " >>";
|
|
str += data.communityName + " >> ";
|
|
str += data.districtName + " >> ";
|
|
str += data.buildingName;
|
|
$('#houseAddrStr').html(str);
|
|
}, function (code, data) {
|
|
$('#houseAddrStr').html('未选择楼栋单元或区域');
|
|
});
|
|
}
|
|
|
|
// 初始化表格
|
|
function initTable() {
|
|
table.render({
|
|
elem: '#dataTable',
|
|
id: 'dataTable',
|
|
url: top.restAjax.path(tableUrl, []),
|
|
width: admin.screen() > 1 ? '100%' : '',
|
|
height: $win.height() - 160,
|
|
where:{
|
|
cityBuildingId : cityBuildingId
|
|
},
|
|
limit: 20,
|
|
limits: [20, 40, 60, 80, 100, 200],
|
|
toolbar: '#headerToolBar',
|
|
defaultToolbar: [],
|
|
request: {
|
|
pageName: 'page',
|
|
limitName: 'rows'
|
|
},
|
|
cols: [
|
|
[
|
|
{type:'checkbox', fixed: 'left'},
|
|
{field:'rowNum', width:80, title: '序号', fixed: 'left', align:'center', templet: '<span>{{d.LAY_INDEX}}</span>'},
|
|
{field: 'houseName', width: 180, title: '房屋名称', align:'center',
|
|
templet: function(row) {
|
|
var rowData = row[this.field];
|
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
|
return '-';
|
|
}
|
|
return rowData;
|
|
}
|
|
},
|
|
{field: 'houseStatus', width: 180, title: '房屋状态', align:'center',
|
|
templet: function(row) {
|
|
var rowData = row[this.field];
|
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
|
return '其他';
|
|
}
|
|
return rowData;
|
|
}
|
|
},
|
|
{field: 'ownerName', width: 180, title: '房主姓名', align:'center',
|
|
templet: function(row) {
|
|
var rowData = row[this.field];
|
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
|
return '-';
|
|
}
|
|
return rowData;
|
|
}
|
|
},
|
|
{field: 'ownerPhone', width: 180, title: '房主联系方式', align:'center',
|
|
templet: function(row) {
|
|
var rowData = row[this.field];
|
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
|
return '-';
|
|
}
|
|
return rowData;
|
|
}
|
|
},
|
|
{field: 'countsOfLive', width: 180, title: '当前入住', align:'center',
|
|
templet: function(row) {
|
|
var rowData = row[this.field];
|
|
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
|
|
rowData = 0;
|
|
}
|
|
rowData = '<span class="layui-badge layui-bg-blue">' + rowData + '人</span>';
|
|
return rowData;
|
|
}
|
|
},
|
|
{field: 'addUser', fixed: 'right', width: 150, title: '操作', align:'center',
|
|
templet: function(row) {
|
|
var rowData = '<a class="layui-btn layui-btn-xs" lay-event="addUserEvent">详情信息</a>';
|
|
return rowData;
|
|
}
|
|
}
|
|
]
|
|
],
|
|
page: true,
|
|
parseData: function(data) {
|
|
return {
|
|
'code': 0,
|
|
'msg': '',
|
|
'count': data.total,
|
|
'data': data.rows
|
|
};
|
|
}
|
|
});
|
|
}
|
|
|
|
// 重载表格
|
|
function reloadTable(currentPage) {
|
|
table.reload('dataTable', {
|
|
url: top.restAjax.path(tableUrl, []),
|
|
where: {
|
|
keywords: $('#keywords').val(),
|
|
houseStatus: $('#houseStatus').val()
|
|
},
|
|
page: {
|
|
curr: currentPage
|
|
},
|
|
height: $win.height() - 160
|
|
});
|
|
}
|
|
|
|
// 事件 - 搜索
|
|
$(document).on('click', '#search', function() {
|
|
reloadTable(1);
|
|
});
|
|
|
|
table.on('tool(dataTable)', function(obj){
|
|
var layEvent = obj.event;
|
|
if(layEvent === 'addUserEvent'){
|
|
layer.open({
|
|
type: 2,
|
|
title: '入住成员列表',
|
|
closeBtn: 1,
|
|
area: ['90%', '90%'],
|
|
shadeClose: false,
|
|
anim: 2,
|
|
content: top.restAjax.path('route/buildinghouse/list-house-user.html?id={arg}', [obj.data.buildingHouseId]),
|
|
end: function() {
|
|
reloadTable(1);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
|
|
// 事件 - 增删改
|
|
table.on('toolbar(dataTable)', function(obj) {
|
|
var layEvent = obj.event;
|
|
var checkStatus = table.checkStatus('dataTable');
|
|
var checkDatas = checkStatus.data;
|
|
if(layEvent === 'saveEvent') {
|
|
if(cityBuildingId == ''){
|
|
layer.msg('请先选择楼栋单元或区域后再进行添加');
|
|
return;
|
|
}
|
|
layer.open({
|
|
type: 2,
|
|
title: '新增房屋',
|
|
closeBtn: 1,
|
|
area: ['30%', '60%'],
|
|
shadeClose: false,
|
|
anim: 2,
|
|
content: top.restAjax.path('route/buildinghouse/save.html?cityBuildingId={arg}', [cityBuildingId]),
|
|
end: function() {
|
|
reloadTable();
|
|
}
|
|
});
|
|
}
|
|
if(layEvent === 'updateEvent') {
|
|
if(checkDatas.length === 0) {
|
|
top.dialog.msg(top.dataMessage.table.selectEdit);
|
|
} else if(checkDatas.length > 1) {
|
|
top.dialog.msg(top.dataMessage.table.selectOneEdit);
|
|
} else {
|
|
layer.open({
|
|
type: 2,
|
|
title: '修改房屋',
|
|
closeBtn: 1,
|
|
area: ['30%', '60%'],
|
|
shadeClose: false,
|
|
anim: 2,
|
|
content: top.restAjax.path('route/buildinghouse/update.html?buildingHouseId={buildingHouseId}', [checkDatas[0].buildingHouseId]),
|
|
end: function() {
|
|
reloadTable();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
if(layEvent === 'removeEvent') {
|
|
if(checkDatas.length === 0) {
|
|
top.dialog.msg(top.dataMessage.table.selectDelete);
|
|
} else {
|
|
var ids = '';
|
|
for(var i = 0, item; item = checkDatas[i++];) {
|
|
if(i > 1) {
|
|
ids += '_';
|
|
}
|
|
ids += item['buildingHouseId'];
|
|
}
|
|
removeData(ids);
|
|
}
|
|
}
|
|
});
|
|
|
|
// 删除
|
|
function removeData(ids) {
|
|
top.dialog.msg('删除后房屋和入住信息同时清除!', {
|
|
time: 0,
|
|
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
|
|
shade: 0.3,
|
|
yes: function (index) {
|
|
top.dialog.close(index);
|
|
var layIndex;
|
|
top.restAjax.delete(top.restAjax.path('api/buildinghouse/remove/{ids}', [ids]), {}, null, function (code, data) {
|
|
top.dialog.msg(top.dataMessage.deleteSuccess, {time: 1000});
|
|
reloadTable();
|
|
}, function (code, data) {
|
|
top.dialog.msg(data.msg);
|
|
}, function () {
|
|
layIndex = top.dialog.msg(top.dataMessage.deleting, {icon: 16, time: 0, shade: 0.3});
|
|
}, function () {
|
|
top.dialog.close(layIndex);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |