@yeeyoon/library 3.2.1 → 3.2.5

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,97 @@
1
+ import { Avatar, Popover } from 'antd';
2
+ import React from 'react';
3
+ import PropTypes from 'prop-types';
4
+ import InfoCard from '../InfoCard';
5
+ import styles from './style.less';
6
+
7
+ const defaultHeadUrl =
8
+ 'https://pro-yeeyoon-fm.oss-cn-zhangjiakou.aliyuncs.com/oidc/user_avatar3.png';
9
+ const defaultUserStyle = { border: '1px solid #fff' };
10
+
11
+ const AvatarInfo = ({
12
+ icon = defaultHeadUrl,
13
+ name,
14
+ placement = 'bottomRight',
15
+ showName = true,
16
+ shape,
17
+ style,
18
+ showInfo = true, // 是否展示信息卡片
19
+ size = 30,
20
+ ...rest
21
+ }) => {
22
+ const CustomAvatar = (
23
+ <span>
24
+ <Avatar
25
+ size={size}
26
+ shape={shape}
27
+ className={styles['user-avatar-scale']}
28
+ src={icon}
29
+ style={{ ...defaultUserStyle, ...style }}
30
+ />
31
+ {showName && (
32
+ <span className={styles['user-avatar-name']}>{name || '-'}</span>
33
+ )}
34
+ </span>
35
+ );
36
+
37
+ return showInfo ? (
38
+ <Popover
39
+ placement={placement}
40
+ content={
41
+ <InfoCard
42
+ baseMsg={{
43
+ icon,
44
+ name,
45
+ ...rest,
46
+ }}
47
+ style={{ width: 334, height: 382 }} // 给定宽高 防止Popover第一次出现时闪跳
48
+ />
49
+ }
50
+ >
51
+ {CustomAvatar}
52
+ </Popover>
53
+ ) : (
54
+ CustomAvatar
55
+ );
56
+ };
57
+
58
+ // data: {name, id, phone, icon} 或 [{name, id, phone, icon}]
59
+ const AvatarPackaged = ({ data, maxCount = 5, maxStyle, ...rest }) => {
60
+ return Array.isArray(data) ? (
61
+ <Avatar.Group
62
+ maxCount={maxCount}
63
+ maxStyle={
64
+ maxStyle || {
65
+ color: '#5E5873',
66
+ backgroundColor: '#FFF',
67
+ marginBottom: '5px',
68
+ }
69
+ }
70
+ >
71
+ {data.map((x, i) => (
72
+ <AvatarInfo key={i} {...rest} {...x} />
73
+ ))}
74
+ </Avatar.Group>
75
+ ) : data ? (
76
+ <AvatarInfo {...rest} {...data} />
77
+ ) : null;
78
+ };
79
+
80
+ AvatarInfo.propTypes = {
81
+ icon: PropTypes.string,
82
+ name: PropTypes.string,
83
+ showName: PropTypes.bool,
84
+ placement: PropTypes.string,
85
+ shape: PropTypes.string,
86
+ size: PropTypes.number,
87
+ style: PropTypes.object,
88
+ showInfo: PropTypes.bool,
89
+ };
90
+
91
+ AvatarPackaged.propTypes = {
92
+ data: PropTypes.oneOfType([PropTypes.object, PropTypes.array]),
93
+ maxCount: PropTypes.number,
94
+ maxStyle: PropTypes.object,
95
+ };
96
+
97
+ export default AvatarPackaged;
@@ -0,0 +1,20 @@
1
+ .user-avatar-scale {
2
+ &:hover {
3
+ transform: scale(1.2);
4
+ }
5
+ }
6
+ .user-avatar-name {
7
+ color: #6e6b7b;
8
+ margin-left: 7px;
9
+ &:hover {
10
+ color: @primary-color;
11
+ }
12
+ }
13
+ :global {
14
+ .ant-list:not(.ant-list-lg):not(.ant-list-sm) .ant-list-item {
15
+ padding: 12px 0px !important;
16
+ }
17
+ .ant-progress-text {
18
+ font-size: 0.7em;
19
+ }
20
+ }
@@ -0,0 +1,137 @@
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, ...rest } = 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, baseMsg.id]);
52
+ const getCardData = async () => {
53
+ const resp = await queryOidcUserCardData({
54
+ id: baseMsg.userId || baseMsg?.id,
55
+ });
56
+ const { success, data } = resp;
57
+ if (success) {
58
+ if (data.content.length > 0) {
59
+ let monthContribute = data.content[0].last_month_contribute || '';
60
+ setCardData(data.content[0]);
61
+ setChartData(
62
+ monthContribute?.split(',').map((item) => ({
63
+ 贡献数据数: parseInt(item.split(':')[1]),
64
+ name: item.split(':')[0],
65
+ }))
66
+ );
67
+ } else {
68
+ setCardData(obj);
69
+ }
70
+ }
71
+ };
72
+ return (
73
+ <div className={styles['info-cart-content']} {...rest}>
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 || baseMsg?.icon}
81
+ />
82
+ <div className={styles['info-cart-np']}>
83
+ <span>{baseMsg?.name}</span>
84
+ <span style={{ marginTop: '6px', fontSize: '12px' }}>
85
+ {(baseMsg?.mobile || baseMsg?.phone || '').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="2"
124
+ dot={false}
125
+ />
126
+ <Tooltip cursor={false} />
127
+ <XAxis dataKey="name" style={{ display: 'none' }} />
128
+ </LineChart>
129
+ </div>
130
+ </div>
131
+ );
132
+ }
133
+ InfoCart.propTypes = {
134
+ baseMsg: PropTypes.object,
135
+ dispatch: PropTypes.func,
136
+ };
137
+ export default InfoCart;
File without changes
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeeyoon/library",
3
- "version": "3.2.1",
3
+ "version": "3.2.5",
4
4
  "description": "宜云前端组件库和通用服务",
5
5
  "main": "index.js",
6
6
  "repository": {