Files
SIPAIIS_WMS_JSSW/WebRoot/jsp/document/dataFileEdit.jsp
2026-01-16 14:13:44 +08:00

346 lines
15 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%@ page language="java" pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://www.springsecurity.org/jsp" prefix="security" %>
<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"
src="<%=request.getContextPath()%>/node_modules/ckeditor5-build-balloon/ckeditor.js"
charset="utf-8"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/node_modules/ckeditor5-build-balloon/translations/zh-cn.js"
charset="utf-8"></script>
<script type="text/javascript"
src="<%=request.getContextPath()%>/node_modules/wangeditor/wangEditor.min.js"></script>
<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 insertWord = function () {
$.post(ext.contextPath + '/documentData/doaddData.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 + '/documentData/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 viewFun = function (id) {
$.post(ext.contextPath + '/documentData/doview.do', {
id: id,
tbName: tbName
}, function (data) {
$("#fileInputDiv").html(data);
openModal('fileInputViewModal');
});
}
//浏览
var documentFun = function (id) {
$.post(ext.contextPath + '/documentData/doeditData.do', {
id: id,
masterId: masterId,
companyId: '${param.companyId}',
nameSpace: nameSpace,
tbName: tbName
}, function (data) {
$("#fileInputDiv").html(data);
openModal('fileInputEditModal');
});
}
//获取路径
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();
//rate1rate2rate3 三个比例中取最小的。
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 + '/documentData/getList.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
//field: 'documentName', // 返回json数据中的name
field: 'wName', // 返回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: 'center', // 左右居中
valign: 'middle',// 上下居中
}, {
field: 'insertTime', // 返回json数据中的name
title: '上传时间', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
formatter: function (value, row, index) {
return value.substring(0, 19);
}
}, {
field: 'fileSum', // 返回json数据中的name
title: '附件数量', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
}, {
field: 'fileSize', // 返回json数据中的name
title: '附件大小', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle',// 上下居中
formatter: function (value, row, index) {
var size = '0KB'
var re = /([0-9]+\.[0-9]{2})[0-9]*/;
if (value > 1048576) {
var num = value/1024/1024
size = num.toString().replace(re,"$1") + 'MB'
} else if (value > 0) {
var num = value/1024
size = num.toString().replace(re,"$1") + 'KB'
}
return size
}
},
// {
// field: 'equipmentcardnames', // 返回json数据中的name
// title: '关联设备', // 表格表头显示文字
// align: 'center', // 左右居中
// valign: 'middle', // 上下居中
// },
/*{
field: 'st', // 返回json数据中的name
title: '状态', // 表格表头显示文字
align: 'center', // 左右居中
valign: 'middle' // 上下居中
}, */
{
title: "操作",
align: 'center',
valign: 'middle',
width: 200, // 定义列的宽度单位为像素px
formatter: function (value, row, index) {
var buts = '';
buts += '<button class="btn btn-default btn-sm" title="浏览" onclick="viewFun(\'' + 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="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="editEqu(\'' + row.id + '\')"><i class="fa fa-edit"></i><span class="hidden-md hidden-lg">关联设备</span></button>';
<%--buts += '<security:authorize buttonUrl="document/fileDownload.do">';--%>
<%--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 += '</security:authorize>';--%>
buts += '<security:authorize buttonUrl="document/fileDelete.do">';
buts += '<button class="btn btn-default btn-sm" title="文档编辑" onclick="documentFun(\'' + row.id + '\')"><i class="fa fa fa-file-text-o"></i><span class="hidden-md hidden-lg">编辑</span></button>';
buts += '</security:authorize>';
buts += '<security:authorize buttonUrl="document/fileDelete.do">';
buts += '<button class="btn btn-default btn-sm" title="删除" onclick="delFileFun(\'' + row.id + '\')"><i class="fa fa fa-trash-o"></i><span class="hidden-md hidden-lg">删除</span></button>';
buts += '</security:authorize>';
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">${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>--%>
<%-- <!-- <button type="button" class="btn btn-default" onclick="delDocFun();"><i class="fa fa-trash"></i> 删除</button> -->--%>
</security:authorize>
<button type="button" class="btn btn-default" onclick="insertWord();"><i class="fa fa-plus"></i>新增资料
</button>
</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>