365 lines
16 KiB
HTML
365 lines
16 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<base href="/servicecity/">
|
|
<meta charset="UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=11,chrome=1"/>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.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">
|
|
<style>
|
|
.area-select-item {width: 100%; margin-bottom: 15px;}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="layui-fluid layui-anim layui-anim-fadein">
|
|
<div class="layui-row layui-col-space15">
|
|
<div class="layui-col-lg2 layui-col-md2 layui-col-sm-2 layui-col-xs12">
|
|
<div class="layui-card">
|
|
<div class="layui-card-header">人员选择</div>
|
|
<div class="layui-card-body" id="areaConfigBox">
|
|
<div class="layui-inline layui-form area-select-item" id="area1SelectTemplateBox" lay-filter="area1SelectTemplateBox"></div>
|
|
<script id="area1SelectTemplate" type="text/html">
|
|
<select id="area1" name="area1" class="area-edit" lay-filter="area1" lay-search>
|
|
<option value="">选择一级区域</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<div class="layui-inline layui-form area-select-item" id="area2SelectTemplateBox" lay-filter="area2SelectTemplateBox"></div>
|
|
<script id="area2SelectTemplate" type="text/html">
|
|
<select id="area2" name="area2" class="area-edit" lay-filter="area2" lay-search>
|
|
<option value="">选择二级区域</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<div class="layui-inline layui-form area-select-item" id="area3SelectTemplateBox" lay-filter="area3SelectTemplateBox"></div>
|
|
<script id="area3SelectTemplate" type="text/html">
|
|
<select id="area3" name="area3" class="area-edit" lay-filter="area3" lay-search>
|
|
<option value="">选择三级区域</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<div class="layui-inline layui-form area-select-item" id="area4SelectTemplateBox" lay-filter="area4SelectTemplateBox"></div>
|
|
<script id="area4SelectTemplate" type="text/html">
|
|
<select id="area4" name="area4" class="area-edit" lay-filter="area4" lay-search>
|
|
<option value="">选择四级区域</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<div class="layui-inline layui-form area-select-item" id="area5SelectTemplateBox" lay-filter="area5SelectTemplateBox"></div>
|
|
<script id="area5SelectTemplate" type="text/html">
|
|
<select id="area5" name="area5" class="area-edit" lay-filter="area5" lay-search>
|
|
<option value="">选择五级区域</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.dictionaryId}}">{{item.dictionaryName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<div class="layui-inline layui-form area-select-item" id="gridMemberIdTemplateBox" lay-filter="gridMemberIdTemplateBox"></div>
|
|
<script id="gridMemberIdTemplate" type="text/html">
|
|
<select id="gridMemberId" name="gridMemberId" class="area-edit" lay-filter="gridMemberId" lay-search>
|
|
<option value="">选择网格长</option>
|
|
{{# for(var i = 0, item; item = d[i++];) { }}
|
|
<option value="{{item.gridMemberId}}|{{item.memberName}}">{{item.memberName}}</option>
|
|
{{# } }}
|
|
</select>
|
|
</script>
|
|
<button id="saveEditBtn" class="layui-btn layui-btn-normal" style="width: 100%; display: none;">保存编辑</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="layui-col-lg10 layui-col-md10 layui-col-sm-10 layui-col-xs12">
|
|
<div class="layui-card">
|
|
<div class="layui-card-body" id="areaMapBox">
|
|
<div id="mapContainer" style="width: 100%; height: 100%;"></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript" src="http://api.map.baidu.com/api?type=webgl&v=1.0&ak=mlfOah4gWM1FjEo9CmlI64zK6MhyiMPW"></script>
|
|
<script type="text/javascript" src="assets/js/baidu-map-0.0.1.min.js"></script>
|
|
<script src="assets/layuiadmin/layui/layui.js"></script>
|
|
<script type="text/javascript">
|
|
layui.config({
|
|
base: 'assets/layuiadmin/' //静态资源所在路径
|
|
}).extend({
|
|
index: 'lib/index' //主入口模块
|
|
}).use(['index', 'form', 'laydate', 'laytpl'], function () {
|
|
var $ = layui.$;
|
|
var $win = $(window);
|
|
var form = layui.form;
|
|
var laytpl = layui.laytpl;
|
|
var resizeTimeout = null;
|
|
var baiduMap = null;
|
|
var gridMember = {
|
|
gridMemberId: null,
|
|
memberName: null,
|
|
gridArray: null
|
|
}
|
|
|
|
function initBaiduMap() {
|
|
baiduMap = new BaiduMap('mapContainer', {
|
|
onGridStartEdit: function(baiduMap) {
|
|
$('#saveEditBtn').hide();
|
|
},
|
|
onGridStopEdit: function(gridArray) {
|
|
gridMember.gridArray = gridArray;
|
|
$('#saveEditBtn').show();
|
|
}
|
|
});
|
|
baiduMap.setCenterAndZoom({
|
|
lng: 111,
|
|
lat: 30
|
|
}, 10);
|
|
baiduMap.setDefaultConfig();
|
|
baiduMap.initGridOption();
|
|
baiduMap.initGridOptionEvent();
|
|
baiduMap.initColorOption();
|
|
}
|
|
|
|
// 重置页面大小
|
|
function resizePage() {
|
|
$('#areaConfigBox').css({
|
|
height: ($win.height() - 94) +'px'
|
|
});
|
|
$('#areaMapBox').css({
|
|
height: ($win.height() - 51) +'px'
|
|
});
|
|
}
|
|
|
|
// 初始化选择框、单选、复选模板
|
|
function initSelectRadioCheckboxTemplate(templateId, templateBoxId, data, callback) {
|
|
laytpl(document.getElementById(templateId).innerHTML).render(data, function(html) {
|
|
document.getElementById(templateBoxId).innerHTML = html;
|
|
});
|
|
form.render('select', templateBoxId);
|
|
}
|
|
|
|
// 初始化1级区域下拉选择
|
|
function initArea1Select() {
|
|
top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/6985e913-4766-4841-bdce-7a394e65093b', []), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('area1SelectTemplate', 'area1SelectTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化2级区域下拉选择
|
|
function initArea2Select(area1) {
|
|
if(!area1) {
|
|
initSelectRadioCheckboxTemplate('area2SelectTemplate', 'area2SelectTemplateBox', []);
|
|
return;
|
|
}
|
|
top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/{area1}', [area1]), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('area2SelectTemplate', 'area2SelectTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化3级区域下拉选择
|
|
function initArea3Select(area2) {
|
|
if(!area2) {
|
|
initSelectRadioCheckboxTemplate('area3SelectTemplate', 'area3SelectTemplateBox', []);
|
|
return;
|
|
}
|
|
top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/{area2}', [area2]), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('area3SelectTemplate', 'area3SelectTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化4级区域下拉选择
|
|
function initArea4Select(area3) {
|
|
if(!area3) {
|
|
initSelectRadioCheckboxTemplate('area4SelectTemplate', 'area4SelectTemplateBox', []);
|
|
return;
|
|
}
|
|
top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/{area3}', [area3]), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('area4SelectTemplate', 'area4SelectTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化5级区域下拉选择
|
|
function initArea5Select(area4) {
|
|
if(!area4) {
|
|
initSelectRadioCheckboxTemplate('area5SelectTemplate', 'area5SelectTemplateBox', []);
|
|
return;
|
|
}
|
|
top.restAjax.get(top.restAjax.path('api/datadictionary/listdictionarybyparentid/{area4}', [area4]), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('area5SelectTemplate', 'area5SelectTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化网格长下拉选择
|
|
function initGridMemberIdSelect(areaId, areaLevel) {
|
|
if(!areaId) {
|
|
initSelectRadioCheckboxTemplate('gridMemberIdTemplate', 'gridMemberIdTemplateBox', []);
|
|
return;
|
|
}
|
|
top.restAjax.get(top.restAjax.path('api/gridmember/listgridmemberbyareaidandlevel/{areaId}/{areaLevel}', [areaId, areaLevel]), {}, null, function(code, data, args) {
|
|
initSelectRadioCheckboxTemplate('gridMemberIdTemplate', 'gridMemberIdTemplateBox', data);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
});
|
|
}
|
|
|
|
// 初始化背景网格
|
|
function initBgGrid(areaId, callback) {
|
|
// 获取同级其他人网格
|
|
top.restAjax.get(top.restAjax.path('api/areapoints/listgridbyareaid/{areaId}', [areaId]), {}, null, function(code, data) {
|
|
var gridArray = [];
|
|
for(var i = 0, item; item = data[i++];) {
|
|
var pointArray = [];
|
|
for(var j = 0, jItem; jItem = item.pointArray[j++];) {
|
|
pointArray.push(new BaiduMap.Point(jItem.lng, jItem.lat));
|
|
}
|
|
gridArray.push({
|
|
id: item.gridId,
|
|
label: item.gridName,
|
|
pointArray: pointArray
|
|
})
|
|
}
|
|
baiduMap.initBackgroundGrid({
|
|
gridArray: gridArray
|
|
});
|
|
callback();
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
}, function () {
|
|
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
|
}, function () {
|
|
top.dialog.close(layIndex);
|
|
});
|
|
}
|
|
// 初始化网格和背景网格
|
|
function initGridAndBgGrid(gridMemberId, memberName) {
|
|
gridMember.gridMemberId = gridMemberId;
|
|
gridMember.memberName = memberName;
|
|
$('#saveEditBtn').hide();
|
|
baiduMap.clearMap();
|
|
if(!gridMemberId) {
|
|
baiduMap.setRelationGroup();
|
|
return;
|
|
}
|
|
baiduMap.setRelationGroup([
|
|
new BaiduMap.Relation(gridMemberId, memberName)
|
|
]);
|
|
top.restAjax.get(top.restAjax.path('api/gridmember/getgridfullbygridmemberid/{gridMemberId}', [gridMemberId]), {}, null, function(code, data) {
|
|
var otherGridArray = [];
|
|
for(var i = 0, item; item = data.otherGrids[i++];) {
|
|
var pointArray = [];
|
|
for(var j = 0, jItem; jItem = item.pointArray[j++];) {
|
|
pointArray.push(new BaiduMap.Point(jItem.lng, jItem.lat));
|
|
}
|
|
otherGridArray.push({
|
|
id: item.gridId,
|
|
label: item.gridName,
|
|
pointArray: pointArray
|
|
})
|
|
}
|
|
baiduMap.initBackgroundGrid({
|
|
gridArray: otherGridArray
|
|
});
|
|
baiduMap.setGridArray(data.currentGrids);
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
}, function () {
|
|
layIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
|
|
}, function () {
|
|
top.dialog.close(layIndex);
|
|
});
|
|
}
|
|
|
|
// 保存网格
|
|
function saveGridMemberGrid() {
|
|
if(!gridMember.gridMemberId) {
|
|
top.dialog.msg('未选择网格员');
|
|
return;
|
|
}
|
|
top.dialog.confirm('确定保存网格配置吗?', function(index) {
|
|
top.dialog.close(index);
|
|
var layIndex;
|
|
top.restAjax.post(top.restAjax.path('api/areapoints/saveareagrid', []), {
|
|
areaId: gridMember.gridMemberId,
|
|
grids: gridMember.gridArray
|
|
}, null, function(code, data) {
|
|
top.dialog.msg('保存成功');
|
|
}, function(code, data) {
|
|
top.dialog.msg(data.msg);
|
|
}, function () {
|
|
layIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
|
|
}, function () {
|
|
top.dialog.close(layIndex);
|
|
});
|
|
})
|
|
}
|
|
|
|
resizePage();
|
|
initBaiduMap();
|
|
initArea1Select();
|
|
initArea2Select();
|
|
initArea3Select();
|
|
initArea4Select();
|
|
initArea5Select();
|
|
initGridMemberIdSelect();
|
|
|
|
$('#saveEditBtn').click(saveGridMemberGrid)
|
|
|
|
$win.on('resize', function() {
|
|
clearTimeout(resizeTimeout);
|
|
resizeTimeout = setTimeout(function() {
|
|
resizePage()
|
|
}, 500);
|
|
});
|
|
// area1 选择事件
|
|
form.on('select(area1)', function(data) {
|
|
initGridMemberIdSelect(data.value, 1);
|
|
initArea2Select(data.value);
|
|
initArea3Select();
|
|
initArea4Select();
|
|
initArea5Select();
|
|
});
|
|
// area2 选择事件
|
|
form.on('select(area2)', function(data) {
|
|
initGridMemberIdSelect(data.value, 2);
|
|
initArea3Select(data.value);
|
|
initArea4Select();
|
|
initArea5Select();
|
|
});
|
|
// area3 选择事件
|
|
form.on('select(area3)', function(data) {
|
|
initGridMemberIdSelect(data.value, 3);
|
|
initArea4Select(data.value);
|
|
initArea5Select();
|
|
});
|
|
// area4 选择事件
|
|
form.on('select(area4)', function(data) {
|
|
initGridMemberIdSelect(data.value, 4);
|
|
initArea5Select(data.value);
|
|
});
|
|
// gridMemberId 选择事件
|
|
form.on('select(gridMemberId)', function(data) {
|
|
var idNameArray = data.value.split('|');
|
|
initGridAndBgGrid(idNameArray[0], idNameArray[1]);
|
|
});
|
|
|
|
});
|
|
</script>
|
|
</body>
|
|
</html> |