社区切换时,小区不切换bug修改 --renpc

This commit is contained in:
Renpc-kilig 2023-10-30 17:57:18 +08:00
parent 3b73d23372
commit ea73a13afb
11 changed files with 912 additions and 24 deletions

View File

@ -160,7 +160,7 @@ public class ResidentialController extends AbstractController {
ClientTokenBO token = ClientTokenManager.getInstance().getClientToken();
String url = projectProperties.getAreaUrl();
url += "resource/dict/listcommunity?areaId=" + params.get("areaId");
url += "/resource/dict/listcommunity?areaId=" + params.get("areaId");
UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl(url)
.queryParam("access_token", token.getAccessToken());

View File

@ -40,9 +40,9 @@ public class HouseRouteController extends AbstractController {
return new ModelAndView("house/list-popu");
}
@GetMapping("find-house")
public ModelAndView findHouse() {
return new ModelAndView("house/find-house");
@GetMapping("list-check")
public ModelAndView listCheck() {
return new ModelAndView("house/list-check");
}
}

View File

@ -35,4 +35,13 @@ public class PopulationRouteController extends AbstractController {
return new ModelAndView("population/list");
}
@GetMapping("find-house")
public ModelAndView findHouse() {
return new ModelAndView("population/find-house");
}
@GetMapping("find-popu")
public ModelAndView findPopu() {
return new ModelAndView("population/find-popu");
}
}

View File

