Commit 168269f2 by 宋祥

1.docx文件在线预览

parent 7f947997
package com.baosight.hggp.hg.wd.service;
import com.baosight.hggp.aspect.annotation.OperationLogAnnotation;
import com.baosight.hggp.util.LogUtils;
import com.baosight.iplat4j.core.ei.EiInfo;
import com.baosight.iplat4j.core.exception.PlatException;
import com.baosight.iplat4j.core.service.impl.ServiceEPBase;
/**
* word预览
*
* @author:songx
* @date:2024/9/4,15:22
*/
public class ServiceHGWD098 extends ServiceEPBase {
/**
* 画面初始化
*
* @param inInfo
* @return
*/
@Override
@OperationLogAnnotation(operModul = "word预览", operType = "查询", operDesc = "初始化")
public EiInfo initLoad(EiInfo inInfo) {
try {
} catch (PlatException e) {
LogUtils.setDetailMsg(inInfo, e, "初始化失败");
}
return inInfo;
}
}
......@@ -263,21 +263,24 @@ let preview = function () {
message("请选择数据");
return;
}
JSUtils.confirm("确定对勾选中的[" + rows.length + "]条数据做\"预览\"操作? ", {
ok: function () {
JSUtils.submitGridsData("result", "HGWD001B", "add", false,
function (res) {
if (res.status > -1) {
for (let i = 0; i < rows.length; i++) {
window.open(downloadHref(rows[i]['docId'], true), '_blank');
}
JSUtils.submitGridsData("result", "HGWD001B", "add", false,
function (res) {
if (res.status > -1) {
for (let i = 0; i < rows.length; i++) {
let row = rows[i];
let docType = row['docType'];
if (!isBlank(docType) && docType.toLowerCase() == ".docx") {
let url = "HGWD098?inqu_status-0-docId=" + row['docId'];
window.open(url, '_blank');
} else {
message(res.msg);
window.open(downloadHref(rows[i]['docId'], true), '_blank');
}
}
);
} else {
message(res.msg);
}
}
});
);
}
/**
......
......@@ -40,7 +40,7 @@
</EF:EFRegion>
<EF:EFRegion id="result" title="明细信息">
<EF:EFGrid blockId="result" autoDraw="override" queryMethod="query" sort="setted">
<EF:EFGrid blockId="result" autoDraw="override" queryMethod="query" sort="setted" checkMode="row">
<EF:EFColumn ename="id" cname="ID" hidden="true"/>
<EF:EFColumn ename="fileId" cname="ID" hidden="true"/>
<EF:EFColumn ename="docId" cname="文件ID" enable="false" width="200" align="center" sort="false"
......
$(document).ready(function () {
let docId = $("#inqu_status-0-docId").val();
if (isBlank(docId)) {
message("文件ID不能为空");
return;
}
fetch(downloadHref(docId, true)).then(res => {
return res.arrayBuffer();
}).then(arrayBuffer => {
renderDocx(arrayBuffer);
});
});
/**
* 渲染word
*
* @param file
*/
function renderDocx(file) {
docx.renderAsync(file, document.getElementById("docx-container")).then((x) => {
console.log("docx: finished")
});
}
<!DOCTYPE html>
<%@ page contentType="text/html; charset=UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="EF" tagdir="/WEB-INF/tags/EF" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<script src="${ctx}/common/docxjs/jszip.min.js"></script>
<script src="${ctx}/common/docxjs/docx-preview.js"></script>
<EF:EFPage title="WORD预览">
<EF:EFRegion id="result" title="展示区域" fitHeight="true">
<EF:EFInput cname="文件ID" ename="docId" blockId="inqu_status" row="0" type="hidden"/>
<div id="docx-container"></div>
</EF:EFRegion>
</EF:EFPage>
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment