Merge branch 'dev-tmp1' of http://47.92.113.182:3000/cq_anquan/safety-eval-service-frontend into dev-tmp1
commit
c06c172f40
|
|
@ -24,6 +24,27 @@ export const getDocByProjectId = declareRequest(
|
|||
'wpsDoc: {} | res.data || {}',
|
||||
);
|
||||
|
||||
/**
|
||||
* 上传已有 Word 文件并创建 WPS 文档,返回可打开的 WPS 文档信息
|
||||
* multipart/form-data,declareRequest 仅支持 json,故手动 fetch
|
||||
* @param {File} file Word 文件(.doc/.docx)
|
||||
* @param {String} projectId 项目 ID
|
||||
*/
|
||||
export async function uploadWpsDoc(file, projectId) {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("projectId", projectId);
|
||||
const res = await fetch(
|
||||
`${window.process.env.app.API_HOST}/safetyEval-h5/wsp/doc/upload`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: { token: sessionStorage.getItem("token") },
|
||||
body: formData,
|
||||
},
|
||||
);
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export const downloadWpsDoc = declareRequest(
|
||||
"downloadDocLoading",
|
||||
"Get > /safetyEval-h5/wsp/v3/3rd/files/{fileId}/download",
|
||||
|
|
@ -339,6 +360,11 @@ export const evalReportSubmit = declareRequest(
|
|||
"Post > @/safetyEval/institution/eval-report/submit",
|
||||
);
|
||||
|
||||
export const evalReportCompletePreparation = declareRequest(
|
||||
"evalReportCompletePreparationLoading",
|
||||
"Post > @/safetyEval/institution/eval-report/preparation/complete",
|
||||
);
|
||||
|
||||
/**
|
||||
* 机构端报告库-批量报送监管端
|
||||
*
|
||||
|
|
|
|||
|
|
@ -8,9 +8,11 @@ import {
|
|||
Tag,
|
||||
Progress,
|
||||
Typography,
|
||||
Upload,
|
||||
message,
|
||||
} from "antd";
|
||||
import { ArrowLeftOutlined } from "@ant-design/icons";
|
||||
import { uploadWpsDoc } from "~/api/safetyEvalBusiness";
|
||||
import WebOfficeSDK from "~/web-office-sdk-solution-v2.0.7/web-office-sdk-solution-v2.0.7.es.js";
|
||||
import { createPortal } from "react-dom";
|
||||
import { tools } from "@cqsjjb/jjb-common-lib";
|
||||
|
|
@ -23,10 +25,12 @@ const { router } = tools;
|
|||
|
||||
const App = (props) => {
|
||||
const { onCancel, safetyEvalBusiness, readOnly } = props;
|
||||
const { createDocLoading } = safetyEvalBusiness;
|
||||
const { createDocLoading, evalReportCompletePreparationLoading } =
|
||||
safetyEvalBusiness;
|
||||
const [expandedMap, setExpandedMap] = useState({});
|
||||
const [fileId, setFileId] = useState(props.fileId);
|
||||
const [templateMap, setTemplateMap] = useState([]);
|
||||
const [uploading, setUploading] = useState(false);
|
||||
const sdkRef = useRef(null);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
@ -48,7 +52,36 @@ const App = (props) => {
|
|||
}
|
||||
|
||||
await sdkRef.current.save();
|
||||
message.success("保存成功");
|
||||
// 完成报告编制:将 REPORT_PREPARATION 节点置为已完成,提交内审
|
||||
const res = await props.evalReportCompletePreparation({
|
||||
data: { projectId: router.query.id },
|
||||
});
|
||||
if (res?.success !== false) {
|
||||
message.success("报告编制已完成,已提交内审");
|
||||
}
|
||||
};
|
||||
|
||||
const beforeUploadWord = (file) => {
|
||||
if (!/\.(docx?|pdf)$/i.test(file.name)) {
|
||||
message.error("仅支持上传 Word / PDF 文件(.doc / .docx / .pdf)");
|
||||
return Upload.LIST_IGNORE;
|
||||
}
|
||||
setUploading(true);
|
||||
uploadWpsDoc(file, router.query.id)
|
||||
.then((res) => {
|
||||
const newFileId = res?.data?.fileId;
|
||||
if (!newFileId) {
|
||||
throw new Error(res?.errMessage || res?.message || "上传失败");
|
||||
}
|
||||
setFileId(newFileId);
|
||||
message.success("Word 文件上传成功,已在编辑器中打开");
|
||||
})
|
||||
.catch((e) => {
|
||||
message.error(e?.message || "上传失败,请重试");
|
||||
})
|
||||
.finally(() => setUploading(false));
|
||||
// 阻止 antd 自动上传,由手动 fetch 提交
|
||||
return false;
|
||||
};
|
||||
|
||||
const handleDownload = async () => {
|
||||
|
|
@ -162,9 +195,26 @@ const App = (props) => {
|
|||
}
|
||||
extra={
|
||||
<Flex gap={12}>
|
||||
{!readOnly && <Button onClick={handleSave}>保存</Button>}
|
||||
{!readOnly && (
|
||||
<Upload
|
||||
accept=".doc,.docx,.pdf"
|
||||
showUploadList={false}
|
||||
beforeUpload={beforeUploadWord}
|
||||
disabled={uploading}
|
||||
>
|
||||
<Button loading={uploading}>上传已编制报告</Button>
|
||||
</Upload>
|
||||
)}
|
||||
{!readOnly && (
|
||||
<Button
|
||||
loading={evalReportCompletePreparationLoading}
|
||||
onClick={handleSave}
|
||||
>
|
||||
完成报告编制提交内审
|
||||
</Button>
|
||||
)}
|
||||
<Button onClick={handleDownload}>下载报告</Button>
|
||||
|
||||
|
||||
</Flex>
|
||||
}
|
||||
>
|
||||
|
|
|
|||
Loading…
Reference in New Issue