报告编制支持pdf
parent
c116b4aed8
commit
ad35026c7f
|
|
@ -13,8 +13,8 @@ module.exports = {
|
|||
//API_HOST: "http://localhost:80",
|
||||
|
||||
// API_HOST: "http://192.168.0.134",
|
||||
API_HOST: "http://192.168.0.150", //太浅
|
||||
// API_HOST: "https://gbs-gateway.qhdsafety.com",
|
||||
//API_HOST: "http://192.168.0.150", //太浅
|
||||
API_HOST: "https://gbs-gateway.qhdsafety.com",
|
||||
// API_HOST: "http://192.168.0.103", //huwei
|
||||
},
|
||||
production: {
|
||||
|
|
|
|||
|
|
@ -523,6 +523,7 @@ const EvalProjectMonitorDetail = (props) => {
|
|||
<WpsEditor
|
||||
onCancel={() => setWpsVisible(false)}
|
||||
fileId={wpsDoc?.fileId}
|
||||
fileName={wpsDoc?.name}
|
||||
readOnly
|
||||
/>
|
||||
)}
|
||||
|
|
|
|||
|
|
@ -271,7 +271,7 @@ const ProjectFlow = (props) => {
|
|||
destroyOnHidden
|
||||
/>
|
||||
{visible && (
|
||||
<WpsEditor onCancel={() => setVisible(false)} fileId={wpsDoc?.fileId} readOnly={readOnly || evalProjectDetailData?.archiveFlag === 1} />
|
||||
<WpsEditor onCancel={() => setVisible(false)} fileId={wpsDoc?.fileId} fileName={wpsDoc?.name} readOnly={readOnly || evalProjectDetailData?.archiveFlag === 1} />
|
||||
)}
|
||||
</PageLayout>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -24,11 +24,16 @@ import ErrorBoundary from "./ErrorBoundary";
|
|||
const { router } = tools;
|
||||
|
||||
const App = (props) => {
|
||||
const { onCancel, safetyEvalBusiness, readOnly } = props;
|
||||
const { onCancel, safetyEvalBusiness, readOnly, fileName } = props;
|
||||
const { createDocLoading, evalReportCompletePreparationLoading } =
|
||||
safetyEvalBusiness;
|
||||
const [expandedMap, setExpandedMap] = useState({});
|
||||
const [fileId, setFileId] = useState(props.fileId);
|
||||
// 当前文档类型:word / pdf,决定 SDK 初始化时使用的 officeType;
|
||||
// 初始类型通过初始报告文件名(fileName)推断
|
||||
const [fileType, setFileType] = useState(() =>
|
||||
/\.pdf$/i.test(props.fileName || "") ? "pdf" : "word"
|
||||
);
|
||||
const [templateMap, setTemplateMap] = useState([]);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const sdkRef = useRef(null);
|
||||
|
|
@ -73,12 +78,14 @@ const App = (props) => {
|
|||
if (!newFileId) {
|
||||
throw new Error(res?.errMessage || res?.message || "上传失败");
|
||||
}
|
||||
setFileType(/\.pdf$/i.test(file.name) ? "pdf" : "word");
|
||||
setFileId(newFileId);
|
||||
|
||||
props.queryMyOrCreateDoc({
|
||||
docxUrl: "",
|
||||
projectId:router.query.id,
|
||||
});
|
||||
message.success("Word 文件上传成功,已在编辑器中打开");
|
||||
message.success("文件上传成功,已在编辑器中打开");
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e?.message || "上传失败,请重试");
|
||||
|
|
@ -107,7 +114,7 @@ const App = (props) => {
|
|||
const blobUrl = URL.createObjectURL(blob);
|
||||
const a = document.createElement("a");
|
||||
a.href = blobUrl;
|
||||
a.download = `安全评价报告_${fileId}.docx`;
|
||||
a.download = `安全评价报告_${fileId}.${fileType === "pdf" ? "pdf" : "docx"}`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(blobUrl);
|
||||
message.success("下载成功");
|
||||
|
|
@ -151,7 +158,10 @@ const App = (props) => {
|
|||
try {
|
||||
const instance = WebOfficeSDK.init({
|
||||
// 必填项
|
||||
officeType: WebOfficeSDK.OfficeType.Writer,
|
||||
officeType:
|
||||
fileType === "pdf"
|
||||
? WebOfficeSDK.OfficeType.Pdf
|
||||
: WebOfficeSDK.OfficeType.Writer,
|
||||
appId: "AK20260805KPWYZJ",
|
||||
mount: document.getElementById("app-wps"),
|
||||
fileId: fileId,
|
||||
|
|
@ -177,6 +187,7 @@ const App = (props) => {
|
|||
}
|
||||
})();
|
||||
return () => {
|
||||
console.log(sdkRef.current)
|
||||
sdkRef.current?.destroy();
|
||||
window.removeEventListener("error", onWindowError, { capture: true });
|
||||
window.removeEventListener("unhandledrejection", onWindowError, { capture: true });
|
||||
|
|
@ -364,6 +375,8 @@ const App = (props) => {
|
|||
return;
|
||||
}
|
||||
setFileId(fileId);
|
||||
// 模板为 docx 文档,重置为 Word 类型
|
||||
setFileType("word");
|
||||
});
|
||||
}}
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in New Issue