You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
829 lines
28 KiB
829 lines
28 KiB
2 years ago
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||
|
pageEncoding="UTF-8"%>
|
||
|
<%@ page import="com.lp.cfg.ProConfig"%>
|
||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
|
||
|
<!DOCTYPE html>
|
||
|
<html>
|
||
|
<head>
|
||
|
<%@ include file="/WEB-INF/oss/iot/common/variable.jsp"%>
|
||
|
<%@ include file="/WEB-INF/oss/iot/common/variable_js.jsp"%>
|
||
|
<%@ include file="/WEB-INF/oss/iot/common/resource_lib.jsp"%>
|
||
|
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=<%=ProConfig.Map.BAIDU_MAP_KEY%>"></script>
|
||
|
<style type="text/css">
|
||
|
#map {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
|
||
|
.mapContainer{
|
||
|
height: 550px;width:100%;
|
||
|
}
|
||
|
.index_theLeft ul {
|
||
|
width: 100%;
|
||
|
padding: 0px;
|
||
|
margin: 0px;
|
||
|
overflow: auto;
|
||
|
}
|
||
|
|
||
|
.mapContainer{
|
||
|
height: 550px;width:100%;padding-left:170px;
|
||
|
}
|
||
|
|
||
|
.app-container{
|
||
|
background: #f2f2f2;width: 100%;border-top:1px solid #ecf0f5;
|
||
|
}
|
||
|
|
||
|
.box-white {
|
||
|
width: 97%;
|
||
|
min-width: 897px;
|
||
|
padding-bottom: 0;
|
||
|
margin: 0 auto;
|
||
|
}
|
||
|
.box {
|
||
|
padding: 10px;
|
||
|
padding-top:1px;
|
||
|
border-left: 1px solid #d2d6de;
|
||
|
border-right: 1px solid #d2d6de;
|
||
|
border-bottom: 1px solid #d2d6de;
|
||
|
}
|
||
|
.box {
|
||
|
border: 0!important;
|
||
|
box-shadow: 0 0 2px 1px rgba(13,5,9,.08)!important;
|
||
|
}
|
||
|
.box {
|
||
|
position: relative;
|
||
|
border-radius: 3px;
|
||
|
background: #fff;
|
||
|
border-top: 3px solid #d2d6de;
|
||
|
margin-bottom: 20px;
|
||
|
width: 100%;
|
||
|
box-shadow: 0 1px 1px rgba(0,0,0,.1);
|
||
|
}
|
||
|
|
||
|
.sceneList-info{
|
||
|
padding-top: 10px;
|
||
|
padding-left: 10px;
|
||
|
}
|
||
|
.generateStyle ,.infosgs {
|
||
|
position: absolute;
|
||
|
top: 18px;
|
||
|
right: 10px;
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
.webui-popover{
|
||
|
z-index: 19991015;
|
||
|
}
|
||
|
.showbtn{
|
||
|
position: absolute;
|
||
|
top: 22px;
|
||
|
right: 56px;
|
||
|
background: #4CAF50;
|
||
|
color: #fff;
|
||
|
padding: 2px 4px;
|
||
|
border-radius: 3px;
|
||
|
cursor: pointer;
|
||
|
}
|
||
|
.input-map{
|
||
|
background-size: 5% ;
|
||
|
}
|
||
|
.BMap_cpyCtrl {
|
||
|
display: none;
|
||
|
}
|
||
|
.pro-span{
|
||
|
background: #4caf50;
|
||
|
padding: 3px 6px;
|
||
|
color: #fff;
|
||
|
border-radius: 4px;
|
||
|
|
||
|
}
|
||
|
</style>
|
||
|
</head>
|
||
|
<body>
|
||
|
<div>
|
||
|
<!-- 下方部位 -->
|
||
|
<div>
|
||
|
<!-- 左边栏 -->
|
||
|
<div class="float-left index_theLeft" style="width:170px;">
|
||
|
<div class="prolist">
|
||
|
<span>项目列表</span>
|
||
|
</div>
|
||
|
<ul class="dashboard-menu scoll">
|
||
|
<c:forEach items="${info.data.getData()}" varStatus="status" var="obj">
|
||
|
<li onclick="changeScene(this)"
|
||
|
<c:if test="${status.index ==0}">
|
||
|
class="active"
|
||
|
</c:if>
|
||
|
sid="${obj.id}">
|
||
|
<span class="icon-stack-overflow"></span> ${obj.name }
|
||
|
</li>
|
||
|
</c:forEach>
|
||
|
</ul>
|
||
|
</div>
|
||
|
<div class="mapContainer" >
|
||
|
<div class="app-container">
|
||
|
<div class="container-layout sceneList-info">
|
||
|
<div class="box join-device-box">
|
||
|
|
||
|
<div class="search-container jui-search_table" data-options="submit:'#searchbtns',
|
||
|
table:'#init-table'">
|
||
|
<span class="titleName">设备管理</span>
|
||
|
<input type-name="name" placeholder="设备名称" class="input input-self" />
|
||
|
<input type-name="scene_id" class="scene_id" type="hidden" />
|
||
|
|
||
|
<button onclick="bindDevice();" class="button ml-20 bg-iot float-right"><span class=" icon-copy"></span> 绑定设备</button>
|
||
|
<button onclick="addNode();" class="button ml-20 bg-iot float-right"><span class="icon-plus"></span> 新增设备</button>
|
||
|
<button id="searchbtns" class="button ml-20 bg-iot"><span class="icon-search"></span> 查询</button>
|
||
|
</div>
|
||
|
|
||
|
<div style="margin-top:10px;">
|
||
|
<div id="init-table" type-option="table" config-option="url:'/page/node',
|
||
|
param:{ scene_id:'$.scene_id$' },
|
||
|
columns:[
|
||
|
{'name':'序号','type':'seq','value':'seq','width':'5%'},
|
||
|
{'name':'设备名称','value':'name',limit:15,'width':'15%'},
|
||
|
{'name':'设备号','value':'device_code',limit:20,'width':'20%'},
|
||
|
{'name':'设备协议','type':'self','value_callback':'func_type_name','value':'iot_node_type','width':'8%'},
|
||
|
{'name':'上传周期','value':'frequency','width':'9%' },
|
||
|
{'name':'所属项目','value':'scene_name',limit:10,'width':'15%'},
|
||
|
{'name':'属性设置','type':'self','value_callback':'value_function2','width':'8%'},
|
||
|
{'name':'操作','type':'self','value_callback':'value_function','width':'20%'}]" >
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div style="display:none;padding:20px;" type-option="form_submit" id="addNode"
|
||
|
config-option=" 'url':'/node',
|
||
|
'submit':'.add-Btn',
|
||
|
'success':'sunccessReturn' ">
|
||
|
<input type-name="scene_id" class="scene_id" type="hidden" >
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备名称:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="输入设备名称" validate="empty" type-name="name" class="input input-big clear-v" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备号:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<input placeholder="输入设备号SN" type="text" validate="empty:设备号不能为空" maxlength="62" type-name="device_code" class="input input-big clear-v" >
|
||
|
<img class="generateStyle" onclick="generateCode(this)" src="<%=basePath%>/image/oss/iot/generate.png">
|
||
|
<span class="showbtn" onclick="showHexInfo(this)" >HEX格式</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<div class="float-left" style="width: 48%;">
|
||
|
<span class="red">*</span> <span>通讯协议:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<select type-name="iot_node_type" validate="empty" onchange="nodeTypeChange(this)" type-option="selecter"
|
||
|
config-option="'method':'GET','url':'/dictionary/81','init_value':'请选择通讯协议','key':'code','value':'name','type':'list' "
|
||
|
class="input input-big input-select clear-v" ></select>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="float-left" style="width: 48%;margin-left: 4%;" >
|
||
|
<span class="red">*</span> <span>数据协议:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<select type-name="iot_protocal_category" onchange="protocalChange(this)" validate="empty" type-option="selecter"
|
||
|
config-option="'method':'GET','url':'/dictionary/300','init_value':'请选择设备协议','key':'dictionary_name','value':'name','type':'list' "
|
||
|
class="input input-big input-select clear-v nodetypeselect" ></select>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<div>
|
||
|
<span>经纬度:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="设置设备默认经纬度" type-name="lonLat" class="input input-big input-map" style="background-position-x: 524px;" onclick="showMap(this)" >
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line infos-container hide">
|
||
|
<span>配置参数:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;" >
|
||
|
<input placeholder="按照协议填写,可不填" style="padding-right: 50px;" readonly="readonly" type-name="infos" class="input input-big infos" >
|
||
|
<img class="infosgs self-icon" tag='参数配置' onclick="generateCode12(this)" src="<%=basePath%>/image/oss/iot/settings.png">
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line" style="overflow: hidden;zoom:1;">
|
||
|
<div class="float-left" style="width: 49%;">
|
||
|
<span>上传周期[ 秒 ]:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="填写 0,则不进行监控 单位s" value="30" validate="empty" type-name="frequency" class="input input-big" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="float-left" style="width: 49%; margin-left: 2%; ">
|
||
|
<span>排序:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="显示顺序" type="number" oninput="if(value.length>5) value=value.slice(0,5)" value="1" validate="empty" type-name="seq" class="input input-big" >
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line clearfix">
|
||
|
<button onclick="closeAll();" class="button border-gray ml-10 button-big float-right">取消</button>
|
||
|
<button class="add-Btn button ml-20 bg-iot button-big float-right">保存</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div style="display:none;padding:20px;" type-option="form_submit" id="bindNode"
|
||
|
config-option=" 'url':'/node/bind',
|
||
|
'submit':'.bind-Btn',
|
||
|
'success':'sunccessReturn' ">
|
||
|
<input type-name="scene_id" class="scene_id" type="hidden" >
|
||
|
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备号:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<input placeholder="输入设备号SN" validate="empty:设备号不能为空" type="text" maxlength="62" type-name="device_code" class="input input-big clear-v" >
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-line clearfix">
|
||
|
<button onclick="closeAll();" class="button border-gray ml-10 button-big float-right">取消</button>
|
||
|
<button class="bind-Btn button ml-20 bg-iot button-big float-right">保存</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div style="display:none;padding:20px;" type-option="form_submit" id="addCopyNode"
|
||
|
config-option=" 'url':'/node',
|
||
|
'submit':'.add-copy-Btn',
|
||
|
'success':'sunccessReturn' ">
|
||
|
<input type-name="scene_id" class="scene_id" type="hidden" >
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备名称:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="输入设备名称" validate="empty" type-name="name" class="input input-big clear-v" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备号:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<input placeholder="输入设备号SN" validate="empty:设备号不能为空" type="text" maxlength="62" type-name="device_code" class="input input-big clear-v" >
|
||
|
<img class="generateStyle" onclick="generateCode(this)" src="<%=basePath%>/image/oss/iot/generate.png">
|
||
|
<span class="showbtn" onclick="showHexInfo(this)" >HEX格式</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>同类型设备号:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="输入同类型 设备号" validate="empty" type-name="copy_device_code" class="input device_copy input-big clear-v" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line clearfix">
|
||
|
<button onclick="closeAll();" class="button border-gray ml-10 button-big float-right">取消</button>
|
||
|
<button class="add-copy-Btn button ml-20 bg-iot button-big float-right">保存</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div style="display:none;padding:20px;" type-option="form_submit" id="modifyNode"
|
||
|
config-option=" 'url':'/node','method':'put',
|
||
|
'submit':'.modify-Btn',
|
||
|
'success':'sunccessReturn' ">
|
||
|
<div id="detail_get" config-option=" 'url':'/node?id=$#init-id$' , 'success':'successbtn' ">
|
||
|
<input type="hidden" type-name="id" id="init-id" >
|
||
|
<input type-name="scene_id" class="scene_id" type="hidden" >
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备名称:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="设备名称" validate="empty" type-name="name" class="input input-big" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<span class="red">*</span> <span>设备号:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;" >
|
||
|
<input placeholder="输入设备号SN" readonly="readonly" type="text" maxlength="62" validate="empty" type-name="device_code" class="input input-big" >
|
||
|
<span></span>
|
||
|
<span class="showbtn" style="right: 20px;" onclick="showHexInfo(this)" >HEX格式</span>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="form-line">
|
||
|
<div class="float-left" style="width: 48%; ">
|
||
|
<span class="red">*</span> <span>设备通讯协议:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<select type-name="iot_node_type" onchange="nodeTypeChange(this)" validate="empty" type-option="selecter"
|
||
|
config-option="'method':'GET','url':'/dictionary/81','key':'code','value':'name','type':'list' "
|
||
|
class="input input-big input-select modify_node_type " ></select>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="float-left" style="width: 48%;margin-left: 4%;" >
|
||
|
<span class="red">*</span> <span>数据协议:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<select type-name="iot_protocal_category" onchange="protocalChange(this)" validate="empty" class="input input-big input-select nodetypeselect" ></select>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
|
||
|
<div class="form-line infos-container hide">
|
||
|
<span>配置参数:</span>
|
||
|
<div class="pb-10 pt-10" style="position: relative;">
|
||
|
<input placeholder="按照协议填写,可不填" readonly="readonly" style="padding-right: 50px;" type-name="infos" class="input input-big infos infos-edit" >
|
||
|
<img class="infosgs self-icon" tag='参数配置' onclick="generateCode12(this)" src="<%=basePath%>/image/oss/iot/settings.png">
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-line">
|
||
|
<span>经纬度:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="设置设备默认经纬度" type-name="lonLat" class="input input-big input-map" style="background-position-x: 524px;" onclick="showMap(this)" >
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
|
||
|
<div class="form-line">
|
||
|
<div class="float-left" style="width: 49%;">
|
||
|
<span>上传周期[ 秒 ]:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="填写0,则不进行监控,单位s" value="30" validate="empty" type-name="frequency" class="input input-big" >
|
||
|
</div>
|
||
|
</div>
|
||
|
<div class="float-left" style="width: 49%; margin-left: 2%; ">
|
||
|
<span>排序:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<input placeholder="显示顺序" type="number" oninput="if(value.length>5) value=value.slice(0,5)" validate="empty" type-name="seq" class="input input-big" >
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="form-line clearfix">
|
||
|
<button onclick="closeAll();" class="button border-gray ml-10 button-big float-right">取消</button>
|
||
|
<button class="modify-Btn button ml-20 bg-iot button-big float-right">保存</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="map_container" class="hide">
|
||
|
<div style="height: 350px;width: 100%;">
|
||
|
<div id="map"></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div id="template_config" class="hide">
|
||
|
<div class="form-line"style="padding: 10px;">
|
||
|
<table class="table table-bordered">
|
||
|
<thead class="lpro-thead">
|
||
|
<tr>
|
||
|
<td>从机地址</td>
|
||
|
<td>功能码</td>
|
||
|
<td>寄存器起始地址</td>
|
||
|
<td>读取长度</td>
|
||
|
<td style="width: 120px;">操作</td>
|
||
|
</tr>
|
||
|
</thead>
|
||
|
<tbody class="tbody infoslist">
|
||
|
<tr>
|
||
|
<td>
|
||
|
<input id="address" type="number" placeholder="10进制数" class="input">
|
||
|
</td>
|
||
|
<td>
|
||
|
<select class="input" id="fcode" style="width: 90px;">
|
||
|
<option value='01' >01</option>
|
||
|
<option value='02' >02</option>
|
||
|
<option value='03' >03</option>
|
||
|
<option value='04' >04</option>
|
||
|
<option value='05' >05</option>
|
||
|
<option value='06' >06</option>
|
||
|
</select>
|
||
|
</td>
|
||
|
<td>
|
||
|
<input class="input" type="number" placeholder="10进制数" id="startaddress">
|
||
|
</td>
|
||
|
<td>
|
||
|
<input class="input" type="number" placeholder="10进制数" id="length">
|
||
|
</td>
|
||
|
<td>
|
||
|
<button onclick="addInfos()" class="button small-button bg-iot">增加</button>
|
||
|
</td>
|
||
|
</tr>
|
||
|
</tbody>
|
||
|
</table>
|
||
|
<div class="form-line clearfix" style="padding-top: 20px;">
|
||
|
<button onclick="saveInfo();" class="button ml-20 bg-iot button-big float-right">保存确认</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="grant_auth hide">
|
||
|
<div style="padding: 30px;">
|
||
|
<div class="form-line" >
|
||
|
<span class="red">*</span> <span>项目名称:</span>
|
||
|
<div class="pb-10 pt-10">
|
||
|
<select validate="empty:请选择场景名称" config-option=" url:'/page/scene?paged=1&pageSize=100',key:'id',value:'name',init_value:'请选择项目', data :{} " class="input input-big input-select jui-selecter sceneinfoid" ></select>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
<div class="mt-20 clearfix">
|
||
|
<button onclick="closeAll();" class="button border-gray ml-10 button-big float-right">取消</button>
|
||
|
<button onclick="saveSceneInfo();" class="saveScene button ml-20 bg-iot button-big float-right">保存</button>
|
||
|
</div>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
<script type="text/javascript">
|
||
|
|
||
|
var lt ;
|
||
|
function showMap(obj){
|
||
|
lt = openWindow("地图获取","#map_container","600px");
|
||
|
if(! validater.empty( $(obj).val() ) ){
|
||
|
// 如果当前已有定位,则将定位显示到地图上
|
||
|
theLocation2($(obj).val().split(",")[0],$(obj).val().split(",")[1]);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function showHexInfo(obj){
|
||
|
|
||
|
var val = stringToHex($(obj).prev().prev().val()) ;
|
||
|
|
||
|
layer.alert(val, {
|
||
|
title: 'HEX设备码格式',
|
||
|
closeBtn: 0
|
||
|
});
|
||
|
|
||
|
}
|
||
|
|
||
|
var map ;
|
||
|
|
||
|
function theLocation2(lon,lat){
|
||
|
map.clearOverlays();
|
||
|
var icon = new BMap.Icon('<%=basePath%>/image/oss/iot/location2.png', new BMap.Size(32, 32), {
|
||
|
anchor: new BMap.Size(32, 32)
|
||
|
});
|
||
|
var mkr = new BMap.Marker(new BMap.Point(lon,lat), {
|
||
|
icon: icon
|
||
|
});
|
||
|
var new_point = new BMap.Point(lon,lat);
|
||
|
map.addOverlay(mkr);
|
||
|
// 如果已有定位,则地图以改中心点居中
|
||
|
setTimeout(function(){
|
||
|
map.panTo(new_point);
|
||
|
},200);
|
||
|
|
||
|
}
|
||
|
|
||
|
function addNodeType(){
|
||
|
forwardUrl("/iot/device_template_manager");
|
||
|
|
||
|
}
|
||
|
function changeScene(obj){
|
||
|
$(".dashboard-menu li").removeClass("active");
|
||
|
$(obj).addClass("active");
|
||
|
$(".scene_id").val($(".dashboard-menu li.active").attr("sid"));
|
||
|
reflash( $(".dashboard-menu li.active").attr("sid"));
|
||
|
}
|
||
|
function reflash(id){
|
||
|
$("#init-table").data("params",{ scene_id: $(".scene_id").val() });
|
||
|
$("#init-table").tableAdaptor();
|
||
|
}
|
||
|
|
||
|
function addNode(){
|
||
|
// 判断是否增加项目,没有的话,则提示
|
||
|
if($(".scene_id").val()!=null && $(".scene_id").val()!= ''){
|
||
|
openWindow("新增设备","#addNode","600px");
|
||
|
// 清空表单
|
||
|
$("#addNode .clear-v").val("");
|
||
|
$(".infos-container").hide();
|
||
|
$(".input-map").val("");
|
||
|
$(".infos").val('');
|
||
|
}else{
|
||
|
tip("请先添加项目信息");
|
||
|
}
|
||
|
}
|
||
|
function value_function2(data,seq){
|
||
|
return "<span tag='设备配置' onclick='t_editSensor(this,"+data.id+")' class='self-icon icon-list'></span>";
|
||
|
}
|
||
|
function value_function(data,seq){
|
||
|
return "<span tag='编辑' onclick='t_edit(this,"+data.id+")' class='self-icon icon-edit'></span>"+
|
||
|
"<span tag='删除' onclick='t_delete(this,"+data.id+")' class='self-icon icon-bitbucket'></span>"+
|
||
|
"<span tag='克隆新增' onclick='t_copy(this,"+seq+")' class='self-icon icon-copy'></span>"+
|
||
|
"<span tag='设备迁移' onclick='t_generateScene(this,"+data.id+")' class='self-icon icon-exchange'></span>" ;
|
||
|
}
|
||
|
var tmp_node_id = -1 ;
|
||
|
function t_generateScene(obj,id){
|
||
|
tmp_node_id = id ;
|
||
|
openWindow("设备迁移",".grant_auth","400px");
|
||
|
}
|
||
|
|
||
|
function t_editSensor(obj,id){
|
||
|
// 打开窗口查看传感器列表
|
||
|
layer.open({
|
||
|
type: 2,
|
||
|
title: '传感器列表',
|
||
|
shadeClose: true,
|
||
|
shade: 0.7,
|
||
|
maxmin: true, //开启最大化最小化按钮
|
||
|
area: ['900px', '90%'],
|
||
|
content: "<%=basePath%>/service/iot/sensors_manger?node_id="
|
||
|
+ id
|
||
|
});
|
||
|
}
|
||
|
|
||
|
function saveSceneInfo(){
|
||
|
if($(".sceneinfoid").val() != null && $(".sceneinfoid").val() != "" ){
|
||
|
commonAjax('PUT',localUrl+'/node.json', {scene_id:$(".sceneinfoid").val() , id:tmp_node_id },function(data){
|
||
|
if(isOK(data)){
|
||
|
tip("成功");
|
||
|
setTimeout(function(){
|
||
|
$("#init-table").tableAdaptor();
|
||
|
closeAll() ;
|
||
|
}, 500);
|
||
|
}
|
||
|
});
|
||
|
}else{
|
||
|
tip("请选择迁移到的项目名称");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//设备协议
|
||
|
function func_type_name(obj){
|
||
|
if(obj == 82 ){
|
||
|
return "<span class='pro-span'>HTTP</span>" ;
|
||
|
}else if(obj == 83 ){
|
||
|
return "<span class='pro-span'>TCP</span>" ;
|
||
|
}else if(obj == 84) {
|
||
|
return "<span class='pro-span'>MQTT</span>" ;
|
||
|
}else if(obj == 105) {
|
||
|
return "<span class='pro-span'>UDP</span>" ;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function sunccessReturn(data){
|
||
|
if( data.status == status_code.OK ){
|
||
|
tip("成功");
|
||
|
|
||
|
setTimeout(function(){
|
||
|
closeAll();
|
||
|
$("#init-table").tableAdaptor();
|
||
|
},1000)
|
||
|
}else{
|
||
|
tip(data.statusMsg);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function bindDevice(){
|
||
|
if($(".scene_id").val()!=null && $(".scene_id").val()!= ''){
|
||
|
openWindow("绑定设备","#bindNode","600px");
|
||
|
$("#bindNode .clear-v").val("");
|
||
|
}else{
|
||
|
tip("请选择一个项目");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function copyAdd(){
|
||
|
if($(".scene_id").val()!=null && $(".scene_id").val()!= ''){
|
||
|
openWindow("快捷新增设备","#addCopyNode","600px");
|
||
|
$("#addCopyNode .clear-v").val("");
|
||
|
$(".device_copy").attr("readonly",false);
|
||
|
}else{
|
||
|
tip("请选择一个项目");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function t_copy(obj,id){
|
||
|
// addCopyNode
|
||
|
// 判断是否增加项目,没有的话,则提示
|
||
|
if($(".scene_id").val()!=null && $(".scene_id").val()!= ''){
|
||
|
openWindow("快捷新增设备","#addCopyNode","600px");
|
||
|
|
||
|
$("#addCopyNode .clear-v").val("");
|
||
|
$(".device_copy").val( $("#init-table").data("cache")[id].device_code);
|
||
|
$(".device_copy").attr("readonly",true);
|
||
|
// 清空表单
|
||
|
}else{
|
||
|
tip("请先添加项目信息");
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function t_edit(obj,id){
|
||
|
writeVal("init-id",id);
|
||
|
|
||
|
manual_init_detail_get($("#detail_get"));
|
||
|
|
||
|
setTimeout(function() {
|
||
|
openWindow("编辑设备","#modifyNode","600px");
|
||
|
}, 200);
|
||
|
|
||
|
}
|
||
|
|
||
|
function t_delete(obj,id){
|
||
|
lcomfirm('是否确定删除该设备?',function(){
|
||
|
commonAjax("DELETE",localUrl+"/node?id="+id, "",function(){
|
||
|
tip("删除成功");
|
||
|
setTimeout(function(){
|
||
|
closeAll();
|
||
|
$("#init-table").tableAdaptor();
|
||
|
},1000)
|
||
|
});
|
||
|
});
|
||
|
}
|
||
|
function randomWord1(randomFlag, min, max) {
|
||
|
let str = "",
|
||
|
range = min,
|
||
|
arr = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||
|
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
|
||
|
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||
|
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L',
|
||
|
'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];
|
||
|
|
||
|
if (randomFlag) {
|
||
|
range = Math.round(Math.random() * (max - min)) + min;// 任意长度
|
||
|
}
|
||
|
for (var i = 0; i < range; i++) {
|
||
|
pos = Math.round(Math.random() * (arr.length - 1));
|
||
|
str += arr[pos];
|
||
|
}
|
||
|
return str;
|
||
|
}
|
||
|
function generateCode(obj){
|
||
|
$(obj).prev().val(randomWord1(true,6,28));
|
||
|
}
|
||
|
$(function(){
|
||
|
|
||
|
$(".generateStyle").webuiPopover({
|
||
|
content: '随机生成设备码' ,
|
||
|
placement:'top',
|
||
|
trigger:'hover',
|
||
|
style:'inverse',
|
||
|
padding:false});
|
||
|
|
||
|
$(".scene_id").val($(".dashboard-menu li.active").attr("sid"));
|
||
|
|
||
|
|
||
|
// 百度地图API功能
|
||
|
map = new BMap.Map("map"); // 创建Map实例
|
||
|
map.setMapStyle({
|
||
|
styleJson: [{
|
||
|
"featureType": "road",//道路
|
||
|
"elementType": "all",
|
||
|
"stylers": {
|
||
|
"color": "#ffffff",
|
||
|
"visibility": "off"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"featureType": "building",
|
||
|
"elementType": "all",
|
||
|
"stylers": {
|
||
|
"visibility": "off"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"featureType": "poilabel",//景点
|
||
|
"elementType": "all",
|
||
|
"stylers": {
|
||
|
"visibility": "off"
|
||
|
}
|
||
|
},
|
||
|
{
|
||
|
"featureType": "manmade",//学院
|
||
|
"elementType": "all",
|
||
|
"stylers": {
|
||
|
"visibility": "off"
|
||
|
}
|
||
|
}
|
||
|
]
|
||
|
});
|
||
|
map.centerAndZoom('南京', 9); // 初始化地图,设置中心点坐标和地图级别
|
||
|
//添加地图类型控件
|
||
|
map.addControl(new BMap.MapTypeControl({
|
||
|
mapTypes:[
|
||
|
BMAP_NORMAL_MAP,
|
||
|
BMAP_HYBRID_MAP
|
||
|
]}));
|
||
|
map.enableScrollWheelZoom(true); //开启鼠标滚轮缩放
|
||
|
|
||
|
map.addEventListener("click", showInfo);
|
||
|
|
||
|
function showInfo(e){
|
||
|
theLocation(e.point.lng , e.point.lat);
|
||
|
}
|
||
|
|
||
|
function theLocation(lon,lat){
|
||
|
map.clearOverlays();
|
||
|
var icon = new BMap.Icon('<%=basePath%>/image/oss/iot/location2.png', new BMap.Size(32, 32), {
|
||
|
anchor: new BMap.Size(32, 32)
|
||
|
});
|
||
|
var mkr = new BMap.Marker(new BMap.Point(lon,lat), {
|
||
|
icon: icon
|
||
|
});
|
||
|
var new_point = new BMap.Point(lon,lat);
|
||
|
map.addOverlay(mkr);
|
||
|
tip("标注成功");
|
||
|
gic("lonLat").val(lon+","+lat);
|
||
|
setTimeout(function() {
|
||
|
layer.close(lt) ;
|
||
|
}, 1000);
|
||
|
}
|
||
|
|
||
|
})
|
||
|
function stringToHex(str){
|
||
|
var val="";
|
||
|
for(var i = 0; i < str.length; i++){
|
||
|
if(val == "")
|
||
|
val = str.charCodeAt(i).toString(16).toUpperCase();
|
||
|
else
|
||
|
val += str.charCodeAt(i).toString(16).toUpperCase();
|
||
|
}
|
||
|
return val;
|
||
|
}
|
||
|
|
||
|
var aindex ;
|
||
|
|
||
|
function generateCode12(obj){
|
||
|
$(".aaa").remove();
|
||
|
try{
|
||
|
if( $(".infos-edit").val() != '' ){
|
||
|
var data = $.parseJSON( $(".infos-edit").val() );
|
||
|
for(var i=0;i< data.length;i++){
|
||
|
$(".infoslist").append( reHtmlVal(data[i].address,data[i].fcode,data[i].saddr,data[i].length ) );
|
||
|
}
|
||
|
}
|
||
|
aindex = openWindow("ModbusRTU批量读配置【可不填】","#template_config","700px");
|
||
|
}catch(a){
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function addInfos(){
|
||
|
var a = $("#address").val();
|
||
|
var b = $("#fcode").val();
|
||
|
var c = $("#startaddress").val();
|
||
|
var d = $("#length").val();
|
||
|
if(a == "" || c=="" || d==""){
|
||
|
tip("请填写完整");
|
||
|
return ;
|
||
|
}
|
||
|
$(".infoslist").append( reHtmlVal(a,b,c,d ) );
|
||
|
$("#address").val('');
|
||
|
$("#fcode").val('');
|
||
|
$("#startaddress").val('');
|
||
|
$("#length").val('');
|
||
|
}
|
||
|
|
||
|
function reHtmlVal(a,b,c,d){
|
||
|
return "<tr class='aaa'><td>"+a+"</td><td>"+b+"</td><td>"+c+"</td><td>"+d+"</td><td> <button onclick='removeinfo(this)' style='color:red;' class='button'>删除</button> </td> </tr>" ;
|
||
|
}
|
||
|
|
||
|
function removeinfo(obj){
|
||
|
$(obj).parent().parent().remove();
|
||
|
}
|
||
|
|
||
|
function saveInfo(){
|
||
|
var dataall = [] ;
|
||
|
for(var i=0; i < $(".aaa").length ; i++ ){
|
||
|
dataall.push({
|
||
|
address:$(".aaa").eq(i).children().eq(0).html() ,
|
||
|
fcode:$(".aaa").eq(i).children().eq(1).html() ,
|
||
|
saddr:$(".aaa").eq(i).children().eq(2).html() ,
|
||
|
length:$(".aaa").eq(i).children().eq(3).html()
|
||
|
});
|
||
|
}
|
||
|
$(".infos").val(JSON.stringify(dataall));
|
||
|
layer.close(aindex);
|
||
|
}
|
||
|
|
||
|
function nodeTypeChange(obj, default_value){
|
||
|
var s = '' ;
|
||
|
if( default_value != null ){
|
||
|
s+= default_value ;
|
||
|
}
|
||
|
if( $(obj).val() == '83' ){
|
||
|
// TCP
|
||
|
init_select({ 'method':'GET','url':'/dictionary/300','init_value':'请选择设备协议','key':'dictionary_name','value':'name','type':'list','default_value':s } ,$(".nodetypeselect") );
|
||
|
}else if( $(obj).val() == '84' || $(obj).val() == '82' || $(obj).val() == '105' ){
|
||
|
// MQTT
|
||
|
init_select({'method':'GET','url':'/dictionary?ids=305','init_value':'请选择设备协议','key':'dictionary_name','value':'name','type':'list','default_value':s } ,$(".nodetypeselect") );
|
||
|
}else{
|
||
|
$(".nodetypeselect").val('');
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function protocalChange(obj){
|
||
|
if( $(obj).val() == 'ProtocalModbus' || $(obj).val() == 'ProtocalModbusTcp' ){
|
||
|
$(".infos-container").show();
|
||
|
}else{
|
||
|
$(".infos-container").hide();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
function successbtn(data){
|
||
|
if(data.data.iot_protocal_category == 'ProtocalModbus' || data.data.iot_protocal_category == 'ProtocalModbusTcp' ){
|
||
|
$(".infos-container").show();
|
||
|
}else{
|
||
|
$(".infos-container").hide();
|
||
|
}
|
||
|
|
||
|
nodeTypeChange( $(".modify_node_type"), data.data.iot_protocal_category ) ;
|
||
|
}
|
||
|
$(function(){
|
||
|
$(document).delegate(".limiter","click",function(){
|
||
|
layer.tips($(this).attr("tag") , this, {
|
||
|
tips: [1, '#4682B4']
|
||
|
});
|
||
|
})
|
||
|
})
|
||
|
|
||
|
</script>
|
||
|
</html>
|