first commit
This commit is contained in:
304
WebRoot/jsp/valueEngineering/compareAdd.jsp
Normal file
304
WebRoot/jsp/valueEngineering/compareAdd.jsp
Normal file
@ -0,0 +1,304 @@
|
||||
<%@ page language="java" pageEncoding="UTF-8"%>
|
||||
<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">
|
||||
|
||||
//选择条件后生成对比数据
|
||||
var createCompareFun = function () {
|
||||
var checkedItems = $("#equipmentTable").bootstrapTable('getAllSelections');
|
||||
//console.info(checkedItems)
|
||||
if(checkedItems!= null && checkedItems!=""){
|
||||
var models="";
|
||||
var ids ="";
|
||||
$.each(checkedItems, function(index, item){
|
||||
if(models!=""){
|
||||
models+=",";
|
||||
}
|
||||
models+=item.equipmentmodel;
|
||||
if(ids!=""){
|
||||
ids+=",";
|
||||
}
|
||||
ids += item.id;
|
||||
});
|
||||
$("#model").val(models);
|
||||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||||
$.post(ext.contextPath + '/valueEngineering/equipmentEvaluate/createCompareData.do',$("#subForm").serialize(),function (result) {
|
||||
if (result.res > 0){
|
||||
closeModal('subModal');
|
||||
data = result.rows;
|
||||
selectEquipmentIds = ids;
|
||||
finishSelectFun();
|
||||
}else if(result.res == 0){
|
||||
showAlert('d','没有找到对比数据','alertDiv');
|
||||
data = "";
|
||||
clearAllTable();
|
||||
}else{
|
||||
showAlert('d',data.res,'alertDiv');
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
}else{
|
||||
showAlert('d','未选择设备','alertDiv');
|
||||
}
|
||||
};
|
||||
|
||||
//表格查询参数
|
||||
function queryParamsFun(params) { // 请求服务器数据时发送的参数,可以在这里添加额外的查询参数,返回false则终止请求
|
||||
return {
|
||||
rows: params.limit, // 每页要显示的数据条数
|
||||
page: params.offset/params.limit+1, // 每页显示数据的开始页码
|
||||
sort: params.sort, // 要排序的字段
|
||||
order: params.order,
|
||||
equipmentClassId : $("#classId").val(),
|
||||
specification: $("#specification").val(),
|
||||
useTime : $("#useTime").val(),
|
||||
}
|
||||
};
|
||||
//清除选择
|
||||
var clearFun = function(){
|
||||
$("#useTime").select2({language: "zh-CN",minimumResultsForSearch: 10,placeholder:'请选择'}).val('').trigger("change");
|
||||
$("#classId").select2({language: "zh-CN",minimumResultsForSearch: 10,placeholder:'请选择'}).val('').trigger("change");
|
||||
$("#specification").select2({language: "zh-CN",minimumResultsForSearch: 10,placeholder:'请选择'}).val('').trigger("change");
|
||||
dosearch();
|
||||
}
|
||||
var dosearch = function() {
|
||||
$("#equipmentTable").bootstrapTable('refresh');
|
||||
};
|
||||
//选择规格
|
||||
var selectSpecification = function(){
|
||||
$.post(ext.contextPath + "/valueEngineering/equipmentEvaluate/getEquipmentSpecificationForSelect.do",{
|
||||
companyId: '${param.companyId}',equipmentClassId: $("#classId").val()
|
||||
}, function(data) {
|
||||
var selelct_s =$("#specification").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;} // 函数用于呈现当前的选择
|
||||
});
|
||||
selelct_s.val('${specification}').trigger("change");
|
||||
initFun();
|
||||
selelct_s.on("change",function(e){
|
||||
dosearch();
|
||||
});
|
||||
},'json');
|
||||
}
|
||||
//选择设备类型及已用年限
|
||||
var selectClassIdFun = function(){
|
||||
//选择设备类型
|
||||
$.post(ext.contextPath + "/equipment/equipmentClass/getEquipmentClassForSelect.do", {
|
||||
class_pid:'1,12'
|
||||
}, function(data) {
|
||||
$("#classId").empty();
|
||||
var selelct =$("#classId").select2({
|
||||
data: data,
|
||||
placeholder:'请选择',//默认文字提示
|
||||
allowClear: false,//允许清空
|
||||
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;} // 函数用于呈现当前的选择
|
||||
});
|
||||
selelct.val('${classId}').trigger("change");
|
||||
selectSpecification();
|
||||
selelct.on("change",function(){
|
||||
//var equipmentClassId = $(this).val();
|
||||
$("#specification").empty();
|
||||
selectSpecification();
|
||||
});
|
||||
},'json');
|
||||
}
|
||||
//显示已经勾选的数据
|
||||
function stateFormatter(value, row, index) {
|
||||
var flag=false;
|
||||
console.info(selectEquipmentIds)
|
||||
$.each(selectEquipmentIds.split(','), function(index, item){
|
||||
if(row.id == item){
|
||||
flag=true;
|
||||
checkedItem = row;
|
||||
}
|
||||
});
|
||||
if (flag)
|
||||
return {
|
||||
checked : true//设置选中
|
||||
};
|
||||
|
||||
return value;
|
||||
}
|
||||
//初始化表格
|
||||
var initFun = function(){
|
||||
$("#equipmentTable").bootstrapTable({ // 对应table标签的id
|
||||
url: ext.contextPath + '/valueEngineering/equipmentEvaluate/getEquipmentList.do', // 获取表格数据的url
|
||||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||||
striped: true, //表格显示条纹,默认为false
|
||||
pagination: true, // 在表格底部显示分页组件,默认false
|
||||
pageList: [10, 20,50], // 设置页面可以显示的数据条数
|
||||
pageSize: 50, // 页面数据条数
|
||||
pageNumber: 1, // 首页页码
|
||||
sidePagination: 'server', // 设置为服务器端分页
|
||||
queryParams:queryParamsFun,
|
||||
sortName: 'id', // 要排序的字段
|
||||
sortOrder: 'desc', // 排序规则
|
||||
columns: [
|
||||
{
|
||||
checkbox: true, // 显示一个勾选框
|
||||
formatter: stateFormatter
|
||||
},/* {
|
||||
field: 'id', // 返回json数据中的name
|
||||
title: '统一编号', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle' // 上下居中
|
||||
}, {
|
||||
field: 'equipmentname', // 返回json数据中的name
|
||||
title: '名称', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle' // 上下居中
|
||||
},*/{
|
||||
field: 'equipmentTypeNumber.name', // 返回json数据中的name
|
||||
title: '设备型号', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle'
|
||||
},{
|
||||
field: 'equipmentClass.name', // 返回json数据中的name
|
||||
title: '设备类型', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle'
|
||||
},{
|
||||
field: 'equipmentSpecification.name', // 返回json数据中的name
|
||||
title: '设备规格', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle'
|
||||
},
|
||||
],
|
||||
onLoadSuccess: function(){ //加载成功时执行
|
||||
adjustBootstrapTableView("equipmentTable");
|
||||
},
|
||||
onLoadError: function(){ //加载失败时执行
|
||||
console.info("加载数据失败");
|
||||
}
|
||||
})
|
||||
}
|
||||
$(function(){
|
||||
//选择已用年限
|
||||
$.post(ext.contextPath + "/equipment/equipmentUseAge/getEquipmentUseAgeForSelect.do", {}, function(data) {
|
||||
var select_u =$("#useTime").select2({
|
||||
data: data,
|
||||
placeholder:'请选择',//默认文字提示
|
||||
allowClear: false,//允许清空
|
||||
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;} // 函数用于呈现当前的选择
|
||||
});
|
||||
select_u.val('${useTime}').trigger("change");
|
||||
select_u.on("change",function(){
|
||||
dosearch();
|
||||
})
|
||||
},'json');
|
||||
selectClassIdFun();
|
||||
$("#subForm").bootstrapValidator({
|
||||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||||
fields: {
|
||||
classId: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '设备类型不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
specification: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '设备规格不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
useTime: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '已用年限不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
<div class="modal fade" id="subModal">
|
||||
<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">
|
||||
<form class="form-horizontal" id="subForm">
|
||||
<!-- 界面提醒div强制id为alertDiv -->
|
||||
<div id="alertDiv"></div>
|
||||
<div class="form-group">
|
||||
<input type="hidden" id="model" name="model">
|
||||
<label class="col-sm-2 control-label">已用年限</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control select2" id="useTime"
|
||||
name ="useTime" style="width: 170px;">
|
||||
<!-- <option value="0">1-3年</option>
|
||||
<option value="1">3-5年</option>
|
||||
<option value="2">5-7年</option>
|
||||
<option value="3">7年以上</option> -->
|
||||
</select>
|
||||
</div>
|
||||
<label class="col-sm-2 control-label">设备类型</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control select2" id="classId"
|
||||
name ="classId" style="width: 170px;">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">规格</label>
|
||||
<div class="col-sm-4">
|
||||
<select class="form-control select2" id="specification"
|
||||
name ="specification" style="width: 170px;">
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="button" class="btn btn-info" onclick="clearFun()" id="btn_save">清除选择</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<div class="box box-primary" >
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">设备型号列表</h3>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body ">
|
||||
<table id="equipmentTable"></table>
|
||||
</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="createCompareFun()" id="btn_save">确定</button>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
</div>
|
||||
Reference in New Issue
Block a user