Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/visual/mPointListForVisualSelect.jsp

252 lines
11 KiB
Plaintext
Raw Permalink Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.sipai.tools.SessionManager"%>
<%
SessionManager sessionManager = new SessionManager();
%>
<%@page import="com.sipai.entity.scada.MPoint"%>
<%request.setAttribute("Flag_Enable",MPoint.Flag_Enable);%>
<%request.setAttribute("Flag_Disable",MPoint.Flag_Disable);%>
<script type="text/javascript">
var dosearchMp = function () {
$("#table_mpoint").bootstrapTable('refresh');
};
function doselect() {
var checkedItems = $("#table_mpoint").bootstrapTable('getAllSelections');
if (checkedItems.length != 0) {
$('#${param.formId} #${param.hiddenId}').val(checkedItems[0].id);
$('#${param.formId} #${param.textId}').val(checkedItems[0].name);
//console.log(checkedItems[0].id);
}
closeModal("mpSubModal");
};
function initialSelectionIds() {
//var check_array = new Array();
selectionIds = "${param.mPointIds}".split(",");
// if (check_array != null && check_array.length > 0) {
// selectionIds = new Array(check_array.length);
// for (var i = 0; i < check_array.length; i++) {
// selectionIds[i] = check_array[i];
// }
// }
//var checks = "${param.mPointIds}".split(",");
//check_array = [].slice.call(checks);
}
//显示已经勾选的数据
function stateFormatter(value, row, index) {
var flag = false;
if (row.id == '${mpid}') {
flag = true;
checkedItem = "";
}
if (flag)
return {
checked: true//设置选中
};
return value;
}
function getCheckedIds() {
var ids = "";
var check_array = $("#table_mpoint").bootstrapTable('getAllSelections');
$.each(check_array, function (index, item) {
if (ids != "") {
ids += ",";
}
ids += item.id;
});
return ids;
}
var $table;
var switchStatus = false;
var selectionIds = []; //保存选中ids s
function queryParams(params) {
var temp = {
//pid: params.pid,
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order, // 排序规则
search_name: $('#search_mpointname').val(),
search_mpointcode: $('#search_mpointcode').val(),
};
var status = $('#switchBtn').bootstrapSwitch('state')
if (status) {
temp.checkedIds = getCheckedIds();
}
return temp;
}
$(function () {
$('#switchBtn').bootstrapSwitch({
onText: '是',
offText: '否',
size: "small",
});
$(".select2-selection--single").css({ 'height': '30px', 'paddingTop': '4px' });
initialSelectionIds();
$table = $("#table_mpoint").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/work/mpoint/getlist.do', // 获取表格数据的url
//cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
clickToSelect: true,
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20], // 设置页面可以显示的数据条数
pageSize: 10, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
responseHandler: responseHandler, //在渲染页面数据之前执行的方法,此配置很重要!!!!!!!
queryParams: queryParams,
queryParamsType: "limit",
sortName: 'id', // 要排序的字段
sortOrder: 'desc', // 排序规则
/* showColumns: true,
showRefresh: true, */
columns: [
{
checkbox: true, // 显示一个勾选框
//formatter: stateFormatter
formatter: function (i, row) { // 每次加载 checkbox 时判断当前 row 的 id 是否已经存在全局 Set() 里
if ($.inArray(row.id, Array.from(selectionIds)) != -1) { // 因为 Set是集合,需要先转换成数组
return {
checked: true // 存在则选中
}
}
}
}, {
field: 'mpointcode', // 返回json数据中的name
title: '测量点Code', // 表格表头显示文字
sortable: true,
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'parmname', // 返回json数据中的name
title: '名称', // 表格表头显示文字
sortable: true,
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'signaltype', // 返回json数据中的name
title: '信号类型', // 表格表头显示文字
sortable: true,
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, {
field: 'active', // 返回json数据中的name
title: '启用状态', // 表格表头显示文字
sortable: true,
align: 'center', // 左右居中
valign: 'middle',
formatter: function (value, row) {
if ('${Flag_Enable}' == value) {
return "启用";
} else {
return "禁用";
}
} // 上下居中
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("table_mpoint");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
})
//绑定选中事件、取消事件、全部选中、全部取消
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows, obj) {
if ('check' == e.type) {
$('#table_layout4Select .checked').removeClass("checked");
obj.parent().addClass("checked");
checkedItem = rows;
} else {
obj.parent().removeClass("checked");
checkedItem = "";
}
});
//选中事件操作数组
var union = function (array, ids) {
$.each(ids, function (i, id) {
if ($.inArray(id, array) == -1) {
array[array.length] = id;
}
});
return array;
};
//取消选中事件操作数组
var difference = function (array, ids) {
$.each(ids, function (i, id) {
var index = $.inArray(id, array);
if (index != -1) {
array.splice(index, 1);
}
});
return array;
};
var _ = { "union": union, "difference": difference };
//表格分页之前处理多选框数据
function responseHandler(res) {
$.each(res.rows, function (i, row) {
row.checkStatus = $.inArray(row.id, selectionIds) != -1; //判断当前行的数据id是否存在与选中的数组存在则将多选框状态变为true
});
return res;
}
});
</script>
<div class="modal fade" id="mpSubModal">
<div class="modal-dialog modal-md">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">选择测量点</h4>
</div>
<div class="modal-body">
<div id="mpoint_mainAlertdiv"></div>
<div id="modal-body">
<div class="form-group pull-right form-inline">
<div class="form-group" style="margin-right: 20px;width:100%">
<label class="col-sm-2 control-label">只看选中</label>
<div class="col-sm-2">
<div class="switch" data-on="primary" data-off="info">
<input id="switchBtn" type="checkbox" />
</div>
</div>
<div class="col-sm-8">
<div class="input-group input-group-sm " style="width: 160px;">
<input type="text" id="search_mpointname" name="search_mpointname"
class="form-control pull-right" placeholder="点位名称">
</div>
<div class="input-group input-group-sm " style="width: 160px;">
<input type="text" id="search_mpointcode" name="search_mpointcode"
class="form-control " placeholder="点位编码">
<div class="input-group-btn">
<button class="btn btn-default" onclick="dosearchMp();"><i
class="fa fa-search"></i></button>
</div>
</div>
</div>
</div>
</div>
<div class="table-scrollable">
<table class="table table-bordered table-striped" style="overflow:auto;width:100%"
id="table_mpoint"></table>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default pull-left" data-dismiss="modal">关闭</button>
<button type="button" class="btn btn-primary" onclick="doselect()" id="btn_save">确定</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>