238 lines
7.4 KiB
JavaScript
238 lines
7.4 KiB
JavaScript
let element, layer, table, tree;
|
|
const bidCode = parent.$('#bidPro').val();
|
|
var map;
|
|
|
|
layui.use(['layer', 'element', 'table', 'tree'], function () {
|
|
element = layui.element;
|
|
layer = layui.layer;
|
|
table = layui.table;
|
|
tree = layui.tree;
|
|
|
|
//人员列表
|
|
PersonnelList();
|
|
|
|
//人员运动趋预警
|
|
PersonnelMovementWarning();
|
|
|
|
//穿戴装备
|
|
wearGarList();
|
|
|
|
});
|
|
|
|
// 人员列表
|
|
function PersonnelList(){
|
|
const url = commonUrl + "screen/largeScreen/personnelControl/getPersonnelList";
|
|
const params = {
|
|
"roleCode": roleCode,
|
|
"orgId": orgId,
|
|
"userId": userId,
|
|
"bidCode": bidCode,
|
|
"keyWord": $("#keyWord").val()
|
|
}
|
|
let encryptStr = encryptCBC(JSON.stringify(params));
|
|
ajaxRequest(url, "POST", encryptStr, true, function () {
|
|
}, function (result) {
|
|
console.log(result);
|
|
if (result.code === 200) {
|
|
// 人员列表树
|
|
let treeList = getTreeList(result.data, bidCode, []);
|
|
renderTree(treeList);
|
|
} else if (result.code === 500) {
|
|
layer.msg(result.msg, { icon: 2 });
|
|
}else if(result.code === 401){
|
|
loginout(1)
|
|
}
|
|
}, function (xhr) {
|
|
// error(xhr)
|
|
}, "application/json");
|
|
|
|
}
|
|
|
|
//递归拼接树
|
|
function getTreeList(rootList, id, List) {
|
|
for (let item of rootList) {
|
|
if (item.parentId == id) {
|
|
let newItem = Object.assign({}, item); // 创建一个新的对象,避免直接修改原始对象
|
|
newItem.spread = true;
|
|
newItem.children = [];
|
|
List.push(newItem);
|
|
getTreeList(rootList, newItem.id, newItem.children);
|
|
}
|
|
}
|
|
return List;
|
|
}
|
|
|
|
//layui渲染树
|
|
function renderTree(treeList) {
|
|
tree.render({
|
|
elem: '#tree',
|
|
data: treeList,
|
|
isJump: false, // 禁止点击节点时跳转
|
|
showLine: false, // 不显示连接线
|
|
onlyIconControl: false, // 仅允许节点左侧图标控制展开收起
|
|
click: function(obj) {
|
|
}
|
|
});
|
|
}
|
|
|
|
//人员运动趋预警
|
|
function PersonnelMovementWarning(){
|
|
const url = commonUrl + "screen/largeScreen/personnelControl/getPersonnelMovementList";
|
|
|
|
table.render({
|
|
elem: '#dome',
|
|
url: url,
|
|
skin: 'line',
|
|
page: false,
|
|
headers:{
|
|
decrypt:"decrypt",
|
|
"Authorization":token
|
|
},
|
|
where: {
|
|
roleCode: roleCode,
|
|
orgId: orgId,
|
|
userId: userId,
|
|
bidCode: bidCode
|
|
},
|
|
cols: [[
|
|
{field: 'warningTime', align: 'center', title: '时间'},
|
|
{field: 'warningContent', align: 'center', title: '预警内容'},
|
|
]],
|
|
initComplete: function () {
|
|
// 在表格渲染完成后,重新渲染序号列
|
|
var that = this.elem.next();
|
|
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
|
|
tool.find("tr").each(function (index, item) {
|
|
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
|
|
});
|
|
},
|
|
done:function(res, curr, count, origin){
|
|
console.log(res);
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
//穿戴装备
|
|
function wearGarList(){
|
|
const url = commonUrl + "screen/largeScreen/personnelControl/getWearEquipmentList";
|
|
|
|
table.render({
|
|
elem: '#dome1',
|
|
url: url,
|
|
skin: 'line',
|
|
page: false,
|
|
headers:{
|
|
decrypt:"decrypt",
|
|
"Authorization":token
|
|
},
|
|
where: {
|
|
roleCode: roleCode,
|
|
orgId: orgId,
|
|
userId: userId,
|
|
bidCode: bidCode
|
|
},
|
|
cols: [[
|
|
{field: 'number', width:80,title: '序号', align: 'center', type: 'numbers'},
|
|
{field: 'deviceType', align: 'center', title: '装备类型'},
|
|
{field: 'deviceName', align: 'center', title: '装备名称'},
|
|
{field: 'userName', align: 'center', title: '负责人'},
|
|
{field: 'status', align: 'center', title: '状态' ,templet: function (d) {
|
|
if(d.status == 1){
|
|
return "在线";
|
|
}else if(d.status == 0){
|
|
return '<span color={red}>离线</span>';
|
|
}
|
|
}
|
|
},
|
|
{field: 'warningContent', align: 'center', title: '操作', templet: function (d) {
|
|
if (d.status == 0) {
|
|
return "--";
|
|
}else{
|
|
return '<span color={red}>开启对讲</span>';
|
|
}
|
|
|
|
}
|
|
},
|
|
]],
|
|
initComplete: function () {
|
|
// 在表格渲染完成后,重新渲染序号列
|
|
var that = this.elem.next();
|
|
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
|
|
tool.find("tr").each(function (index, item) {
|
|
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
|
|
});
|
|
},
|
|
done:function(res, curr, count, origin){
|
|
console.log(res);
|
|
}
|
|
})
|
|
|
|
}
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// 获取经纬度
|
|
var lat,lon;
|
|
if (navigator.geolocation) {
|
|
navigator.geolocation.getCurrentPosition(function (position) {
|
|
lat = position.coords.latitude;
|
|
lon = position.coords.longitude;
|
|
map= new BMap.Map("map");
|
|
map.centerAndZoom(new BMap.Point(lon,lat), 11);
|
|
map.enableScrollWheelZoom(true);
|
|
|
|
|
|
var marker = new BMap.Marker(new BMap.Point(lon,lat)); // 创建标注
|
|
map.addOverlay(marker);
|
|
});
|
|
} else {
|
|
console.log("浏览器不支持 Geolocation API");
|
|
}
|
|
let overlay; // 用于存储绘制的电子围栏
|
|
// 添加按钮点击事件
|
|
document.getElementById('customizeBtn').addEventListener('click', function() {
|
|
document.getElementById('popup').style.display = 'block';
|
|
let shapeSelect = document.getElementById('shape');
|
|
let shapeType = shapeSelect.options[shapeSelect.selectedIndex].value;
|
|
|
|
if (shapeType === 'circle') {
|
|
map.addEventListener("click", drawCircle);
|
|
} else if (shapeType === 'polygon') {
|
|
map.addEventListener("click", drawPolygon);
|
|
}
|
|
});
|
|
// 绘制圆形电子围栏
|
|
function drawCircle(e) {
|
|
if (overlay) {
|
|
map.removeOverlay(overlay);
|
|
}
|
|
let center = e.point;
|
|
let circle = new BMap.Circle(center, 2000, {
|
|
fillColor: "blue",
|
|
fillOpacity: 0.3,
|
|
strokeColor: "blue",
|
|
strokeWeight: 2,
|
|
strokeOpacity: 0.8
|
|
});
|
|
map.addOverlay(circle);
|
|
overlay = circle;
|
|
}
|
|
|
|
// 绘制多边形电子围栏
|
|
function drawPolygon(e) {
|
|
if (overlay) {
|
|
map.removeOverlay(overlay);
|
|
}
|
|
let polygon = new BMap.Polygon([
|
|
new BMap.Point(e.point.lng, e.point.lat),
|
|
new BMap.Point(e.point.lng + 0.1, e.point.lat + 0.1),
|
|
new BMap.Point(e.point.lng + 0.1, e.point.lat - 0.1)
|
|
], {strokeColor: "red", strokeWeight: 2, strokeOpacity: 0.8, fillColor: "red", fillOpacity: 0.3});
|
|
map.addOverlay(polygon);
|
|
overlay = polygon;
|
|
}
|
|
});
|
|
|
|
|
|
|