cfel-base-components 2.4.4 → 2.5.1

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.
@@ -1,13 +1,10 @@
1
1
  import React, { useEffect, useState } from "react";
2
2
  import { Layout, Menu, MenuProps, Popover } from "antd";
3
- import { SwapOutlined, FormOutlined } from "@ant-design/icons";
3
+ import UserCard from "./user-card";
4
4
  import "./index.scss";
5
5
 
6
- const currencyList = [
7
- { value: "JPY", label: "日元", icon: "¥" },
8
- { value: "USD", label: "美元", icon: "$" },
9
- { value: "CNY", label: "人民币", icon: "¥" },
10
- ];
6
+ const { Sider } = Layout;
7
+
11
8
  export interface LiosLayoutlProps {
12
9
  appName?: any;
13
10
  productCode: string;
@@ -15,20 +12,8 @@ export interface LiosLayoutlProps {
15
12
  menuList: any;
16
13
  onMenuClick: (item: any) => void;
17
14
  selectedKeys: string[];
15
+ customAction: (item: any) => void;
18
16
  actions?: any[];
19
- user?: {
20
- name: string;
21
- avatar: string;
22
- tenantName: string;
23
- role: any[];
24
- };
25
- custom?: {
26
- type: string;
27
- isCompleted: number;
28
- isAudited: number;
29
- hrefUrl: string;
30
- historyAction?: any;
31
- };
32
17
  myWalletInfo?: {
33
18
  availableCashAmount: string;
34
19
  availableAmount: string;
@@ -42,8 +27,6 @@ export interface LiosLayoutlProps {
42
27
  logoutUrl?: string;
43
28
  switchTenantUrl?: string;
44
29
  defaultOpenKeys?: string[];
45
- productList?: any;
46
- logoUrl?: string;
47
30
  isHideHeader?: boolean; //是否隐藏header
48
31
  }
49
32
 
@@ -51,295 +34,130 @@ export default function LiosLayout(props: LiosLayoutlProps) {
51
34
  const {
52
35
  appName,
53
36
  productCode,
54
- logoUrl,
55
37
  menuList,
56
38
  onMenuClick,
57
39
  selectedKeys,
40
+
41
+ customAction,
58
42
  actions,
59
- user,
60
- custom,
61
- logoutUrl,
62
- switchTenantUrl,
43
+
63
44
  defaultOpenKeys,
64
- productList,
65
45
  myWalletInfo,
66
46
  amountInfo,
67
47
  myWalletInfoAction,
68
48
  isHideHeader,
69
49
  } = props;
70
50
 
71
- const { name, avatar, tenantName, role } = user || {};
72
- const { isCompleted, isAudited, hrefUrl, historyAction } = custom || {};
73
-
74
- const { availableCashAmount, availableAmount, currency } = myWalletInfo || {};
75
-
76
- const { residueNum, currencyCode } = amountInfo || {};
51
+ const { user, logo, subLogo } = (window as any)?.g_config;
52
+ const { name, avatar } = user || {};
77
53
 
78
54
  const [openKeys, setOpenKeys] = useState<any>(defaultOpenKeys || []);
79
- // const [currentProduct, setCurrentProduct] = useState<any>({});
80
-
81
- const { Sider } = Layout;
82
55
 
83
- const [collapsed, setCollapsed] = useState(false);
84
-
85
- // useEffect(() => {
86
- // if (!productList) return
87
- // let cp = productList?.filter((i: any) => i.productCode == productCode)[0]
88
- // setCurrentProduct(cp)
89
- // }, [productList])
56
+ const [collapsed, setCollapsed] = useState(
57
+ localStorage.getItem("layout_collapsed") === "true"
58
+ );
90
59
 
91
60
  const onOpenChange: MenuProps["onOpenChange"] = (keys) => {
92
61
  setOpenKeys(keys);
93
62
  };
94
- const editUserInfo = () => {
95
- const { origin } = window.location;
96
- if (historyAction) {
97
- historyAction?.push({
98
- pathname: hrefUrl,
99
- });
100
- } else {
101
- window.location.href = origin + hrefUrl;
102
- }
103
- };
104
- const currencyText = (currencyText: any) => {
105
- let text = "";
106
- currencyList.some((item: any) => {
107
- if (item.value == currencyText) {
108
- text = item.icon;
109
- return true;
110
- }
111
- });
112
- return text;
113
- };
114
-
115
- const UserCard = () => {
116
- return (
117
- <div className="user-card">
118
- <div className="user-info">
119
- <img className="author" src={avatar} />
120
- <div className="user-info-right">
121
- <span className="name">{name}</span>
122
- <div className="role-list">
123
- {role?.map((i) => (
124
- <span className="role-item" key={i}>
125
- {i}
126
- </span>
127
- ))}
128
- </div>
129
- </div>
130
- </div>
131
-
132
- {myWalletInfo && (
133
- <div className="lios-userInfo">
134
- <div className="lios-li">
135
- <div className="lios-key">现金余额</div>
136
- <div className="lios-value">
137
- <span>{currencyText(currency)}</span>
138
- {availableCashAmount || "加载中..."}
139
- </div>
140
- </div>
141
- <div className="lios-li">
142
- <div className="lios-key">可用额度</div>
143
- <div className="lios-value">
144
- <span>{currencyText(currency)}</span>
145
- {availableAmount || "加载中..."}
146
- </div>
147
- </div>
148
- {amountInfo && (
149
- <div className="lios-li">
150
- <div className="lios-key">抵用金余额</div>
151
- <div className="lios-value">
152
- <span>{currencyText(currencyCode)}</span>
153
- {residueNum || "加载中..."}
154
- </div>
155
- </div>
156
- )}
157
- </div>
158
- )}
159
- {custom && (
160
- <div className="lios-userInfo">
161
- <div className="lios-li li-flex">
162
- <div className="lios-key">客户类型</div>
163
- <div className="lios-value">{custom.type || ""}</div>
164
- <div
165
- className="lios-icon"
166
- onClick={() => {
167
- editUserInfo();
168
- }}
169
- >
170
- <FormOutlined />
171
- </div>
172
- </div>
173
- <div className="lios-li">
174
- <div className="lios-key">是否审核</div>
175
- <div className="lios-value">{isAudited ? "是" : "否"}</div>
176
- </div>
177
- <div className="lios-li">
178
- <div className="lios-key">是否资料完备</div>
179
- <div className="lios-value">{isCompleted ? "是" : "否"}</div>
180
- </div>
181
- </div>
182
- )}
183
-
184
- {tenantName && (
185
- <div className="lios-tenant">
186
- <div className="tenant-label">租户</div>
187
- <div className="tenant-switch">
188
- <div className="tenant-value">{tenantName}</div>
189
- {switchTenantUrl && (
190
- <div
191
- className="tenant-icon"
192
- onClick={() => {
193
- location.href = switchTenantUrl;
194
- }}
195
- >
196
- <SwapOutlined />
197
- </div>
198
- )}
199
- </div>
200
- </div>
201
- )}
202
-
203
- {logoutUrl && (
204
- <div
205
- className="lios-logout"
206
- onClick={() => {
207
- location.href = logoutUrl;
208
- }}
209
- >
210
- <svg
211
- className="logout-icon"
212
- viewBox="0 0 1024 1024"
213
- version="1.1"
214
- xmlns="http://www.w3.org/2000/svg"
215
- p-id="5022"
216
- width="16"
217
- height="16"
218
- >
219
- <path
220
- d="M295.589 239.512c17.942-12.888 42.935-8.79 55.823 9.153 12.888 17.942 8.79 42.935-9.153 55.823C266.667 358.783 221 445.786 221 540.488 221 700.92 351.272 831 512 831s291-130.08 291-290.512c0-94.663-45.63-181.634-121.17-235.935-17.937-12.895-22.026-37.89-9.131-55.827 12.894-17.938 37.889-22.026 55.827-9.132C824.752 308.766 883 419.788 883 540.488 883 745.13 716.884 911 512 911S141 745.13 141 540.488c0-120.75 58.297-231.812 154.589-300.976z"
221
- fill="currentColor"
222
- p-id="5023"
223
- ></path>
224
- <path
225
- d="M512 113c21.87 0 39.641 17.552 39.995 39.339L552 153v297c0 22.091-17.909 40-40 40-21.87 0-39.641-17.552-39.995-39.339L472 450V153c0-22.091 17.909-40 40-40z"
226
- fill="currentColor"
227
- p-id="5024"
228
- ></path>
229
- </svg>
230
- 退出登录
231
- </div>
232
- )}
233
- </div>
234
- );
235
- };
236
63
 
237
- const ProductListFunc = () => {
238
- return (
239
- <div className="app-list-other">
240
- {productList?.map((item) => {
241
- return (
242
- <div
243
- onClick={() => {
244
- item.productCode != productCode &&
245
- item?.portalUrl &&
246
- window.open(item?.portalUrl);
247
- }}
248
- key={item.id}
249
- className={`product-list-item ${
250
- item.productCode == productCode ? "current-product" : ""
251
- }`}
252
- >
64
+ return (
65
+ <Layout className="layout-warp">
66
+ {Array.isArray(menuList) && menuList.length > 0 && (
67
+ <Sider
68
+ className="layout-side"
69
+ style={{
70
+ backgroundSize: collapsed ? "1800%" : "900%",
71
+ }}
72
+ collapsible
73
+ collapsed={collapsed}
74
+ width={240}
75
+ onCollapse={(value) => {
76
+ localStorage.setItem("layout_collapsed", value.toString());
77
+ setCollapsed(value);
78
+ }}
79
+ >
80
+ <div className="layout-logo">
81
+ {
82
+ <img
83
+ className={`logo-img ${
84
+ !collapsed ? "current-logo" : "hide-logo"
85
+ }`}
86
+ src={logo || ""}
87
+ />
88
+ }
89
+ {
253
90
  <img
91
+ className={`logo-img sub-logo
92
+ ${collapsed ? "current-logo" : "hide-sub-logo"}`}
254
93
  src={
255
- item?.logoUrl ||
256
- "https://pic.imgdb.cn/item/64c760291ddac507cc68440a.png"
94
+ subLogo ||
95
+ "https://cdn.chengfengerlai.com/logo/company-logo/chengfengerlai-white.png"
257
96
  }
258
- alt=""
259
97
  />
260
- <div> {item?.productName}</div>
261
- </div>
262
- );
263
- })}
264
- </div>
265
- );
266
- };
267
-
268
- const MenuStyle = {
269
- width: collapsed ? 80 : 240,
270
- };
271
-
272
- return (
273
- <Layout className="layout-warp">
274
- {!isHideHeader && (
275
- <div className="layout-header">
276
-
277
- <div className="background">
278
- <img
279
- className="background-img"
280
- src="https://pic.imgdb.cn/item/64813de01ddac507cc192a6e.jpg"
281
- alt=""
282
- />
283
- <div className="background-mask" />
284
- </div>
285
-
286
- <strong className="layout-header-logo">
287
- {logoUrl && <img className="logo-img" src={logoUrl || ""} />}
288
- {logoUrl && appName && <div className="interval" />}
289
- {appName && <div className="app-name">{appName}</div>}
290
- </strong>
291
-
292
- <div className="layout-header-fill" />
293
-
294
- <div className="layout-header-actions">
295
- {actions?.map((item, index) => {
296
- return (
297
- <div className="actions-item" key={index}>
298
- {item}
299
- </div>
300
- );
301
- })}
98
+ }
302
99
  </div>
303
100
 
304
- <Popover
305
- placement="bottom"
306
- content={<UserCard />}
307
- arrow={false}
308
- trigger="click"
309
- onOpenChange={(e) => {
310
- if (!e) return;
311
- myWalletInfoAction && myWalletInfoAction();
312
- }}
313
- >
314
- <div className="layout-header-user">
315
- <img className="author" src={avatar} />
316
- <div className="name">{name}</div>
317
- </div>
318
- </Popover>
319
- </div>
320
- )}
321
- <div className="layout-main">
322
- {Array.isArray(menuList) && menuList.length > 0 && (
323
- <Sider
324
- className="layout-side"
325
- theme={"light"}
326
- collapsible
327
- collapsed={collapsed}
328
- width={240}
329
- onCollapse={(value) => setCollapsed(value)}
330
- >
101
+ <div className="layout-menu-container">
331
102
  <Menu
332
103
  mode="inline"
333
104
  openKeys={openKeys}
334
105
  onOpenChange={onOpenChange}
335
106
  items={menuList}
336
- style={MenuStyle}
337
107
  onClick={(item): any => {
338
108
  onMenuClick && onMenuClick(item);
339
109
  }}
340
110
  selectedKeys={selectedKeys}
111
+ theme="dark"
112
+ color="red"
341
113
  />
342
- </Sider>
114
+ </div>
115
+ </Sider>
116
+ )}
117
+
118
+ <div className="layout-main">
119
+ {!isHideHeader && (
120
+ <div className="layout-header">
121
+ {appName && (
122
+ <div className="app-name">
123
+ <strong>{appName}</strong>
124
+ </div>
125
+ )}
126
+
127
+ <div className="layout-header-fill" />
128
+
129
+ <div className="layout-header-actions">
130
+ {actions?.map((item, index) => {
131
+ return (
132
+ <div className="actions-item" key={index}>
133
+ {item}
134
+ </div>
135
+ );
136
+ })}
137
+ </div>
138
+
139
+ <Popover
140
+ placement="bottom"
141
+ content={
142
+ <UserCard
143
+ myWalletInfo={myWalletInfo}
144
+ amountInfo={amountInfo}
145
+ customAction={customAction}
146
+ />
147
+ }
148
+ arrow={false}
149
+ trigger="click"
150
+ onOpenChange={(e) => {
151
+ if (!e) return;
152
+ myWalletInfoAction && myWalletInfoAction();
153
+ }}
154
+ >
155
+ <div className="layout-header-user">
156
+ <img className="avatar" src={avatar} />
157
+ <div className="name">{name}</div>
158
+ </div>
159
+ </Popover>
160
+ </div>
343
161
  )}
344
162
  <div className="layout-content">{props.children}</div>
345
163
  </div>
@@ -0,0 +1,144 @@
1
+ //用户卡片
2
+ .layout-user-card {
3
+ min-width: 182px;
4
+ max-width: 262px;
5
+
6
+ .user-info {
7
+ display: flex;
8
+
9
+ .user-avatar {
10
+ width: 72px;
11
+ height: 72px;
12
+ border-radius: 50%;
13
+ background: rgba(255, 255, 255, 0.3);
14
+ margin-right: 12px;
15
+ }
16
+
17
+ .user-info-right {
18
+ flex: 1;
19
+ }
20
+
21
+ .name {
22
+ display: inline-block;
23
+ margin-top: 18px;
24
+ }
25
+
26
+ .role-list {
27
+ font-size: 12px;
28
+ line-height: 16px;
29
+ margin-top: 4px;
30
+
31
+ .role-item {
32
+ background: rgba(204, 204, 204, 0.55);
33
+ padding: 2px 8px;
34
+ border-radius: 8px;
35
+ display: inline-block;
36
+ margin-right: 4px;
37
+ margin-bottom: 4px;
38
+ }
39
+ }
40
+ }
41
+
42
+ .lios-tenant {
43
+ padding: 5px 0px;
44
+ margin: 5px 0px;
45
+ border-top: 1px solid rgba(5, 5, 5, 0.06);
46
+
47
+ .tenant-label {
48
+ font-size: 12px;
49
+ color: rgba(0, 0, 0, 0.5);
50
+ }
51
+
52
+ .tenant-switch {
53
+ display: flex;
54
+
55
+ .tenant-value {
56
+ flex: 1;
57
+ font-size: 14px;
58
+ color: rgba(0, 0, 0, 0.85);
59
+ }
60
+
61
+ .tenant-icon {
62
+ width: 40px;
63
+ text-align: center;
64
+ color: rgba(0, 0, 0, 0.45);
65
+ display: flex;
66
+ justify-content: center;
67
+ align-items: center;
68
+ }
69
+
70
+ .tenant-icon:hover {
71
+ cursor: pointer;
72
+ color: rgba(0, 0, 0, 0.85);
73
+ }
74
+ }
75
+ }
76
+
77
+ .lios-userInfo {
78
+ padding: 5px 0px;
79
+ margin: 5px 0px;
80
+ border-top: 1px solid rgba(5, 5, 5, 0.06);
81
+
82
+ .li-flex {
83
+ display: flex;
84
+
85
+ .lios-value {
86
+ flex: 1;
87
+ }
88
+ }
89
+
90
+ .lios-li {
91
+ line-height: 22px;
92
+
93
+ .lios-key {
94
+ font-size: 12px;
95
+ color: rgba(0, 0, 0, 0.5);
96
+ display: inline-block;
97
+ }
98
+
99
+ .lios-value {
100
+ padding-left: 8px;
101
+ display: inline-block;
102
+ font-size: 12px;
103
+ color: rgba(0, 0, 0, 0.85);
104
+
105
+ span {
106
+ padding-left: 5px;
107
+ }
108
+ }
109
+
110
+ .lios-icon {
111
+ width: 40px;
112
+ text-align: center;
113
+ color: rgba(0, 0, 0, 0.45);
114
+ transition: all 0.3s;
115
+ }
116
+
117
+ .lios-icon:hover {
118
+ cursor: pointer;
119
+ color: rgba(0, 0, 0, 0.85);
120
+ }
121
+ }
122
+ }
123
+
124
+ .lios-logout {
125
+ cursor: pointer;
126
+ display: flex;
127
+ justify-content: center;
128
+ align-items: center;
129
+ color: rgba(0, 0, 0, 0.45);
130
+ border-radius: 4px;
131
+ transition: background 0.3s;
132
+ padding: 4px;
133
+
134
+ &:hover {
135
+ background: rgba(0, 0, 0, 0.08);
136
+ }
137
+
138
+ .logout-icon {
139
+ width: 16px;
140
+ height: 16px;
141
+ margin-right: 8px;
142
+ }
143
+ }
144
+ }