@yeeyoon/library 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,136 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Image, Tooltip as AntdTooltip } from 'antd';
3
+ import styles from './index.less';
4
+ import { LineChart, Line, Tooltip, XAxis } from 'recharts';
5
+ import PropTypes from 'prop-types';
6
+ import { QuestionCircleOutlined } from '@ant-design/icons';
7
+ import { queryOidcUserCardData } from './service';
8
+
9
+ function InfoCart(props) {
10
+ const { baseMsg } = props;
11
+ const reg = /^(\d{3})\d*(\d{4})$/;
12
+ const [cardData, setCardData] = useState({});
13
+ const [chartData, setChartData] = useState({});
14
+ const [projectData] = useState([
15
+ {
16
+ title: '贡献数据',
17
+ tips: '创建相关项目的数据数',
18
+ number: 'contribute_data_total',
19
+ updateTitle: '本月新增:',
20
+ updateNumber: 'month_contribute_data_add',
21
+ },
22
+ {
23
+ title: '参与项目数',
24
+ tips: '',
25
+ number: 'participate_project_total',
26
+ updateTitle: '本月新增:',
27
+ updateNumber: 'month_participate_project_add',
28
+ },
29
+ {
30
+ title: '上传文件数',
31
+ tips: '',
32
+ number: 'upload_file_total',
33
+ updateTitle: '本月新增:',
34
+ updateNumber: 'month_upload_file_add',
35
+ },
36
+ ]);
37
+ const obj = {
38
+ application_name: '智慧项目',
39
+ contribute_data_total: 0,
40
+ last_month_contribute: '0',
41
+ month_contribute_data_add: 0,
42
+ month_participate_project_add: 0,
43
+ month_upload_file_add: 0,
44
+ participate_project_total: 0,
45
+ upload_file_total: 0,
46
+ user_id: '',
47
+ user_name: '',
48
+ };
49
+ useEffect(() => {
50
+ getCardData();
51
+ }, [baseMsg.userId]);
52
+ const getCardData = async () => {
53
+ const resp = await queryOidcUserCardData({ id: baseMsg.userId });
54
+ const { success, data } = resp;
55
+ if (success) {
56
+ if (data.content.length > 0) {
57
+ let monthContribute = data.content[0].last_month_contribute || '';
58
+ setCardData(data.content[0]);
59
+ Object.keys(monthContribute).length
60
+ ? setChartData(
61
+ monthContribute?.split(',').map((item) => ({
62
+ 贡献数据数: parseInt(item.split(':')[1]),
63
+ name: item.split(':')[0],
64
+ }))
65
+ )
66
+ : setChartData([{ 贡献数据数: 0 }]);
67
+ } else {
68
+ setCardData(obj);
69
+ }
70
+ }
71
+ };
72
+ return (
73
+ <div className={styles['info-cart-content']}>
74
+ <div className={styles['info-cart-base']}>
75
+ <Image
76
+ width="50px"
77
+ height="50px"
78
+ preview={false}
79
+ style={{ borderRadius: '5px' }}
80
+ src={baseMsg?.headUrl}
81
+ />
82
+ <div className={styles['info-cart-np']}>
83
+ <span>{baseMsg?.name}</span>
84
+ <span style={{ marginTop: '6px', fontSize: '12px' }}>
85
+ {(baseMsg?.mobile || '').replace(reg, '$1****$2')}
86
+ </span>
87
+ </div>
88
+ </div>
89
+ <div className={styles['info-cart-project']}>
90
+ <p>{cardData.application_name}</p>
91
+ <div className={styles['info-cart-data']}>
92
+ {projectData &&
93
+ projectData.map((item, index) => (
94
+ <div className={styles['info-cart-data-item']} key={index}>
95
+ <span className={styles['info-cart-data-item-title']}>
96
+ {item.title}
97
+ {item.tips && (
98
+ <AntdTooltip title={item.tips}>
99
+ <QuestionCircleOutlined
100
+ style={{ fontSize: '14px', marginLeft: '4px' }}
101
+ />
102
+ </AntdTooltip>
103
+ )}
104
+ </span>
105
+ <b style={{ color: '#5e5873', fontSize: '16px' }}>
106
+ {cardData[item.number] || 0}
107
+ </b>
108
+ <span style={{ color: '#6E6B7B', fontSize: '12px' }}>
109
+ {item.updateTitle}
110
+ {cardData[item.updateNumber] || 0}
111
+ </span>
112
+ </div>
113
+ ))}
114
+ </div>
115
+ </div>
116
+ <div className={styles['info-cart-form']}>
117
+ <p>贡献数据(最近30天)</p>
118
+ <LineChart width={288} height={70} data={chartData}>
119
+ <Line
120
+ type="monotone"
121
+ dataKey="贡献数据数"
122
+ stroke="#7367F0"
123
+ strokeWidth="1.5"
124
+ />
125
+ <Tooltip />
126
+ <XAxis dataKey="name" style={{ display: 'none' }} />
127
+ </LineChart>
128
+ </div>
129
+ </div>
130
+ );
131
+ }
132
+ InfoCart.propTypes = {
133
+ baseMsg: PropTypes.object,
134
+ dispatch: PropTypes.func,
135
+ };
136
+ export default InfoCart;
@@ -0,0 +1,59 @@
1
+ // 卡片
2
+ .info-cart-content {
3
+ padding: 7px 3px;
4
+ .info-cart-base {
5
+ display: flex;
6
+ width: 320px;
7
+ padding-bottom: 20px;
8
+ border-bottom: 1px solid #eeeeee;
9
+ .info-cart-np {
10
+ display: flex;
11
+ flex-direction: column;
12
+ justify-content: center;
13
+ margin-left: 12px;
14
+ span {
15
+ color: #5e5873;
16
+ }
17
+ }
18
+ }
19
+ .info-cart-project {
20
+ margin-top: 20px;
21
+ p {
22
+ margin-bottom: 24px;
23
+ color: #5e5873;
24
+ font-size: 16px;
25
+ }
26
+ .info-cart-data {
27
+ display: flex;
28
+ &-item {
29
+ display: flex;
30
+ flex-direction: column;
31
+ align-items: center;
32
+ justify-content: center;
33
+ width: 96px;
34
+ margin-right: 16px;
35
+ &-title {
36
+ color: #5e5873;
37
+ }
38
+ b {
39
+ margin: 14px 0 6px 0;
40
+ }
41
+ }
42
+ :last-child {
43
+ margin-right: 0;
44
+ }
45
+ }
46
+ }
47
+ .info-cart-form {
48
+ width: 320px;
49
+ height: 126px;
50
+ margin-top: 24px;
51
+ padding: 16px;
52
+ background: #f9f9f9;
53
+ border-radius: 4px;
54
+ p {
55
+ margin-bottom: 16px;
56
+ color: #6e6b7b;
57
+ }
58
+ }
59
+ }
@@ -0,0 +1,10 @@
1
+ import request from '../../utils/request';
2
+ import { API_IAM } from '../../config/env';
3
+ // 查询用户卡片信息
4
+ export async function queryOidcUserCardData(params) {
5
+ return request('/data/findOidcUserCardData', {
6
+ prefix: `${API_IAM}/api/oidc/v1`,
7
+ data: params,
8
+ method: 'post',
9
+ });
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {
@@ -32,6 +32,7 @@
32
32
  "qs": "^6.10.1",
33
33
  "react": "^17.0.0",
34
34
  "react-dom": "^17.0.0",
35
+ "recharts": "^1.8.5",
35
36
  "socket.io-client": "^4.1.2",
36
37
  "umi-request": "^1.3.9",
37
38
  "uuid": "^8.3.2"