bug修改。

This commit is contained in:
Renpc-kilig 2022-04-12 14:23:42 +08:00
parent 7dddaf1596
commit 3e0a09e538
8 changed files with 332 additions and 42 deletions

View File

@ -15,6 +15,8 @@ import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -108,4 +110,14 @@ public class FileUploadController extends DefaultBaseController {
return new SuccessResultData<>(fileUploadService.count(params)); return new SuccessResultData<>(fileUploadService.count(params));
} }
@ApiOperation(value = "文档上传详情", notes = "文档上传详情接口")
@ApiImplicitParams({
@ApiImplicitParam(name = "fileUploadId", value = "文档上传ID", paramType = "path")
})
@ApiResponses({@ApiResponse(code = 400, message = "请求失败", response = ErrorResult.class)})
@GetMapping("get-pdf/{fileUploadId}")
public void getPdf(@PathVariable("fileUploadId") String fileUploadId, HttpServletRequest request, HttpServletResponse response) {
fileUploadService.getPdf(fileUploadId, request, response);
}
} }

View File

@ -20,6 +20,8 @@ public class FileUploadDTO {
private String catalogueId; private String catalogueId;
@ApiModelProperty(name = "fileTypeId", value = "文档类型") @ApiModelProperty(name = "fileTypeId", value = "文档类型")
private String fileTypeId; private String fileTypeId;
@ApiModelProperty(name = "fileTypeName", value = "文档类型名称")
private String fileTypeName;
@ApiModelProperty(name = "catalogueName", value = "所属目录名称") @ApiModelProperty(name = "catalogueName", value = "所属目录名称")
private String catalogueName; private String catalogueName;
@ApiModelProperty(name = "catalogueType", value = "文档类型(个人、公共)") @ApiModelProperty(name = "catalogueType", value = "文档类型(个人、公共)")
@ -54,6 +56,10 @@ public class FileUploadDTO {
private String shareRole; private String shareRole;
@ApiModelProperty(name = "pdfFilePath", value = "") @ApiModelProperty(name = "pdfFilePath", value = "")
private String pdfFilePath; private String pdfFilePath;
@ApiModelProperty(name = "oldFileType", value = "")
private String oldFileType;
@ApiModelProperty(name = "fileHz", value = "")
private String fileHz;
public String getFileUploadId() { public String getFileUploadId() {
return fileUploadId == null ? "" : fileUploadId.trim(); return fileUploadId == null ? "" : fileUploadId.trim();
@ -79,6 +85,14 @@ public class FileUploadDTO {
this.fileTypeId = fileTypeId; this.fileTypeId = fileTypeId;
} }
public String getFileTypeName() {
return fileTypeName;
}
public void setFileTypeName(String fileTypeName) {
this.fileTypeName = fileTypeName;
}
public String getCatalogueName() { public String getCatalogueName() {
return catalogueName; return catalogueName;
} }
@ -214,4 +228,20 @@ public class FileUploadDTO {
public void setPdfFilePath(String pdfFilePath) { public void setPdfFilePath(String pdfFilePath) {
this.pdfFilePath = pdfFilePath; this.pdfFilePath = pdfFilePath;
} }
public String getOldFileType() {
return oldFileType;
}
public void setOldFileType(String oldFileType) {
this.oldFileType = oldFileType;
}
public String getFileHz() {
return fileHz;
}
public void setFileHz(String fileHz) {
this.fileHz = fileHz;
}
} }

View File

@ -30,6 +30,8 @@ public class FileUploadVO {
private String remake; private String remake;
@ApiModelProperty(name = "fileModular", value = "文件模块(单文件、多文件)") @ApiModelProperty(name = "fileModular", value = "文件模块(单文件、多文件)")
private String fileModular; private String fileModular;
@ApiModelProperty(name = "pdfFilePath", value = "")
private String pdfFilePath;
public String getCatalogueId() { public String getCatalogueId() {
return catalogueId == null ? "" : catalogueId.trim(); return catalogueId == null ? "" : catalogueId.trim();
@ -86,4 +88,12 @@ public class FileUploadVO {
public void setFileModular(String fileModular) { public void setFileModular(String fileModular) {
this.fileModular = fileModular; this.fileModular = fileModular;
} }
public String getPdfFilePath() {
return pdfFilePath;
}
public void setPdfFilePath(String pdfFilePath) {
this.pdfFilePath = pdfFilePath;
}
} }

View File

@ -7,6 +7,8 @@ import cn.com.tenlion.systemoa.pojo.vos.fileupload.FileUploadVO;
import cn.com.tenlion.systemoa.pojo.bos.fileupload.FileUploadBO; import cn.com.tenlion.systemoa.pojo.bos.fileupload.FileUploadBO;
import cn.com.tenlion.systemoa.pojo.pos.fileupload.FileUploadPO; import cn.com.tenlion.systemoa.pojo.pos.fileupload.FileUploadPO;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -185,4 +187,5 @@ public interface IFileUploadService {
*/ */
Integer count(Map<String, Object> params); Integer count(Map<String, Object> params);
void getPdf(String fileUploadId, HttpServletRequest request, HttpServletResponse response);
} }

View File

@ -14,26 +14,29 @@ import cn.com.tenlion.systemoa.utils.OfficeToPDFUtils;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import ink.wgink.common.base.DefaultBaseService; import ink.wgink.common.base.DefaultBaseService;
import ink.wgink.exceptions.SearchException;
import ink.wgink.module.file.dao.IFileDao; import ink.wgink.module.file.dao.IFileDao;
import ink.wgink.module.file.service.IFileService; import ink.wgink.module.file.service.IFileService;
import ink.wgink.pojo.ListPage; import ink.wgink.pojo.ListPage;
import ink.wgink.pojo.bos.UserInfoBO; import ink.wgink.pojo.bos.UserInfoBO;
import ink.wgink.pojo.pos.FilePO; import ink.wgink.pojo.pos.FilePO;
import ink.wgink.pojo.result.SuccessResultList; import ink.wgink.pojo.result.SuccessResultList;
import ink.wgink.properties.FileProperties;
import ink.wgink.util.UUIDUtil; import ink.wgink.util.UUIDUtil;
import ink.wgink.util.date.DateUtil;
import ink.wgink.util.map.HashMapUtil; import ink.wgink.util.map.HashMapUtil;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.Base64; import java.util.*;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/** /**
* @ClassName: FileUploadServiceImpl * @ClassName: FileUploadServiceImpl
@ -57,6 +60,8 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
private IFileDao fileDao; private IFileDao fileDao;
@Autowired @Autowired
private ConfigPro configPro; private ConfigPro configPro;
@Autowired
private FileProperties fileProperties;
@Override @Override
public void save(FileUploadVO fileUploadVO) { public void save(FileUploadVO fileUploadVO) {
@ -76,6 +81,7 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
@Override @Override
public String saveReturnId(String token, FileUploadVO fileUploadVO) { public String saveReturnId(String token, FileUploadVO fileUploadVO) {
String fileUploadId = UUIDUtil.getUUID(); String fileUploadId = UUIDUtil.getUUID();
toPdf(fileUploadVO, fileUploadId);
Map<String, Object> params = HashMapUtil.beanToMap(fileUploadVO); Map<String, Object> params = HashMapUtil.beanToMap(fileUploadVO);
params.put("fileUploadId", fileUploadId); params.put("fileUploadId", fileUploadId);
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
@ -118,6 +124,7 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
@Override @Override
public void update(String token, String fileUploadId, FileUploadVO fileUploadVO) { public void update(String token, String fileUploadId, FileUploadVO fileUploadVO) {
toPdf(fileUploadVO, fileUploadId);
Map<String, Object> params = HashMapUtil.beanToMap(fileUploadVO); Map<String, Object> params = HashMapUtil.beanToMap(fileUploadVO);
params.put("fileUploadId", fileUploadId); params.put("fileUploadId", fileUploadId);
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
@ -126,11 +133,28 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
setAppUpdateInfo(token, params); setAppUpdateInfo(token, params);
} }
fileUploadDao.update(params); fileUploadDao.update(params);
} }
@Override @Override
public FileUploadDTO get(Map<String, Object> params) { public FileUploadDTO get(Map<String, Object> params) {
FileUploadDTO fileUploadDTO = fileUploadDao.get(params); FileUploadDTO fileUploadDTO = fileUploadDao.get(params);
if(null != fileUploadDTO) {
if(!StringUtils.isEmpty(fileUploadDTO.getFileTypeId())) {
FileTypeDTO fileTypeDTO = fileTypeService.get(fileUploadDTO.getFileTypeId());
if(null != fileTypeDTO) {
fileUploadDTO.setOldFileType(fileTypeDTO.getTypeName());
fileUploadDTO.setFileTypeName(fileTypeDTO.getTypeName());
}
}
if(!StringUtils.isEmpty(fileUploadDTO.getFileId())) {
params.put("fileId", fileUploadDTO.getFileId());
FilePO filePO = fileDao.getPO(params);
if(null != filePO) {
fileUploadDTO.setFileHz(filePO.getFileName());
}
}
}
return fileUploadDTO; return fileUploadDTO;
} }
@ -191,7 +215,7 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
FileUploadDTO fileUploadDTO = (FileUploadDTO) it.next(); FileUploadDTO fileUploadDTO = (FileUploadDTO) it.next();
params.put("fileTypeId", fileUploadDTO.getFileTypeId()); params.put("fileTypeId", fileUploadDTO.getFileTypeId());
FileTypeDTO fileTypeDTO = fileTypeService.get(params); FileTypeDTO fileTypeDTO = fileTypeService.get(params);
if(null != params.get("typeBelong")) { if(null != params.get("typeBelong") && null != fileTypeDTO) {
if(!params.get("typeBelong").toString().equals(fileTypeDTO.getTypeBelong())) { if(!params.get("typeBelong").toString().equals(fileTypeDTO.getTypeBelong())) {
it.remove(); it.remove();
continue; continue;
@ -201,27 +225,6 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
fileUploadDTO.setCatalogueType(fileTypeDTO.getTypeBelong()); fileUploadDTO.setCatalogueType(fileTypeDTO.getTypeBelong());
fileUploadDTO.setCatalogueName(fileTypeDTO.getTypeName()); fileUploadDTO.setCatalogueName(fileTypeDTO.getTypeName());
} }
// 生成临时PDF文件
if("文件".equals(fileUploadDTO.getFileType())) {
if("单文件".equals(fileUploadDTO.getFileModular())) {
String fileId = fileUploadDTO.getFileId();
params.put("fileId", fileId);
FilePO filePO = fileDao.getPO(params);
if(null != filePO) {
String pdfPath = "src/main/resources/static/route/viewpdf/"+fileUploadDTO.getFileUploadId()+".pdf";
if("pdf".equals(filePO.getFileType())) {
fileUploadDTO.setPdfFilePath(filePO.getFilePath());
}else {
File file = new File(pdfPath);
if(file.exists()) {
file.delete();
}
OfficeToPDFUtils.trans(filePO.getFilePath(), pdfPath, filePO.getFileType());
fileUploadDTO.setPdfFilePath(pdfPath);
}
}
}
}
} }
} }
/*if(null != fileUploadDTOList && fileUploadDTOList.size() > 0) { /*if(null != fileUploadDTOList && fileUploadDTOList.size() > 0) {
@ -261,4 +264,62 @@ public class FileUploadServiceImpl extends DefaultBaseService implements IFileUp
return count == null ? 0 : count; return count == null ? 0 : count;
} }
@Override
public void getPdf(String fileUploadId, HttpServletRequest request, HttpServletResponse response) {
FileUploadDTO fileUploadDTO = get(fileUploadId);
if(null != fileUploadDTO) {
if(!StringUtils.isEmpty(fileUploadDTO.getPdfFilePath())) {
File file = new File(fileUploadDTO.getPdfFilePath());
if(file.exists()) {
byte[] data = null;
try{
FileInputStream inputStream = new FileInputStream(file);
data = new byte[inputStream.available()];
inputStream.read(data);
response.getOutputStream().write(data);
inputStream.close();
}catch (Exception e) {
e.printStackTrace();
}
}else {
throw new SearchException("文件不存在");
}
}
}
}
private void toPdf(FileUploadVO fileUploadVO, String fileUploadId) {
Map<String, Object> params = new HashMap<>();
// 生成临时PDF文件
if("文件".equals(fileUploadVO.getFileType())) {
if("单文件".equals(fileUploadVO.getFileModular())) {
String fileId = fileUploadVO.getFileId();
params.put("fileId", fileId);
FilePO filePO = fileDao.getPO(params);
if(null != filePO) {
String baseUploadPath = fileProperties.getUploadPath();
StringBuilder filePath = new StringBuilder();
if (!baseUploadPath.endsWith(File.separator)) {
filePath.append(baseUploadPath).append(File.separator);
} else {
filePath.append(baseUploadPath);
}
filePath.append("viewPdfFile");
filePath.append(File.separator).append(DateUtil.getDays());
String pdfPath = filePath + "/" + fileUploadId + ".pdf";
if("pdf".equals(filePO.getFileType())) {
fileUploadVO.setPdfFilePath(filePO.getFilePath());
}else {
File file = new File(pdfPath);
if(file.exists()) {
file.delete();
}
OfficeToPDFUtils.trans(filePO.getFilePath(), pdfPath, filePO.getFileType(), filePath.toString());
fileUploadVO.setPdfFilePath(pdfPath);
}
}
}
}
}
} }

View File

@ -15,7 +15,7 @@ public class OfficeToPDFUtils {
public static boolean judgeLicense() { public static boolean judgeLicense() {
boolean result = false; boolean result = false;
try { try {
license = OfficeToPDFUtils.class.getClassLoader().getResourceAsStream("license/license.xml"); //文件路径 license = OfficeToPDFUtils.class.getClassLoader().getResourceAsStream("static/assets/js/pdf/license"); //文件路径
if (license != null) { if (license != null) {
License aposeLic = new License(); License aposeLic = new License();
aposeLic.setLicense(license); aposeLic.setLicense(license);
@ -28,13 +28,17 @@ public class OfficeToPDFUtils {
} }
// 转换 // 转换
public static void trans(String filePath, String pdfPath, String type) { public static void trans(String filePath, String pdfPath, String type, String folderPath) {
if (!judgeLicense()) { if (!judgeLicense()) {
System.out.println("license错误"); System.out.println("license错误");
} }
try { try {
System.out.println("as开始" + filePath); System.out.println("as开始" + filePath);
long old = System.currentTimeMillis(); long old = System.currentTimeMillis();
File folder = new File(folderPath);
if(!folder.exists() && !folder.isDirectory()) {
folder.mkdirs();
}
File file = new File(pdfPath); File file = new File(pdfPath);
toPdf(file, filePath, pdfPath, type); toPdf(file, filePath, pdfPath, type);
long now = System.currentTimeMillis(); long now = System.currentTimeMillis();
@ -181,10 +185,10 @@ public class OfficeToPDFUtils {
} }
} }
public static void main(String[] args) { /*public static void main(String[] args) {
String filePath = "C:\\Users\\29492\\Desktop\\test.pdf"; String filePath = "C:\\Users\\29492\\Desktop\\test.pdf";
String PdfFilePath = "C:\\Users\\29492\\Desktop\\test111.pdf"; String PdfFilePath = "C:\\Users\\29492\\Desktop\\test111.pdf";
trans(filePath, PdfFilePath, "pdf"); trans(filePath, PdfFilePath, "pdf");
} }*/
} }

View File

@ -20,6 +20,7 @@
<result column="edit_role" property="editRole"/> <result column="edit_role" property="editRole"/>
<result column="del_role" property="delRole"/> <result column="del_role" property="delRole"/>
<result column="share_role" property="shareRole"/> <result column="share_role" property="shareRole"/>
<result column="pdf_file_path" property="pdfFilePath"/>
</resultMap> </resultMap>
<resultMap id="fileUploadBO" type="cn.com.tenlion.systemoa.pojo.bos.fileupload.FileUploadBO"> <resultMap id="fileUploadBO" type="cn.com.tenlion.systemoa.pojo.bos.fileupload.FileUploadBO">
@ -65,6 +66,7 @@
content, content,
remake, remake,
file_modular, file_modular,
pdf_file_path,
creator, creator,
gmt_create, gmt_create,
modifier, modifier,
@ -79,6 +81,7 @@
#{content}, #{content},
#{remake}, #{remake},
#{fileModular}, #{fileModular},
#{pdfFilePath},
#{creator}, #{creator},
#{gmtCreate}, #{gmtCreate},
#{modifier}, #{modifier},
@ -138,6 +141,9 @@
</if> </if>
<if test="fileModular != null and fileModular != ''"> <if test="fileModular != null and fileModular != ''">
file_modular = #{fileModular}, file_modular = #{fileModular},
</if>
<if test="pdfFilePath != null and pdfFilePath != ''">
pdf_file_path = #{pdfFilePath},
</if> </if>
gmt_modified = #{gmtModified}, gmt_modified = #{gmtModified},
modifier = #{modifier}, modifier = #{modifier},
@ -156,6 +162,7 @@
t1.content, t1.content,
t1.remake, t1.remake,
t1.file_modular, t1.file_modular,
t1.pdf_file_path,
t1.file_upload_id t1.file_upload_id
FROM FROM
data_file_upload t1 data_file_upload t1
@ -231,6 +238,7 @@
t1.content, t1.content,
t1.remake, t1.remake,
t1.file_modular, t1.file_modular,
t1.pdf_file_path,
t1.creator, t1.creator,
t1.gmt_create, t1.gmt_create,
t1.modifier, t1.modifier,

View File

@ -45,9 +45,15 @@
</div> </div>
<div class="layui-card-body" style="padding: 15px;"> <div class="layui-card-body" style="padding: 15px;">
<form class="layui-form layui-form-pane" lay-filter="dataForm"> <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"> <div class="layui-form-item" id="fileTypeIdDiv">
<label class="layui-form-label">文档类型<span style="color: red;vertical-align: middle;">*</span></label> <label class="layui-form-label" style="width: 136px;">可修改文档类型<span style="color: red;vertical-align: middle;">*</span></label>
<div class="layui-input-block layui-form" id="fileTypeIdSelectTemplateBox" lay-filter="fileTypeIdSelectTemplateBox"></div> <div class="layui-input-block layui-form" style="margin-left: 136px;" id="fileTypeIdSelectTemplateBox" lay-filter="fileTypeIdSelectTemplateBox"></div>
<script id="fileTypeIdSelectTemplate" type="text/html"> <script id="fileTypeIdSelectTemplate" type="text/html">
<select id="fileTypeId" name="fileTypeId" lay-filter="fileTypeId" lay-verify="required" lay-search> <select id="fileTypeId" name="fileTypeId" lay-filter="fileTypeId" lay-verify="required" lay-search>
<option value="">请选择文档类型</option> <option value="">请选择文档类型</option>
@ -167,6 +173,7 @@
<script src="assets/js/vendor/viewer/viewer.min.js"></script> <script src="assets/js/vendor/viewer/viewer.min.js"></script>
<script src="assets/js/pdf/build/pdf.js"></script> <script src="assets/js/pdf/build/pdf.js"></script>
<script src="assets/layuiadmin/layui/layui.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> <script>
layui.config({ layui.config({
base: 'assets/layuiadmin/' //静态资源所在路径 base: 'assets/layuiadmin/' //静态资源所在路径
@ -187,18 +194,60 @@
var fileModularVal; var fileModularVal;
var fileTypeVal; var fileTypeVal;
var pdfUrl; var pdfUrl;
var fileId;
var fileHz;
$('.viewPdf').on('click', function() { $(document).on('click', '.showFile',function() {
showPdf(); 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() { window.viewPdf = function showPdf() {
var pathName = window.document.location.pathname; // $('#pdfViewDiv').show();
var projectName = pathName.substring(0,pathName.substr(1).indexOf('/')+1); // $("#displayPdfIframe").attr("src",'assets/js/pdf/web/viewer.html?file='+getWebRootPath()+'/api/fileupload/get-pdf/'+fileUploadId);
$('#pdfViewDiv').show(); var url = getWebRootPath() + "/route/file/download/false/" + fileId;
// setTimeout(function(){ var previewUrl = url + '?fullfilename=' + fileHz;
$("#displayPdfIframe").attr("src",'assets/js/pdf/web/viewer.html?file=' + projectName +'/route/viewpdf/'+fileUploadId+'.pdf');
//}, 3000); 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() {
}
});
} }
// 初始化组织名称 // 初始化组织名称
@ -247,6 +296,116 @@
// 拼接文件html代码 // 拼接文件html代码
function appendFile(fileId) { 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; var html;
if('单文件' == fileModularVal) { if('单文件' == fileModularVal) {
html = ' <label class="layui-form-label">单文件</label>\n' + html = ' <label class="layui-form-label">单文件</label>\n' +
@ -361,7 +520,7 @@
$('#fileDiv').empty(); $('#fileDiv').empty();
$('#fileDiv').append(html); $('#fileDiv').append(html);
initFileIdUploadFile(); initFileIdUploadFile();
} }*/
// 拼接图片html代码 // 拼接图片html代码
function appendPhoto(fileId) { function appendPhoto(fileId) {
@ -821,10 +980,13 @@
} }
var loadLayerIndex; var loadLayerIndex;
top.restAjax.get(top.restAjax.path('api/fileupload/get/{fileUploadId}', [fileUploadId]), {}, null, function(code, data) { top.restAjax.get(top.restAjax.path('api/fileupload/get/{fileUploadId}', [fileUploadId]), {}, null, function(code, data) {
console.log(data) data.oldFileTyleId = data.fileTypeId;
pdfUrl = data.pdfFilePath; pdfUrl = data.pdfFilePath;
fileModularVal = data.fileModular; fileModularVal = data.fileModular;
fileTypeVal = data.fileType; fileTypeVal = data.fileType;
fileId = data.fileId;
fileHz = data.fileHz;
initAppend(fileModularVal, fileTypeVal, data.fileId); initAppend(fileModularVal, fileTypeVal, data.fileId);
var dataFormData = {}; var dataFormData = {};
for(var i in data) { for(var i in data) {