429 lines
18 KiB
Plaintext
429 lines
18 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
|
||
<!DOCTYPE html>
|
||
|
||
<style type="text/css">
|
||
.box-header {
|
||
padding: 10px 10px 10px 0px;
|
||
}
|
||
</style>
|
||
|
||
<script type="text/javascript">
|
||
|
||
var $table;
|
||
var switchStatus = false;
|
||
var selectionIds = []; //保存选中ids
|
||
|
||
var doSearchEquipments = function () {
|
||
$("#table_equipment").bootstrapTable('refresh');
|
||
};
|
||
|
||
function doSelectEquipment() {
|
||
var checkedItems = $("#table_equipment").bootstrapTable('getSelections');
|
||
var datas_id = "";
|
||
var datas_name = "";
|
||
var datas_cardId = "";
|
||
$.each(checkedItems, function (index, item) {
|
||
datas_id += item.id + ",";
|
||
datas_name += item.equipmentname + ",";
|
||
datas_cardId += item.equipmentcardid + ",";
|
||
});
|
||
if (datas_id != null && datas_id != '') {
|
||
datas_id = datas_id.substr(0, datas_id.length - 1);
|
||
datas_name = datas_name.substr(0, datas_name.length - 1);
|
||
datas_cardId = datas_cardId.substr(0, datas_name.length - 1);
|
||
}
|
||
|
||
//用于分页多选设备
|
||
datas_id = selectionIds + '';
|
||
|
||
//调用上一界面方法完成选择
|
||
doFinishSelectEquipment(datas_id, datas_name, datas_cardId);
|
||
//在上个页面确定是否关闭 有些为单选有些多选
|
||
// closeModal("equipment4SelectModal");
|
||
};
|
||
|
||
function stateFormatter(value, row, index) {
|
||
var flag = false;
|
||
$.each(eval('${goodsIds}'), function (index, item) {
|
||
if (row.id == item.id) {
|
||
flag = true;
|
||
}
|
||
});
|
||
if (flag)
|
||
return {
|
||
checked: true//设置选中
|
||
};
|
||
return value;
|
||
}
|
||
|
||
function initialSelectionIds() {
|
||
var check_array = eval('${goodsIds}');
|
||
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;
|
||
}
|
||
}
|
||
console.log("selectionIds is ", selectionIds)
|
||
}
|
||
|
||
function getCheckedIds() {
|
||
var ids = "";
|
||
var check_array = eval('${goodsIds}');
|
||
$.each(check_array, function (index, item) {
|
||
if (ids != "") {
|
||
ids += ",";
|
||
}
|
||
ids += item.id;
|
||
});
|
||
return ids;
|
||
}
|
||
|
||
function queryParams(params) {
|
||
var temp = {
|
||
rows: params.limit, // 每页要显示的数据条数
|
||
page: params.offset / params.limit + 1, // 每页显示数据的开始页码
|
||
sort: params.sort, // 要排序的字段
|
||
order: params.order,
|
||
unitId: '${param.unitId}',
|
||
processSectionId: $('#process_section_id').val(),
|
||
equipmentClassId: $('#equipment_class_id').val(),
|
||
search_name: $('#search_name').val(),
|
||
timeSelect: $('#timeSelect').val()
|
||
};
|
||
if ('${ids}') {
|
||
temp.ids = '${ids}'
|
||
}
|
||
/* var status =$('#switchBtn').bootstrapSwitch('state')
|
||
if(status){
|
||
temp.checkedIds=getCheckedIds();
|
||
} */
|
||
return temp;
|
||
}
|
||
|
||
//点击工艺段(按钮)
|
||
function proFun() {
|
||
document.getElementById('button1').className = 'btn btn-primary btn-sm';
|
||
document.getElementById('button2').className = 'btn btn-default btn-sm';
|
||
proTreeView();
|
||
}
|
||
|
||
//点击设备类型(按钮)
|
||
function equFun() {
|
||
document.getElementById('button1').className = 'btn btn-default btn-sm';
|
||
document.getElementById('button2').className = 'btn btn-primary btn-sm';
|
||
equTreeView();
|
||
}
|
||
|
||
/**
|
||
* 加载工艺段
|
||
*/
|
||
var proTreeView = function () {
|
||
$.post(ext.contextPath + '/equipment/getProcessSection4EquipmentCardTree.do', {
|
||
unitId: '${param.unitId}'
|
||
}, function (data) {
|
||
var treeData = data.result;
|
||
$('#tree').treeview({data: treeData});
|
||
//默认选中对应的树节点
|
||
var node = $('#tree').treeview('findNodes', [$('#process_section_id').val(), 'id']);
|
||
$('#tree').treeview('selectNode', [node[0], {silent: true}]);
|
||
|
||
$('#tree').on('nodeSelected', function (event, treeList) {
|
||
$('#process_section_id').val(treeList.id);
|
||
doSearchEquipments();
|
||
});
|
||
}, 'json');
|
||
};
|
||
|
||
/**
|
||
* 加载设备类型
|
||
*/
|
||
var equTreeView = function () {
|
||
$.post(ext.contextPath + '/equipment/getEquipmentClass4EquipmentCardTree.do', {
|
||
unitId: '${param.unitId}'
|
||
}, function (data) {
|
||
var treeData = data.result;
|
||
$('#tree').treeview({data: treeData});
|
||
$('#tree').on('nodeSelected', function (event, treeList) {
|
||
$('#equipment_class_id').val(treeList.id);
|
||
doSearchEquipments();
|
||
});
|
||
}, 'json');
|
||
};
|
||
|
||
var doResetSelect = function () {
|
||
// closeModal("equipment4SelectModal");
|
||
// doEditEquipment();
|
||
selectionIds = [];
|
||
$('#equipment_class_id').val('');
|
||
$('#process_section_id').val('');
|
||
|
||
$("#search_name").keyup(function () {
|
||
if (event.keyCode == 13) {
|
||
console.log(133333333333)
|
||
event.preventDefault();
|
||
//回车查询
|
||
doSearchEquipments();
|
||
event.stopPropagation();
|
||
}
|
||
})
|
||
initialSelectionIds();
|
||
|
||
$('#table_equipment').bootstrapTable('destroy');
|
||
loadTable();
|
||
|
||
//绑定选中事件、取消事件、全部选中、全部取消
|
||
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
|
||
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);
|
||
});
|
||
proFun();
|
||
|
||
}
|
||
|
||
var loadTable = function () {
|
||
$table = $("#table_equipment").bootstrapTable({
|
||
url: ext.contextPath + '/equipment/getList4EquipmentCard.do', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 20, 50, 200, 500], // 设置页面可以显示的数据条数
|
||
pageSize: 10, // 页面数据条数
|
||
pageNumber: 1, // 首页页码
|
||
sidePagination: 'server', // 设置为服务器端分页
|
||
queryParams: queryParams,
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
checkbox: true, // 显示一个勾选框
|
||
//formatter: stateFormatter
|
||
width: '40px',
|
||
formatter: function (i, row) { // 每次加载 checkbox 时判断当前 row 的 id 是否已经存在全局 Set() 里
|
||
if ($.inArray(row.id, Array.from(selectionIds)) != -1) { // 因为 Set是集合,需要先转换成数组
|
||
return {
|
||
checked: true// 存在则选中
|
||
}
|
||
}
|
||
}
|
||
}, {
|
||
field: 'equipmentcardid', // 返回json数据中的name
|
||
title: '设备编号', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value + "'>" + value + "</span>";
|
||
}
|
||
}, {
|
||
field: 'equipmentname', // 返回json数据中的name
|
||
title: '名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value + "'>" + value + "</span>";
|
||
}
|
||
}, {
|
||
field: 'processSection.sname', // 返回json数据中的name
|
||
title: '工艺段', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value + "'>" + value + "</span>";
|
||
}
|
||
}, {
|
||
field: 'equipmentClass.name', // 返回json数据中的name
|
||
title: '设备类型', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value + "'>" + value + "</span>";
|
||
}
|
||
}, {
|
||
field: 'equipmentmodelname', // 返回json数据中的name
|
||
title: '设备型号', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle',
|
||
width: '20%',
|
||
formatter: function (value, row, index) {
|
||
return "<span style='display: block;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;' title='" + value + "'>" + value + "</span>";
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
adjustBootstrapTableView("table_equipment");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
});
|
||
}
|
||
|
||
$(function () {
|
||
$("#search_name").keyup(function () {
|
||
if (event.keyCode == 13) {
|
||
event.preventDefault();
|
||
//回车查询
|
||
doSearchEquipments();
|
||
event.stopPropagation();
|
||
}
|
||
})
|
||
initialSelectionIds();
|
||
|
||
loadTable();
|
||
|
||
//绑定选中事件、取消事件、全部选中、全部取消
|
||
$table.on('check.bs.table check-all.bs.table uncheck.bs.table uncheck-all.bs.table', function (e, rows) {
|
||
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);
|
||
});
|
||
proFun();
|
||
|
||
});
|
||
|
||
//选中事件操作数组
|
||
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 timeSelect = $("#timeSelect").select2({
|
||
minimumResultsForSearch: 10,
|
||
placeholder: '全部',
|
||
}).val('').trigger("change");
|
||
timeSelect.on("change", function (e) {
|
||
|
||
});
|
||
|
||
var statusSelect = $("#statusSelect").select2({
|
||
minimumResultsForSearch: 10,
|
||
placeholder: '全部',
|
||
}).val('').trigger("change");
|
||
statusSelect.on("change", function (e) {
|
||
|
||
});
|
||
|
||
</script>
|
||
|
||
<div class="modal fade" id="equipment4SelectModal">
|
||
<div class="modal-dialog modal-xlg">
|
||
<div class="modal-content">
|
||
<div class="modal-header">
|
||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||
<span aria-hidden="true">×</span></button>
|
||
<h4 class="modal-title">选择设备</h4>
|
||
</div>
|
||
<div class="modal-body " style="width:100%">
|
||
<div id="alertDiv"></div>
|
||
<div class="row">
|
||
<div class="col-lg-3 col-md-4">
|
||
<input type="hidden" id="equipment_class_id" name="equipment_class_id" value="">
|
||
<input type="hidden" id="process_section_id" name="process_section_id"
|
||
value="${param.processSectionId}">
|
||
<div class="box box-solid" id="leftToolsLvl2">
|
||
<div class="box-header with-border">
|
||
<div class="btn-group" style="width: 100%;">
|
||
<button type="button" id="button1" class="btn btn-primary btn-sm"
|
||
onclick="proFun();">
|
||
工艺段
|
||
</button>
|
||
<button type="button" id="button2" class="btn btn-default btn-sm"
|
||
onclick="equFun();">
|
||
设备类型
|
||
</button>
|
||
</div>
|
||
</div>
|
||
<div class="box-body no-padding">
|
||
<div id="tree" style="height:550px;overflow:auto; "></div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div class="col-lg-9 col-md-8">
|
||
<div class="btn-group" style="width: 220px;padding-bottom:10px;"></div>
|
||
<div class="form-group pull-right form-inline">
|
||
|
||
<%--只有保养模块才显示--%>
|
||
<c:if test="${choiceType == '1'}">
|
||
<div class="form-group">
|
||
<label class="form-label">近期需保养设备:</label>
|
||
<select class="form-control select2 " id="timeSelect" name="timeSelect"
|
||
style="width: 120px;">
|
||
<option value="0">全部</option>
|
||
<option value="1">1个月</option>
|
||
<option value="3">3个月</option>
|
||
<option value="6">6个月</option>
|
||
<option value="12">12个月</option>
|
||
</select>
|
||
</div>
|
||
<%--<div class="form-group">
|
||
<label class="form-label">保养状态:</label>
|
||
<select class="form-control select2 " id="statusSelect" name="statusSelect"
|
||
style="width: 120px;">
|
||
<option value="0">全部</option>
|
||
<option value="1">已保养</option>
|
||
<option value="3">未保养</option>
|
||
</select>
|
||
</div>--%>
|
||
</c:if>
|
||
|
||
<div class="input-group input-group-sm" style="width: 250px;">
|
||
<input type="text" id="search_name" name="search_name"
|
||
class="form-control pull-right" placeholder="设备名称" style="height:34px;">
|
||
<div class="input-group-btn">
|
||
<button class="btn btn-default" onclick="doSearchEquipments();" style="height:34px;"><i
|
||
class="fa fa-search"></i></button>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
<div>
|
||
<table id="table_equipment" style="table-layout:fixed;"></table>
|
||
</div>
|
||
</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="doResetSelect()">重置筛选</button>
|
||
<button type="button" class="btn btn-primary" onclick="doSelectEquipment()">确认</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div> |