316 lines
14 KiB
Plaintext
316 lines
14 KiB
Plaintext
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
|
||
<!DOCTYPE html>
|
||
|
||
<script type="text/javascript">
|
||
var doSearchEquipment = function() {
|
||
//$("#table_stock").bootstrapTable('refresh');
|
||
console.info($('#equipmentName').val());
|
||
$("#table_equipmentCard").bootstrapTable('refresh');
|
||
};
|
||
function doSelectEquipment() {
|
||
//var checkItems = $("#table_stock").bootstrapTable('getAllSelections');
|
||
var datas="";
|
||
datas_name="";
|
||
$.each(selectionIds, function(index, item){
|
||
if(datas!=""){
|
||
datas+=",";
|
||
}
|
||
datas+=item;
|
||
|
||
|
||
});
|
||
console.log("datas value is="+datas);
|
||
doFinishSelects(datas);
|
||
closeModal("subDetailModal");
|
||
};
|
||
var $table;
|
||
var switchStatus=false;
|
||
var selectionIds = []; //保存选中ids
|
||
var dosearchTable = function() {
|
||
$("#table_equipmentCard").bootstrapTable('refresh');
|
||
};
|
||
function stateFormatter(value, row, index) {
|
||
var flag=false;
|
||
$.each(eval('${equipmentCardIds}'), 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 check_array =eval('${equipmentCardIds}');
|
||
|
||
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 check_array =eval('${equipmentCardIds}');
|
||
$.each(check_array, function(index, item){
|
||
if(ids!=""){
|
||
ids+=",";
|
||
}
|
||
ids+=item.id;
|
||
});
|
||
return ids;
|
||
}
|
||
var companyId;
|
||
$(function() {
|
||
//工艺段
|
||
$.post(ext.contextPath + "/user/processSection/getProcessSection4Select.do", {companyId:companyId}, function(data) {
|
||
$("#processSection").empty();
|
||
var selelct_ =$("#processSection").select2({
|
||
data: data,
|
||
cache : false,
|
||
placeholder:'请选择',//默认文字提示
|
||
allowClear: true,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据大于10个启用搜索框
|
||
formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||
});
|
||
$(".select2-selection--single").css({'height':'30px','paddingTop':'4px'})
|
||
selelct_.val('').trigger("change");
|
||
selelct_.on("change",function(e){
|
||
dosearchTable();
|
||
});
|
||
},'json');
|
||
//$("#").attr("onsubmit","return false;");
|
||
$("#equipmentName").keyup(function(){
|
||
if (event.keyCode == 13) {
|
||
event.preventDefault();
|
||
//回车查询
|
||
doSearchEquipment();
|
||
event.stopPropagation();
|
||
}
|
||
})
|
||
|
||
//选择厂区
|
||
$.post(ext.contextPath + "/user/getSearchBizsByUserId4Select.do", {}, function(data) {
|
||
if(data.length == 1){
|
||
//选择厂区为一个厂时隐藏选择框
|
||
$("#search_code").css("display", "none");
|
||
$("#company").text(data[0].text);
|
||
companyId=data[0].id;
|
||
//initFun();
|
||
}else{
|
||
$("#company").css("display", "none");
|
||
var selelct=$("#search_code").select2({
|
||
data : data ,
|
||
placeholder:'请选择',//默认文字提示
|
||
allowClear: true,//允许清空
|
||
escapeMarkup: function (markup) { return markup; }, // 自定义格式化防止xss注入
|
||
language: "zh-CN",
|
||
minimumInputLength: 0,
|
||
minimumResultsForSearch: 10,//数据超过十个启用搜索框
|
||
formatResult: function formatRepo(repo){return repo.text;}, // 函数用来渲染结果
|
||
formatSelection: function formatRepoSelection(repo){return repo.text;} // 函数用于呈现当前的选择
|
||
});
|
||
$(".select2-selection--single").css({'height':'30px','paddingTop':'4px'})
|
||
selelct.val('').trigger("change");
|
||
//initFun();
|
||
selelct.on("change",function(e){
|
||
companyId= $(this).val();
|
||
//initFun();
|
||
dosearchTable();
|
||
});
|
||
}
|
||
},'json');
|
||
initialSelectionIds();
|
||
$table=$("#table_equipmentCard").bootstrapTable({
|
||
url: ext.contextPath + '/equipment/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,
|
||
equipmentName: $('#equipmentName').val(),
|
||
//companyId : '${param.companyId}',
|
||
unitId : unitId,
|
||
processSection : $('#processSection').val()
|
||
|
||
}
|
||
},
|
||
sortName: 'id', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
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: 'company.name', // 返回json数据中的name
|
||
title: '公司名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
}
|
||
,{
|
||
field: 'equipmentcardid', // 返回json数据中的name
|
||
title: '设备厂内编码', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
},{
|
||
field: 'equipmentname', // 返回json数据中的name
|
||
title: '设备名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
},{
|
||
field: 'areaid', // 返回json数据中的name
|
||
title: '安装地点', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},{
|
||
field: 'assetnumber', // 返回json数据中的name
|
||
title: '资产编码', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, {
|
||
field: 'equipmentmanufacturer', // 返回json数据中的name
|
||
title: '生产商', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, {
|
||
field: 'equipmentvalue', // 返回json数据中的name
|
||
title: '资产原值(元)', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
|
||
},{
|
||
field: 'residualvalue', // 返回json数据中的name
|
||
title: '剩余价值(元)', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},
|
||
|
||
],
|
||
onLoadSuccess: function(){ //加载成功时执行
|
||
adjustBootstrapTableView("table_equipmentCard");
|
||
},
|
||
onLoadError: function(){ //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
|
||
});
|
||
//绑定选中事件、取消事件、全部选中、全部取消
|
||
$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);
|
||
});
|
||
});
|
||
//选中事件操作数组
|
||
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="subDetailModal">
|
||
<div class="modal-dialog">
|
||
<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="alertDetailDiv"></div>
|
||
<div class="form-group form-inline" >
|
||
<div class="form-group form-inline">
|
||
<div class="form-group">
|
||
<label class="form-label">水厂:</label>
|
||
|
||
<!-- <label class="form-label" id="companylabel">水厂:</label> -->
|
||
<!-- <label class="form-label" id="company" style="width:180px;border: none;background: transparent;" ></label> -->
|
||
<input name="bizid" id="bizid" type="hidden" value="${company.id}"/>
|
||
<p class="form-control-static" >${company.sname}</p>
|
||
</div>
|
||
<!-- <div class="form-group">
|
||
<select class="form-control select2 " id="search_code" name ="search_code" style="width: 220px;"></select>
|
||
</div> -->
|
||
</div>
|
||
<!--工艺段筛选-->
|
||
<div class="input-group input-group-sm " style="margin-right: 1%;">
|
||
<label class="form-label" style="float: left;line-height: 2;">工艺段:</label>
|
||
<select class="form-control select2 " id="processSection" name ="processSection" style="width: 100px;"></select>
|
||
</div>
|
||
|
||
<div class="form-group form-inline pull-right">
|
||
<div class="input-group input-group-sm" style="width: 250px;">
|
||
<input type="text" id="equipmentName" name="equipmentName" class="form-control pull-right" placeholder="设备名称/设备编码/资产编码">
|
||
<div class="input-group-btn">
|
||
<button class="btn btn-default" onclick="doSearchEquipment();"><i class="fa fa-search"></i></button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<div>
|
||
|
||
<div id="table_equipmentCard" style="height:230px;overflow:auto;width:100%"></div>
|
||
</div>
|
||
</div>
|
||
<div class="modal-footer">
|
||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||
<button type="button" class="btn btn-primary" onclick="doSelectEquipment()">确认</button>
|
||
</div>
|
||
</div>
|
||
<!-- /.modal-content -->
|
||
</div>
|
||
<!-- /.modal-dialog -->
|
||
</div> |