system-oa/src/main/resources/templates/fileupload/update.html
2022-04-12 14:23:42 +08:00

1047 lines
65 KiB
HTML

<!doctype html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<base th:href="${#request.getContextPath() + '/'}">
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta HTTP-EQUIV="Cache-Control" CONTENT="no-cache">
<meta HTTP-EQUIV="Expires" CONTENT="0">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
<link rel="stylesheet" href="assets/fonts/font-awesome/css/font-awesome.css"/>
<link rel="stylesheet" href="assets/layuiadmin/layui/css/layui.css" media="all">
<link rel="stylesheet" href="assets/layuiadmin/style/admin.css" media="all">
<link rel="stylesheet" type="text/css" href="assets/js/vendor/viewer/viewer.min.css">
<style type="text/css">
.lightbox{
position: fixed;
top: 0px;
left: 0px;
height: 100%;
width: 100%;
z-index: 7;
opacity: 0.3;
display: block;
background-color: rgb(0, 0, 0);
}
.pop{
position: absolute;
left: 50%;
width: 894px;
margin-left: -447px;
z-index: 9;
}
</style>
</head>
<body>
<div class="layui-fluid layui-anim layui-anim-fadein">
<div class="layui-card">
<div class="layui-card-header">
<span class="layui-breadcrumb" lay-filter="breadcrumb" style="visibility: visible;">
<a class="close" href="javascript:void(0);">上级列表</a><span lay-separator="">/</span>
<a href="javascript:void(0);"><cite>编辑内容</cite></a>
</span>
</div>
<div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm">
<div class="layui-form-item">
<label class="layui-form-label">原文档类型</label>
<div class="layui-input-block">
<input type="text" id="oldFileType" name="oldFileType" class="layui-input" value="" readonly>
</div>
</div>
<div class="layui-form-item" id="fileTypeIdDiv">
<label class="layui-form-label" style="width: 136px;">可修改文档类型<span style="color: red;vertical-align: middle;">*</span></label>
<div class="layui-input-block layui-form" style="margin-left: 136px;" id="fileTypeIdSelectTemplateBox" lay-filter="fileTypeIdSelectTemplateBox"></div>
<script id="fileTypeIdSelectTemplate" type="text/html">
<select id="fileTypeId" name="fileTypeId" lay-filter="fileTypeId" lay-verify="required" lay-search>
<option value="">请选择文档类型</option>
{{# for(var i = 0, item; item = d[i++];) { }}
<option value="{{item.fileTypeId}}">{{item.typeName}}</option>
{{# } }}
</select>
</script>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">文件类型</label>
<div class="layui-input-block">
<input type="radio" name="fileType" lay-filter="fileType" value="文件" title="文件" checked>
<input type="radio" name="fileType" lay-filter="fileType" value="图片" title="图片">
<input type="radio" name="fileType" lay-filter="fileType" value="视频" title="视频">
<input type="radio" name="fileType" lay-filter="fileType" value="音频" title="音频">
</div>
</div>
<div class="layui-form-item" pane>
<label class="layui-form-label">文件模块</label>
<div class="layui-input-block">
<input type="radio" name="fileModular" lay-filter="fileModular" value="单文件" title="单文件" checked>
<input type="radio" name="fileModular" lay-filter="fileModular" value="多文件" title="多文件">
</div>
</div>
<!-- 单文件 -->
<div class="layui-form-item layui-form-text" id="fileDiv">
<label class="layui-form-label">单文件</label>
<div class="layui-input-block">
<input type="hidden" id="fileId" name="fileId">
<div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>
<script id="fileIdFileDownload" type="text/html">
{{# var fileName = 'fileId'; }}
{{# if(d[fileName] != '') { }}
{{# var files = d[fileName];}}
{{# for(var i = 0, item = files[i]; item = files[i++];) { }}
<span class="layui-btn-group">
<div class="upload-file-box">
{{# if(item.fileType == 'doc' || item.fileType == 'docx'
|| item.fileType == 'xls' || item.fileType == 'xlsx'
|| item.fileType == 'ppt' || item.fileType == 'pptx'
|| item.fileType == 'pdf') { }}
<a class="upload-file-a viewPdf" target="_blank" href="javascript:void(0)" title="点击预览">
{{# } else { }}
<a class="upload-file-a" href="route/file/download/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">
{{# } }}
{{# if(item.fileType == 'doc' || item.fileType == 'docx') { }}
<img src="assets/images/filetype/word.png"/>
{{# } else if(item.fileType == 'xls' || item.fileType == 'xlsx') { }}
<img src="assets/images/filetype/excel.png"/>
{{# } else if(item.fileType == 'ppt' || item.fileType == 'pptx') { }}
<img src="assets/images/filetype/ppt.png"/>
{{# } else if(item.fileType == 'apk') { }}
<img src="assets/images/filetype/apk.png"/>
{{# } else if(item.fileType == 'pdf') { }}
<img src="assets/images/filetype/pdf.png"/>
{{# } else if(item.fileType == 'rar') { }}
<img src="assets/images/filetype/rar.png"/>
{{# } else if(item.fileType == 'zip') { }}
<img src="assets/images/filetype/zip.png"/>
{{# } else if(item.fileType == 'txt') { }}
<img src="assets/images/filetype/txt.png"/>
{{# } else { }}
<img src="assets/images/filetype/file.png"/>
{{# } }}
</a>
<span class="upload-file-title">{{item.fileName}}</span>
<a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">
<i class="fa fa-trash-o"></i>
</a>
</div>
</span>
{{# } }}
{{# } }}
{{# if(d[fileName].length < 1) { }}
<div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">
<a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">
<i class="fa fa-plus-square-o" style="font-size: 70px;"></i>
</a>
</div>
{{# } }}
</script>
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">文件说明</label>
<div class="layui-input-block">
<input type="text" id="content" name="content" class="layui-input" value="" placeholder="请输入文件说明" maxlength="255">
</div>
</div>
<div class="layui-form-item">
<label class="layui-form-label">备注</label>
<div class="layui-input-block">
<input type="text" id="remake" name="remake" class="layui-input" value="" placeholder="请输入备注" maxlength="500">
</div>
</div>
<div class="layui-form-item" id="pdfViewDiv" style="display: none;width: 100%;height: 700px;">
<iframe id="displayPdfIframe" width="100%" height="100%"></iframe>
</div>
<div class="layui-form-item layui-layout-admin">
<div class="layui-input-block">
<div class="layui-footer" style="left: 0;">
<button type="button" class="layui-btn" lay-submit lay-filter="submitForm">提交新增</button>
<button type="button" class="layui-btn layui-btn-primary close">返回上级</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="assets/js/vendor/wangEditor/wangEditor.min.js"></script>
<script src="assets/js/vendor/ckplayer/ckplayer/ckplayer.js"></script>
<script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/js/pdf/build/pdf.js"></script>
<script src="assets/layuiadmin/layui/layui.js"></script>
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/js-base64@3.6.0/base64.min.js"></script>
<script>
layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径
}).extend({
index: 'lib/index' //主入口模块
}).use(['index', 'form', 'laydate', 'laytpl'], function(){
var $ = layui.$;
var form = layui.form;
var laytpl = layui.laytpl;
var laydate = layui.laydate;
var fileUploadId = top.restAjax.params(window.location.href).fileUploadId;
var typeBelong = top.restAjax.params(window.location.href).typeBelong;
var isView = top.restAjax.params(window.location.href).isView;
var wangEditor = window.wangEditor;
var wangEditorObj = {};
var viewerObj = {};
var fileModularVal;
var fileTypeVal;
var pdfUrl;
var fileId;
var fileHz;
$(document).on('click', '.showFile',function() {
var url = getWebRootPath() + "/route/file/download/false/" + fileId;
var previewUrl = url + '&fullfilename=' + fileHz;
layer.open({
type: 2,
title: false,
closeBtn: 1,
area: ['80%', '80%'],
shadeClose: true,
anim: 2,
content: 'http://192.168.0.120:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)),
end: function() {
}
});
});
var getWebRootPath = function () {
var a = window.document.location.href;//
var b = window.document.location.pathname;
var pos = a.indexOf(b);
var path = a.substring(0, pos);
a = a.substring(a.indexOf("/") + 2, a.length);
a = a.substring(a.indexOf("/") + 1, a.length);
var pathName = a.substring(0, a.indexOf("/"));
return path + "/" + pathName;
}
window.viewPdf = function showPdf() {
// $('#pdfViewDiv').show();
// $("#displayPdfIframe").attr("src",'assets/js/pdf/web/viewer.html?file='+getWebRootPath()+'/api/fileupload/get-pdf/'+fileUploadId);
var url = getWebRootPath() + "/route/file/download/false/" + fileId;
var previewUrl = url + '?fullfilename=' + fileHz;
console.log(previewUrl)
console.log(encodeURIComponent(Base64.encode(previewUrl)))
layer.open({
type: 2,
title: false,
closeBtn: 1,
area: ['80%', '80%'],
shadeClose: true,
anim: 2,
content: 'http://192.168.0.120:8012/onlinePreview?url='+encodeURIComponent(Base64.encode(previewUrl)),
end: function() {
}
});
}
// 初始化组织名称
function initFileTypeIdSelect(selectValue) {
top.restAjax.get(top.restAjax.path('api/filetype/list?typeBelong={typeBelong}&method={method}', [typeBelong, '修改']), {}, null, function(code, data, args) {
laytpl(document.getElementById('fileTypeIdSelectTemplate').innerHTML).render(data, function(html) {
document.getElementById('fileTypeIdSelectTemplateBox').innerHTML = html;
});
form.render('select', 'fileTypeIdSelectTemplateBox');
var selectObj = {};
selectObj['fileTypeId'] = selectValue;
form.val('dataForm', selectObj);
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
form.on('radio(fileModular)', function (data) {
var value = data.value;
fileModularVal = value;
if(fileTypeVal == '文件') {
appendFile();
}else if(fileTypeVal == '图片') {
appendPhoto();
}else if(fileTypeVal == '视频') {
appendVideo();
}else if(fileTypeVal == '音频') {
appendAudio();
}
});
form.on('radio(fileType)', function (data) {
var value = data.value;
fileTypeVal = value;
if(value == '文件') {
appendFile();
}else if(value == '图片') {
appendPhoto();
}else if(value == '视频') {
appendVideo();
}else if(value == '音频') {
appendAudio();
}
});
// 拼接文件html代码
function appendFile(fileId) {
var html;
if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单文件</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <span class="layui-btn-group">\n' +
' <div class="upload-file-box">\n' +
' <a class="upload-file-a" href="javascript:void(0)" onclick="viewPdf();" title="点击预览">\n' +
' {{# if(item.fileType == \'doc\' || item.fileType == \'docx\') { }}\n' +
' <img src="assets/images/filetype/word.png"/>\n' +
' {{# } else if(item.fileType == \'xls\' || item.fileType == \'xlsx\') { }}\n' +
' <img src="assets/images/filetype/excel.png"/>\n' +
' {{# } else if(item.fileType == \'ppt\' || item.fileType == \'pptx\') { }}\n' +
' <img src="assets/images/filetype/ppt.png"/>\n' +
' {{# } else if(item.fileType == \'apk\') { }}\n' +
' <img src="assets/images/filetype/apk.png"/>\n' +
' {{# } else if(item.fileType == \'pdf\') { }}\n' +
' <img src="assets/images/filetype/pdf.png"/>\n' +
' {{# } else if(item.fileType == \'rar\') { }}\n' +
' <img src="assets/images/filetype/rar.png"/>\n' +
' {{# } else if(item.fileType == \'zip\') { }}\n' +
' <img src="assets/images/filetype/zip.png"/>\n' +
' {{# } else if(item.fileType == \'txt\') { }}\n' +
' <img src="assets/images/filetype/txt.png"/>\n' +
' {{# } else { }}\n' +
' <img src="assets/images/filetype/file.png"/>\n' +
' {{# } }}\n' +
' </a>\n' +
' <span class="upload-file-title">{{item.fileName}}</span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' </span>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 1) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
if('多文件' == fileModularVal) {
html = ' <label class="layui-form-label">多文件</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <span class="layui-btn-group">\n' +
' <div class="upload-file-box">\n' +
' <a class="upload-file-a" href="route/file/download/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">\n' +
' {{# if(item.fileType == \'doc\' || item.fileType == \'docx\') { }}\n' +
' <img src="assets/images/filetype/word.png"/>\n' +
' {{# } else if(item.fileType == \'xls\' || item.fileType == \'xlsx\') { }}\n' +
' <img src="assets/images/filetype/excel.png"/>\n' +
' {{# } else if(item.fileType == \'ppt\' || item.fileType == \'pptx\') { }}\n' +
' <img src="assets/images/filetype/ppt.png"/>\n' +
' {{# } else if(item.fileType == \'apk\') { }}\n' +
' <img src="assets/images/filetype/apk.png"/>\n' +
' {{# } else if(item.fileType == \'pdf\') { }}\n' +
' <img src="assets/images/filetype/pdf.png"/>\n' +
' {{# } else if(item.fileType == \'rar\') { }}\n' +
' <img src="assets/images/filetype/rar.png"/>\n' +
' {{# } else if(item.fileType == \'zip\') { }}\n' +
' <img src="assets/images/filetype/zip.png"/>\n' +
' {{# } else if(item.fileType == \'txt\') { }}\n' +
' <img src="assets/images/filetype/txt.png"/>\n' +
' {{# } else { }}\n' +
' <img src="assets/images/filetype/file.png"/>\n' +
' {{# } }}\n' +
' </a>\n' +
' <span class="upload-file-title">{{item.fileName}}</span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' </span>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 9) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
$('#fileDiv').empty();
$('#fileDiv').append(html);
initFileIdUploadFile();
}
// 拷贝
/*function appendFile(fileId) {
var html;
if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单文件</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <span class="layui-btn-group">\n' +
' <div class="upload-file-box">\n' +
' {{# if(item.fileType == \'doc\' || item.fileType == \'docx\' \n' +
' || item.fileType == \'xls\' || item.fileType == \'xlsx\'\n' +
' || item.fileType == \'ppt\' || item.fileType == \'pptx\'\n' +
' || item.fileType == \'pdf\') { }}\n' +
' <a class="upload-file-a" href="javascript:void(0)" onclick="viewPdf();" title="点击预览">\n' +
' {{# } else { }}\n' +
' <a class="upload-file-a" href="route/file/download/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">\n' +
' {{# } }}\n' +
' {{# if(item.fileType == \'doc\' || item.fileType == \'docx\') { }}\n' +
' <img src="assets/images/filetype/word.png"/>\n' +
' {{# } else if(item.fileType == \'xls\' || item.fileType == \'xlsx\') { }}\n' +
' <img src="assets/images/filetype/excel.png"/>\n' +
' {{# } else if(item.fileType == \'ppt\' || item.fileType == \'pptx\') { }}\n' +
' <img src="assets/images/filetype/ppt.png"/>\n' +
' {{# } else if(item.fileType == \'apk\') { }}\n' +
' <img src="assets/images/filetype/apk.png"/>\n' +
' {{# } else if(item.fileType == \'pdf\') { }}\n' +
' <img src="assets/images/filetype/pdf.png"/>\n' +
' {{# } else if(item.fileType == \'rar\') { }}\n' +
' <img src="assets/images/filetype/rar.png"/>\n' +
' {{# } else if(item.fileType == \'zip\') { }}\n' +
' <img src="assets/images/filetype/zip.png"/>\n' +
' {{# } else if(item.fileType == \'txt\') { }}\n' +
' <img src="assets/images/filetype/txt.png"/>\n' +
' {{# } else { }}\n' +
' <img src="assets/images/filetype/file.png"/>\n' +
' {{# } }}\n' +
' </a>\n' +
' <span class="upload-file-title">{{item.fileName}}</span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' </span>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 1) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
if('多文件' == fileModularVal) {
html = ' <label class="layui-form-label">多文件</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <span class="layui-btn-group">\n' +
' <div class="upload-file-box">\n' +
' <a class="upload-file-a" href="route/file/download/false/{{item.fileId}}" title="{{item.fileName}} - 点击下载">\n' +
' {{# if(item.fileType == \'doc\' || item.fileType == \'docx\') { }}\n' +
' <img src="assets/images/filetype/word.png"/>\n' +
' {{# } else if(item.fileType == \'xls\' || item.fileType == \'xlsx\') { }}\n' +
' <img src="assets/images/filetype/excel.png"/>\n' +
' {{# } else if(item.fileType == \'ppt\' || item.fileType == \'pptx\') { }}\n' +
' <img src="assets/images/filetype/ppt.png"/>\n' +
' {{# } else if(item.fileType == \'apk\') { }}\n' +
' <img src="assets/images/filetype/apk.png"/>\n' +
' {{# } else if(item.fileType == \'pdf\') { }}\n' +
' <img src="assets/images/filetype/pdf.png"/>\n' +
' {{# } else if(item.fileType == \'rar\') { }}\n' +
' <img src="assets/images/filetype/rar.png"/>\n' +
' {{# } else if(item.fileType == \'zip\') { }}\n' +
' <img src="assets/images/filetype/zip.png"/>\n' +
' {{# } else if(item.fileType == \'txt\') { }}\n' +
' <img src="assets/images/filetype/txt.png"/>\n' +
' {{# } else { }}\n' +
' <img src="assets/images/filetype/file.png"/>\n' +
' {{# } }}\n' +
' </a>\n' +
' <span class="upload-file-title">{{item.fileName}}</span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-file" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' </span>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 9) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
$('#fileDiv').empty();
$('#fileDiv').append(html);
initFileIdUploadFile();
}*/
// 拼接图片html代码
function appendPhoto(fileId) {
var html;
if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单图片</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName].length > 0) { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-image-box">\n' +
' <span class="upload-image-span">\n' +
' <img src="route/file/download/false/{{item.fileId}}" align="加载失败">\n' +
' </span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 1) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
if('多文件' == fileModularVal) {
html = ' <label class="layui-form-label">多图片</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\'; }}\n' +
' {{# if(d[fileName].length > 0) { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-image-box">\n' +
' <span class="upload-image-span">\n' +
' <img src="route/file/download/false/{{item.fileId}}" align="加载失败">\n' +
' </span>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-image" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 20) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
$('#fileDiv').empty();
$('#fileDiv').append(html);
initFileIdUploadPhoto();
}
// 拼接视频html代码
function appendVideo(fileId) {
var html;
if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单视频</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\' }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-video-box">\n' +
' <div id="{{fileName}}{{i}}" style="width:300px; height:200px;"></div>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-video" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 1) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
if('多文件' == fileModularVal) {
html = ' <label class="layui-form-label">多视频</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\' }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-video-box">\n' +
' <div id="{{fileName}}{{i}}" style="width:300px; height:200px;"></div>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-video" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 5) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
$('#fileDiv').empty();
$('#fileDiv').append(html);
initFileIdUploadVideo();
}
// 拼接音频html代码
function appendAudio(fileId) {
var html;
if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单音频</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\' }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-audio-box">\n' +
' <audio src="route/file/download/true/{{item.fileId}}" controls="controls">您的浏览器不支持 audio 标签。</audio>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-audio" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 1) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
if('多文件' == fileModularVal) {
html = ' <label class="layui-form-label">多音频</label>\n' +
' <div class="layui-input-block">\n' +
' <input type="hidden" id="fileId" name="fileId" value="'+fileId+'">\n' +
' <div class="layui-btn-container" id="fileIdFileBox" style="border: 1px solid #e6e6e6;"></div>\n' +
' <sc'+'ript id="fileIdFileDownload" type="text/html">\n' +
' {{# var fileName = \'fileId\' }}\n' +
' {{# if(d[fileName] != \'\') { }}\n' +
' {{# var files = d[fileName];}}\n' +
' {{# for(var i = 0, item = files[i]; item = files[i++];) { }}\n' +
' <div class="upload-audio-box">\n' +
' <audio src="route/file/download/true/{{item.fileId}}" controls="controls">您的浏览器不支持 audio 标签。</audio>\n' +
' <a class="layui-btn layui-btn-xs layui-btn-danger text-danger remove-audio" href="javascript:void(0);" lay-form-button data-id="{{item.fileId}}" data-name="{{fileName}}" lay-filter="fileIdRemoveFile">\n' +
' <i class="fa fa-trash-o"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' {{# } }}\n' +
' {{# if(d[fileName].length < 5) { }}\n' +
' <div class="upload-image-box" style="width: auto; height: auto; padding: 5px;">\n' +
' <a href="javascript:void(0);" lay-form-button data-explain="文件ID" data-name="fileId" lay-filter="fileIdUploadFile">\n' +
' <i class="fa fa-plus-square-o" style="font-size: 70px;"></i>\n' +
' </a>\n' +
' </div>\n' +
' {{# } }}\n' +
' </sc'+'ript>\n'+
'</div>';
}
$('#fileDiv').empty();
$('#fileDiv').append(html);
initFileIdUploadAudio();
}
function closeBox() {
parent.layer.close(parent.layer.getFrameIndex(window.name));
}
function refreshDownloadTemplet(fileName, file) {
var dataRander = {};
dataRander[fileName] = file;
laytpl(document.getElementById(fileName +'FileDownload').innerHTML).render(dataRander, function(html) {
document.getElementById(fileName +'FileBox').innerHTML = html;
});
}
// 初始化文件列表
function initFileList(fileName, ids, callback) {
var dataForm = {};
dataForm[fileName] = ids;
form.val('dataForm', dataForm);
if(!ids) {
refreshDownloadTemplet(fileName, []);
if(callback) {
callback(fileName, []);
}
return;
}
top.restAjax.get(top.restAjax.path('api/file/list', []), {
ids: ids
}, null, function(code, data) {
refreshDownloadTemplet(fileName, data);
if(callback) {
callback(fileName, data);
}
}, function(code, data) {
top.dialog.msg(data.msg);
});
}
// 初始化视频
function initVideo(fileName, data) {
for(var i = 0, item; item = data[i++];) {
var player = new ckplayer({
container: '#'+ fileName + i,
variable: 'player',
flashplayer: false,
video: {
file: 'route/file/download/true/'+ item.fileId,
type: 'video/mp4'
}
});
}
}
// 初始化文件ID文件上传
function initFileIdUploadFile() {
var files = $('#fileId').val();
initFileList('fileId', files);
form.on('button(fileIdUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'file',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function() {});
}
}
});
});
form.on('button(fileIdRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files);
});
}
// 初始化文件ID图片上传
function initFileIdUploadPhoto() {
var files = $('#fileId').val();
initFileList('fileId', files, function(fileName) {
var viewer = new Viewer(document.getElementById(fileName +'FileBox'), {navbar: false});
viewerObj[fileName] = viewer;
});
form.on('button(fileIdUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'image',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
}
}
});
});
form.on('button(fileIdRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files, function(fileName) {
viewerObj[fileName].update();
});
});
}
// 初始化文件ID视频上传
function initFileIdUploadVideo() {
var files = $('#fileId').val();
initFileList('fileId', files, initVideo);
form.on('button(fileIdUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'video',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files, initVideo);
}
}
});
});
form.on('button(fileIdRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files, initVideo);
});
}
// 初始化文件ID音频上传
function initFileIdUploadAudio() {
var files = $('#fileId').val();
initFileList('fileId', files);
form.on('button(fileIdUploadFile)', function(obj) {
var name = this.dataset.name;
var explain = this.dataset.explain;
top.dialog.file({
type: 'audio',
title: '上传'+ explain,
width: '400px',
height: '420px',
maxFileCount: '1',
onClose: function() {
var uploadFileArray = top.dialog.dialogData.uploadFileArray;
if(typeof(uploadFileArray) != 'undefined' && uploadFileArray.length > 0) {
var files = $('#'+ name).val();
for(var j = 0, file = uploadFileArray[j]; file = uploadFileArray[j++];) {
if(files.length > 0) {
files += ',';
}
files += file.data;
}
initFileList(name, files);
}
}
});
});
form.on('button(fileIdRemoveFile)', function(obj) {
var name = this.dataset.name;
var id = this.dataset.id;
var files = $('#'+ name).val().replace(id, '');
files = files.replace(/\,+/g, ',');
if(files.charAt(0) == ',') {
files = files.substring(1);
}
if(files.charAt(files.length - 1) == ',') {
files = files.substring(0, files.length - 1);
}
initFileList(name, files);
});
}
function initAppend(fileModularVal, fileTypeVal, fileId) {
if(fileTypeVal == '文件') {
appendFile(fileId);
}else if(fileTypeVal == '图片') {
appendPhoto(fileId);
}else if(fileTypeVal == '视频') {
appendVideo(fileId);
}else if(fileTypeVal == '音频') {
appendAudio(fileId);
}
}
// 初始化内容
function initData() {
if(isView == 'yes') {
$('#submitBtn').hide();
}
var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/fileupload/get/{fileUploadId}', [fileUploadId]), {}, null, function(code, data) {
data.oldFileTyleId = data.fileTypeId;
pdfUrl = data.pdfFilePath;
fileModularVal = data.fileModular;
fileTypeVal = data.fileType;
fileId = data.fileId;
fileHz = data.fileHz;
initAppend(fileModularVal, fileTypeVal, data.fileId);
var dataFormData = {};
for(var i in data) {
dataFormData[i] = data[i] +'';
}
initFileTypeIdSelect(data.fileTypeId);
form.val('dataForm', dataFormData);
form.render(null, 'dataForm');
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.loading, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
}
initData();
// 提交表单
form.on('submit(submitForm)', function(formData) {
top.dialog.confirm(top.dataMessage.commit, function(index) {
top.dialog.close(index);
var loadLayerIndex;
top.restAjax.put(top.restAjax.path('api/fileupload/update/{fileUploadId}', [fileUploadId]), formData.field, null, function(code, data) {
var layerIndex = top.dialog.msg(top.dataMessage.updateSuccess, {
time: 0,
btn: [top.dataMessage.button.yes, top.dataMessage.button.no],
shade: 0.3,
yes: function(index) {
top.dialog.close(index);
window.location.reload();
},
btn2: function() {
closeBox();
}
});
}, function(code, data) {
top.dialog.msg(data.msg);
}, function() {
loadLayerIndex = top.dialog.msg(top.dataMessage.committing, {icon: 16, time: 0, shade: 0.3});
}, function() {
top.dialog.close(loadLayerIndex);
});
});
return false;
});
$('.close').on('click', function() {
closeBox();
});
// 校验
form.verify({
});
});
</script>
</body>
</html>