@ -286,10 +286,24 @@
t1.is_delete = 0
<if test="keywords != null and keywords != ''">
AND (
<!-- 这里添加其他条件 -->
t1.id LIKE CONCAT('%', #{keywords}, '%')
t1.name LIKE CONCAT('%', #{keywords}, '%')
)
</if>
<if test="name != null and name != ''">
AND t1.name LIKE CONCAT('%', #{name}, '%')
</if>
<if test="street != null and street != ''">
AND t1.street = #{street}
</if>
<if test="streetName != null and streetName != ''">
AND t1.street_name LIKE CONCAT('%', #{streetName}, '%')
</if>
<if test="community != null and community != ''">
AND t1.community = #{community}
</if>
<if test="communityName != null and communityName != ''">
AND t1.community_name LIKE CONCAT('%', #{communityName}, '%')
</if>
<if test="startTime != null and startTime != ''">
AND
LEFT(t1.gmt_create, 10) <![CDATA[ >= ]]> #{startTime}

View File

@ -163,19 +163,29 @@
var laydate = layui.laydate;
var viewerObj = {};
// 小区名称change事件
form.on('select(street)', function(data){
if(data.value) {
initCommunityNameSelect(data.value);
initResidentialNameSelect(data.value, '');
}else {
initCommunityNameSelect('9999');
initResidentialNameSelect('', '');
}
});
// 社区change事件
form.on('select(community)', function(data){
var streetValue = $("#street").val();
if(data.value) {
initResidentialNameSelect(streetValue, data.value);
}else {
initResidentialNameSelect(streetValue, '');
}
});
// 初始化社区下拉选择
function initCommunityNameSelect(areaId) {
top.restAjax.get(top.restAjax.path('api/residential/getCommunityList?areaId=' + areaId, []), {}, null, function(code, data, args) {
console.log(data)
laytpl(document.getElementById('communityNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('communityNameSelectTemplateBox').innerHTML = html;
});
@ -218,11 +228,11 @@
})
// 初始化小区名称下拉选择
initResidentialNameSelect();
initResidentialNameSelect('9999', '9999');
function initResidentialNameSelect() {
top.restAjax.get(top.restAjax.path('api/residential/list', []), {}, null, function(code, data, args) {
console.log(data)
function initResidentialNameSelect(street, community) {
top.restAjax.get(top.restAjax.path('api/residential/list?street={street}&community={community}',
[street, community]), {}, null, function(code, data, args) {
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
});

View File

@ -165,12 +165,23 @@
var viewerObj = {};
// 小区名称change事件
form.on('select(street)', function(data){
if(data.value) {
initCommunityNameSelect(data.value);
initResidentialNameSelect(data.value, '');
}else {
initCommunityNameSelect('9999');
initResidentialNameSelect('', '');
}
});
// 社区change事件
form.on('select(community)', function(data){
var streetValue = $("#street").val();
if(data.value) {
initResidentialNameSelect(streetValue, data.value);
}else {
initResidentialNameSelect(streetValue, '');
}
});
@ -225,8 +236,9 @@
})
// 初始化小区名称下拉选择
function initResidentialNameSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/residential/list', []), {}, null, function(code, data, args) {
function initResidentialNameSelect(street, community, selectValue) {
top.restAjax.get(top.restAjax.path('api/residential/list?street={street}&community={community}',
[street, community]), {}, null, function(code, data, args) {
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
});
@ -344,7 +356,7 @@
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
initImageUploadFile();
initResidentialNameSelect(data['residentialId']);
initResidentialNameSelect(data['street'], data['community'], data['residentialId']);
initStreetNameSelect(data['street']);
initCommunityNameSelect(data['street'], data['community']);
}, function(code, data) {

View File

@ -0,0 +1,527 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<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">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-row">
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-body">
<div class="test-table-reload-btn" style="margin-bottom: 10px;">
<div class="layui-inline">
<input type="text" id="keywords" class="layui-input search-item search-item-width-100" placeholder="输入关键字">
</div>
新增时间
<div class="layui-inline">
<input type="text" id="startTime" class="layui-input search-item search-item-width-100" placeholder="开始时间" readonly>
</div>
<div class="layui-inline">
<input type="text" id="endTime" class="layui-input search-item search-item-width-100" placeholder="结束时间" readonly>
</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 src="assets/js/vendor/viewer/viewer.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/'
}).extend({
index: 'lib/index'
}).use(['index', 'table', 'laydate', 'common'], function() {
var $ = layui.$;
var $win = $(window);
var table = layui.table;
var admin = layui.admin;
var laydate = layui.laydate;
var common = layui.common;
var resizeTimeout = null;
var tableUrl = 'api/population/findHouse?keywords={keywords}';
var keywords = top.restAjax.params(window.location.href).keywords;
// 初始化表格
function initTable() {
table.render({
elem: '#dataTable',
id: 'dataTable',
url: top.restAjax.path(tableUrl, [keywords]),
width: admin.screen() > 1 ? '100%' : '',
height: $win.height() - 90,
limit: 20,
limits: [20, 40, 60, 80, 100, 200],
toolbar: '#headerToolBar',
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: 'communityName', width: 180, title: '社区名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'residentialName', width: 180, title: '小区名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'buildingName', width: 180, title: '楼/排名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'affiliationUnit', width: 180, title: '所在单元/列', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'affiliationFloors', width: 180, title: '所在层/院', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'houseNum', width: 180, title: '门牌号', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'categoryName', width: 180, title: '房屋类别', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'natureName', width: 180, title: '房屋性质', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'typeName', width: 180, title: '房屋种类', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'structureName', width: 180, title: '房屋结构', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'buildingPurposeName', width: 180, title: '建筑用途', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'roomNum', width: 180, title: '房间数量', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'roomArea', width: 180, title: '房屋面积', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'roomUseName', width: 180, title: '房屋用途', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'dangerName', width: 180, title: '隐患类型', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'certificateNum', width: 180, title: '产权证号', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'registrationDate', width: 180, title: '登记日期', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'affiliatedUnit', width: 180, title: '所属单位', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'isRental', width: 180, title: '是否出租屋', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'isVacant', width: 180, title: '是否空置房', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'lodgeTypeName', width: 180, title: '租住类型', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'rentalPurposes', width: 180, title: '出租用途', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'homeowner', width: 180, title: '房主名称', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'documentName', width: 180, title: '证件种类', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'documentNum', width: 180, title: '证件号码', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'phone', width: 180, title: '联系电话', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'custodian', width: 180, title: '托管人姓名', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'custodianDocumentName', width: 180, title: '证件种类', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'custodianDocumentNum', width: 180, title: '证件号码', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'custodianPhone', width: 180, title: '联系电话', align:'center',
templet: function(row) {
var rowData = row[this.field];
if(typeof(rowData) === 'undefined' || rowData == null || rowData == '') {
return '-';
}
return rowData;
}
},
{field: 'relationshipHomeowner', 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', fixed: 'right', width: 150, title: '入住人员', align:'center',
templet: function(row) {
var rowData = '<a class="layui-btn layui-btn-xs" lay-event="rentalHis">入住人员</a>';;
return rowData;
}
}
]
],
page: true,
parseData: function(data) {
console.log(data)
return {
'code': 0,
'msg': '',
'count': data.total,
'data': data.rows
};
}
});
}
// 房屋租住记录
function rentalHis(data) {
top.dialog.open({
url: top.restAjax.path('route/population/list?houseId={houseId}', [data.houseId]),
title: "房屋人口",
width: '98%',
height: '98%',
onClose: function() {
reloadTable();
}
});
}
//监听行单击事件
table.on('tool(dataTable)', function(obj){
var data = obj.data;
if('rentalHis' == obj.event) {
rentalHis(data);
}
});
// 重载表格
function reloadTable(currentPage) {
table.reload('dataTable', {
where: {
keywords: $('#keywords').val(),
startTime: $('#startTime').val(),
endTime: $('#endTime').val()
},
page: {
curr: currentPage
},
});
}
// 初始化日期
function initDate() {
// 日期选择
laydate.render({
elem: '#startTime',
format: 'yyyy-MM-dd'
});
laydate.render({
elem: '#endTime',
format: 'yyyy-MM-dd'
});
}
// 删除
function removeData(ids) {
top.dialog.msg(top.dataMessage.delete, {
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/house/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);
});
}
});
}
initTable();
initDate();
// 事件 - 页面变化
$win.on('resize', function() {
clearTimeout(resizeTimeout);
resizeTimeout = setTimeout(function() {
reloadTable();
}, 500);
});
// 事件 - 搜索
$(document).on('click', '#search', 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') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/house/save', []),
end: function() {
reloadTable();
}
});
} else 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: false,
closeBtn: 0,
area: ['100%', '100%'],
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/house/update?houseId={houseId}', [checkDatas[0].houseId]),
end: function() {
reloadTable();
}
});
}
} else 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['houseId'];
}
removeData(ids);
}
}
});
});
</script>
</body>
</html>

