@yuku123/z-team-component 0.2.4 → 0.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,490 @@
1
+ import { jsxs as i, jsx as e, Fragment as A } from "react/jsx-runtime";
2
+ import { useState as o, useEffect as oe } from "react";
3
+ import { Form as m, message as r, Button as d, Input as B, Row as ae, Col as z, Card as v, Statistic as S, Alert as T, Space as p, Typography as se, Tabs as de, Popconfirm as F, Table as _, Tag as h, Tooltip as ce, Modal as he, Radio as O, Select as w, InputNumber as ue } from "antd";
4
+ import { PlusOutlined as me, ClockCircleOutlined as $, CheckCircleOutlined as j, LinkOutlined as U, CopyOutlined as x, QrcodeOutlined as M, UserDeleteOutlined as K, TeamOutlined as pe, MailOutlined as q, DeleteOutlined as ye, UserAddOutlined as N, CloseCircleOutlined as W } from "@ant-design/icons";
5
+ import { l as ge, b as fe, g as ve, c as we, d as xe, e as Ce, f as be } from "./api-Gpz6URwP.js";
6
+ import { b as Ie, T as ke } from "./ProjectApp-DjHsGbam.js";
7
+ const { Text: c } = se, De = () => {
8
+ const [C] = m.useForm(), [D, L] = o(!1), [y, G] = o([]), [R, H] = o([]), [J, Q] = o(null), [u, V] = o(""), [X, b] = o(!1), [Y, E] = o(!1), [a, P] = o(null), [l, Z] = o(localStorage.getItem("userInfo") && JSON.parse(localStorage.getItem("userInfo") || "{}").tenantCode || "");
9
+ oe(() => {
10
+ l && g();
11
+ }, [l]);
12
+ const g = async () => {
13
+ if (!l) {
14
+ r.warning("请先选择租户");
15
+ return;
16
+ }
17
+ L(!0);
18
+ try {
19
+ const [t, n, s] = await Promise.all([
20
+ ge(l).catch(() => []),
21
+ fe(l).catch(() => []),
22
+ ve().catch(() => null)
23
+ ]);
24
+ if (G(t || []), H(n || []), s) {
25
+ Q(s.userId);
26
+ const k = (s.memberships || []).find((re) => re.tenantCode === l);
27
+ V((k == null ? void 0 : k.roleCode) || "");
28
+ }
29
+ } catch (t) {
30
+ r.error("加载失败: " + ((t == null ? void 0 : t.message) || t));
31
+ } finally {
32
+ L(!1);
33
+ }
34
+ }, ee = async () => {
35
+ try {
36
+ const t = await C.validateFields();
37
+ E(!0);
38
+ const n = await be({
39
+ tenantCode: l,
40
+ inviteeEmail: t.inviteeEmail,
41
+ roleCode: t.roleCode,
42
+ type: t.type,
43
+ maxUses: t.maxUses
44
+ });
45
+ n && n.id && (r.success("邀请创建成功!"), P(n), b(!1), C.resetFields(), g());
46
+ } catch (t) {
47
+ if (t != null && t.errorFields) return;
48
+ r.error("创建失败: " + ((t == null ? void 0 : t.message) || t));
49
+ } finally {
50
+ E(!1);
51
+ }
52
+ }, te = async (t) => {
53
+ try {
54
+ await Ce(t, l), r.success("已撤销"), g();
55
+ } catch (n) {
56
+ r.error("撤销失败: " + ((n == null ? void 0 : n.message) || n));
57
+ }
58
+ }, ne = async (t, n) => {
59
+ try {
60
+ await xe(t, l), r.success(`已移除成员 ${n}`), g();
61
+ } catch (s) {
62
+ r.error("移除失败: " + ((s == null ? void 0 : s.message) || s));
63
+ }
64
+ }, ie = async () => {
65
+ try {
66
+ await we(l), r.success("已退出该租户"), window.location.href = "/onboarding";
67
+ } catch (t) {
68
+ r.error("退出失败: " + ((t == null ? void 0 : t.message) || t));
69
+ }
70
+ }, f = (t, n = "已复制") => {
71
+ navigator.clipboard.writeText(t), r.success(n);
72
+ }, le = {
73
+ 0: { color: "processing", text: "待接受", icon: /* @__PURE__ */ e($, {}) },
74
+ 1: { color: "success", text: "已接受", icon: /* @__PURE__ */ e(j, {}) },
75
+ 2: { color: "default", text: "已撤销", icon: /* @__PURE__ */ e(W, {}) },
76
+ 3: { color: "error", text: "已过期", icon: /* @__PURE__ */ e(W, {}) }
77
+ }, I = {
78
+ total: y.length,
79
+ pending: y.filter((t) => t.status === 0).length,
80
+ accepted: y.filter((t) => t.status === 1).length
81
+ };
82
+ return /* @__PURE__ */ i("div", { children: [
83
+ /* @__PURE__ */ e(
84
+ Ie,
85
+ {
86
+ title: "邀请管理",
87
+ subtitle: `租户: ${l}`
88
+ }
89
+ ),
90
+ /* @__PURE__ */ e(
91
+ ke,
92
+ {
93
+ left: /* @__PURE__ */ e(
94
+ B,
95
+ {
96
+ placeholder: "租户编码",
97
+ value: l,
98
+ onChange: (t) => Z(t.target.value),
99
+ onPressEnter: g,
100
+ style: { width: 200 }
101
+ }
102
+ ),
103
+ right: /* @__PURE__ */ e(d, { type: "primary", icon: /* @__PURE__ */ e(me, {}), onClick: () => b(!0), children: "创建邀请" }),
104
+ extra: null
105
+ }
106
+ ),
107
+ /* @__PURE__ */ i(ae, { gutter: 16, style: { marginBottom: 16 }, children: [
108
+ /* @__PURE__ */ e(z, { span: 8, children: /* @__PURE__ */ e(v, { size: "small", children: /* @__PURE__ */ e(S, { title: "总邀请数", value: I.total }) }) }),
109
+ /* @__PURE__ */ e(z, { span: 8, children: /* @__PURE__ */ e(v, { size: "small", children: /* @__PURE__ */ e(
110
+ S,
111
+ {
112
+ title: "待接受",
113
+ value: I.pending,
114
+ styles: { content: { color: "#1890ff" } },
115
+ prefix: /* @__PURE__ */ e($, {})
116
+ }
117
+ ) }) }),
118
+ /* @__PURE__ */ e(z, { span: 8, children: /* @__PURE__ */ e(v, { size: "small", children: /* @__PURE__ */ e(
119
+ S,
120
+ {
121
+ title: "已接受",
122
+ value: I.accepted,
123
+ styles: { content: { color: "#52c41a" } },
124
+ prefix: /* @__PURE__ */ e(j, {})
125
+ }
126
+ ) }) })
127
+ ] }),
128
+ a && /* @__PURE__ */ e(
129
+ T,
130
+ {
131
+ type: "success",
132
+ showIcon: !0,
133
+ style: { marginBottom: 16 },
134
+ message: "邀请创建成功!",
135
+ description: /* @__PURE__ */ i(p, { orientation: "vertical", style: { width: "100%" }, children: [
136
+ a.inviteUrl && /* @__PURE__ */ i(p, { children: [
137
+ /* @__PURE__ */ e(U, {}),
138
+ /* @__PURE__ */ e("code", { style: { background: "#f0f0f0", padding: "2px 6px", borderRadius: 3 }, children: a.inviteUrl }),
139
+ /* @__PURE__ */ e(
140
+ d,
141
+ {
142
+ size: "small",
143
+ icon: /* @__PURE__ */ e(x, {}),
144
+ onClick: () => f(a.inviteUrl, "邀请链接已复制"),
145
+ children: "复制链接"
146
+ }
147
+ )
148
+ ] }),
149
+ a.inviteCode && /* @__PURE__ */ i(p, { children: [
150
+ /* @__PURE__ */ e(M, {}),
151
+ /* @__PURE__ */ e("code", { style: {
152
+ background: "#f0f0f0",
153
+ padding: "4px 12px",
154
+ borderRadius: 4,
155
+ fontSize: 18,
156
+ letterSpacing: 4,
157
+ fontWeight: "bold"
158
+ }, children: a.inviteCode }),
159
+ /* @__PURE__ */ e(
160
+ d,
161
+ {
162
+ size: "small",
163
+ icon: /* @__PURE__ */ e(x, {}),
164
+ onClick: () => f(a.inviteCode, "邀请码已复制"),
165
+ children: "复制码"
166
+ }
167
+ )
168
+ ] }),
169
+ /* @__PURE__ */ i(c, { type: "secondary", style: { fontSize: 12 }, children: [
170
+ "过期时间: ",
171
+ new Date(a.expireAt).toLocaleString()
172
+ ] })
173
+ ] }),
174
+ closable: !0,
175
+ onClose: () => P(null)
176
+ }
177
+ ),
178
+ /* @__PURE__ */ e(v, { size: "small", styles: { body: { paddingTop: 8 } }, children: /* @__PURE__ */ e(
179
+ de,
180
+ {
181
+ size: "small",
182
+ defaultActiveKey: "members",
183
+ items: [
184
+ {
185
+ key: "members",
186
+ label: /* @__PURE__ */ i("span", { children: [
187
+ /* @__PURE__ */ e(pe, {}),
188
+ " 成员管理 (",
189
+ R.length,
190
+ ")"
191
+ ] }),
192
+ children: /* @__PURE__ */ i(A, { children: [
193
+ u && u !== "owner" && /* @__PURE__ */ e(
194
+ T,
195
+ {
196
+ type: "warning",
197
+ showIcon: !0,
198
+ style: { marginBottom: 12 },
199
+ message: `你是 ${u}, 退出后回游离态, owner 需先转让`,
200
+ action: /* @__PURE__ */ e(
201
+ F,
202
+ {
203
+ title: "确认退出该租户?",
204
+ description: "退出后将回到游离态, 可重新加入或创建新租户",
205
+ onConfirm: ie,
206
+ children: /* @__PURE__ */ e(d, { size: "small", danger: !0, icon: /* @__PURE__ */ e(K, {}), children: "退出租户" })
207
+ }
208
+ )
209
+ }
210
+ ),
211
+ /* @__PURE__ */ e(
212
+ _,
213
+ {
214
+ size: "small",
215
+ loading: D,
216
+ dataSource: R,
217
+ rowKey: "id",
218
+ pagination: { pageSize: 20, size: "small" },
219
+ locale: { emptyText: "暂无成员" },
220
+ columns: [
221
+ { title: "ID", dataIndex: "id", width: 60 },
222
+ { title: "用户ID", dataIndex: "userId", width: 80 },
223
+ {
224
+ title: "角色",
225
+ dataIndex: "roleCode",
226
+ width: 100,
227
+ render: (t) => /* @__PURE__ */ i(
228
+ h,
229
+ {
230
+ color: t === "owner" ? "gold" : t === "admin" ? "blue" : "default",
231
+ children: [
232
+ t === "owner" && "👑 ",
233
+ t
234
+ ]
235
+ }
236
+ )
237
+ },
238
+ {
239
+ title: "状态",
240
+ dataIndex: "memberStatus",
241
+ width: 80,
242
+ render: (t) => /* @__PURE__ */ e(
243
+ h,
244
+ {
245
+ color: t === 1 ? "success" : "default",
246
+ children: t === 1 ? "正常" : "已退出"
247
+ }
248
+ )
249
+ },
250
+ {
251
+ title: "加入时间",
252
+ dataIndex: "joinedAt",
253
+ width: 160,
254
+ render: (t) => t ? new Date(t).toLocaleString() : "-"
255
+ },
256
+ {
257
+ title: "操作",
258
+ width: 100,
259
+ fixed: "right",
260
+ render: (t, n) => u !== "owner" && u !== "admin" ? /* @__PURE__ */ e(
261
+ c,
262
+ {
263
+ type: "secondary",
264
+ children: "-"
265
+ }
266
+ ) : n.roleCode === "owner" ? /* @__PURE__ */ e(
267
+ c,
268
+ {
269
+ type: "secondary",
270
+ children: "owner"
271
+ }
272
+ ) : n.userId === J ? /* @__PURE__ */ e(c, { type: "secondary", children: "自己" }) : u === "admin" && n.roleCode === "admin" ? /* @__PURE__ */ e(
273
+ c,
274
+ {
275
+ type: "secondary",
276
+ children: "-"
277
+ }
278
+ ) : /* @__PURE__ */ e(
279
+ F,
280
+ {
281
+ title: "确认移除该成员?",
282
+ description: "移除后该用户将回游离态, 可重新接受邀请加入",
283
+ onConfirm: () => ne(n.id, `userId=${n.userId}`),
284
+ children: /* @__PURE__ */ e(
285
+ d,
286
+ {
287
+ size: "small",
288
+ type: "text",
289
+ danger: !0,
290
+ icon: /* @__PURE__ */ e(K, {}),
291
+ children: "移除"
292
+ }
293
+ )
294
+ }
295
+ )
296
+ }
297
+ ]
298
+ }
299
+ )
300
+ ] })
301
+ },
302
+ {
303
+ key: "invitations",
304
+ label: /* @__PURE__ */ i("span", { children: [
305
+ /* @__PURE__ */ e(N, {}),
306
+ " 邀请记录 (",
307
+ y.length,
308
+ ")"
309
+ ] }),
310
+ children: /* @__PURE__ */ e(
311
+ _,
312
+ {
313
+ size: "small",
314
+ loading: D,
315
+ dataSource: y,
316
+ rowKey: "id",
317
+ pagination: { pageSize: 10, size: "small" },
318
+ locale: { emptyText: "暂无邀请, 点右上角创建第一个" },
319
+ columns: [
320
+ { title: "ID", dataIndex: "id", width: 60 },
321
+ {
322
+ title: "类型",
323
+ dataIndex: "type",
324
+ width: 80,
325
+ render: (t, n) => n.token ? /* @__PURE__ */ e(h, { color: "blue", icon: /* @__PURE__ */ e(U, {}), children: "链接" }) : n.inviteCode ? /* @__PURE__ */ e(h, { color: "purple", icon: /* @__PURE__ */ e(M, {}), children: "码" }) : "-"
326
+ },
327
+ {
328
+ title: "内容",
329
+ render: (t, n) => n.token ? /* @__PURE__ */ i(p, { children: [
330
+ /* @__PURE__ */ i("code", { style: { fontSize: 11 }, children: [
331
+ n.token.substring(0, 16),
332
+ "..."
333
+ ] }),
334
+ /* @__PURE__ */ e(
335
+ d,
336
+ {
337
+ size: "small",
338
+ type: "link",
339
+ icon: /* @__PURE__ */ e(x, {}),
340
+ onClick: () => f(
341
+ `https://opc.zopc.top/invite?token=${n.token}`,
342
+ "完整链接已复制"
343
+ ),
344
+ children: "复制"
345
+ }
346
+ )
347
+ ] }) : n.inviteCode ? /* @__PURE__ */ i(p, { children: [
348
+ /* @__PURE__ */ e("code", { style: {
349
+ fontSize: 16,
350
+ letterSpacing: 2,
351
+ fontWeight: "bold",
352
+ background: "#f0f0f0",
353
+ padding: "2px 8px",
354
+ borderRadius: 3
355
+ }, children: n.inviteCode }),
356
+ /* @__PURE__ */ e(
357
+ d,
358
+ {
359
+ size: "small",
360
+ type: "link",
361
+ icon: /* @__PURE__ */ e(x, {}),
362
+ onClick: () => f(n.inviteCode, "邀请码已复制"),
363
+ children: "复制"
364
+ }
365
+ )
366
+ ] }) : "-"
367
+ },
368
+ {
369
+ title: "被邀请人",
370
+ render: (t, n) => n.inviteeEmail ? /* @__PURE__ */ i(p, { size: 4, children: [
371
+ /* @__PURE__ */ e(q, {}),
372
+ " ",
373
+ n.inviteeEmail
374
+ ] }) : n.inviteePhone || /* @__PURE__ */ e(c, { type: "secondary", children: "不限 (公开码)" })
375
+ },
376
+ {
377
+ title: "角色",
378
+ dataIndex: "roleCode",
379
+ width: 80,
380
+ render: (t) => /* @__PURE__ */ e(
381
+ h,
382
+ {
383
+ color: t === "owner" ? "gold" : t === "admin" ? "blue" : "default",
384
+ children: t
385
+ }
386
+ )
387
+ },
388
+ {
389
+ title: "使用情况",
390
+ width: 100,
391
+ render: (t, n) => /* @__PURE__ */ e(ce, { title: `最多 ${n.maxUses || 1} 次`, children: /* @__PURE__ */ i(h, { children: [
392
+ n.usedCount || 0,
393
+ " / ",
394
+ n.maxUses || 1
395
+ ] }) })
396
+ },
397
+ {
398
+ title: "状态",
399
+ dataIndex: "status",
400
+ width: 90,
401
+ render: (t) => {
402
+ const n = le[t] || { color: "default", text: "?" };
403
+ return /* @__PURE__ */ e(h, { color: n.color, icon: n.icon, children: n.text });
404
+ }
405
+ },
406
+ {
407
+ title: "过期时间",
408
+ dataIndex: "expireAt",
409
+ width: 140,
410
+ render: (t) => t ? /* @__PURE__ */ e(
411
+ c,
412
+ {
413
+ type: new Date(t) < /* @__PURE__ */ new Date() ? "danger" : "secondary",
414
+ style: { fontSize: 12 },
415
+ children: new Date(t).toLocaleString()
416
+ }
417
+ ) : "-"
418
+ },
419
+ {
420
+ title: "操作",
421
+ width: 80,
422
+ fixed: "right",
423
+ render: (t, n) => n.status === 0 ? /* @__PURE__ */ e(
424
+ d,
425
+ {
426
+ size: "small",
427
+ type: "text",
428
+ danger: !0,
429
+ icon: /* @__PURE__ */ e(ye, {}),
430
+ onClick: () => te(n.id),
431
+ children: "撤销"
432
+ }
433
+ ) : /* @__PURE__ */ e(c, { type: "secondary", children: "-" })
434
+ }
435
+ ]
436
+ }
437
+ )
438
+ }
439
+ ]
440
+ }
441
+ ) }),
442
+ /* @__PURE__ */ i(
443
+ he,
444
+ {
445
+ title: /* @__PURE__ */ i(A, { children: [
446
+ /* @__PURE__ */ e(N, {}),
447
+ " 创建邀请"
448
+ ] }),
449
+ open: X,
450
+ onCancel: () => b(!1),
451
+ onOk: ee,
452
+ confirmLoading: Y,
453
+ okText: "创建",
454
+ children: [
455
+ /* @__PURE__ */ i(m, { form: C, layout: "vertical", initialValues: { type: "link", roleCode: "member", maxUses: 1 }, children: [
456
+ /* @__PURE__ */ e(m.Item, { name: "type", label: "类型", rules: [{ required: !0 }], children: /* @__PURE__ */ i(O.Group, { children: [
457
+ /* @__PURE__ */ i(O.Button, { value: "link", children: [
458
+ /* @__PURE__ */ e(U, {}),
459
+ " 邀请链接"
460
+ ] }),
461
+ /* @__PURE__ */ i(O.Button, { value: "code", children: [
462
+ /* @__PURE__ */ e(M, {}),
463
+ " 邀请码"
464
+ ] })
465
+ ] }) }),
466
+ /* @__PURE__ */ e(m.Item, { name: "inviteeEmail", label: "被邀请人邮箱 (可选, 链接模式可指定)", children: /* @__PURE__ */ e(B, { prefix: /* @__PURE__ */ e(q, {}), placeholder: "留空则任何人都可用 (码模式)" }) }),
467
+ /* @__PURE__ */ e(m.Item, { name: "roleCode", label: "加入后角色", rules: [{ required: !0 }], children: /* @__PURE__ */ i(w, { children: [
468
+ /* @__PURE__ */ e(w.Option, { value: "owner", children: "owner (完全管理)" }),
469
+ /* @__PURE__ */ e(w.Option, { value: "admin", children: "admin (管理员)" }),
470
+ /* @__PURE__ */ e(w.Option, { value: "member", children: "member (普通成员)" })
471
+ ] }) }),
472
+ /* @__PURE__ */ e(
473
+ m.Item,
474
+ {
475
+ name: "maxUses",
476
+ label: "最大使用次数",
477
+ extra: "码模式可 > 1 (批量邀请), 链接模式固定 1",
478
+ children: /* @__PURE__ */ e(ue, { min: 1, max: 100, style: { width: "100%" } })
479
+ }
480
+ )
481
+ ] }),
482
+ /* @__PURE__ */ e(T, { type: "info", showIcon: !0, title: "链接模式 7 天过期, 码模式同 7 天" })
483
+ ]
484
+ }
485
+ )
486
+ ] });
487
+ };
488
+ export {
489
+ De as default
490
+ };
@@ -0,0 +1,17 @@
1
+ import { jsxs as r, jsx as e } from "react/jsx-runtime";
2
+ import "react";
3
+ import { useParams as t } from "react-router-dom";
4
+ import { L as d, c as i } from "./ProjectApp-DjHsGbam.js";
5
+ const c = () => {
6
+ const { entity: o } = t();
7
+ return o ? o === "_model" ? /* @__PURE__ */ e(d, {}) : /* @__PURE__ */ e(i, {}) : /* @__PURE__ */ r("div", { style: { padding: 24 }, children: [
8
+ "缺少实体编码. 请访问 ",
9
+ /* @__PURE__ */ e("code", { children: "/form/_model" }),
10
+ " 编辑模型, 或 ",
11
+ /* @__PURE__ */ e("code", { children: "/form/{entityCode}" }),
12
+ " 运行时 CRUD."
13
+ ] });
14
+ };
15
+ export {
16
+ c as default
17
+ };