detail.jsx
2.82 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import React, { useState } from "react";
import { history } from "umi";
import { Tabs } from "antd-mobile";
import commonConfig from "@/utils/config";
import * as commonServices from "@/services/services";
import * as commonFunc from "@/components/Common/commonFunc";
import { useEffect } from "react";
import styles from "./quotationDetail.less";
import SelectInput from "../components/SelectInput";
const QuotationAllprogressDetail = props => {
// const {state} = props.location
// console.log(JSON.parse(state), "QuotationAllprogressDetail");
console.log(props, "QuotationAllprogressDetail props");
return (
<div className={styles.quotationDetailBox}>
<QuotationDetail {...props} />
</div>
);
};
const QuotationDetail = props => {
const { location, app } = props;
const { token } = app;
const [state, setState] = useState(null);
// 初始化状态
const { formData = [] } = state || {};
const { quotationData } = JSON.parse(location.state) || {};
const [masterConfig, setMasterConfig] = useState(null);
useEffect(() => {
// 安全地解析 state
let parsedState = {};
try {
parsedState = JSON.parse(location.state || "{}");
} catch (error) {
console.error("Error parsing state:", error);
}
const { sModelsId } = parsedState;
// 构造请求 URL
const configUrl = `${commonConfig.server_host}business/getModelBysId/${"172129113112117428019179600"}?sModelsId=${"172129113112117428019179600"}`;
// 调用服务获取数据
commonServices
.getService(token, configUrl)
.then(({ data: configReturn }) => {
if (configReturn.code === 1) {
const formData = configReturn.dataset.rows[0]?.formData;
setMasterConfig(formData[0]);
setState(pre => ({ ...pre, formData }));
}
})
.catch(error => {
console.error("Error fetching data:", error);
});
}, [location, app]);
// 主表
const list = masterConfig?.gdsconfigformslave.filter(item => item.sName && item.bVisible);
console.log("🚀 ~ list:", list);
// 客户
const customer = list?.find(x => x.showName === "客户名称") || {};
// console.log("🚀 ~ ableConfigs:", masterConfig);
console.log("🚀 ~ customer:", customer);
return (
<div>
<div>{quotationData?.showName || "Loading..."}</div>
{/* {list&& list.length
? list.map((item, index) => {
return (
<div key={index} className={styles.customer}>
<div className={styles.quotationDetailTitle}>{item.showName}</div>
<SelectInput {...props} detailData={item}/>
</div>
);
})
: ""} */}
<div className={styles.customer}>
<div>客户名称</div>
<SelectInput {...props} />
</div>
</div>
);
};
export default QuotationAllprogressDetail;