first commit
This commit is contained in:
461
WebRoot/jsp/equipment/equipmentCardLinksEdit.jsp
Normal file
461
WebRoot/jsp/equipment/equipmentCardLinksEdit.jsp
Normal file
@ -0,0 +1,461 @@
|
||||
<%@ 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">
|
||||
function doupdate() {
|
||||
$("#subForm").bootstrapValidator('validate');//提交验证
|
||||
if ($("#subForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||||
$.post(ext.contextPath + "/equipment/equipmentCardLinks/doupdate.do", $("#subForm").serialize(), function(data) {
|
||||
if (data.res == 1){
|
||||
closeModal('subModal');
|
||||
$("#table").bootstrapTable('refresh');
|
||||
}else if(data.res == 0){
|
||||
showAlert('d','保存失败');
|
||||
}else{
|
||||
showAlert('d',data.res);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//编辑链接内容
|
||||
var editParameterFun = function(id) {
|
||||
stopBubbleDefaultEvent();
|
||||
$.post(ext.contextPath + '/equipment/equipmentCardLinksParameter/doedit.do', {id:id} , function(data) {
|
||||
$("#subParameterDiv").html(data);
|
||||
openModal('subParameterModal');
|
||||
});
|
||||
};
|
||||
function dosaveParameter() {
|
||||
$("#subParameterForm").bootstrapValidator('validate');//提交验证
|
||||
if ($("#subParameterForm").data('bootstrapValidator').isValid()) {//获取验证结果,如果成功,执行下面代码
|
||||
$.post(ext.contextPath + "/equipment/equipmentCardLinksParameter/dosave.do", $("#subParameterForm").serialize(), function(data) {
|
||||
if (data.res == 1){
|
||||
$("#table_Parameter").bootstrapTable('refresh');
|
||||
}else if(data.res == 0){
|
||||
showAlert('d','保存失败');
|
||||
}else{
|
||||
showAlert('d',data.res);
|
||||
}
|
||||
},'json');
|
||||
}
|
||||
|
||||
}
|
||||
//删除多条明细数据
|
||||
var deletesParameterFun = function(id) {
|
||||
var datas="";
|
||||
if(id!=null && id !=undefined && id!=''){
|
||||
datas=id;
|
||||
}else{
|
||||
var checkedItems = $("#table_Parameter").bootstrapTable('getSelections');
|
||||
$.each(checkedItems, function(index, item){
|
||||
datas+=item.id+",";
|
||||
});
|
||||
}
|
||||
if(datas==""){
|
||||
showAlert('d','请先选择记录','alertDiv');
|
||||
}else{
|
||||
swal({
|
||||
text: "您确定要删除此记录?",
|
||||
dangerMode: true,
|
||||
buttons: {
|
||||
cancel: {
|
||||
text: "取消",
|
||||
value: null,
|
||||
visible: true,
|
||||
className: "btn btn-default btn-sm",
|
||||
closeModal: true,
|
||||
},
|
||||
confirm: {
|
||||
text: "确定",
|
||||
value: true,
|
||||
visible: true,
|
||||
className: "btn btn-danger btn-sm",
|
||||
closeModal: true
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(function(willDelete) {
|
||||
if (willDelete) {
|
||||
$.post(ext.contextPath + '/equipment/equipmentCardLinksParameter/dodeletes.do', {ids:datas} , function(data) {
|
||||
if(data>0){
|
||||
$("#table_Parameter").bootstrapTable('refresh');
|
||||
}else{
|
||||
showAlert('d','删除失败','alertDiv');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
$(function(){
|
||||
$("#active").select2({minimumResultsForSearch: 10}).val("${equipmentCardLinks.active}").trigger("change");
|
||||
$("#linkType").select2({minimumResultsForSearch: 10}).val("${equipmentCardLinks.linkType}").trigger("change");
|
||||
|
||||
//输入框验证
|
||||
$("#subForm").bootstrapValidator({
|
||||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||||
fields: {
|
||||
linkName: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '链接名称不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
linkUrl: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '链接地址不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
});
|
||||
//输入框验证
|
||||
$("#subParameterForm").bootstrapValidator({
|
||||
live: 'disabled',//验证时机,enabled是内容有变化就验证(默认),disabled和submitted是提交再验证
|
||||
fields: {
|
||||
parameter: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '参数不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
parameterType: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '类型不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
active: {
|
||||
validators: {
|
||||
notEmpty: {
|
||||
message: '状态不能为空'
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
}
|
||||
});
|
||||
var dynamic = [{ id: 'aaaa', text: '设备台账', disabled: true },{ id: 'equipmentname', text: '设备名称:equipmentname' },{ id: 'equipmentmodel', text: '设备型号:equipmentmodel' }
|
||||
,{ id: 'assetnumber', text: '资产编号:assetnumber' },{ id: 'equipmentManufacturer', text: '生产商:equipmentManufacturer' },{ id: 'leaveFactoryNumber', text: '出厂编号:leaveFactoryNumber' }];
|
||||
//销毁表格
|
||||
$('#table_Parameter').bootstrapTable('destroy');
|
||||
$("#table_Parameter").bootstrapTable({ // 对应table标签的id
|
||||
url: ext.contextPath + '/equipment/equipmentCardLinksParameter/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,
|
||||
linkId: '${equipmentCardLinks.id}',
|
||||
}
|
||||
},
|
||||
sortName: 'id', // 要排序的字段
|
||||
sortOrder: 'desc', // 排序规则
|
||||
columns: [
|
||||
{
|
||||
field: 'parameter', // 返回json数据中的name
|
||||
title: '链接参数', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
},{
|
||||
field: 'parameterValue', // 返回json数据中的name
|
||||
title: '参数固定值', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
}, {
|
||||
field: 'parameterType', // 返回json数据中的name
|
||||
title: '参数类型', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: 100, // 定义列的宽度,单位为像素px
|
||||
formatter: function (value, row, index){
|
||||
switch (value){
|
||||
case 'dynamic' :
|
||||
return "动态";
|
||||
case 'fixed' :
|
||||
return "固定";
|
||||
default :
|
||||
return value;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'dynamic', // 返回json数据中的name
|
||||
title: '动态参数', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle',// 上下居中
|
||||
formatter: function (value, row, index){
|
||||
var res = value;
|
||||
for(var i=0;i<dynamic.length;i++){
|
||||
var ob = dynamic[i];
|
||||
if(ob.id==value){
|
||||
res = ob.text;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'morder', // 返回json数据中的name
|
||||
title: '顺序', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: 85, // 定义列的宽度,单位为像素px
|
||||
},
|
||||
{
|
||||
field: 'active', // 返回json数据中的name
|
||||
title: '状态', // 表格表头显示文字
|
||||
align: 'center', // 左右居中
|
||||
valign: 'middle', // 上下居中
|
||||
width: 100, // 定义列的宽度,单位为像素px
|
||||
formatter: function (value, row, index){
|
||||
switch (value){
|
||||
case '0' :
|
||||
return "禁用";
|
||||
case '1' :
|
||||
return "启用";
|
||||
default :
|
||||
return value;
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
align: 'center',
|
||||
valign: 'middle',
|
||||
width: 90, // 定义列的宽度,单位为像素px
|
||||
formatter: function (value, row, index) {
|
||||
var buts= '';
|
||||
if(row.id!=null){
|
||||
buts+= '<security:authorize buttonUrl="equipment/equipmentCardLinksParameter/edit.do">';
|
||||
buts+= '<button class="btn btn-default btn-sm" title="编辑" onclick="editParameterFun(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg"> 编辑</span></button>';
|
||||
buts+= '</security:authorize>';
|
||||
buts+= '<security:authorize buttonUrl="equipment/equipmentCardLinksParameter/delete.do">';
|
||||
buts+='<a class="btn btn-default btn-sm" title="删除" onclick="deletesParameterFun(\''+row.id+'\')"><i class="fa fa fa-trash-o"></i><span class="hidden-md hidden-lg">删除</span></a';
|
||||
buts+= '</security:authorize>';
|
||||
}else{
|
||||
buts+= '<security:authorize buttonUrl="equipment/equipmentCardLinksParameter/new.do">';
|
||||
buts+= '<a class="btn btn-default btn-sm" title="添加" onclick="dosaveParameter()"><i class="fa fa-plus"></i><span class="hidden-md hidden-lg"> 添加</span></a>';
|
||||
buts+= '</security:authorize>';
|
||||
}
|
||||
buts='<div class="btn-group" >'+buts+'</div>';
|
||||
return buts;
|
||||
}
|
||||
}
|
||||
],
|
||||
onLoadSuccess: function(){ //加载成功时执行
|
||||
adjustBootstrapTableView("table");
|
||||
var newData = [{
|
||||
'parameter': '<input id="parameter" name="parameter" type="text" class="form-control" value="" />',
|
||||
'parameterValue': '<input id="parameterValue" name="parameterValue" type="text" class="form-control" value=""/>',
|
||||
'parameterType':'<input id="parameterType" name="parameterType" type="text" class="form-control" value=""/>',
|
||||
'dynamic': '<input id="dynamic" name="dynamic" type="text" class="form-control"/>',
|
||||
'morder': '<input type="number" class="form-control" id="morder" name ="morder" placeholder="顺序" >',
|
||||
'active': '<input id="parameter_active" name="active" type="text" class="form-control" value="" />',
|
||||
}];
|
||||
$('#table_Parameter').bootstrapTable('prepend', newData);
|
||||
$("#parameterType").empty();
|
||||
var parameterType = [{ id: 'fixed', text: '固定' },{ id: 'dynamic', text: '动态' }];
|
||||
var selelct_parameterType =$("#parameterType").select2({
|
||||
data: parameterType,
|
||||
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_parameterType.on('change', function (e) {
|
||||
if(e.target.value==parameterType[1].id){
|
||||
//动态
|
||||
$("#parameterValue").attr("readonly","readonly");
|
||||
//$("#dynamic").removeAttr("readonly");
|
||||
$("#dynamic").empty();
|
||||
var selelct_dynamic =$("#dynamic").select2({
|
||||
data: dynamic,
|
||||
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;}, // 函数用于呈现当前的选择
|
||||
disabled:false
|
||||
});
|
||||
}else{
|
||||
$("#parameterValue").removeAttr("readonly");
|
||||
//$("#dynamic").attr("readonly","readonly");
|
||||
$("#dynamic").empty();
|
||||
var selelct_dynamic =$("#dynamic").select2({
|
||||
data: dynamic,
|
||||
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;}, // 函数用于呈现当前的选择
|
||||
disabled:true
|
||||
});
|
||||
}
|
||||
})
|
||||
$("#parameter_active").empty();
|
||||
var parameter_active = [{ id: '1', text: '启用' },{ id: '0', text: '禁用' }];
|
||||
var selelct_parameter_active =$("#parameter_active").select2({
|
||||
data: parameter_active,
|
||||
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;} // 函数用于呈现当前的选择
|
||||
});
|
||||
|
||||
$("#dynamic").empty();
|
||||
var selelct_dynamic =$("#dynamic").select2({
|
||||
data: dynamic,
|
||||
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;}, // 函数用于呈现当前的选择
|
||||
disabled:true
|
||||
});
|
||||
},
|
||||
onLoadError: function(){ //加载失败时执行
|
||||
console.info("加载数据失败");
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
//<select class="form-control select2" id="active" name ="active"><option value= "1" selected = "selected">启用</option><option value= "0">禁用</option></select>
|
||||
//<select class="form-control select2" id="parameterType" name ="parameterType"><option value= "fixed" selected = "selected">固定值</option><option value= "dynamic">动态值</option></select>
|
||||
</script>
|
||||
<div class="modal fade" id="subModal">
|
||||
<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">
|
||||
<!-- 新增界面formid强制为subForm -->
|
||||
<form class="form-horizontal" id="subForm">
|
||||
<!-- 界面提醒div强制id为alertDiv -->
|
||||
<div id="alertDiv"></div>
|
||||
<input type="hidden" name="id" value= "${equipmentCardLinks.id}">
|
||||
<input type="hidden" name="equipmentId" value= "${equipmentId}">
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*链接名称</label>
|
||||
<div class="col-sm-10">
|
||||
<input type="text" class="form-control" id="linkName" name ="linkName" placeholder="名称" value="${equipmentCardLinks.linkName}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">内网IP端口</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="2" id ="linkIpIntranet" name ="linkIpIntranet" placeholder="内网IP端口">${equipmentCardLinks.linkIpIntranet}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">外网IP端口</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="2" id ="linkIpExtranet" name ="linkIpExtranet" placeholder="外网IP端口">${equipmentCardLinks.linkIpExtranet}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*接口</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="2" id ="linkUrl" name ="linkUrl" placeholder="接口">${equipmentCardLinks.linkUrl}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*链接类型</label>
|
||||
<div class="col-sm-6">
|
||||
<select class="form-control select2" id="linkType" name ="linkType" style="width: 270px;">
|
||||
<option value= "external" selected = "selected">外部</option>
|
||||
<option value= "inside">内部</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">*启用状态</label>
|
||||
<div class="col-sm-6">
|
||||
<select class="form-control select2" id="active" name ="active" style="width: 270px;">
|
||||
<option value= "1" selected = "selected">启用</option>
|
||||
<option value= "0">禁用</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">顺序</label>
|
||||
<div class="col-sm-6">
|
||||
<input type="number" class="form-control" id="morder" name ="morder" placeholder="顺序" value="${equipmentCardLinks.morder}" >
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-2 control-label">备注</label>
|
||||
<div class="col-sm-10">
|
||||
<textarea class="form-control" rows="2" id ="remarks" name ="remarks" placeholder="备注...">${equipmentCardLinks.remarks}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<form class="form-horizontal" id="subParameterForm">
|
||||
<input type="hidden" name="linkId" value= "${equipmentCardLinks.id}">
|
||||
<div class="box box-primary" style="margin-top:20px">
|
||||
<div class="box-header with-border">
|
||||
<h3 class="box-title">链接参数</h3>
|
||||
<div class="box-tools pull-right">
|
||||
<a onclick="deletesParameterFun()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i class="glyphicon glyphicon-minus"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.box-header -->
|
||||
<div class="box-body ">
|
||||
<table id="table_Parameter"></table>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</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="doupdate()" id="btn_update">保存</button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- /.modal-content -->
|
||||
</div>
|
||||
<!-- /.modal-dialog -->
|
||||
</div>
|
||||
Reference in New Issue
Block a user