change - 设备参数页面监控单元加载处理

main
wenjy 3 years ago
parent 53289c0e18
commit a924795a43

@ -6,10 +6,14 @@
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-deviceParam-add">
<div class="form-group">
<label class="col-sm-3 control-label">设备标识:</label>
<input name="deviceId" type="hidden" id="treeId"/>
<div class="form-group">
<label class="col-sm-3 control-label">监控单元:</label>
<div class="col-sm-8">
<input name="deviceId" class="form-control" type="text">
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectMonitorTree()" id="treeName">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
@ -46,6 +50,38 @@
$.operate.save(prefix + "/add", $('#form-deviceParam-add').serialize());
}
}
/* 选择监控单元树 */
function selectMonitorTree() {
var deptId = $.common.isEmpty($("#treeId").val()) ? "" : $("#treeId").val();
var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
$(()=>{
var cp_keynum = "alarmModule_MonitorUnit";
var str = localStorage.getItem(cp_keynum);
var num = JSON.parse(str);
if(num != null) {
$("#treeId").val(num.cp_num_value.substring(0, num.cp_num_value.indexOf('/')));
$("#treeName").val(num.cp_num_value.substring(num.cp_num_value.indexOf('/')+1,num.cp_num_value.length ));
}
})
</script>
</body>
</html>

@ -2,8 +2,33 @@
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
<th:block th:include="include :: header('设备参数列表')" />
<th:block th:include="include :: layout-latest-css"/>
<th:block th:include="include :: ztree-css"/>
</head>
<body class="gray-bg">
<div class="ui-layout-west">
<div class="box box-main">
<div class="box-header">
<div class="box-title">
<i class="fa icon-grid"></i> 监控单元
</div>
<div class="box-tools pull-right">
<a type="button" class="btn btn-box-tool" href="#" onclick="monitorUnitInfo()" title="监控单元"><i
class="fa fa-edit"></i></a>
<button type="button" class="btn btn-box-tool" id="btnExpand" title="展开" style="display:none;"><i
class="fa fa-chevron-up"></i></button>
<button type="button" class="btn btn-box-tool" id="btnCollapse" title="折叠"><i
class="fa fa-chevron-down"></i></button>
<button type="button" class="btn btn-box-tool" id="btnRefresh" title="刷新"><i class="fa fa-refresh"></i>
</button>
</div>
</div>
<div class="ui-layout-content">
<div id="tree" class="ztree"></div>
</div>
</div>
</div>
<div class="ui-layout-center">
<div class="container-div">
<div class="row">
<div class="col-sm-12 search-collapse">
@ -57,14 +82,41 @@
</div>
</div>
</div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: layout-latest-js"/>
<th:block th:include="include :: ztree-js"/>
<script th:inline="javascript">
var editFlag = [[${@permission.hasPermi('base:deviceParam:edit')}]];
var removeFlag = [[${@permission.hasPermi('base:deviceParam:remove')}]];
var enableFlagDatas = [[${@dict.getType('enable_flag')}]];
var prefix = ctx + "base/deviceParam";
$(function() {
$(() => {
if (typeof (Storage) == 'undefined') {
alert('对不起,您的浏览器不支持 web 存储。')
}
});
$(function () {
var panehHidden = false;
if ($(this).width() < 769) {
panehHidden = true;
}
$('body').layout({initClosed: panehHidden, west__size: 185});
// 回到顶部绑定
if ($.fn.toTop !== undefined) {
var opt = {
win: $('.ui-layout-center'),
doc: $('.ui-layout-center')
};
$('#scroll-up').toTop(opt);
}
queryDeviceParamsList();
queryMonitorTree();
});
function queryDeviceParamsList() {
var options = {
url: prefix + "/list",
createUrl: prefix + "/add",
@ -76,12 +128,12 @@
checkbox: true
},
{
field: 'ObjId',
field: 'objId',
title: '主键标识',
visible: false
},
{
field: 'deviceId',
field: 'monitorunitName',
title: '设备标识'
},
{
@ -120,14 +172,56 @@
align: 'center',
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.ObjId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.ObjId + '\')"><i class="fa fa-remove"></i>删除</a>');
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.objId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.objId + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');
}
}]
};
$.table.init(options);
}
function queryMonitorTree() {
let url = ctx + "base/monitorUnitInfo/treeData";
let options = {
url: url,
expandLevel: 2,
onClick: zOnClick
};
$.tree.init(options);
function zOnClick(event, treeId, treeNode) {
$("#monitorunitId").val(treeNode.id);
$.table.search();
var num = new Object;
num.cp_keynum = "deviceParam_MonitorUnit";
num.cp_num_value = treeNode.id + "/" + treeNode.name;
var str = JSON.stringify(num); // 将对象转换为字符串
localStorage.setItem(num.cp_keynum, str);
}
}
$('#btnExpand').click(function () {
$._tree.expandAll(true);
$(this).hide();
$('#btnCollapse').show();
});
$('#btnCollapse').click(function () {
$._tree.expandAll(false);
$(this).hide();
$('#btnExpand').show();
});
$('#btnRefresh').click(function () {
queryMonitorTree();
});
function monitorUnitInfo() {
var url = ctx + "base/monitorUnitInfo";
$.modal.openTab("监控单元", url);
}
</script>
</body>
</html>

