index.tsx
3.46 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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import React from 'react';
import { Card, Alert } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import request from '@/utils/request';
export default class ReportBlock extends React.Component {
more = '加载更多';
state: any;
constructor(props: any) {
super(props);
this.state.block = {
blockList: [],
totalItems: 0,
totalPages: 1,
page: 1,
per_page: 6
};
}
componentDidMount() {
let id: string = '';
this.blockhistory(
{ page: this.state.page, per_page: this.state.per_page, report_id: id }
).then((resp: any) => {
this.state.blockList = resp.data;
this.state.totalItems = resp.total_items;
this.state.totalPages = resp.total_pages;
if (this.state.totalPages === 1) {
this.more = '加载完成';
}
if (this.state.blockList.length === 0) {
this.more = '没有历史';
}
});
}
componentWillUnmount() {
}
blockhistory(params: any) {
return request('/api/rule', {
method: 'GET',
data: {
...params,
method: 'get',
},
});
}
getMore = () => {
let id: string = '1';
if (this.state.page + 1 < this.state.totalPages) {
this.blockhistory(
{ page: this.state.page + 1, per_page: this.state.per_page, report_id: id }
).then((r: any) => {
let history = r.data;
this.setState({
page: r.page,
totalItems: r.total_items,
totalPages: r.total_pages,
blockList: [this.state.blockList, ...history]
});
});
} else {
this.more = '加载完成';
}
}
listItems = () => {
return this.state.blockList.map((block: any) =>
<li>
<div className="status-content-before">
{block.created_at} {block.content}
<span>报告已存证</span>
</div>
<div className="status-time-before">md5值: {block.content_md5}</div>
<div className="status-time-before">交易id: {block.transaction_id? block.transaction_id : '--'}</div>
<a className="status-a cert" href="http://testnet.ebookchain.org/assets/{{block.object_id}}"
target="_blank">报告证书
</a>
<a className="status-a" href="http://testnet.ebookchain.org/transactions/{{block.transaction_id}}"
target="_blank">交易详情
</a>
</li>
);
}
render() {
return (
<PageHeaderWrapper>
<Card bordered={false}>
<div className="package-status">
<div className="status-box">
<h2 style={{paddingLeft: '30%', textAlign: 'left'}}>报告追溯详情</h2>
<ul className="status-list">
{this.listItems()}
</ul>
<button type="button" onClick={this.getMore}>{this.more}</button>
</div>
</div>
</Card>
</PageHeaderWrapper>
);
};
}