批量新增代码提交 --renpc

This commit is contained in:
Renpc-kilig 2023-11-13 17:40:38 +08:00
parent 1a17b0205b
commit cc047622a6
3 changed files with 470 additions and 0 deletions

View File

@ -50,4 +50,9 @@ public class HouseRouteController extends AbstractController {
return new ModelAndView("house/list-myself");
}
@GetMapping("save-batch")
public ModelAndView saveBatch() {
return new ModelAndView("house/save-batch");
}
}

View File

@ -35,6 +35,9 @@
<!-- 表头按钮组 -->
<script type="text/html" id="headerToolBar">
<div class="layui-btn-group">
<button type="button" class="layui-btn layui-btn-sm" lay-event="batchSaveEvent">
<i class="fa fa-lg fa-plus"></i> 批量新增房屋
</button>
<button type="button" class="layui-btn layui-btn-sm" lay-event="saveEvent">
<i class="fa fa-lg fa-plus"></i> 新增
</button>
@ -260,6 +263,20 @@
reloadTable();
}
});
} else if(layEvent === 'batchSaveEvent') {
layer.open({
type: 2,
title: false,
closeBtn: 0,
area: ['50%', '100%'],
offset: 'r',
shadeClose: true,
anim: 2,
content: top.restAjax.path('route/building/save-batch', []),
end: function() {
reloadTable();
}
});
} else if(layEvent === 'updateEvent') {
if(checkDatas.length === 0) {
top.dialog.msg(top.dataMessage.table.selectEdit);

View File

@ -0,0 +1,448 @@
<!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">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
</head>
<body>
<div class="layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>新增内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<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-form-item">
<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-form-item">
<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 class="layui-form-item">
<label class="layui-form-label">楼排名称</label>
<div class="layui-input-block">
<input type="text" id="name" name="name" class="layui-input" value="" placeholder="请输入楼排名称" maxlength="255">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">楼/排号</label>
<div class="layui-input-block">
<input type="number" id="buildNum" name="buildNum" class="layui-input" value="" placeholder="请输入楼/排号" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">楼层数</label>
<div class="layui-input-block">
<input type="number" id="floorsNum" name="floorsNum" class="layui-input" value="" placeholder="请输入楼层数" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">单元/排数</label>
<div class="layui-input-block">
<input type="number" id="unitNum" name="unitNum" class="layui-input" value="" placeholder="请输入单元/排数" lay-verify="required">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">详细地址</label>
<div class="layui-input-block">
<input type="text" id="address" name="address" class="layui-input" value="" placeholder="请输入详细地址" maxlength="255">
</div>
</div>
<div class="layui-row" id="mapDiv">
<div class="layui-col-md12 layui-col-sm12" style="padding: 0 0px;">
<div id="mapContainer" style="width: 100%;height: 350px;"></div>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-xs6">
<label class="layui-form-label">经度</label>
<div class="layui-input-block">
<input type="text" readonly id="longitude" name="longitude" class="layui-input" value="" placeholder="请输入经度" maxlength="255">
</div>
</div>
<div class="layui-col-xs6">
<label class="layui-form-label">纬度</label>
<div class="layui-input-block">
<input type="text" readonly id="latitude" name="latitude" class="layui-input" value="" placeholder="请输入纬度" maxlength="255">
</div>
</div>
</div>
<div class="layui-form-item layui-form-text">
<label class="layui-form-label">图片</label>
<div class="layui-input-block">
<input type="hidden" id="image" name="image">
<div class="layui-btn-container" id="imageFileBox" style="border: 1px solid #e6e6e6;"></div>
<script id="imageFileDownload" type="text/html">
{{# var fileName = 'image'; }}
{{# if(d[fileName].length > 0) { }}
{{# var files = d[fileName];}}
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
<div class="upload-image-box">
<span class="upload-image-span">
<img src="route/file/download/false/{{item.fileId}}" align="加载失败">
</span>
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="imageRemoveFile">
<i class="fa fa-trash-o"></i>
</a>
</div>
{{# } }}
{{# } }}
{{# if(d[fileName].length < 9) { }}
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
<a href="javascript:void(0);" lay-form-button data-explain="图片" data-name="image" lay-filter="imageUploadFile">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
{{# } }}
</script>
</div>
</div>
<!-- 手动添加房屋信息 -->
<div class="div-base-population-info">
<div class="layui-form-item layui-row">
<div class="">
<div class="layui-footer" style="left: 98%;">
<button type="button" class="layui-btn selUnit">选择单元</button>
</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" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=3.0&ak=oWU9RD4ihDHAafexgI6XOrTK8lDatRju"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script th:inline="javascript"></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;
var viewerObj = {};
var centerPoint = {
lng: [[${mapLng}]],
lat: [[${mapLat}]],
}
// 房主搜索
function homeownerSearch() {
top.dialog.open({
url: top.restAjax.path('route/house/list-popu', []),
title: '人员选择',
width: '80%',
height: '80%',
onClose: function(data) {
var popuData = top.dialog.dialogData.popuData;
$('#homeowner').val(popuData.name);
$('#documentId').val('b7d74045-d984-4822-b0f3-711b15b933ca');
$('#documentNum').val(popuData.idcard);
$('#phone').val(popuData.phone);
}
});
}
//初始化百度地图
function initMap(longitude, latitude) {
map = new BMap.Map("mapContainer", {enableMapClick: false,});
var point = new BMap.Point(longitude, latitude);
map.centerAndZoom(point, 13);
map.disableDoubleClickZoom();
map.addControl(new BMap.NavigationControl());
map.addControl(new BMap.ScaleControl());
map.addControl(new BMap.OverviewMapControl());
map.addControl(new BMap.MapTypeControl());
map.enableScrollWheelZoom();//启用地图滚轮放大缩小
map.enableContinuousZoom();//开启缩放平滑
// 点击获取地址
var geocoder= new BMap.Geocoder();
mapMarkPoint(map, point);
map.addEventListener("click", function(e) {
map.clearOverlays();
$('#longitude').val(e.point.lng);
$('#latitude').val(e.point.lat);
point = new BMap.Point(e.point.lng, e.point.lat);
mapMarkPoint(map, point);
geocoder.getLocation(e.point, function(rs) {
$('#address').val(rs.address);
});
});
}
function mapMarkPoint(map, point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
}
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) {
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);
});
}
// 初始化小区名称下拉选择
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);
});
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化图片图片上传
function initImageUploadFile() {
var files = $('#image').val();
initFileList('image', files, function(fileName) {
var viewer = new Viewer(document.getElementById(fileName +'FileBox'), {navbar: false});
viewerObj[fileName] = viewer;
});
form.on('button(imageUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'image',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
}
}
});
});
form.on('button(imageRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
});
}
// 初始化内容
function initData() {
initImageUploadFile();
initCommunityNameSelect('9999');
initMap(centerPoint.lng, centerPoint.lat);
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
// 设置所在街道和社区的选中值
var streetName = $('#street').find("option:selected").text();
var communityName = $('#community').find("option:selected").text();
formData.field.streetName = streetName;
formData.field.communityName = communityName;
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.post(top.restAjax.path('api/building/save', []), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.commitSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
$('.homeownerSearch').on('click', function() {
homeownerSearch();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>