303 lines
13 KiB
Plaintext
303 lines
13 KiB
Plaintext
<%@ page language="java" pageEncoding="UTF-8" %>
|
||
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
|
||
<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 masterId = '${data.id}';
|
||
var tbName = 'tb_doc_file'; //数据表
|
||
var nameSpace = 'Document';//保存文件夹
|
||
//上传文件
|
||
var fileinput = function () {
|
||
$.post(ext.contextPath + '/document/fileinput4data.do', {
|
||
masterId: masterId,
|
||
tbName: tbName,
|
||
nameSpace: nameSpace,
|
||
companyId: '${param.companyId}'
|
||
}, function (data) {
|
||
$("#fileInputDiv").html(data);
|
||
openModal('fileInputModal');
|
||
});
|
||
};
|
||
var editEqu = function (id) {
|
||
$.post(ext.contextPath + '/document/fileEditEqu.do', {
|
||
id: id,
|
||
tbName: tbName,
|
||
}, function (data) {
|
||
$("#fileInputDiv").html(data);
|
||
openModal('fileInputModal');
|
||
});
|
||
};
|
||
//下载文件
|
||
var fileDownload = function (id) {
|
||
window.open(ext.contextPath + "/base/downloadFile.do?key=" + id + "&tbName=" + tbName);
|
||
};
|
||
var delFileFun = function (id) {
|
||
stopBubbleDefaultEvent();
|
||
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 + '/document/dodeleteFile.do', {id: id, tbName: tbName}, function (data) {
|
||
if (data == 1) {
|
||
$("#fileTable").bootstrapTable('refresh');
|
||
} else {
|
||
showAlert('d', '删除失败', 'mainAlertdiv');
|
||
}
|
||
});
|
||
|
||
}
|
||
});
|
||
};
|
||
var dosearchFile = function () {
|
||
$("#fileTable").bootstrapTable("refresh");
|
||
};
|
||
|
||
//获取路径
|
||
var fileView = function (id) {
|
||
var tbName = 'tb_doc_file';
|
||
$.post(ext.contextPath + '/base/getInputFile4Id.do', {id: id, tbName: tbName}, function (data) {
|
||
if (data.length > 0) {
|
||
var jsonstr = $.parseJSON(data);
|
||
//图片路径转换
|
||
var path = jsonstr[0].abspath;
|
||
path = path.substring(path.indexOf('webapps') + 7, path.length);
|
||
path = ext.basePath.replace(ext.contextPath, '') + path.replace(/\\/g, "\/");
|
||
;
|
||
|
||
//判断是否为图片
|
||
if (jsonstr[0].type.indexOf('image') != -1) {
|
||
showimg(path);
|
||
} else {
|
||
layer.msg("不是图片格式!");
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
//弹出图片 宽高自适应
|
||
function showimg(src) {
|
||
if (src == "") {
|
||
layer.msg("无图片!");
|
||
return;
|
||
}
|
||
//src = "../" + src;//加入 ../ 防止找不到图片
|
||
var img = new Image();
|
||
img.onload = function () {//避免图片还未加载完成无法获取到图片的大小。
|
||
//避免图片太大,导致弹出展示超出了网页显示访问,所以图片大于浏览器时下窗口可视区域时,进行等比例缩小。
|
||
var max_height = $(window).height() - 100;
|
||
var max_width = $(window).width();
|
||
|
||
//rate1,rate2,rate3 三个比例中取最小的。
|
||
var rate1 = max_height / img.height;
|
||
var rate2 = max_width / img.width;
|
||
var rate3 = 1;
|
||
var rate = Math.min(rate1, rate2, rate3);
|
||
//等比例缩放
|
||
var imgHeight = img.height * rate; //获取图片高度
|
||
var imgWidth = img.width * rate; //获取图片宽度
|
||
|
||
var imgHtml = "<img src='" + src + "' width='" + imgWidth + "px' height='" + imgHeight + "px'/>";
|
||
//弹出层
|
||
layer.open({
|
||
type: 1,
|
||
title: false,
|
||
closeBtn: 0,
|
||
area: ['auto', 'auto'],
|
||
skin: 'layui-layer-nobg', //没有背景色
|
||
shadeClose: true,
|
||
content: imgHtml
|
||
});
|
||
}
|
||
img.src = src;
|
||
}
|
||
|
||
|
||
$(function () {
|
||
$("#search_fileName").keyup(function () {
|
||
if (event.keyCode == 13) {
|
||
event.preventDefault();
|
||
//回车查询
|
||
dosearchFile();
|
||
event.stopPropagation();
|
||
}
|
||
})
|
||
$("#st").select2({minimumResultsForSearch: 10}).val("${data.st}").trigger("change");
|
||
$("#fileTable").bootstrapTable({ // 对应table标签的id
|
||
url: ext.contextPath + '/document/getInputFileList.do', // 获取表格数据的url
|
||
cache: false, // 设置为 false 禁用 AJAX 数据缓存, 默认为true
|
||
striped: true, //表格显示条纹,默认为false
|
||
pagination: true, // 在表格底部显示分页组件,默认false
|
||
pageList: [10, 15, 20], // 设置页面可以显示的数据条数
|
||
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, // 排序规则
|
||
masterId: '${nodeIds}',
|
||
tbName: tbName,
|
||
fileName: $("#search_fileName").val()
|
||
}
|
||
},
|
||
sortName: 'insdt', // 要排序的字段
|
||
sortOrder: 'desc', // 排序规则
|
||
columns: [
|
||
{
|
||
field: 'filename', // 返回json数据中的name
|
||
title: '资料名称', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
},/* {
|
||
field: 'abspath', // 返回json数据中的name
|
||
title: '路径', // 表格表头显示文字
|
||
align: 'left', // 左右居中
|
||
valign: 'middle',// 上下居中
|
||
formatter:function(value,row,index){
|
||
return '<a onclick="fileDownload(\'' + row.id + '\')">'+value+'</a>'
|
||
}
|
||
}, */{
|
||
field: 'user.caption', // 返回json数据中的name
|
||
title: '上传者', // 表格表头显示文字
|
||
align: 'left', // 左右居中
|
||
valign: 'middle',// 上下居中
|
||
}, {
|
||
field: 'equipmentcardnames', // 返回json数据中的name
|
||
title: '关联设备', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle', // 上下居中
|
||
},
|
||
/*{
|
||
field: 'st', // 返回json数据中的name
|
||
title: '状态', // 表格表头显示文字
|
||
align: 'center', // 左右居中
|
||
valign: 'middle' // 上下居中
|
||
}, */
|
||
{
|
||
title: "操作",
|
||
align: 'center',
|
||
valign: 'middle',
|
||
width: 150, // 定义列的宽度,单位为像素px
|
||
formatter: function (value, row, index) {
|
||
var buts = '';
|
||
buts += '<button class="btn btn-default btn-sm" title="图片预览" onclick="fileView(\'' + row.id + '\')"><i class="fa fa-eye"></i><span class="hidden-md hidden-lg">图片预览</span></button>';
|
||
buts += '<button class="btn btn-default btn-sm" title="下载" onclick="fileDownload(\'' + row.id + '\')"><i class="fa fa-download"></i><span class="hidden-md hidden-lg">下载</span></button>';
|
||
buts = '<div class="btn-group" >' + buts + '</div>';
|
||
return buts;
|
||
}
|
||
}
|
||
],
|
||
onLoadSuccess: function () { //加载成功时执行
|
||
//$(".bs-checkbox").css({'text-align':'center','vertical-align':'middle'})
|
||
adjustBootstrapTableView("fileTable");
|
||
},
|
||
onLoadError: function () { //加载失败时执行
|
||
console.info("加载数据失败");
|
||
}
|
||
})
|
||
});
|
||
</script>
|
||
<%-- <div class="box box-primary" >
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">详情</h3>
|
||
<div class="box-tools pull-right">
|
||
<a onclick="doupdate()" class="btn btn-box-tool" data-toggle="tooltip" title="保存"><i class="glyphicon glyphicon-floppy-disk"></i></a>
|
||
<a onclick="dodel()" class="btn btn-box-tool" data-toggle="tooltip" title="删除"><i class="glyphicon glyphicon-trash"></i></a>
|
||
</div>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body ">
|
||
<form class="form-horizontal " id="subForm">
|
||
<input id="id" name="id" type="hidden" value="${data.id}"/>
|
||
<!-- 界面提醒div强制id为alertDiv -->
|
||
<div id="alertDiv"></div>
|
||
<div id="fault4SelectDiv"></div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">名称</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="docname" name ="docname" placeholder="名称" value="${data.docname }">
|
||
</div>
|
||
<label class="col-sm-2 control-label">上级菜单</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="pname" name ="pname" placeholder="上级菜单" onclick="showDocument4SelectFun();" value="${data.pname}">
|
||
<input id="pid" name="pid" type="hidden" value="${data.pid}"/>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">编号</label>
|
||
<div class="col-sm-4">
|
||
<input type="text" class="form-control" id="number" name ="number" placeholder="编号" value="${data.number}">
|
||
</div>
|
||
<label class="col-sm-2 control-label">启用</label>
|
||
<div class="col-sm-4">
|
||
<select id ="st" name="st" class="form-control select2">
|
||
<option value="1" >启用</option>
|
||
<option value="0" >禁用</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
<div class="form-group">
|
||
<label class="col-sm-2 control-label">简要说明</label>
|
||
<div class="col-sm-10">
|
||
<textarea class="form-control " id="details" name="details" rows="2">${data.details}</textarea>
|
||
</div>
|
||
</div>
|
||
</form>
|
||
</div>
|
||
</div> --%>
|
||
|
||
<div class="box box-primary">
|
||
<div class="box-header with-border">
|
||
<h3 class="box-title">${param.text}</h3>
|
||
<div class="box-tools pull-right">
|
||
</div>
|
||
</div>
|
||
<!-- /.box-header -->
|
||
<div class="box-body ">
|
||
<div>
|
||
<div class="btn-group" style="width: 220px;padding-bottom:10px;">
|
||
<%--<security:authorize buttonUrl="document/fileUpload.do">
|
||
<button type="button" class="btn btn-default" onclick="fileinput();"><i class="fa fa-plus"></i>上传文件
|
||
</button>
|
||
</security:authorize>--%>
|
||
</div>
|
||
<div class="input-group input-group-sm pull-right" style="width:250px">
|
||
<input type="text" id="search_fileName" name="search_fileName" autocomplete="off" style="height:35px"
|
||
class="form-control pull-right" placeholder="资料名称/设备名称/设备编号">
|
||
<div class="input-group-btn">
|
||
<button class="btn btn-default" style="height:35px" onclick="dosearchFile();"><i
|
||
class="fa fa-search"></i></button>
|
||
</div>
|
||
</div>
|
||
<table id="fileTable"></table>
|
||
</div>
|
||
</div>
|
||
</div> |