View File

@ -392,12 +392,23 @@
var laytpl = layui.laytpl;
var laydate = layui.laydate;
// 小区名称change事件
form.on('select(street)', function(data){
if(data.value) {
initCommunityNameSelect(data.value);
initResidentialNameSelect(data.value, '');
}else {
initCommunityNameSelect('9999');
initResidentialNameSelect('', '');
}
});
// 社区change事件
form.on('select(community)', function(data){
var streetValue = $("#street").val();
if(data.value) {
initResidentialNameSelect(streetValue, data.value);
}else {
initResidentialNameSelect(streetValue, '');
}
});
@ -491,9 +502,10 @@
}
// 初始化所在小区下拉选择
initResidentialNameSelect();
function initResidentialNameSelect() {
top.restAjax.get(top.restAjax.path('api/residential/list', []), {}, null, function(code, data, args) {
initResidentialNameSelect('9999', '9999');
function initResidentialNameSelect(street, community) {
top.restAjax.get(top.restAjax.path('api/residential/list?street={street}&community={community}',
[street, community]), {}, null, function(code, data, args) {
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
});

View File

@ -393,12 +393,23 @@
var laydate = layui.laydate;
var houseId = top.restAjax.params(window.location.href).houseId;
// 小区名称change事件
form.on('select(street)', function(data){
if(data.value) {
initCommunityNameSelect(data.value);
initResidentialNameSelect(data.value, '');
}else {
initCommunityNameSelect('9999');
initResidentialNameSelect('', '');
}
});
// 社区change事件
form.on('select(community)', function(data){
var streetValue = $("#street").val();
if(data.value) {
initResidentialNameSelect(streetValue, data.value);
}else {
initResidentialNameSelect(streetValue, '');
}
});
@ -507,8 +518,9 @@
}
// 初始化所在小区下拉选择
function initResidentialNameSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/residential/list', []), {}, null, function(code, data, args) {
function initResidentialNameSelect(street, community, selectValue) {
top.restAjax.get(top.restAjax.path('api/residential/list?street={street}&community={community}',
[street, community]), {}, null, function(code, data, args) {
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
});
@ -737,7 +749,7 @@
form.render(null, 'dataForm');
// 初始化下拉框数据
initResidentialNameSelect(data['residentialId']);
initResidentialNameSelect(data['street'], data['community'], data['residentialId']);
var buildingValue = data['buildingId'] + '_' + data['unitNum'] + '_' + data['floorsNum'];
initBuildingNameSelect(data['residentialId'], buildingValue);
initCategoryNameSelect(data['categoryId']);

View File

@ -0,0 +1,292 @@
<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<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">
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="div-base-population-info">
<div style="color: #333;font-weight: bold;font-size: 35px;margin-bottom: 30px;margin-top: 30px;text-align: center;">以房找人</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg4">
<label class="layui-form-label">所在街道<span style="color: red;vertical-align: middle;">*</span></label>
<input type="hidden" id="streetName" name="streetName" class="layui-input" value="" maxlength="36">
<div class="layui-input-block layui-form" id="streetNameSelectTemplateBox" lay-filter="streetNameSelectTemplateBox"></div>
<script id="streetNameSelectTemplate" type="text/html">
<select id="street" name="street" lay-filter="street" lay-verify="required" lay-search>
<option value="">请选择街道</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.id}}">{{item.name}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label">所在社区<span style="color: red;vertical-align: middle;">*</span></label>
<input type="hidden" id="communityName" name="communityName" class="layui-input" value="" maxlength="36">
<div class="layui-input-block layui-form" id="communityNameSelectTemplateBox" lay-filter="communityNameSelectTemplateBox"></div>
<script id="communityNameSelectTemplate" type="text/html">
<select id="community" name="community" lay-filter="community" lay-verify="required" lay-search>
<option value="">请选择社区</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.communityId}}">{{item.communityName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label">小区<span style="color: red;vertical-align: middle;">*</span></label>
<input type="hidden" id="residentialName" name="residentialName" class="layui-input" value="" placeholder="请输入小区名称" maxlength="36">
<div class="layui-input-block layui-form" id="residentialNameSelectTemplateBox" lay-filter="residentialNameSelectTemplateBox"></div>
<script id="residentialNameSelectTemplate" type="text/html">
<select id="residentialId" name="residentialId" lay-filter="residentialId" lay-verify="required" lay-search>
<option value="">请选择小区</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.residentialId}}">{{item.name}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg4">
<label class="layui-form-label">楼/排<span style="color: red;vertical-align: middle;">*</span></label>
<input type="hidden" id="buildingName" name="buildingName" class="layui-input" value="" maxlength="36">
<div class="layui-input-block layui-form" id="buildingNameSelectTemplateBox" lay-filter="buildingNameSelectTemplateBox"></div>
<script id="buildingNameSelectTemplate" type="text/html">
<select id="buildingId" name="buildingId" lay-filter="buildingId" lay-verify="required" lay-search>
<option value="">请选择楼/排</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.buildingId}}_{{item.nuitNum}}_{{item.floorsNum}}">{{item.name}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label">所在单元/列</label>
<div class="layui-input-block" id="affiliationUnitDiv">
<select id="affiliationUnit" name="affiliationUnit"></select>
</div>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label">所在层/院</label>
<div class="layui-input-block" id="affiliationFloorsDiv">
<select id="affiliationFloors" name="affiliationFloors"></select>
</div>
</div>
</div>
<div class="layui-form-item layui-row" pane>
<div class="layui-col-lg4">
<label class="layui-form-label">门牌号</label>
<div class="layui-input-block">
<input type="number" id="houseNum" name="houseNum" class="layui-input" value="" placeholder="请输入门牌号" lay-verify="required">
</div>
</div>
<div class="layui-col-lg4 layui-form-pane">
<label class="layui-form-label">是否出租屋</label>
<div class="layui-input-block">
<input type="radio" name="isRental" lay-filter="isRental" value="1" title="是">
<input type="radio" name="isRental" lay-filter="isRental" value="0" title="否" checked>
</div>
</div>
<div class="layui-col-lg4 layui-form-pane">
<label class="layui-form-label">是否空置房</label>
<div class="layui-input-block">
<input type="radio" name="isVacant" lay-filter="isVacant" value="1" title="是">
<input type="radio" name="isVacant" lay-filter="isVacant" value="0" title="否" checked>
</div>
</div>
</div>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn search">搜索</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
// 搜索方法
function searchFun() {
top.dialog.open({
url: top.restAjax.path('route/house/list-check?keywords={keywords}', [keywords]),
title: "查看人口信息信息",
width: '80%',
height: '80%',
onClose: function() {
}
});
}
form.on('select(street)', function(data){
if(data.value) {
initCommunityNameSelect(data.value);
initResidentialNameSelect(data.value, '');
}else {
initCommunityNameSelect('9999');
initResidentialNameSelect('', '');
}
});
// 社区change事件
form.on('select(community)', function(data){
var streetValue = $("#street").val();
if(data.value) {
initResidentialNameSelect(streetValue, data.value);
}else {
initResidentialNameSelect(streetValue, '');
}
});
// 初始化社区下拉选择
function initCommunityNameSelect(areaId) {
top.restAjax.get(top.restAjax.path('api/residential/getCommunityList?areaId=' + areaId, []), {}, null, function(code, data, args) {
console.log(data)
laytpl(document.getElementById('communityNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('communityNameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'communityNameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化街道下拉选择
initStreetNameSelect();
function initStreetNameSelect() {
top.restAjax.get(top.restAjax.path('api/residential/getStreetList', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('streetNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('streetNameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'streetNameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化单元/列数下拉列表
function initAffiliationUnit(num) {
if(num > 0) {
for(var i=1; i<=num; i++) {
var html = '<option value="' + i + '">' + i + '</option>';
$('#affiliationUnitDiv').find('select').append(html);
}
}else {
var html = '<option></option>'
$('#affiliationUnitDiv').find('select').html(html);
}
form.render(null, 'dataForm');
}
// 初始化所在层/院数下拉列表
function initAffiliationFloors(num) {
if(num > 0) {
for(var i=1; i<=num; i++) {
var html = '<option value="' + i + '">' + i + '</option>';
$('#affiliationFloorsDiv').find('select').append(html);
}
}else {
var html = '<option></option>'
$('#affiliationFloorsDiv').find('select').html(html);
}
form.render(null, 'dataForm');
}
// 初始化所在小区下拉选择
initResidentialNameSelect('9999', '9999');
function initResidentialNameSelect(street, community) {
top.restAjax.get(top.restAjax.path('api/residential/list?street={street}&community={community}',
[street, community]), {}, null, function(code, data, args) {
laytpl(document.getElementById('residentialNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('residentialNameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'residentialNameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 小区名称change事件
form.on('select(residentialId)', function(data){
if(data.value) {
initBuildingNameSelect(data.value);
}else {
initBuildingNameSelect('9999');
}
});
// 初始化楼/排下拉选择
function initBuildingNameSelect(residentialId) {
top.restAjax.get(top.restAjax.path('api/building/list?residentialId=' + residentialId, []), {}, null, function(code, data, args) {
laytpl(document.getElementById('buildingNameSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('buildingNameSelectTemplateBox').innerHTML = html;
});
form.render('select', 'buildingNameSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 楼/排change事件
form.on('select(buildingId)', function(data){
if(data.value) {
var unitNum = data.value.split("_");
initAffiliationUnit(unitNum[1]);
initAffiliationFloors(unitNum[2]);
}else {
initAffiliationUnit('0');
initAffiliationFloors('0');
}
});
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化内容
function initData() {
initBuildingNameSelect('9999');
initCommunityNameSelect('9999');
}
initData();
$('.search').on('click', function() {
searchFun();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>