index.js
1.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* eslint-disable */
import React, { useEffect, useRef } from "react";
import jsPreviewPdf from "@js-preview/pdf";
import * as commonConfig from "@/utils/config";
import useCommonBase from "@/components/Common/CommonHooks/useCommonBase";
import styles from "./index.less";
const ProcessInstructionBookNewEvent = props => {
const { formData = [] } = props;
useEffect(
() => {
if (!formData.length) return;
handleGetData();
},
[formData.length]
);
// 获取数据集
const handleGetData = async () => {
let addState = {};
const config = formData[0];
const conditonValues = props.onGetSqlConditionValues(config);
const result =
(await props.onGetDataSet({
name: "slave",
configData: config,
condition: {
sSqlCondition: conditonValues,
},
isWait: true,
})) || {};
addState = { ...addState, ...result };
props.onSaveState(addState);
};
return {
...props,
};
};
const ProcessInstructionBookNew = baseProps => {
const props = ProcessInstructionBookNewEvent(useCommonBase(baseProps));
const { slaveData = [], app } = props;
const [slaveRow = {}] = slaveData;
const { sPicturePath } = slaveRow;
const fileUrl = `${commonConfig.file_host}file/download?savePathStr=${encodeURIComponent(sPicturePath)}&sModelsId=100&token=${app.token}`;
const officeRef = useRef(null);
useEffect(
() => {
if (!sPicturePath) return;
const myDocxPreviewer = jsPreviewPdf.init(officeRef.current);
myDocxPreviewer.preview(fileUrl);
},
[sPicturePath]
);
return (
<div className={styles.processInstructionBookNew} ref={officeRef}>
{!sPicturePath && <div className={styles.noData}>请先上传工艺作业指导书!</div>}
</div>
);
};
export default ProcessInstructionBookNew;