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
/* eslint-disable react/jsx-key */
import { doFetch } from '@/utils/doFetch';
import { useRequest } from 'ahooks';
import { Divider } from 'antd';
import React, { useState, useEffect } from 'react';
import { ProDescriptions } from '@ant-design/pro-components';
import DetailNode from './detailnode';
import AutoTable from '../AutoTable/mtable';
const Detail = (props) => {
const { path, params, titleColumns, detailKey, columns } = props;
console.log(params);
let [firstcolumns, ...mescolumns] = titleColumns;
// columns?.forEach((it) => {
// if (it?.valueType == 'table') {
// tableColumns.push(it);
// } else {
// detailColumns.push(it);
// }
// });
const detailData = useRequest(async () => {
let res = await doFetch({ url: path, params });
return res?.data?.dataList;
});
return (
<>
<h2 style={{ fontWeight: 700, marginBottom: 16 }}>
{firstcolumns?.title}:{detailData?.data?.[0]?.[firstcolumns?.dataIndex] || '--'}
</h2>
<ProDescriptions columns={mescolumns} dataSource={detailData?.data?.[0]} />
<Divider />
<div>
{detailData?.data?.map((it, index) => {
const detailColumns = [],
tableColumns = [];
columns[it?.operationType]?.forEach((it) => {
if (it?.valueType == 'table') {
tableColumns.push(it);
} else {
detailColumns.push(it);
}
});
return (
<DetailNode
key={it?.id}
data={it}
index={index}
operationType={it?.operationType}
columns={detailColumns}
hasTable={true}
>
{tableColumns?.map((t) => {
return (
<div style={{ marginTop: 8, marginBottom: 8 }}>
<b>{t?.title}</b>
<AutoTable
dataSource={it[t?.key]}
columns={t?.columns}
style={{ marginTop: 8 }}
/>
</div>
);
})}
</DetailNode>
);
})}
</div>
</>
);
};
export default Detail;