wlcb-system-house/src/main/resources/templates/residential/save.html
2021-11-22 17:44:53 +08:00

517 lines
23 KiB
HTML

<!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-fluid 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">小区名称</label>
<div class="layui-input-block">
<input type="text" id="residentialName" name="residentialName" 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">
<select name="residentialType" id="residentialType" lay-filter="residentialType">
<option value="">请选择小区类型</option>
<option value="住宅">住宅</option>
<option value="公寓">公寓</option>
<option value="工业园区">工业园区</option>
<option value="高新园区">高新园区</option>
</select>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">社区</label>
<div class="layui-input-block">
<input type="text" id="community" name="community" class="layui-input" value="" placeholder="请输入社区" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg4">
<label class="layui-form-label">物业名称</label>
<div class="layui-input-block">
<input type="text" id="propertyName" name="propertyName" class="layui-input" value="" placeholder="请输入物业名称" maxlength="255">
</div>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label">物业联系人</label>
<div class="layui-input-block">
<input type="text" id="linkMan" name="linkMan" class="layui-input" value="" placeholder="请输入物业联系人" maxlength="255">
</div>
</div>
<div class="layui-col-lg4">
<label class="layui-form-label" style="width: 120px;">物业联系方式</label>
<div class="layui-input-block" style="margin-left: 120px;">
<input type="text" id="phone" name="phone" class="layui-input" value="" placeholder="请输入物业联系方式" maxlength="11">
</div>
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg6">
<label class="layui-form-label">所在地</label>
<input type="hidden" id="locationCode" name="locationCode" class="layui-input" value="" placeholder="请输入一级区域名称" maxlength="255">
<div class="layui-input-block">
<input type="text" id="location" name="location" class="layui-input" value="" placeholder="点击选择所在地" maxlength="11">
</div>
</div>
<div class="layui-col-lg6">
<label class="layui-form-label">所属网格</label>
<div class="layui-input-block layui-form" id="gridSelectTemplateBox" lay-filter="gridSelectTemplateBox"></div>
<script id="gridSelectTemplate" type="text/html">
<select id="grid" name="grid" lay-filter="grid">
<option value="">请选择网格</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.gridId}}">{{item.gridName}}</option>
{{# } }}
</select>
</script>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">详细地址</label>
<div class="layui-input-block">
<input type="text" id="residentialAddress" name="residentialAddress" class="layui-input" value="" placeholder="请输入详细地址" maxlength="255">
</div>
</div>
<div class="layui-form-item layui-row">
<div class="layui-col-lg6">
<label class="layui-form-label">经度</label>
<div class="layui-input-block">
<input type="text" id="longitude" name="longitude" class="layui-input" value="" placeholder="请输入经度" maxlength="255">
</div>
</div>
<div class="layui-col-lg6">
<label class="layui-form-label">纬度</label>
<div class="layui-input-block">
<input type="text" 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">
<div id="remake"></div>
</div>
</div>
<div class="layui-row" id="mapDiv" style="display: none;">
<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-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/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<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 wangEditor = window.wangEditor;
var wangEditorObj = {};
// 选择所在地
$(document).on('click', '#location', function() {
top.dialog.open({
title: '选择地区',
url: top.restAjax.path('route/area/get-select?areaName={areaName}', [encodeURI($('#location').val())]),
width: '800px',
height: '225px',
onClose: function () {
var selectedAreaArray = top.dialog.dialogData.selectedAreaArray;
var areaCode = '';
var areaName = '';
if (selectedAreaArray.length > 0) {
areaCode = selectedAreaArray[selectedAreaArray.length - 1].areaCode;
for (var i = 0, item; item = selectedAreaArray[i++];) {
if (areaName) {
areaName += ',';
}
areaName += item.areaName;
}
}
$('#locationCode').val(areaCode);
$('#location').val(areaName);
initGridSelect(areaCode);
}
})
});
// 初始化地区网格
function initGridSelect(areaCode) {
if(!areaCode) {
laytpl(document.getElementById('gridSelectTemplate').innerHTML).render([], function(html) {
document.getElementById('gridSelectTemplateBox').innerHTML = html;
});
form.render('select', 'gridSelectTemplateBox');
return;
}
top.restAjax.get(top.restAjax.path('api/residential/grid-list/{areaCode}', [areaCode]), {}, null, function(code, data, args) {
laytpl(document.getElementById('gridSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('gridSelectTemplateBox').innerHTML = html;
});
form.render('select', 'gridSelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化任务一级地区下拉选择
function initArea1Select() {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/0', []), {}, null, function(code, data, args) {
laytpl(document.getElementById('area1SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area1SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area1SelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化任务二级地区下拉选择
function initArea2Select(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('area2SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area2SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area2SelectTemplateBox');
}else {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/' + value, []), {}, null, function(code, data, args) {
laytpl(document.getElementById('area2SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area2SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area2SelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务三级地区下拉选择
function initArea3Select(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('area3SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area3SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area3SelectTemplateBox');
}else {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/' + value, []), {}, null, function(code, data, args) {
laytpl(document.getElementById('area3SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area3SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area3SelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务四级地区下拉选择
function initArea4Select(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('area4SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area4SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area4SelectTemplateBox');
}else {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/' + value, []), {}, null, function(code, data, args) {
laytpl(document.getElementById('area4SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area4SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area4SelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 初始化任务五级地区下拉选择
function initArea5Select(value) {
if(!value) {
var data = [
{
areaId: '',
areaName: '请选择上级数据'
}
];
laytpl(document.getElementById('area5SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area5SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area5SelectTemplateBox');
}else {
top.restAjax.get(top.restAjax.path('api/area/listbyparentid/' + value, []), {}, null, function(code, data, args) {
laytpl(document.getElementById('area5SelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('area5SelectTemplateBox').innerHTML = html;
});
form.render('select', 'area5SelectTemplateBox');
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
}
// 任务一级change事件
form.on('select(area1)', function(data){
initArea2Select(data.value);
if(!data.value) {
$('#mapDiv').hide();
$('#area1Id').val('')
$('#area1Name').val('')
}else {
var valueArr = data.value.split(',');
if(4 == valueArr.length) {
$('#area1Id').val(valueArr[0]);
$('#area1Name').val(valueArr[3]);
$('#mapDiv').show();
initMap(valueArr[1], valueArr[2])
}
}
$("#area2Name").empty();
form.render("select");
});
// 任务二级change事件
form.on('select(area2)', function(data){
initArea3Select(data.value);
if(!data.value) {
$('#area2Id').val('')
$('#area2Code').val('')
}else {
var valueArr = data.value.split(',');
if(4 == valueArr.length) {
$('#area2Id').val(valueArr[0]);
$('#area2Name').val(valueArr[3]);
$('#mapDiv').show();
initMap(valueArr[1], valueArr[2])
}
}
$("#area3Name").empty();
form.render("select");
});
// 任务三级change事件
form.on('select(area3)', function(data){
initArea4Select(data.value);
if(!data.value) {
$('#area3Id').val('')
$('#area3Code').val('')
}else {
var valueArr = data.value.split(',');
if(4 == valueArr.length) {
$('#area3Id').val(valueArr[0]);
$('#area3Name').val(valueArr[3]);
$('#mapDiv').show();
initMap(valueArr[1], valueArr[2])
}
}
$("#area4Name").empty();
form.render("select");
});
// 任务四级change事件
form.on('select(area4)', function(data){
initArea5Select(data.value);
if(!data.value) {
$('#taskArea4Id').val('')
$('#taskArea4Code').val('')
}else {
var valueArr = data.value.split(',');
if(4 == valueArr.length) {
$('#area4Id').val(valueArr[0]);
$('#area4Name').val(valueArr[3]);
$('#mapDiv').show();
initMap(valueArr[1], valueArr[2])
}
}
$("#area5Name").empty();
form.render("select");
});
// 任务五级change事件
form.on('select(area5)', function(data){
if(!data.value) {
$('#area5Id').val('')
$('#area5Code').val('')
}else {
var valueArr = data.value.split(',');
if(4 == valueArr.length) {
$('#area5Id').val(valueArr[0]);
$('#area5Name').val(valueArr[3]);
$('#mapDiv').show();
initMap(valueArr[1], valueArr[2])
}
}
});
//初始化百度地图
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) {
$('#shopAddress').val(rs.address);
});
});
}
function mapMarkPoint(map, point) {
var marker = new BMap.Marker(point);
map.addOverlay(marker);
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
// 初始化备注富文本
function initRemakeRichText() {
var editor = new wangEditor('#remake');
editor.customConfig.zIndex = 0;
editor.customConfig.uploadImgMaxSize = 5 * 1024 * 1024;
editor.customConfig.uploadImgMaxLength = 1;
editor.customConfig.uploadFileName = 'image';
editor.customConfig.uploadImgServer = 'api/file/wangeditorimage';
editor.customConfig.uploadImgHooks = {
fail: function (xhr, editor, result) {
top.dialog.msg('系统错误,图片上传失败');
},
error: function (xhr, editor) {
top.dialog.msg('网络异常');
},
timeout: function (xhr, editor) {
top.dialog.msg('网络请求超时');
}
};
editor.create();
wangEditorObj['remake'] = editor;
}
// 初始化内容
function initData() {
initRemakeRichText();
initGridSelect();
var lng = '113.137743';
var lat = '41.002057';
initMap(lng, lat);
/*initArea1Select();
initArea2Select();
initArea3Select();
initArea4Select();
initArea5Select();*/
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
formData.field['remake'] = wangEditorObj['remake'].txt.html();
top.restAjax.post(top.restAjax.path('api/residential/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();
});
});
</script>
</body>
</html>