Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/evaluation/selectCriterion.jsp

268 lines
10 KiB
Plaintext
Raw Permalink Normal View History

2026-01-16 14:13:44 +08:00
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<link rel="stylesheet" href="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css"/>
<script type="text/javascript" src="<%=request.getContextPath()%>/node_modules/bootstrap-switch/dist/js/bootstrap-switch.min.js" charset="utf-8"></script>
<script type="text/javascript">
function doSelect() {
//var checkedItems = $("#table_user").bootstrapTable('getAllSelections');
var datas="";
datas_name="";
$.each(selectionIds, function(index, item){
if(datas!=""){
datas+=",";
}
datas+=item;
});
$.post(ext.contextPath + '/evaluation/criterion/getListForJson.do', {Ids : datas}, function(resp) {
$.each(resp, function(index, item){
if(datas_name!=""){
datas_name+=",";
}
datas_name += item.criterionName;
});
datas_name = datas_name.replace(/\ +/g,"").replace(/[\r\n]/g,"");
//console.log("datas_name:"+datas_name);
if('${pid}' != null && '${pid}' != ''){
$('#${pid}').val(datas);
$('#${pname}').val(datas_name);
}else{
$('#evaluationCriterionIds').val(datas);
$('#evaluationCriterions').val(datas_name);
}
closeModal("criterion4SelectModal");
},'json');
};
function stateFormatter(value, row, index) {
var flag=false;
var evaluationCriterions = '${evaluationCriterions}'.replace(/\ +/g,"").replace(/[\r\n]/g,"");
$.each(eval(evaluationCriterions), function(index, item){
if(row.id==item.id){
flag=true;
}
});
if (flag)
return {
checked : true//设置选中
};
return value;
}
var $table;
var switchStatus=false;
var selectionIds = []; //保存选中ids
function initialSelectionIds(){
var evaluationCriterions = '${evaluationCriterions}'.replace(/\ +/g,"").replace(/[\r\n]/g,"");
var check_array =eval(evaluationCriterions);
//console.log(check_array.length);
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].id;
}
}
}
function getCheckedIds(){
var ids="";
var evaluationCriterions = '${evaluationCriterions}'.replace(/\ +/g,"").replace(/[\r\n]/g,"");
var check_array =eval(evaluationCriterions);
$.each(check_array, function(index, item){
if(ids!=""){
ids+=",";
}
ids+=item.id;
});
return ids;
}
$(function() {
initialSelectionIds();
$table=$("#table_criterion").bootstrapTable({ // 对应table标签的id
url: ext.contextPath + '/evaluation/criterion/getList.do', // 获取表格数据的url
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
striped: true, //表格显示条纹默认为false
pagination: true, // 在表格底部显示分页组件默认false
pageList: [10, 20, 50, 100], // 设置页面可以显示的数据条数
pageSize: 100, // 页面数据条数
pageNumber: 1, // 首页页码
sidePagination: 'server', // 设置为服务器端分页
queryParams: function (params) { // 请求服务器数据时发送的参数可以在这里添加额外的查询参数返回false则终止请求
return {
rows: params.limit, // 每页要显示的数据条数
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
sort: params.sort, // 要排序的字段
order: params.order
}
},
sortName: 'insdt', // 要排序的字段
sortOrder: 'desc', // 排序规则
onClickRow: function (row) {//单击行事件,执行查看功能
viewFun(row.id);
},
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: 'criterionName', // 返回json数据中的name
title: '标准名称', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle', // 上下居中
width:120
}, {
field: 'condition', // 返回json数据中的name
title: '条件', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
width:100,
formatter: function(value, row, index){
if(row.condition == '1'){
return '大于';
}else if(row.condition == '2'){
return '小于';
}else if(row.condition == '3'){
return '区间内';
}else{
return '区间外';
}
}
},{
field: 'condition', // 返回json数据中的name
title: '国家标准', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
width:100,
formatter: function(value, row, index){
if(row.condition == '1' || row.condition == '2'){
return row.nationCriterionValue;
}else if(row.condition == '3'){
return '[' + row.nationCriterionMin + ',' + row.nationCriterionMax + ']';
}else{
return '[-∞,' + row.nationCriterionMin + '],[' + row.nationCriterionMax + ',+∞]';
}
}
}, {
field: 'condition', // 返回json数据中的name
title: '地区标准', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
width:100,
formatter: function (value, row, index) {
if(row.condition == '1' || row.condition == '2'){
return row.areaCriterionValue;
}else if(row.condition == '3'){
return '[' + row.areaCriterionMin + ',' + row.areaCriterionMax + ']';
}else{
return '[-∞,' + row.areaCriterionMin + '],[' + row.areaCriterionMax + ',+∞]';
}
}
},{
field: 'condition', // 返回json数据中的name
title: '内控值', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
width:100,
formatter: function (value, row, index) {
if(row.condition == '1' || row.condition == '2'){
return row.companyCriterionValue;
}else if(row.condition == '3'){
return '[' + row.companyCriterionMin + ',' + row.companyCriterionMax + ']';
}else{
return '[-∞,' + row.companyCriterionMin + '],[' + row.companyCriterionMax + ',+∞]';
}
}
}
],
onLoadSuccess: function () { //加载成功时执行
adjustBootstrapTableView("table");
},
onLoadError: function () { //加载失败时执行
console.info("加载数据失败");
}
})
//绑定选中事件、取消事件、全部选中、全部取消
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e,rows, obj) {
var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) {
return row.id;
});
func = $.inArray(e.type, ['check', 'check-all']) > -1 ? 'union' : 'difference';
selectionIds = _[func](selectionIds, ids);
if('check'==e.type){
obj.parent().addClass("checked");
}else{
obj.parent().removeClass("checked");
}
//adjustBootstrapTableView("table_user");
});
});
//选中事件操作数组
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;
}
var closeSelect = function () {
closeModal("criterion4SelectModal");
}
</script>
<div class="modal fade" id="criterion4SelectModal">
<div class="modal-dialog" style="width: 600px;">
<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 " style="width:100%">
<div id="alertDiv"></div>
<div>
<div id="table_criterion" style="overflow:auto;width: 100%;"></div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" onclick="closeSelect()">关闭</button>
<button type="button" class="btn btn-primary" onclick="doSelect()">确认</button>
</div>
</div>
<!-- /.modal-content -->
</div>
<!-- /.modal-dialog -->
</div>