Skip to content

Commit 69377c5

Browse files
authored
Merge pull request #32 from kne-union/linzp
添加report
2 parents 13f7a86 + e382219 commit 69377c5

File tree

15 files changed

+1163
-1
lines changed

15 files changed

+1163
-1
lines changed

.DS_Store

6 KB
Binary file not shown.

README.md

Lines changed: 292 additions & 0 deletions
Large diffs are not rendered by default.

doc/example.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,24 @@
108108
"packageName": "antd"
109109
}
110110
]
111+
},
112+
{
113+
"title": "Report",
114+
"description": "",
115+
"code": "./report.js",
116+
"scope": [
117+
{
118+
"name": "_InfoPage",
119+
"packageName": "@kne/current-lib_info-page"
120+
},
121+
{
122+
"packageName": "@kne/current-lib_info-page/dist/index.css"
123+
},
124+
{
125+
"name": "antd",
126+
"packageName": "antd"
127+
}
128+
]
111129
}
112130
]
113131
}

doc/report.js

Lines changed: 284 additions & 0 deletions
Large diffs are not rendered by default.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@kne/info-page",
3-
"version": "0.1.14",
3+
"version": "0.1.15",
44
"description": "一般用在复杂的详情展示页面,InfoPage提供了一个标准的展示信息的格式",
55
"syntax": {
66
"esmodules": true

src/Report/List.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { Flex, Row, Col } from 'antd';
3+
import get from 'lodash/get';
4+
import style from './style.module.scss';
5+
6+
const List = ({ report }) => {
7+
return (
8+
<Flex vertical gap={16}>
9+
{get(report, 'list', []).map(({ label, content }, index) => {
10+
return (
11+
<Row wrap={false} key={index}>
12+
<Col span={3} className={style['list-label-col']}>
13+
<div className={style['list-label']}>{label}</div>
14+
</Col>
15+
<Col span={21} className={style['list-content-col']}>
16+
<div className={style['list-content']}>{content}</div>
17+
</Col>
18+
</Row>
19+
);
20+
})}
21+
</Flex>
22+
);
23+
};
24+
25+
export default List;

src/Report/Part.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import { Space } from 'antd';
3+
import get from 'lodash/get';
4+
import classnames from 'classnames';
5+
import style from './style.module.scss';
6+
7+
const Part = ({ report }) => {
8+
return (
9+
<Space direction="vertical" size={32}>
10+
{get(report, 'list', []).map(({ label, content, hasBgColor, ...props }, index) => {
11+
return (
12+
<div {...props} key={index}>
13+
<div className={style['part-label']}>{label}</div>
14+
<div
15+
className={classnames(style['part-content'], {
16+
[style['has-bg-color']]: hasBgColor
17+
})}
18+
>
19+
{content}
20+
</div>
21+
</div>
22+
);
23+
})}
24+
</Space>
25+
);
26+
};
27+
28+
export default Part;

src/Report/PrintPageBreak.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import style from './style.module.scss';
3+
4+
const PrintPageBreak = () => {
5+
return <div className={style['print-page-break']} />;
6+
};
7+
8+
export default PrintPageBreak;

src/Report/Result.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import React from 'react';
2+
import { Row, Col } from 'antd';
3+
import get from 'lodash/get';
4+
import style from './style.module.scss';
5+
6+
const Result = ({ report }) => {
7+
const totalScore = get(report, 'total.score');
8+
const totalLabel = get(report, 'total.label');
9+
const list = get(report, 'list', []);
10+
return (
11+
<Row wrap={false} gutter={16} className={style['result-view']}>
12+
<Col span={3}>
13+
<div className={style['result-total']}>
14+
<div className={style['result-total-score']}>{totalScore}</div>
15+
<div className={style['result-total-label']}>{totalLabel}</div>
16+
</div>
17+
</Col>
18+
<Col span={21}>
19+
<div className={style['result-list']}>
20+
{list.map(({ label, content, score }, index) => {
21+
return (
22+
<div className={style['result-item']} key={index}>
23+
<div className={style['result-item-label']}>
24+
{label}<span className={style['result-item-score']}>{score}</span>
25+
</div>
26+
<div className={style['result-item-content']}>{content}</div>
27+
</div>
28+
);
29+
})}
30+
</div>
31+
</Col>
32+
</Row>
33+
);
34+
};
35+
36+
export default Result;

src/Report/Score.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import React from 'react';
2+
import classnames from 'classnames';
3+
import { Row, Col } from 'antd';
4+
import style from './style.module.scss';
5+
6+
const ScoreItem = ({ score, staticScore }) => {
7+
score = Number.isNaN(score) ? 0 : Number(score);
8+
return (
9+
<div
10+
className={classnames('score', style['score-item'], {
11+
[style['is-grey']]: staticScore > score,
12+
[style['low-score']]: score < 3,
13+
[style['middle-score']]: score === 3,
14+
[style['high-score']]: score > 3
15+
})}
16+
/>
17+
);
18+
};
19+
20+
const Score = ({ className, value, total = 5 }) => {
21+
return (
22+
<Row justify="space-between" gutter={[4, 0]} className={classnames(className, style['score'])} wrap={false} flex={1}>
23+
{Array.from({ length: total }).map((n, index) => (
24+
<Col key={index + 1} span={5} className={style['score-item-col']}>
25+
<ScoreItem score={value} staticScore={index + 1} />
26+
</Col>
27+
))}
28+
</Row>
29+
);
30+
};
31+
32+
export default Score;

0 commit comments

Comments
 (0)