Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/work/modbusInterfaceEdit.jsp

491 lines
20 KiB
Plaintext
Raw Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ page import="com.sipai.entity.base.ServerObject" %>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security" %>
<%@page import="com.sipai.entity.data.DataCurve" %>
<style type="text/css">
.select2-container .select2-selection--single {
height: 34px;
line-height: 34px;
}
.select2-selection__arrow {
margin-top: 3px;
}
</style>
<script type="text/javascript">
function doFAsave() {
$.post(ext.contextPath + "/work/interfaceModbus/doUpdate.do", $("#subForm_interfaceEdit").serialize(), function (result) {
if (result.code == 1) {
showAlert('s', '更新成功!');
initTreeView($("#id").val());
} else {
showAlert('d', result.msg);
}
});
}
//多删
var delConfigFuns = function () {
var checkedItems = $("#config_table").bootstrapTable('getSelections');
var datas = "";
$.each(checkedItems, function (index, item) {
datas += item.id + ",";
});
if (datas == "") {
showAlert('d', '请先选择记录', 'mainAlertdiv');
} else {
swal({
text: "您确定要删除此记录?",
dangerMode: true,
buttons: {
cancel: {
text: "取消",
value: null,
visible: true,
className: "btn btn-default btn-sm",
closeModal: true,
},
confirm: {
text: "确定",
value: true,
visible: true,
className: "btn btn-danger btn-sm",
closeModal: true
}
}
})
.then(function (willDelete) {
if (willDelete) {
$.post(ext.contextPath + '/work/configModbus/deletes.do', {ids: datas}, function (data) {
if (data.code == 1) {
$("#config_table").bootstrapTable('refresh');
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
});
}
});
}
};
//多删
var delPointFuns = function () {
var checkedItems = $("#point_table").bootstrapTable('getSelections');
var datas = "";
$.each(checkedItems, function (index, item) {
datas += item.id + ",";
});
if (datas == "") {
showAlert('d', '请先选择记录', 'mainAlertdiv');
} else {
swal({
text: "您确定要删除此记录?",
dangerMode: true,
buttons: {
cancel: {
text: "取消",
value: null,
visible: true,
className: "btn btn-default btn-sm",
closeModal: true,
},
confirm: {
text: "确定",
value: true,
visible: true,
className: "btn btn-danger btn-sm",
closeModal: true
}
}
})
.then(function (willDelete) {
if (willDelete) {
$.post(ext.contextPath + '/work/pointModbus/deletes.do', {ids: datas}, function (data) {
if (data.code == 1) {
$("#point_table").bootstrapTable('refresh');
} else {
showAlert('d', '删除失败', 'mainAlertdiv');
}
});
}
});
}
};
$("#subForm_interfaceEdit").bootstrapValidator({
live: 'disabled',//验证时机enabled是内容有变化就验证默认disabled和submitted是提交再验证
fields: {
name: {
validators: {
notEmpty: {
message: '名称不能为空'
}
}
},
ip: {
validators: {
notEmpty: {
message: 'ip不能为空'
}
}
},
port: {
validators: {
notEmpty: {
message: 'ip不能为空'
}
}
}
}
});
function dodel() {
$.post(ext.contextPath + '/work/interfaceModbus/delete.do', {id: '${modbusInterface.id}'}, function (data) {
if (data.code == 1) {
initTreeView();
} else {
showAlert('d', result.msg);
}
});
}
function doInit() {
$.post(ext.contextPath + '/work/interfaceModbus/doInit.do', {id: '${modbusInterface.id}'}, function (data) {
if (data.code == 1) {
showAlert('s', result.msg);
} else {
showAlert('d', result.msg);
}
});
}
function dotest() {
$.post(ext.contextPath + '/work/interfaceModbus/dotest.do', {}, function (data) {
if (data.code == 1) {
showAlert('s', result.msg);
} else {
showAlert('d', result.msg);
}
});
}
var addConfigFun = function () {
$.post(ext.contextPath + '/work/configModbus/doAdd.do', {pid: '${modbusInterface.id}'}, function (data) {
$("#configsubDiv").html(data);
openModal('subdivConfig');
});
};
var addPointFun = function (pid) {
$.post(ext.contextPath + '/work/pointModbus/doAdd.do', {pId: '${modbusInterface.id}'}, function (data) {
$("#pointsubDiv").html(data);
openModal('subdivPointAdd');
});
};
var editMpointFun = function (id) {
$.post(ext.contextPath + '/data/editMPoint.do', {unitId: unitId, id: id, pid: '${curve.id}'}, function (data) {
$("#subDiv").html(data);
openModal('subModal');
//ComponentsDateTimePickers.init();
});
};
var editConfigFun = function (id) {
$.post(ext.contextPath + '/work/configModbus/doEdit.do', {id: id}, function (data) {
$("#configEditsubDiv").html(data);
openModal('configEditsubModel');
});
};
var editPointFun = function (id) {
$.post(ext.contextPath + '/work/pointModbus/doEdit.do', {id: id}, function (data) {
$("#pointEditsubDiv").html(data);
openModal('subdivPointEdit');
});
};
function addProgrammeFun() {
$.post(ext.contextPath + '/data/addSYSCurve.do', {unitId: unitId, pid: '${curve.id}'}, function (data) {
$("#subDiv").html(data);
openModal('programmeSubModal');
});
}
function initConfigTable() {
$("#config_table").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/work/configModbus/getList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20,50], // 设置页面可以显示的数据条数
pageSize: 50, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
pid: '${modbusInterface.id}'
}
},
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
onClickRow: function (row) {//单击行事件,执行查看功能
// viewFun(row.id);
},
columns: [
{
checkbox: true,
},
{
field: 'typeText', // 返回json数据中的name
title: '数据类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
/*formatter:function(value,row,index){
return row.company.name;
}*/
},{
field: 'dataTypeText', // 返回json数据中的name
title: '数据类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
title: "操作",
align: 'center',
valign: 'middle',
width: 150, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var str="";
str+='<button class="btn btn-default btn-sm" onclick="editConfigFun(\'' + row.id + '\')" data-toggle="tooltip" title="编辑"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
str='<div class="btn-group" >'+str+'</div>';
return str;
}
}
],
onLoadSuccess: function(){ //加载成功时执行
setDataCardView("table");
var businessKey=sessionStorage.getItem("businessKey");
markRow("table",businessKey)
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
})
}
function initPointTable() {
$("#point_table").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/work/pointModbus/getList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20,50], // 设置页面可以显示的数据条数
pageSize: 10, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset/params.limit+1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order,
pId: '${modbusInterface.id}'
}
},
sortName: 'address', // 要排序的字段
sortOrder: 'desc', // 排序规则
onClickRow: function (row) {//单击行事件,执行查看功能
// viewFun(row.id);
},
columns: [
{
checkbox: true,
},
{
field: 'name', // 返回json数据中的name
title: '名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
/*formatter:function(value,row,index){
return row.company.name;
}*/
},{
field: 'address', // 返回json数据中的name
title: '寄存器地址', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
field: 'resgusterTypeText', // 返回json数据中的name
title: '寄存器类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
field: 'slaveId', // 返回json数据中的name
title: '从站Id', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
field: 'pointTypeText', // 返回json数据中的name
title: '数据类型', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
field: 'statusText', // 返回json数据中的name
title: '状态', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',
},{
title: "操作",
align: 'center',
valign: 'middle',
width: 150, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var str="";
str+='<button class="btn btn-default btn-sm" onclick="editPointFun(\'' + row.id + '\')" data-toggle="tooltip" title="编辑"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
str='<div class="btn-group" >'+str+'</div>';
return str;
}
}
],
onLoadSuccess: function(){ //加载成功时执行
setDataCardView("table");
var businessKey=sessionStorage.getItem("businessKey");
markRow("table",businessKey)
},
onLoadError: function(){ //加载失败时执行
console.info("加载数据失败");
}
})
}
function doTest() {
$.post(ext.contextPath + '/enums/getEnumsList.do', {enumName: 'ModbusDataTypeEnum'}, function (data) {
console.log(data)
});
}
$(function () {
initConfigTable();
initPointTable();
});
</script>
<div class="box box-primary">
<div class="box-header with-border">
<h3 class="box-title">详情</h3>
<div class="box-tools pull-right">
<a onclick="doFAsave()" class="btn btn-box-tool" data-toggle="tooltip" title="保存"><i
class="glyphicon glyphicon-floppy-disk"></i></a>
<a onclick="dodel()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i
class="glyphicon glyphicon-trash"></i></a>
<a onclick="doInit()" class="btn btn-box-tool" data-toggle="tooltip" title="初始化"><i
class="glyphicon glyphicon-refresh"></i></a>
<%-- <a onclick="dotest()" class="btn btn-box-tool" data-toggle="tooltip" title="初始化"><i--%>
<%-- class="glyphicon glyphicon-refresh"></i></a>--%>
</div>
</div>
<!-- /.box-header -->
<div class="box-body ">
<form class="form-horizontal " id="subForm_interfaceEdit">
<input id="id" name="id" type="hidden" value="${modbusInterface.id}"/>
<!-- 界面提醒div强制id为alertDiv -->
<div id="alertDiv"></div>
<div id="menu4SelectDiv"></div>
<div class="form-group">
<label class="col-sm-2 control-label">名称</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="name" name="name" placeholder="名称"
value="${modbusInterface.name }">
</div>
<label class="col-sm-2 control-label">状态</label>
<div class="col-sm-4">
<select id="status" name="status" class="form-control select2">
<option value=0 <c:if test="${modbusInterface.status == 0 }">selected</c:if>>禁用
</option>
<option value=1 <c:if test="${modbusInterface.status == 1 }">selected</c:if>>启用</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">ip</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="ip" name="ip" placeholder="ip地址"
value="${modbusInterface.ip}">
</div>
<label class="col-sm-2 control-label">端口号</label>
<div class="col-sm-4">
<input type="text" class="form-control" id="port" name="port" placeholder="ip地址"
value="${modbusInterface.port}">
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">偏移量</label>
<div class="col-sm-4">
<input type="number" class="form-control" id="offset" name="offset" placeholder="偏移量" value="${modbusInterface.offset}">
</div>
</div>
</form>
</div>
</div>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">数据类型配置</h3>
<div class="box-tools pull-right">
</div>
</div>
<div class="box-body ">
<div>
<div id="alertDiv_config"></div>
<div class="btn-group" style="width: 280px;padding-bottom:10px;">
<button type="button" class="btn btn-default" onclick="addConfigFun();"><i class="fa fa-plus"></i>
新增
</button>
<button type="button" class="btn btn-default" style="margin-left: 10px;" onclick="delConfigFuns();">
<i class="fa fa-trash-o"></i>删除
</button>
</div>
<div id="configDiv"></div>
<div id="menu4SelectDiv_config"></div>
<br>
<table id="config_table" data-use-row-attr-func="true" data-reorderable-rows="true"></table>
</div>
</div>
</div>
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">寄存器地址配置</h3>
<div class="box-tools pull-right">
</div>
</div>
<div class="box-body ">
<div>
<div id="alertDiv_point"></div>
<div class="btn-group" style="width: 280px;padding-bottom:10px;">
<button type="button" class="btn btn-default" onclick="addPointFun();"><i class="fa fa-plus"></i>
新增
</button>
<button type="button" class="btn btn-default" style="margin-left: 10px;" onclick="delPointFuns();">
<i class="fa fa-trash-o"></i>删除
</button>
</div>
<div id="pointDiv"></div>
<div id="menu4SelectDiv_point"></div>
<br>
<table id="point_table" data-use-row-attr-func="true" data-reorderable-rows="true"></table>
</div>
</div>
</div>