index.js
1.49 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
import React, { useState } from "react";
import { ConfigProvider } from "antd";
import zhCN from "antd/lib/locale-provider/zh_CN";
import VerifyScrapList from "../verifyScrapList";
import VerifyScrapBill from "../verifyScrapBill";
import styles from "./index.less";
const useIndexPadEvent = props => {
const [state, setState] = useState({ showType: "list" });
// 获取token
const { pathname } = location;
const pathnameList = pathname.split("/");
const token = pathnameList[5];
// 新增表单
const handleAddBill = () => {
setState({
showType: "bill",
billType: "add"
});
};
// 查看表单
const handleViewBill = record => {
setState({
showType: "bill",
billType: "view",
copyTo: { masterData: record }
});
};
// 返回列表
const handleBackList = () => {
setState({
showType: "list"
});
};
return {
...props,
...state,
app: { ...props.app, token },
onAddBill: handleAddBill,
onBackList: handleBackList,
onViewBill: handleViewBill
};
};
const IndexPad = baseProps => {
const props = useIndexPadEvent(baseProps);
const { showType } = props;
return (
<ConfigProvider locale={zhCN} styles={{ width: "100%", height: "100%" }}>
<div className={`mesContent ${styles.indexPad}`}>
{showType === "list" ? (
<VerifyScrapList {...props} />
) : (
<VerifyScrapBill {...props} />
)}
</div>
</ConfigProvider>
);
};
export default IndexPad;