<%@ page import="com.yc.sdk.shopping.util.SettingKey" %><%--
|
Created by IntelliJ IDEA.
|
User: xinyb_
|
Date: 2022-02-28
|
Time: 16:34
|
To change this template use File | Settings | File Templates.
|
--%>
|
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
|
<%
|
String hostUrl = SettingKey.getHostUrl(request);
|
String id = request.getParameter("id");
|
String pant = request.getParameter("pant");
|
String obj = request.getParameter("obj");
|
System.out.println(id);
|
System.out.println(pant);
|
System.out.println(obj);
|
%>
|
<html>
|
<head>
|
<title>格线附件上传控件</title>
|
<link rel="stylesheet" type="text/css"
|
href="<%=hostUrl%>/js/bootstrap/v5.1.3/css/bootstrap.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/css/bootstrap.css")%>">
|
<link rel="stylesheet" type="text/css"
|
href="<%=hostUrl%>/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/icons/font/bootstrap-icons.css")%>">
|
<link rel="stylesheet" type="text/css"
|
href="<%=hostUrl%>/js/bootstrap/fileinput/css/fileinput.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/css/fileinput.css")%>">
|
<link rel="stylesheet" type="text/css"
|
href="/general/Viewer/css/viewer.min.css?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/general/Viewer/css/viewer.min.css")%>">
|
<script type="text/javascript"
|
src="<%=hostUrl%>/help/js/JQuery-3.6.0.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/help/js/JQuery-3.6.0.js")%>"></script>
|
<script type="text/javascript"
|
src="<%=hostUrl%>/js/bootstrap/v5.1.3/js/bootstrap.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/v5.1.3/js/bootstrap.js")%>"></script>
|
<script type="text/javascript"
|
src="<%=hostUrl%>/js/bootstrap/fileinput/js/fileinput.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/js/fileinput.js")%>"></script>
|
<script type="text/javascript"
|
src="<%=hostUrl%>/js/bootstrap/fileinput/js/locales/zh.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/js/bootstrap/fileinput/js/locales/zh.js")%>"></script>
|
<script type="text/javascript"
|
src="/general/Viewer/js/viewer-jquery.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/general/Viewer/js/viewer-jquery.min.js")%>"></script>
|
<script type="text/javascript"
|
src="/general/Viewer/js/viewer.min.js?v=<%=com.yc.utils.FileUtil.getVerstion(request,"/general/Viewer/js/viewer.min.js")%>"></script>
|
<style>
|
.image {
|
text-align: center;
|
/*width: calc(100% - 100px);*/
|
height: calc(100% - 150px);
|
margin-top: 50px;
|
}
|
|
.image img {
|
/*max-width: calc(100% - 200px);*/
|
height: 100%;
|
}
|
|
.hide {
|
display: none;
|
}
|
|
.fileInput {
|
margin: 30px;
|
}
|
|
/*.krajee-default.file-preview-frame .kv-file-content {*/
|
/* width: auto !important;*/
|
/* height: 110px !important;*/
|
/*}*/
|
|
.file-preview {
|
min-height: 150px;
|
}
|
|
.file-drop-zone {
|
min-height: auto !important;
|
border: 0px dashed white !important;
|
cursor: pointer;
|
}
|
|
.file-drop-zone .file-drop-zone-title {
|
padding: 30px 10px !important;
|
font-size: 1em;
|
}
|
|
.file-drop-zone div {
|
cursor: pointer !important;
|
}
|
|
.file-footer-buttons .btn-sm {
|
padding: 0.1rem 0.1rem !important;
|
margin-top: 5px !important;
|
}
|
|
.kv-file-content html {
|
overflow: hidden;
|
}
|
|
.file-drop-zone .file-preview-thumbnails .kv-preview-thumb {
|
margin: 0px 5px !important;
|
border-radius: 6px;
|
}
|
</style>
|
</head>
|
<body>
|
<div style="margin: 5px;padding: 5px">
|
<div class="image hide">
|
<img id="bimges" src="" alt="">
|
</div>
|
<div class="fileInput hide">
|
<input id="file-input" name="file-input" value="" type="file">
|
<input id="file-inputv" type="hidden" value="">
|
</div>
|
</div>
|
<script>
|
//加密
|
const rsakey = {
|
pubkey: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkRupiYcKVGGUtDBDoR1t/1zm3ZtZgnte39iTJW6hlqjdY0UagKjpNiIv7J6XjtgfX7SgsR4AWnivqQHAICIvdPKfGZZzIs62OQ19MqrDTMoB/LvK5teNWhClv23WMUfRbP+EHgprT6hTw8U5apw1IB6i/y57NkLav792wiYBYRU4X45NoTaT+aiTSLFEflbfm94EXnhSS3vFkBmrZGy5BRNI8gmzafroslGx2Hk90CqlNdeKYxgZQ6xtvj+u33yrszWvPT6F9fsJT8aMjtvH050iYKRVct+x6Q7VRJgCI4MgvAexnTKdxW54YzvXCuO5bDiy5la7CgerWkTAq9dzXwIDAQAB"
|
};
|
//渲染出附件界面出来9,19
|
const BootstrapFileInputOption = function (g) {
|
let o = {
|
e: $('#file-input'),
|
grid: g,
|
option: {//属性
|
uploadUrl: '#', // String,用于上传处理操作的URL(通常是基于Ajax的处理)
|
language: 'zh', // 语言
|
uploadAsync: false, // bool是否多文件批量上传将并行异步/。默认为true
|
showCaption: false,//是否显示被选文件的简介
|
showBrowse: false,//是否显示文件浏览按钮
|
showUpload: false,//是否显示上传按钮
|
showCancel: false,//是否显示取消按钮
|
showRemove: false,//是否显示移除按钮
|
showDrag: false,//是否显示拖动按钮
|
showClose: false,//是否显示关闭按钮
|
dropZoneEnabled: true, //是否显示拖拽区域
|
browseOnZoneClick: true, //布尔值,是否在点击预览区域时触发文件浏览/选择。默认为false
|
showUploadedThumbs: true, // 是否在预览窗口中持续显示已经上传的文件缩略图(用于ajax上传),直到按下删除/清除按钮
|
maxFilesNum: 10, // 上传最大的文件数量
|
maxFileCount: 0, // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
|
isNine: false, // 19类型就为false,9类型就为true,下面有判断
|
validateInitialCount: false, // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
|
overwriteInitial: true, // 是否要覆盖初始预览内容和标题设置
|
initialPreviewAsData: true,
|
allowedFileExtensions: null,//允许上传的文件扩展名列表。默认情况下设置为 null
|
dropZoneTitle: '点击或拖拽文件',
|
dropZoneClickTitle: '',
|
layoutTemplates: {
|
indicator: ''//去掉上传状态图标
|
, actionUpload: ''//去除缩略图中文件上传操作按钮的模板
|
, actionDrag: ''//去掉缩略图拖动图标
|
, footer: '<div class="file-thumbnail-footer" style="height: auto">\n' +
|
' {actions}\n' +
|
'</div>'
|
},
|
//自定义按钮(权限)
|
otherActionButtons: '<button type="button" onclick="top.mylockFile(this)" ' +
|
'class="kv-file-lock btn btn-sm btn-kv btn-default btn-outline-secondary"' +
|
'title="权限"{dataKey}><i class="bi-shield-lock"></i></button>',
|
fileActionSettings: {//用于在预览窗口中为新选择的文件缩略图设置文件操作的配置
|
showUpload: false,//是否在缩略图中显示上传按钮
|
showZoom: true
|
},
|
// usePdfRenderer: true,//启动自定义的内部插件,false值或不设置这个属性将是默认的插件
|
// pdfRendererUrl: '/general/pdf/web/viewer.jsp',//预览pdf格式的插件路径
|
initialPreview: [], // 字符串或者数组,要显示的初始预览内容
|
initialPreviewConfig: [], // 数组,为每个initialPreview条目(就是initialPreview中的每个预览)设置重要属性的配置
|
showPreview: true, // 布尔值,是否显示文件预览。默认值为true
|
maxFileSize: 0//允许上传的文件大小(默认为0,不限制)
|
},
|
fileInput: function () {//渲染,并且绑定事件
|
let F = this.e;
|
let g = this.grid;
|
F.fileinput(this.option).on("filebatchselected", function (event, files) {
|
//触发上传功能
|
F.fileinput('upload');
|
}).on('filebatchuploadsuccess', function (event, data) {
|
// 此事件仅在ajax上传且文件批量上传成功之后触发
|
if (g) {
|
let tmp = {};
|
let v = $('#file-inputv');
|
let oldKey = v.val();// 旧的值
|
let newKey = data.response.uuid ? data.response.uuid + ";" : ""; // 新的值
|
if (oldKey != "") {
|
let keys = oldKey.split(";");
|
for (let i = 1; i < keys.length; i++) {
|
newKey = newKey.replace(";" + keys[i] + ";", ";");
|
}
|
}
|
tmp.key = newKey;
|
tmp.type = data.response.type;
|
// tmp.filedId = name;
|
tmp.oldKey = oldKey;
|
v.val(data.response.uuid ? data.response.uuid + ";" : "")
|
data.thumbs.attr("data-key", JSON.stringify(tmp));
|
let unId = data.response.uuid ? data.response.uuid : "";
|
let grid = g.id;
|
let obj = unId + ";" + data.response.fileType;// by by danaus 2020/4/30 11:32
|
grid.SetValue(g.row, g.col, obj, 0);
|
grid.RefreshCell(g.row, g.col);
|
}
|
}).on('filebeforedelete', function (event, params) {
|
// 在删除initialPreview内容集中的每个缩略图文件之前触发此事件
|
let e = !confirm("您确定要删除吗?");
|
return e;
|
}).on('filedeleted', function (event, key) {
|
// 在删除initialPreview内容集中的每个缩略图文件之后触发此事件
|
if (g) {
|
let grid = g.id;
|
let obj = "";
|
grid.SetValue(g.row, g.col, obj, 0);
|
grid.RefreshCell(g.row, g.col);
|
}
|
}).on('filesuccessremove', function (event, val) {
|
// 使用缩略图删除按钮删除成功上传的缩略图后,会触发此事件
|
let uuid = val.key.split(";")[0];
|
let seq = val.key.split(";")[1];
|
$.ajax({
|
type: "POST",
|
dataType: 'json',
|
url: '/attachment/deleteOwnerAttachment.do?type=' + val.type + '&unid=' + uuid + '&seq=' + seq, // 删除路径
|
success: function (data) {
|
if (data.status == 'success') {
|
if (g) {
|
var grid = g.id;
|
var obj = "";
|
grid.SetValue(g.row, g.col, obj, 0);
|
grid.RefreshCell(g.row, g.col);
|
}
|
}
|
}
|
})
|
}).on('filezoomshown', function (event, params) {
|
//此事件在模态对用户可见后触发(将等待 CSS 转换完成)
|
$('#kvFileinputModal .file-zoom-content img').viewer({title: false});
|
}).on('filezoomprev', function (event, params) {
|
//事件在缩放预览模式下,当点击上一个导航按钮查看上一个文件时触发(也在缩放模式下按下键盘左箭头时触发)
|
$('#kvFileinputModal .file-zoom-content img').viewer({title: false});
|
}).on('filezoomnext', function (event, params) {
|
//该事件在缩放预览模式下,当点击下一个导航按钮查看下一个文件时触发(也在缩放模式下按下键盘右箭头时触发)。
|
$('#kvFileinputModal .file-zoom-content img').viewer({title: false});
|
});
|
}
|
}
|
return o;
|
}
|
//附件控件类型9,19
|
const getFile = function (value, g) {
|
let fileInput = BootstrapFileInputOption(g); // 加载图片需要的属性(固定ID)
|
let controlType = 9; // 专用于格线
|
let encrypt = new top.JSEncrypt();
|
encrypt.setPublicKey(rsakey.pubkey);
|
let param = {};
|
try {// 赋值
|
if ((value.uuid == undefined || value.uuid == '') && (value.oldgrid != null &&
|
value.oldgrid != undefined && value.oldgrid != '')) {
|
let unid = value.oldgrid.split(';');
|
if (unid.length >= 2) {
|
value.uuid = unid[0] + ";" + unid[1];//uuid+seq
|
}
|
if (unid.length >= 4 && unid[0].indexOf('.do') != -1) {
|
if (unid.length > 4) {
|
if (unid[unid.length - 2] != null && !isNaN(unid[unid.length - 2])) {
|
controlType = 19;//存在多个seq,表示是多附件
|
}
|
}
|
value.uuid = unid[1] + ";" + unid[2];//uuid+seq
|
}
|
param.unid = value.uuid.replace("|48|48|", "");
|
}
|
param.fieldid = value.fieldid;
|
param.controltype = controlType;
|
param.formid = value.formid;
|
param.ishd = value.ishd;
|
let strIs = "";
|
if (value.is1 != null && value.is1 != "") {
|
strIs = "&is1=" + value.is1 + "&ishd=" + value.ishd;
|
} else if (value.is8 != null && value.is8 != "") {
|
strIs = "&is8=" + value.is8 + "&ishd=" + value.ishd;
|
} else {
|
strIs = "&ishd=" + value.ishd;
|
}
|
param.docstatus = value.docstatus == null ? 0 : value.docstatus;
|
param.rowid = value.rowid;
|
param.usercode = value.usercode;
|
param.doccode = value.doccode;
|
param.headflag = (value.ishd == 0) ? 1 : 0;
|
let readerUserCodes = top.$('#readerusercodes').val();
|
try {
|
if (param.doccode == null) {
|
param.doccode = top.$('#doccode').val();
|
if (param.doccode == null)
|
param.doccode = top.panMain[top.panIndex].panelAuditValue.doccode;
|
}
|
if (param.doccode && readerUserCodes != null && readerUserCodes != '') {
|
param.readerusercodes = readerUserCodes;
|
}
|
} catch (e) {
|
param.doccode = "";
|
}
|
$('#file-inputv').val(param.unid);//赋值
|
|
// 图片显示的方法
|
$.ajax({
|
url: '/attachment/getAttachmentList.do',
|
type: "POST",
|
async: false,
|
data: {pant: JSON.stringify(param)},
|
dataType: 'json',
|
success: function (jsons) {
|
if ((value.uuid != null && value.uuid != '') ||
|
(value.oldgrid != null && value.oldgrid != null && value.oldgrid != '')) {
|
for (var i = 0; i < jsons.length; i++) {
|
// 图片属性
|
if (param.usercode == "") {
|
param.usercode = jsons[i].userCode;
|
value.usercode = jsons[i].userCode;
|
}
|
if (i == 0) {
|
param.username = jsons[i].userName;
|
param.dbid = jsons[i].dbid;
|
param.domain = jsons[i].domain;
|
value.username = jsons[i].userName;
|
value.dbid = jsons[i].dbid;
|
value.domain = jsons[i].domain;
|
}
|
//文件路径
|
let fileURL = top.getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid,
|
jsons[i].unid + "@p@" + jsons[i].seq, jsons[i].domain, jsons[i].dbid,
|
false, 60, 60, jsons[i].orgFileType);
|
//文件显示信息
|
let title = '文件名:' + jsons[i].originalFileName +
|
' \n类型:' + jsons[i].fileType +
|
' \n大小:' + jsons[i].fileSizeStr +
|
' \n上传者:' + jsons[i].authorName +
|
' \n上传时间:' + jsons[i].uploadTimeStr;
|
//删除地址
|
let deleURL = jsons[i].domain + '/attachment/deleteAttachmentV2.do?' +
|
'type=' + (controlType == 9 ? '1' : '3') + '&formid=' + param.formid +
|
'&doccode=' + param.doccode + '&fieldid=' + jsons[i].fieldid + '&unid=' + jsons[i].unid +
|
'&seq=' + jsons[i].seq + '&docstatus=' + param.docstatus + '&ishd=' + param.ishd +
|
'&usercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].authorCode)) +
|
'&readerusercodes=' + readerUserCodes +
|
'&dbid=' + encodeURIComponent(encrypt.encrypt(jsons[i].dbid)) +
|
'&curUsername=' + encodeURIComponent(encrypt.encrypt(jsons[i].userName)) +
|
'&curUsercode=' + encodeURIComponent(encrypt.encrypt(jsons[i].userCode));
|
//下载地址
|
let Down = jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" +
|
jsons[i].unid + "@p@" + jsons[i].seq + "_" + jsons[i].dbid + "_" +
|
jsons[i].formid + "_" + jsons[i].orgFileType;
|
//pdf格式调用插件
|
if (jsons[i].orgFileType == 'pdf') {
|
fileURL = jsons[i].domain + '/general/pdf/web/viewer.jsp?file=' + fileURL;
|
}
|
//设置office文件
|
if (jsons[i].orgFileType == 'doc' || jsons[i].orgFileType == 'docx' || jsons[i].orgFileType == 'xls'
|
|| jsons[i].orgFileType == 'xlsx' || jsons[i].orgFileType == 'ppt' || jsons[i].orgFileType == 'pptx') {
|
jsons[i].fileType = 'office';
|
}
|
//填充
|
fileInput.option.initialPreview.push(fileURL);
|
fileInput.option.initialPreviewConfig.push({
|
'caption': jsons[i].originalFileName, // 上传的图片名称
|
'filename': jsons[i].physicalFile, // 上传文件名
|
'time': jsons[i].uploadTimeStr, //上传开始时间
|
'name': jsons[i].authorName, //作者名称
|
'size': jsons[i].fileSizeStr, // 上传的图片大小
|
'type': jsons[i].fileType, // 上传的图片类型
|
'filetype': jsons[i].fileType + '/' + jsons[i].orgFileType,
|
'key': jsons[i].unid + ';' + jsons[i].seq,
|
'title': title,//title
|
'downloadUrl': jsons[i].allowDownload ? Down : false,//jsons[i].domain + "/attachment/downLoadAttachment.do?filePath=" + fileURL,//top.getAttachmentUrl(jsons[i].staticUrl, jsons[i].formid, jsons[i].unid + "@p@" + jsons[i].seq, "", jsons[i].dbid, false, 60, 60, jsons[i].orgFileType, true),
|
'url': deleURL,//删除
|
'hasZoom': jsons[i].allowView,//是否能查看
|
// 'hasDwn': jsons[i].allowDownload,//是否能下载
|
'hasDel': jsons[i].allowDelete,//是否能删除
|
'hasLock': jsons[i].authorCode != null && jsons[i].authorCode == param.usercode ? true : false//是否能显示权限
|
});
|
}
|
}
|
//下载地址
|
let upURL = value.domain + '/attachment/uploadAttachmentV2.do?type=' +
|
(controlType == 9 ? '1' : '3') + '&formid=' + value.formid
|
+ '&doccode=' + value.doccode + '&fieldid=' + value.fieldid
|
+ '&usercode=' + encodeURIComponent(encrypt.encrypt(value.usercode)) +
|
'&username=' + encodeURIComponent(encrypt.encrypt(value.username)) +
|
'&dbid=' + encodeURIComponent(encrypt.encrypt(value.dbid))
|
+ strIs + '&rowid=' + value.rowid + '&uuid=' + (value.unid == undefined ? "" : value.unid);
|
fileInput.option.uploadUrl = upURL; // 附件上传路径
|
fileInput.option.maxFileCount = 1; // 为每个多次上载允许的最大文件数。如果设置为0,则意味着允许的文件数是无限的。默认值为0。
|
fileInput.option.isNine = true;
|
fileInput.option.validateInitialCount = true; // 是否包括初始预览文件数(服务器上传文件)验证minfilecount和maxfilecount。默认为false.
|
fileInput.option.overwriteInitial = false; // 是否要覆盖初始预览内容和标题设置
|
if (jsons.length > 0) {
|
let size = jsons[0].allowMaxFileSize != '' ? jsons[0].allowMaxFileSize : 0;
|
fileInput.option.maxFileSize = size;//从后台取数回来 by danaus 2020/8/7 10:47
|
}
|
}
|
});
|
} catch (e) {
|
alert(e);
|
} finally {
|
fileInput.fileInput();// 加载图片显示
|
$(".image").addClass("hide");
|
$(".fileInput").removeClass("hide");
|
}
|
}
|
//图片类型控件 40
|
const getImage = function (value, g) {
|
if (value.oldgrid != null) {
|
let srcURL = '';
|
if (value.oldgrid.indexOf('http') != -1) { //判断http协议,有无地址
|
srcURL = value.oldgrid.split(";")[1]; //显示网址图片
|
} else {
|
// let src = value.oldgrid.replace(".do;",".do?type="+(controlType == 9?"1":"3")+"&uuid=");
|
let obj = value.oldgrid.split(";");
|
let unid = obj[1];
|
let seq = obj[2];
|
let fileExt = obj[obj.length - 1];
|
if (obj.length > 4) {
|
fileExt = "unknown";
|
}
|
if ('jpge;jpg;png;gif'.indexOf(fileExt.toLowerCase()) == -1) {//不是图片后缀的
|
//执行9 19类型控件
|
getFile(value, g);
|
return;
|
}
|
if (seq != null && seq != undefined && seq != "") {
|
unid = unid + "@p@" + seq;
|
}
|
srcURL = top.getAttachmentUrl(value.staticUrl, value.formid, unid, value.domain, value.dbid, false, 80, 80, fileExt);
|
}
|
$("#bimges").attr("src", srcURL);
|
}
|
$(".image").removeClass("hide");
|
$(".fileInput").addClass("hide");
|
$('#bimges').viewer({title: false});
|
}
|
//拆分
|
const getSplit = function () {
|
let v = {};
|
let value = top.gridFileInputVal;
|
if (value != null) {
|
let pant = value.split("?")[1];
|
let pants = pant.split("&");
|
for (var i = 0; i < pants.length; i++) {
|
let c = pants[i].split("=");
|
v[c[0]] = c[1];
|
}
|
}
|
return v;
|
}
|
$(function () {
|
let g = top.gridFileInputRow;
|
let value = getSplit();
|
if (value != null && g != null) {
|
if (g.type == 40 || g.type == 9 || g.type == 19) {
|
getFile(value, g);//附件控件类型9,19
|
} else if (g.type == 40) {
|
getImage(value, g);//图片类型控件 40
|
} else {
|
return;
|
}
|
} else {
|
alert('获取不到文件解析内容');
|
}
|
})
|
</script>
|
</body>
|
</html>
|