@ -7,11 +7,21 @@
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
<form class="form-horizontal m" id="form-deviceParam-edit" th:object="${baseDeviceParam}">
<input name="ObjId" th:field="*{ObjId}" type="hidden">
<div class="form-group">
<input name="deviceId" type="hidden" th:field="*{deviceId}" id="treeId"/>
<!--<div class="form-group">
<label class="col-sm-3 control-label">设备标识:</label>
<div class="col-sm-8">
<input name="deviceId" th:field="*{deviceId}" class="form-control" type="text">
</div>
</div>-->
<div class="form-group">
<label class="col-sm-3 control-label">监控单元:</label>
<div class="col-sm-8">
<div class="input-group">
<input class="form-control" type="text" name="treeName" onclick="selectMonitorTree()" id="treeName" th:field="*{monitorunitName}">
<span class="input-group-addon"><i class="fa fa-search"></i></span>
</div>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">参数标题:</label>
@ -47,6 +57,27 @@
$.operate.save(prefix + "/edit", $('#form-deviceParam-edit').serialize());
}
}
/* 选择监控单元树 */
function selectMonitorTree() {
var deptId = $.common.isEmpty($("#treeId").val()) ? "" : $("#treeId").val();
var url = ctx + "base/monitorUnitInfo/selectMonitorUnitInfoTree/" + deptId;
var options = {
title: '选择部门',
width: "380",
url: url,
callBack: doSubmit
};
$.modal.openOptions(options);
}
function doSubmit(index, layero){
var tree = layero.find("iframe")[0].contentWindow.$._tree;
var body = $.modal.getChildFrame(index);
$("#treeId").val(body.find('#treeId').val());
$("#treeName").val(body.find('#treeName').val());
$.modal.close(index);
}
</script>
</body>
</html>

@ -578,7 +578,7 @@
$.cookie('userID', '0000');
var wsImpl = window.WebSocket || window.MozWebSocket;
console.log("connecting to server ..");
window.ws = new wsImpl('ws://121.36.58.109:7181');
window.ws = new wsImpl('ws://127.0.0.1:7181');
ws.onmessage = function (evt) {
let result = $.parseJSON(evt.data);
console.log(result);

@ -42,6 +42,8 @@ public class BaseDeviceParam extends BaseEntity
@Excel(name = "是否启用")
private Long enableFlag;
private String monitorunitName;
public void setObjId(Long ObjId)
{
this.ObjId = ObjId;
@ -88,6 +90,14 @@ public class BaseDeviceParam extends BaseEntity
return enableFlag;
}
public String getMonitorunitName() {
return monitorunitName;
}
public void setMonitorunitName(String monitorunitName) {
this.monitorunitName = monitorunitName;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -5,8 +5,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<mapper namespace="com.ruoyi.system.mapper.BaseDeviceParamMapper">
<resultMap type="BaseDeviceParam" id="BaseDeviceParamResult">
<result property="ObjId" column="ObjId" />
<result property="objId" column="ObjId" />
<result property="deviceId" column="Device_Id" />
<result property="monitorunitName" column="MonitorUnit_Name" />
<result property="paramTitle" column="Param_Title" />
<result property="paramValue" column="Param_Value" />
<result property="enableFlag" column="Enable_Flag" />
@ -17,21 +18,43 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectBaseDeviceParamVo">
select ObjId, Device_Id, Param_Title, Param_Value, Enable_Flag, Create_By, Create_Time, Update_By, Update_Time from base_device_param
select t1.ObjId,
t1.Device_Id,
t2.MonitorUnit_Name,
t1.Param_Title,
t1.Param_Value,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_device_param t1
left join base_monitorunit_info t2 on t1.Device_Id = t2.MonitorUnit_Id
</sql>
<select id="selectBaseDeviceParamList" parameterType="BaseDeviceParam" resultMap="BaseDeviceParamResult">
<include refid="selectBaseDeviceParamVo"/>
select t1.ObjId,
t1.Device_Id,
t2.MonitorUnit_Name,
t1.Param_Title,
t1.Param_Value,
t1.Enable_Flag,
t1.Create_By,
t1.Create_Time,
t1.Update_By,
t1.Update_Time
from base_device_param t1
left join base_monitorunit_info t2 on t1.Device_Id = t2.MonitorUnit_Id
<where>
<if test="deviceId != null and deviceId != ''"> and Device_Id = #{deviceId}</if>
<if test="paramTitle != null and paramTitle != ''"> and Param_Title = #{paramTitle}</if>
<if test="enableFlag != null "> and Enable_Flag = #{enableFlag}</if>
<if test="deviceId != null and deviceId != ''"> and t1.Device_Id = #{deviceId}</if>
<if test="paramTitle != null and paramTitle != ''"> and t1.Param_Title = #{paramTitle}</if>
<if test="enableFlag != null "> and t1.Enable_Flag = #{enableFlag}</if>
</where>
</select>
<select id="selectBaseDeviceParamByObjId" parameterType="Long" resultMap="BaseDeviceParamResult">
<include refid="selectBaseDeviceParamVo"/>
where ObjId = #{ObjId}
where t1.ObjId = #{ObjId}
</select>
<insert id="insertBaseDeviceParam" parameterType="BaseDeviceParam" useGeneratedKeys="true" keyProperty="ObjId">

Loading…
Cancel
Save