com-angel-authorization 1.0.17 → 1.0.20
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.
- package/README.md +57 -3
- package/dist/index.cjs +173 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -2
- package/dist/index.d.ts +85 -2
- package/dist/index.js +167 -3
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +1022 -23
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.d.cts +96 -4
- package/dist/react/index.d.ts +96 -4
- package/dist/react/index.js +1016 -21
- package/dist/react/index.js.map +1 -1
- package/dist/vue/index.cjs +1178 -29
- package/dist/vue/index.cjs.map +1 -1
- package/dist/vue/index.d.cts +130 -3
- package/dist/vue/index.d.ts +130 -3
- package/dist/vue/index.js +1174 -26
- package/dist/vue/index.js.map +1 -1
- package/package.json +1 -1
package/dist/vue/index.js
CHANGED
|
@@ -498,7 +498,7 @@ function toStringArray(value) {
|
|
|
498
498
|
}).filter(Boolean);
|
|
499
499
|
}
|
|
500
500
|
if (typeof value === "string" && value.trim()) {
|
|
501
|
-
return value.split(",").map((
|
|
501
|
+
return value.split(",").map((s6) => s6.trim()).filter(Boolean);
|
|
502
502
|
}
|
|
503
503
|
return [];
|
|
504
504
|
}
|
|
@@ -3375,23 +3375,1159 @@ var RoleManager = defineComponent4({
|
|
|
3375
3375
|
}
|
|
3376
3376
|
});
|
|
3377
3377
|
|
|
3378
|
+
// src/vue/UserManager.ts
|
|
3379
|
+
import {
|
|
3380
|
+
defineComponent as defineComponent5,
|
|
3381
|
+
h as h4,
|
|
3382
|
+
onMounted as onMounted4,
|
|
3383
|
+
reactive as reactive4,
|
|
3384
|
+
ref as ref4,
|
|
3385
|
+
watch as watch4
|
|
3386
|
+
} from "vue";
|
|
3387
|
+
|
|
3388
|
+
// src/users/index.ts
|
|
3389
|
+
function asIdList(value) {
|
|
3390
|
+
if (!Array.isArray(value)) return [];
|
|
3391
|
+
return value.map((item) => {
|
|
3392
|
+
if (item === void 0 || item === null || item === "") return "";
|
|
3393
|
+
if (typeof item === "object") {
|
|
3394
|
+
const row = item;
|
|
3395
|
+
const id = row.groupId ?? row.roleId ?? row.id;
|
|
3396
|
+
return id === void 0 || id === null ? "" : String(id);
|
|
3397
|
+
}
|
|
3398
|
+
return String(item);
|
|
3399
|
+
}).filter(Boolean);
|
|
3400
|
+
}
|
|
3401
|
+
function asNameList(value) {
|
|
3402
|
+
if (!Array.isArray(value)) return void 0;
|
|
3403
|
+
const names = value.map((item) => {
|
|
3404
|
+
if (item === void 0 || item === null) return "";
|
|
3405
|
+
if (typeof item === "object") {
|
|
3406
|
+
return String(item.name ?? "");
|
|
3407
|
+
}
|
|
3408
|
+
return String(item);
|
|
3409
|
+
}).filter(Boolean);
|
|
3410
|
+
return names.length ? names : void 0;
|
|
3411
|
+
}
|
|
3412
|
+
function mapSystemUser(item) {
|
|
3413
|
+
if (!item || typeof item !== "object") return null;
|
|
3414
|
+
const row = item;
|
|
3415
|
+
const userId = row.userId ?? row.user_id ?? row.id;
|
|
3416
|
+
if (userId === void 0 || userId === null || userId === "") return null;
|
|
3417
|
+
return {
|
|
3418
|
+
userId: String(userId),
|
|
3419
|
+
username: String(row.username ?? row.account ?? ""),
|
|
3420
|
+
name: String(row.name ?? ""),
|
|
3421
|
+
groupIds: asIdList(row.groupIds ?? row.group_ids ?? row.groups),
|
|
3422
|
+
roleIds: asIdList(row.roleIds ?? row.role_ids ?? row.roles),
|
|
3423
|
+
groupNames: asNameList(row.groupNames ?? row.group_names ?? row.groups),
|
|
3424
|
+
roleNames: asNameList(row.roleNames ?? row.role_names ?? row.roles),
|
|
3425
|
+
enabled: Boolean(row.enabled ?? row.enable ?? true)
|
|
3426
|
+
};
|
|
3427
|
+
}
|
|
3428
|
+
function mapSystemGroupOption(item) {
|
|
3429
|
+
if (!item || typeof item !== "object") return null;
|
|
3430
|
+
const row = item;
|
|
3431
|
+
const groupId = row.groupId ?? row.group_id ?? row.id;
|
|
3432
|
+
if (groupId === void 0 || groupId === null || groupId === "") return null;
|
|
3433
|
+
return {
|
|
3434
|
+
groupId: String(groupId),
|
|
3435
|
+
name: String(row.name ?? "")
|
|
3436
|
+
};
|
|
3437
|
+
}
|
|
3438
|
+
function mapSystemRoleOption(item) {
|
|
3439
|
+
if (!item || typeof item !== "object") return null;
|
|
3440
|
+
const row = item;
|
|
3441
|
+
const roleId = row.roleId ?? row.role_id ?? row.id;
|
|
3442
|
+
if (roleId === void 0 || roleId === null || roleId === "") return null;
|
|
3443
|
+
return {
|
|
3444
|
+
roleId: String(roleId),
|
|
3445
|
+
name: String(row.name ?? "")
|
|
3446
|
+
};
|
|
3447
|
+
}
|
|
3448
|
+
function validateUsername(username) {
|
|
3449
|
+
const value = username.trim();
|
|
3450
|
+
if (value.length < 6) return "\u8D26\u53F7\u957F\u5EA6\u4E0D\u5C11\u4E8E 6 \u4E2A\u5B57\u7B26";
|
|
3451
|
+
if (!/[A-Za-z]/.test(value) || !/[0-9]/.test(value)) {
|
|
3452
|
+
return "\u8D26\u53F7\u9700\u540C\u65F6\u5305\u542B\u5B57\u6BCD\u548C\u6570\u5B57";
|
|
3453
|
+
}
|
|
3454
|
+
return null;
|
|
3455
|
+
}
|
|
3456
|
+
function buildListUrl3(params) {
|
|
3457
|
+
const parts = [];
|
|
3458
|
+
appendQueryParam(parts, "keyword", params?.keyword ?? "");
|
|
3459
|
+
if (params?.enabled !== void 0) {
|
|
3460
|
+
appendQueryParam(parts, "enabled", String(params.enabled));
|
|
3461
|
+
}
|
|
3462
|
+
appendQueryParam(parts, "page-token", params?.pagination?.pageToken ?? "");
|
|
3463
|
+
appendQueryParam(parts, "page-size", params?.pagination?.pageSize ?? "20");
|
|
3464
|
+
appendQueryParam(parts, "page-direction", params?.pagination?.pageDirection ?? "current");
|
|
3465
|
+
return parts.length ? `/system/users?${parts.join("&")}` : "/system/users";
|
|
3466
|
+
}
|
|
3467
|
+
function buildKeywordUrl(base, keyword) {
|
|
3468
|
+
const parts = [];
|
|
3469
|
+
appendQueryParam(parts, "keyword", keyword ?? "");
|
|
3470
|
+
return parts.length ? `${base}?${parts.join("&")}` : base;
|
|
3471
|
+
}
|
|
3472
|
+
function buildCreateUserBody(values) {
|
|
3473
|
+
return {
|
|
3474
|
+
username: values.username.trim(),
|
|
3475
|
+
name: values.name.trim(),
|
|
3476
|
+
password: values.password,
|
|
3477
|
+
groupIds: [...new Set(values.groupIds.map(String))],
|
|
3478
|
+
roleIds: [...new Set(values.roleIds.map(String))],
|
|
3479
|
+
enabled: Boolean(values.enabled)
|
|
3480
|
+
};
|
|
3481
|
+
}
|
|
3482
|
+
function buildUpdateUserBody(values) {
|
|
3483
|
+
const body = {
|
|
3484
|
+
username: values.username.trim(),
|
|
3485
|
+
name: values.name.trim(),
|
|
3486
|
+
groupIds: [...new Set(values.groupIds.map(String))],
|
|
3487
|
+
roleIds: [...new Set(values.roleIds.map(String))],
|
|
3488
|
+
enabled: Boolean(values.enabled)
|
|
3489
|
+
};
|
|
3490
|
+
if (values.password.trim()) {
|
|
3491
|
+
body.password = values.password;
|
|
3492
|
+
}
|
|
3493
|
+
return body;
|
|
3494
|
+
}
|
|
3495
|
+
function createSystemUserApi(request) {
|
|
3496
|
+
return {
|
|
3497
|
+
async list(params, signal) {
|
|
3498
|
+
const json = await request({
|
|
3499
|
+
method: "GET",
|
|
3500
|
+
url: buildListUrl3(params),
|
|
3501
|
+
signal
|
|
3502
|
+
});
|
|
3503
|
+
const records = extractRecords(json).map(mapSystemUser).filter((item) => item !== null);
|
|
3504
|
+
return {
|
|
3505
|
+
records,
|
|
3506
|
+
...extractPagination(json)
|
|
3507
|
+
};
|
|
3508
|
+
},
|
|
3509
|
+
async create(values, signal) {
|
|
3510
|
+
return request({
|
|
3511
|
+
method: "POST",
|
|
3512
|
+
url: "/system/users",
|
|
3513
|
+
body: buildCreateUserBody(values),
|
|
3514
|
+
signal
|
|
3515
|
+
});
|
|
3516
|
+
},
|
|
3517
|
+
async update(userId, values, signal) {
|
|
3518
|
+
return request({
|
|
3519
|
+
method: "PATCH",
|
|
3520
|
+
url: `/system/users/${encodeURIComponent(userId)}`,
|
|
3521
|
+
body: buildUpdateUserBody(values),
|
|
3522
|
+
signal
|
|
3523
|
+
});
|
|
3524
|
+
},
|
|
3525
|
+
async remove(userId, signal) {
|
|
3526
|
+
return request({
|
|
3527
|
+
method: "DELETE",
|
|
3528
|
+
url: `/system/users/${encodeURIComponent(userId)}`,
|
|
3529
|
+
signal
|
|
3530
|
+
});
|
|
3531
|
+
},
|
|
3532
|
+
async listGroups(params, signal) {
|
|
3533
|
+
const json = await request({
|
|
3534
|
+
method: "GET",
|
|
3535
|
+
url: buildKeywordUrl("/system/groups", params?.keyword),
|
|
3536
|
+
signal
|
|
3537
|
+
});
|
|
3538
|
+
return extractRecords(json).map(mapSystemGroupOption).filter((item) => item !== null);
|
|
3539
|
+
},
|
|
3540
|
+
async listRoleOptions(params, signal) {
|
|
3541
|
+
const json = await request({
|
|
3542
|
+
method: "GET",
|
|
3543
|
+
url: buildKeywordUrl("/system/roles", params?.keyword),
|
|
3544
|
+
signal
|
|
3545
|
+
});
|
|
3546
|
+
return extractRecords(json).map(mapSystemRoleOption).filter((item) => item !== null);
|
|
3547
|
+
}
|
|
3548
|
+
};
|
|
3549
|
+
}
|
|
3550
|
+
|
|
3551
|
+
// src/vue/UserManager.ts
|
|
3552
|
+
var PAGE_SIZE_OPTIONS4 = ["10", "20", "50", "100"];
|
|
3553
|
+
function emptyForm4() {
|
|
3554
|
+
return {
|
|
3555
|
+
username: "",
|
|
3556
|
+
name: "",
|
|
3557
|
+
password: "",
|
|
3558
|
+
groupIds: [],
|
|
3559
|
+
roleIds: [],
|
|
3560
|
+
enabled: true
|
|
3561
|
+
};
|
|
3562
|
+
}
|
|
3563
|
+
var s4 = {
|
|
3564
|
+
root: {
|
|
3565
|
+
display: "flex",
|
|
3566
|
+
flexDirection: "column",
|
|
3567
|
+
gap: "16px",
|
|
3568
|
+
padding: "16px",
|
|
3569
|
+
color: "#101828",
|
|
3570
|
+
fontFamily: '"PingFang SC", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, sans-serif'
|
|
3571
|
+
},
|
|
3572
|
+
toolbar: {
|
|
3573
|
+
display: "flex",
|
|
3574
|
+
alignItems: "center",
|
|
3575
|
+
justifyContent: "space-between",
|
|
3576
|
+
gap: "12px"
|
|
3577
|
+
},
|
|
3578
|
+
title: { margin: "0", fontSize: "18px", fontWeight: "600" },
|
|
3579
|
+
toolbarRight: { display: "flex", alignItems: "center", gap: "8px" },
|
|
3580
|
+
searchBar: {
|
|
3581
|
+
display: "flex",
|
|
3582
|
+
alignItems: "center",
|
|
3583
|
+
gap: "8px",
|
|
3584
|
+
flexWrap: "wrap"
|
|
3585
|
+
},
|
|
3586
|
+
error: {
|
|
3587
|
+
padding: "10px 12px",
|
|
3588
|
+
borderRadius: "8px",
|
|
3589
|
+
background: "#fef3f2",
|
|
3590
|
+
color: "#b42318",
|
|
3591
|
+
fontSize: "13px"
|
|
3592
|
+
},
|
|
3593
|
+
tableWrap: {
|
|
3594
|
+
overflow: "auto",
|
|
3595
|
+
border: "1px solid #eaecf0",
|
|
3596
|
+
borderRadius: "10px",
|
|
3597
|
+
background: "#fff"
|
|
3598
|
+
},
|
|
3599
|
+
table: { width: "100%", borderCollapse: "collapse", minWidth: "720px" },
|
|
3600
|
+
th: {
|
|
3601
|
+
textAlign: "left",
|
|
3602
|
+
padding: "12px 14px",
|
|
3603
|
+
fontSize: "13px",
|
|
3604
|
+
fontWeight: "600",
|
|
3605
|
+
color: "#475467",
|
|
3606
|
+
background: "#f9fafb",
|
|
3607
|
+
borderBottom: "1px solid #eaecf0"
|
|
3608
|
+
},
|
|
3609
|
+
td: {
|
|
3610
|
+
padding: "12px 14px",
|
|
3611
|
+
fontSize: "14px",
|
|
3612
|
+
borderBottom: "1px solid #f2f4f7",
|
|
3613
|
+
verticalAlign: "middle"
|
|
3614
|
+
},
|
|
3615
|
+
empty: {
|
|
3616
|
+
padding: "28px",
|
|
3617
|
+
textAlign: "center",
|
|
3618
|
+
color: "#98a2b3",
|
|
3619
|
+
fontSize: "14px"
|
|
3620
|
+
},
|
|
3621
|
+
linkBtn: {
|
|
3622
|
+
border: "none",
|
|
3623
|
+
background: "transparent",
|
|
3624
|
+
color: "#049BAD",
|
|
3625
|
+
cursor: "pointer",
|
|
3626
|
+
padding: "0 8px 0 0",
|
|
3627
|
+
fontSize: "13px"
|
|
3628
|
+
},
|
|
3629
|
+
badge: {
|
|
3630
|
+
display: "inline-block",
|
|
3631
|
+
padding: "2px 8px",
|
|
3632
|
+
borderRadius: "999px",
|
|
3633
|
+
fontSize: "12px",
|
|
3634
|
+
fontWeight: "500"
|
|
3635
|
+
},
|
|
3636
|
+
badgeOn: { background: "#ecfdf3", color: "#027a48" },
|
|
3637
|
+
badgeOff: { background: "#f2f4f7", color: "#667085" },
|
|
3638
|
+
pagination: {
|
|
3639
|
+
display: "flex",
|
|
3640
|
+
alignItems: "center",
|
|
3641
|
+
justifyContent: "space-between",
|
|
3642
|
+
gap: "12px"
|
|
3643
|
+
},
|
|
3644
|
+
pageSize: {
|
|
3645
|
+
display: "flex",
|
|
3646
|
+
alignItems: "center",
|
|
3647
|
+
gap: "8px",
|
|
3648
|
+
fontSize: "13px",
|
|
3649
|
+
color: "#475467"
|
|
3650
|
+
},
|
|
3651
|
+
pageBtns: { display: "flex", gap: "8px" },
|
|
3652
|
+
primaryBtn: {
|
|
3653
|
+
border: "none",
|
|
3654
|
+
background: "#049BAD",
|
|
3655
|
+
color: "#fff",
|
|
3656
|
+
borderRadius: "8px",
|
|
3657
|
+
padding: "8px 14px",
|
|
3658
|
+
cursor: "pointer",
|
|
3659
|
+
fontSize: "14px"
|
|
3660
|
+
},
|
|
3661
|
+
secondaryBtn: {
|
|
3662
|
+
border: "1px solid #d0d5dd",
|
|
3663
|
+
background: "#fff",
|
|
3664
|
+
color: "#344054",
|
|
3665
|
+
borderRadius: "8px",
|
|
3666
|
+
padding: "8px 14px",
|
|
3667
|
+
cursor: "pointer",
|
|
3668
|
+
fontSize: "14px"
|
|
3669
|
+
},
|
|
3670
|
+
dangerBtn: {
|
|
3671
|
+
border: "none",
|
|
3672
|
+
background: "#d92d20",
|
|
3673
|
+
color: "#fff",
|
|
3674
|
+
borderRadius: "8px",
|
|
3675
|
+
padding: "8px 14px",
|
|
3676
|
+
cursor: "pointer",
|
|
3677
|
+
fontSize: "14px"
|
|
3678
|
+
},
|
|
3679
|
+
select: {
|
|
3680
|
+
border: "1px solid #d0d5dd",
|
|
3681
|
+
borderRadius: "6px",
|
|
3682
|
+
padding: "4px 8px",
|
|
3683
|
+
fontSize: "13px",
|
|
3684
|
+
backgroundColor: "#ffffff",
|
|
3685
|
+
color: "#101828"
|
|
3686
|
+
},
|
|
3687
|
+
mask: {
|
|
3688
|
+
position: "fixed",
|
|
3689
|
+
inset: "0",
|
|
3690
|
+
background: "rgba(16, 24, 40, 0.45)",
|
|
3691
|
+
display: "flex",
|
|
3692
|
+
alignItems: "center",
|
|
3693
|
+
justifyContent: "center",
|
|
3694
|
+
zIndex: "1000",
|
|
3695
|
+
padding: "16px"
|
|
3696
|
+
},
|
|
3697
|
+
dialog: {
|
|
3698
|
+
width: "100%",
|
|
3699
|
+
maxWidth: "480px",
|
|
3700
|
+
background: "#fff",
|
|
3701
|
+
borderRadius: "12px",
|
|
3702
|
+
boxShadow: "0 20px 40px rgba(16,24,40,0.18)",
|
|
3703
|
+
maxHeight: "90vh",
|
|
3704
|
+
overflow: "auto"
|
|
3705
|
+
},
|
|
3706
|
+
dialogHeader: {
|
|
3707
|
+
display: "flex",
|
|
3708
|
+
alignItems: "center",
|
|
3709
|
+
justifyContent: "space-between",
|
|
3710
|
+
padding: "14px 16px",
|
|
3711
|
+
borderBottom: "1px solid #eaecf0",
|
|
3712
|
+
position: "sticky",
|
|
3713
|
+
top: "0",
|
|
3714
|
+
background: "#fff",
|
|
3715
|
+
zIndex: "1"
|
|
3716
|
+
},
|
|
3717
|
+
dialogTitle: { margin: "0", fontSize: "16px", fontWeight: "600" },
|
|
3718
|
+
iconBtn: {
|
|
3719
|
+
border: "none",
|
|
3720
|
+
background: "transparent",
|
|
3721
|
+
fontSize: "22px",
|
|
3722
|
+
lineHeight: "1",
|
|
3723
|
+
cursor: "pointer",
|
|
3724
|
+
color: "#667085"
|
|
3725
|
+
},
|
|
3726
|
+
form: {
|
|
3727
|
+
display: "flex",
|
|
3728
|
+
flexDirection: "column",
|
|
3729
|
+
gap: "12px",
|
|
3730
|
+
padding: "16px"
|
|
3731
|
+
},
|
|
3732
|
+
confirmBody: {
|
|
3733
|
+
display: "flex",
|
|
3734
|
+
flexDirection: "column",
|
|
3735
|
+
gap: "16px",
|
|
3736
|
+
padding: "16px"
|
|
3737
|
+
},
|
|
3738
|
+
confirmText: {
|
|
3739
|
+
margin: "0",
|
|
3740
|
+
fontSize: "14px",
|
|
3741
|
+
color: "#344054",
|
|
3742
|
+
lineHeight: "1.6"
|
|
3743
|
+
},
|
|
3744
|
+
field: { display: "flex", flexDirection: "column", gap: "6px" },
|
|
3745
|
+
fieldset: {
|
|
3746
|
+
border: "1px solid #eaecf0",
|
|
3747
|
+
borderRadius: "8px",
|
|
3748
|
+
margin: "0",
|
|
3749
|
+
padding: "10px 12px 12px"
|
|
3750
|
+
},
|
|
3751
|
+
label: { fontSize: "13px", color: "#344054", fontWeight: "500" },
|
|
3752
|
+
input: {
|
|
3753
|
+
border: "1px solid #d0d5dd",
|
|
3754
|
+
borderRadius: "8px",
|
|
3755
|
+
padding: "8px 10px",
|
|
3756
|
+
fontSize: "14px",
|
|
3757
|
+
outline: "none",
|
|
3758
|
+
backgroundColor: "#ffffff",
|
|
3759
|
+
color: "#101828",
|
|
3760
|
+
boxSizing: "border-box",
|
|
3761
|
+
width: "100%"
|
|
3762
|
+
},
|
|
3763
|
+
multiSelect: {
|
|
3764
|
+
display: "flex",
|
|
3765
|
+
flexDirection: "column",
|
|
3766
|
+
gap: "6px",
|
|
3767
|
+
maxHeight: "160px",
|
|
3768
|
+
overflow: "auto",
|
|
3769
|
+
marginTop: "8px"
|
|
3770
|
+
},
|
|
3771
|
+
checkItem: {
|
|
3772
|
+
display: "flex",
|
|
3773
|
+
alignItems: "center",
|
|
3774
|
+
gap: "8px",
|
|
3775
|
+
fontSize: "14px",
|
|
3776
|
+
color: "#101828",
|
|
3777
|
+
cursor: "pointer"
|
|
3778
|
+
},
|
|
3779
|
+
control: {
|
|
3780
|
+
width: "16px",
|
|
3781
|
+
height: "16px",
|
|
3782
|
+
accentColor: "#049BAD",
|
|
3783
|
+
cursor: "pointer",
|
|
3784
|
+
colorScheme: "light",
|
|
3785
|
+
backgroundColor: "#ffffff"
|
|
3786
|
+
},
|
|
3787
|
+
hint: { fontSize: "13px", color: "#98a2b3", padding: "4px 0" },
|
|
3788
|
+
selectTrigger: {
|
|
3789
|
+
display: "flex",
|
|
3790
|
+
alignItems: "center",
|
|
3791
|
+
justifyContent: "space-between",
|
|
3792
|
+
gap: "8px",
|
|
3793
|
+
width: "100%",
|
|
3794
|
+
border: "1px solid #d0d5dd",
|
|
3795
|
+
borderRadius: "8px",
|
|
3796
|
+
padding: "8px 10px",
|
|
3797
|
+
background: "#fff",
|
|
3798
|
+
cursor: "pointer",
|
|
3799
|
+
fontSize: "14px",
|
|
3800
|
+
color: "#101828",
|
|
3801
|
+
boxSizing: "border-box",
|
|
3802
|
+
textAlign: "left"
|
|
3803
|
+
},
|
|
3804
|
+
selectTriggerText: {
|
|
3805
|
+
flex: "1",
|
|
3806
|
+
overflow: "hidden",
|
|
3807
|
+
textOverflow: "ellipsis",
|
|
3808
|
+
whiteSpace: "nowrap"
|
|
3809
|
+
},
|
|
3810
|
+
selectPlaceholder: { color: "#98a2b3" },
|
|
3811
|
+
selectChevron: { color: "#667085", fontSize: "10px", flexShrink: "0" },
|
|
3812
|
+
required: { color: "#d92d20", marginLeft: "2px" },
|
|
3813
|
+
switchRow: {
|
|
3814
|
+
display: "flex",
|
|
3815
|
+
alignItems: "center",
|
|
3816
|
+
justifyContent: "flex-start",
|
|
3817
|
+
gap: "12px"
|
|
3818
|
+
},
|
|
3819
|
+
switchTrack: {
|
|
3820
|
+
width: "44px",
|
|
3821
|
+
height: "24px",
|
|
3822
|
+
borderRadius: "999px",
|
|
3823
|
+
border: "none",
|
|
3824
|
+
padding: "2px",
|
|
3825
|
+
background: "#d0d5dd",
|
|
3826
|
+
cursor: "pointer",
|
|
3827
|
+
position: "relative",
|
|
3828
|
+
transition: "background 0.15s ease"
|
|
3829
|
+
},
|
|
3830
|
+
switchTrackOn: { background: "#049BAD" },
|
|
3831
|
+
switchThumb: {
|
|
3832
|
+
display: "block",
|
|
3833
|
+
width: "20px",
|
|
3834
|
+
height: "20px",
|
|
3835
|
+
borderRadius: "50%",
|
|
3836
|
+
background: "#fff",
|
|
3837
|
+
boxShadow: "0 1px 2px rgba(16,24,40,0.2)",
|
|
3838
|
+
transform: "translateX(0)",
|
|
3839
|
+
transition: "transform 0.15s ease"
|
|
3840
|
+
},
|
|
3841
|
+
switchThumbOn: { transform: "translateX(20px)" },
|
|
3842
|
+
dialogFooter: {
|
|
3843
|
+
display: "flex",
|
|
3844
|
+
justifyContent: "flex-end",
|
|
3845
|
+
gap: "8px",
|
|
3846
|
+
paddingTop: "4px"
|
|
3847
|
+
}
|
|
3848
|
+
};
|
|
3849
|
+
var UserManager = defineComponent5({
|
|
3850
|
+
name: "UserManager",
|
|
3851
|
+
props: {
|
|
3852
|
+
api: {
|
|
3853
|
+
type: Object,
|
|
3854
|
+
required: true
|
|
3855
|
+
},
|
|
3856
|
+
title: {
|
|
3857
|
+
type: String,
|
|
3858
|
+
default: "\u7528\u6237\u7BA1\u7406"
|
|
3859
|
+
},
|
|
3860
|
+
pageSize: {
|
|
3861
|
+
type: String,
|
|
3862
|
+
default: "20"
|
|
3863
|
+
}
|
|
3864
|
+
},
|
|
3865
|
+
setup(props, { slots }) {
|
|
3866
|
+
const records = ref4([]);
|
|
3867
|
+
const loading = ref4(false);
|
|
3868
|
+
const error = ref4("");
|
|
3869
|
+
const keyword = ref4("");
|
|
3870
|
+
const keywordInput = ref4("");
|
|
3871
|
+
const enabledFilter = ref4("all");
|
|
3872
|
+
const pageSize = ref4(props.pageSize);
|
|
3873
|
+
const pageToken = ref4("");
|
|
3874
|
+
const hasPreviousPage = ref4(false);
|
|
3875
|
+
const hasNextPage = ref4(false);
|
|
3876
|
+
const dialogOpen = ref4(false);
|
|
3877
|
+
const editing = ref4(null);
|
|
3878
|
+
const form = reactive4(emptyForm4());
|
|
3879
|
+
const formError = ref4("");
|
|
3880
|
+
const saving = ref4(false);
|
|
3881
|
+
const deletingRow = ref4(null);
|
|
3882
|
+
const deleting = ref4(false);
|
|
3883
|
+
const groups = ref4([]);
|
|
3884
|
+
const roles = ref4([]);
|
|
3885
|
+
const rolesLoading = ref4(false);
|
|
3886
|
+
const groupsOpen = ref4(false);
|
|
3887
|
+
const groupsLoading = ref4(false);
|
|
3888
|
+
const groupsLoaded = ref4(false);
|
|
3889
|
+
function enabledParam() {
|
|
3890
|
+
if (enabledFilter.value === "all") return void 0;
|
|
3891
|
+
return enabledFilter.value === "true";
|
|
3892
|
+
}
|
|
3893
|
+
async function loadList(direction = "current", token = pageToken.value) {
|
|
3894
|
+
loading.value = true;
|
|
3895
|
+
error.value = "";
|
|
3896
|
+
try {
|
|
3897
|
+
const result = await props.api.list({
|
|
3898
|
+
keyword: keyword.value,
|
|
3899
|
+
enabled: enabledParam(),
|
|
3900
|
+
pagination: {
|
|
3901
|
+
pageToken: token,
|
|
3902
|
+
pageSize: pageSize.value,
|
|
3903
|
+
pageDirection: direction
|
|
3904
|
+
}
|
|
3905
|
+
});
|
|
3906
|
+
records.value = result.records;
|
|
3907
|
+
pageToken.value = result.pageToken;
|
|
3908
|
+
hasPreviousPage.value = result.hasPreviousPage;
|
|
3909
|
+
hasNextPage.value = result.hasNextPage;
|
|
3910
|
+
} catch (err) {
|
|
3911
|
+
error.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u5931\u8D25";
|
|
3912
|
+
} finally {
|
|
3913
|
+
loading.value = false;
|
|
3914
|
+
}
|
|
3915
|
+
}
|
|
3916
|
+
async function loadRoles() {
|
|
3917
|
+
rolesLoading.value = true;
|
|
3918
|
+
try {
|
|
3919
|
+
roles.value = await props.api.listRoleOptions();
|
|
3920
|
+
} catch (err) {
|
|
3921
|
+
formError.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u89D2\u8272\u5931\u8D25";
|
|
3922
|
+
} finally {
|
|
3923
|
+
rolesLoading.value = false;
|
|
3924
|
+
}
|
|
3925
|
+
}
|
|
3926
|
+
async function loadGroups() {
|
|
3927
|
+
if (groupsLoaded.value || groupsLoading.value) return;
|
|
3928
|
+
groupsLoading.value = true;
|
|
3929
|
+
try {
|
|
3930
|
+
groups.value = await props.api.listGroups();
|
|
3931
|
+
groupsLoaded.value = true;
|
|
3932
|
+
} catch (err) {
|
|
3933
|
+
formError.value = err instanceof Error ? err.message : "\u52A0\u8F7D\u90E8\u95E8\u5931\u8D25";
|
|
3934
|
+
} finally {
|
|
3935
|
+
groupsLoading.value = false;
|
|
3936
|
+
}
|
|
3937
|
+
}
|
|
3938
|
+
function handleSearch() {
|
|
3939
|
+
pageToken.value = "";
|
|
3940
|
+
keyword.value = keywordInput.value.trim();
|
|
3941
|
+
}
|
|
3942
|
+
function handleReset() {
|
|
3943
|
+
keywordInput.value = "";
|
|
3944
|
+
keyword.value = "";
|
|
3945
|
+
enabledFilter.value = "all";
|
|
3946
|
+
pageToken.value = "";
|
|
3947
|
+
}
|
|
3948
|
+
function resetGroupPanel() {
|
|
3949
|
+
groupsOpen.value = false;
|
|
3950
|
+
groups.value = [];
|
|
3951
|
+
groupsLoaded.value = false;
|
|
3952
|
+
}
|
|
3953
|
+
function openCreate() {
|
|
3954
|
+
editing.value = null;
|
|
3955
|
+
Object.assign(form, emptyForm4());
|
|
3956
|
+
formError.value = "";
|
|
3957
|
+
resetGroupPanel();
|
|
3958
|
+
dialogOpen.value = true;
|
|
3959
|
+
void loadRoles();
|
|
3960
|
+
}
|
|
3961
|
+
function openEdit(row) {
|
|
3962
|
+
editing.value = row;
|
|
3963
|
+
Object.assign(form, {
|
|
3964
|
+
username: row.username,
|
|
3965
|
+
name: row.name,
|
|
3966
|
+
password: "",
|
|
3967
|
+
groupIds: [...row.groupIds],
|
|
3968
|
+
roleIds: [...row.roleIds],
|
|
3969
|
+
enabled: row.enabled
|
|
3970
|
+
});
|
|
3971
|
+
formError.value = "";
|
|
3972
|
+
resetGroupPanel();
|
|
3973
|
+
dialogOpen.value = true;
|
|
3974
|
+
void loadRoles();
|
|
3975
|
+
}
|
|
3976
|
+
function closeDialog() {
|
|
3977
|
+
if (!saving.value) dialogOpen.value = false;
|
|
3978
|
+
}
|
|
3979
|
+
function toggleGroupsPanel() {
|
|
3980
|
+
groupsOpen.value = !groupsOpen.value;
|
|
3981
|
+
if (groupsOpen.value) void loadGroups();
|
|
3982
|
+
}
|
|
3983
|
+
function toggleId(field, id) {
|
|
3984
|
+
const exists = form[field].includes(id);
|
|
3985
|
+
form[field] = exists ? form[field].filter((x) => x !== id) : [...form[field], id];
|
|
3986
|
+
}
|
|
3987
|
+
async function handleSubmit(event) {
|
|
3988
|
+
event.preventDefault();
|
|
3989
|
+
const usernameError = validateUsername(form.username);
|
|
3990
|
+
if (usernameError) {
|
|
3991
|
+
formError.value = usernameError;
|
|
3992
|
+
return;
|
|
3993
|
+
}
|
|
3994
|
+
if (!form.name.trim()) {
|
|
3995
|
+
formError.value = "\u8BF7\u586B\u5199\u7528\u6237\u540D";
|
|
3996
|
+
return;
|
|
3997
|
+
}
|
|
3998
|
+
if (!editing.value && !form.password.trim()) {
|
|
3999
|
+
formError.value = "\u8BF7\u586B\u5199\u521D\u59CB\u5BC6\u7801";
|
|
4000
|
+
return;
|
|
4001
|
+
}
|
|
4002
|
+
if (!form.groupIds.length) {
|
|
4003
|
+
formError.value = "\u8BF7\u9009\u62E9\u5F52\u5C5E\u90E8\u95E8";
|
|
4004
|
+
return;
|
|
4005
|
+
}
|
|
4006
|
+
saving.value = true;
|
|
4007
|
+
formError.value = "";
|
|
4008
|
+
error.value = "";
|
|
4009
|
+
try {
|
|
4010
|
+
if (editing.value) {
|
|
4011
|
+
await props.api.update(editing.value.userId, { ...form });
|
|
4012
|
+
} else {
|
|
4013
|
+
await props.api.create({ ...form });
|
|
4014
|
+
}
|
|
4015
|
+
dialogOpen.value = false;
|
|
4016
|
+
await loadList("current", "");
|
|
4017
|
+
} catch (err) {
|
|
4018
|
+
formError.value = err instanceof Error ? err.message : "\u4FDD\u5B58\u5931\u8D25";
|
|
4019
|
+
} finally {
|
|
4020
|
+
saving.value = false;
|
|
4021
|
+
}
|
|
4022
|
+
}
|
|
4023
|
+
function askDelete(row) {
|
|
4024
|
+
deletingRow.value = row;
|
|
4025
|
+
}
|
|
4026
|
+
function closeDeleteDialog() {
|
|
4027
|
+
if (!deleting.value) deletingRow.value = null;
|
|
4028
|
+
}
|
|
4029
|
+
async function confirmDelete() {
|
|
4030
|
+
if (!deletingRow.value) return;
|
|
4031
|
+
deleting.value = true;
|
|
4032
|
+
error.value = "";
|
|
4033
|
+
try {
|
|
4034
|
+
await props.api.remove(deletingRow.value.userId);
|
|
4035
|
+
deletingRow.value = null;
|
|
4036
|
+
await loadList("current", "");
|
|
4037
|
+
} catch (err) {
|
|
4038
|
+
error.value = err instanceof Error ? err.message : "\u5220\u9664\u5931\u8D25";
|
|
4039
|
+
} finally {
|
|
4040
|
+
deleting.value = false;
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
function groupLabel(row) {
|
|
4044
|
+
if (row.groupNames?.length) return row.groupNames.join("\u3001");
|
|
4045
|
+
if (!row.groupIds.length) return "\u2014";
|
|
4046
|
+
return row.groupIds.join("\u3001");
|
|
4047
|
+
}
|
|
4048
|
+
function roleLabel(row) {
|
|
4049
|
+
if (row.roleNames?.length) return row.roleNames.join("\u3001");
|
|
4050
|
+
if (!row.roleIds.length) return "\u2014";
|
|
4051
|
+
const map = new Map(roles.value.map((r) => [r.roleId, r.name]));
|
|
4052
|
+
return row.roleIds.map((id) => map.get(id) || id).join("\u3001");
|
|
4053
|
+
}
|
|
4054
|
+
function selectedGroupSummary() {
|
|
4055
|
+
if (!form.groupIds.length) return "\u8BF7\u9009\u62E9\u5F52\u5C5E\u90E8\u95E8";
|
|
4056
|
+
if (groupsLoaded.value) {
|
|
4057
|
+
const map = new Map(groups.value.map((g) => [g.groupId, g.name]));
|
|
4058
|
+
return form.groupIds.map((id) => map.get(id) || id).join("\u3001");
|
|
4059
|
+
}
|
|
4060
|
+
if (editing.value?.groupNames?.length) {
|
|
4061
|
+
const map = new Map(
|
|
4062
|
+
editing.value.groupIds.map((id, i) => [
|
|
4063
|
+
id,
|
|
4064
|
+
editing.value?.groupNames?.[i] || id
|
|
4065
|
+
])
|
|
4066
|
+
);
|
|
4067
|
+
return form.groupIds.map((id) => map.get(id) || id).join("\u3001");
|
|
4068
|
+
}
|
|
4069
|
+
return `\u5DF2\u9009 ${form.groupIds.length} \u4E2A\u90E8\u95E8`;
|
|
4070
|
+
}
|
|
4071
|
+
onMounted4(() => {
|
|
4072
|
+
void loadList("current", "");
|
|
4073
|
+
void (async () => {
|
|
4074
|
+
try {
|
|
4075
|
+
roles.value = await props.api.listRoleOptions();
|
|
4076
|
+
} catch {
|
|
4077
|
+
}
|
|
4078
|
+
})();
|
|
4079
|
+
});
|
|
4080
|
+
watch4(
|
|
4081
|
+
() => [
|
|
4082
|
+
props.api,
|
|
4083
|
+
pageSize.value,
|
|
4084
|
+
keyword.value,
|
|
4085
|
+
enabledFilter.value
|
|
4086
|
+
],
|
|
4087
|
+
() => {
|
|
4088
|
+
pageToken.value = "";
|
|
4089
|
+
void loadList("current", "");
|
|
4090
|
+
}
|
|
4091
|
+
);
|
|
4092
|
+
return () => h4("div", { style: s4.root }, [
|
|
4093
|
+
h4("div", { style: s4.toolbar }, [
|
|
4094
|
+
h4("h2", { style: s4.title }, props.title),
|
|
4095
|
+
h4("div", { style: s4.toolbarRight }, [
|
|
4096
|
+
slots.toolbarExtra?.(),
|
|
4097
|
+
h4(
|
|
4098
|
+
"button",
|
|
4099
|
+
{ type: "button", style: s4.primaryBtn, onClick: openCreate },
|
|
4100
|
+
"\u65B0\u589E\u7528\u6237"
|
|
4101
|
+
)
|
|
4102
|
+
])
|
|
4103
|
+
]),
|
|
4104
|
+
h4("div", { style: s4.searchBar }, [
|
|
4105
|
+
h4("input", {
|
|
4106
|
+
style: { ...s4.input, maxWidth: "240px" },
|
|
4107
|
+
value: keywordInput.value,
|
|
4108
|
+
placeholder: "\u641C\u7D22\u8D26\u53F7 / \u7528\u6237\u540D",
|
|
4109
|
+
onInput: (e) => {
|
|
4110
|
+
keywordInput.value = e.target.value;
|
|
4111
|
+
},
|
|
4112
|
+
onKeydown: (e) => {
|
|
4113
|
+
if (e.key === "Enter") handleSearch();
|
|
4114
|
+
}
|
|
4115
|
+
}),
|
|
4116
|
+
h4(
|
|
4117
|
+
"select",
|
|
4118
|
+
{
|
|
4119
|
+
style: s4.select,
|
|
4120
|
+
value: enabledFilter.value,
|
|
4121
|
+
onChange: (e) => {
|
|
4122
|
+
pageToken.value = "";
|
|
4123
|
+
enabledFilter.value = e.target.value;
|
|
4124
|
+
}
|
|
4125
|
+
},
|
|
4126
|
+
[
|
|
4127
|
+
h4("option", { value: "all" }, "\u5168\u90E8\u72B6\u6001"),
|
|
4128
|
+
h4("option", { value: "true" }, "\u5DF2\u542F\u7528"),
|
|
4129
|
+
h4("option", { value: "false" }, "\u5DF2\u7981\u7528")
|
|
4130
|
+
]
|
|
4131
|
+
),
|
|
4132
|
+
h4(
|
|
4133
|
+
"button",
|
|
4134
|
+
{ type: "button", style: s4.secondaryBtn, onClick: handleSearch },
|
|
4135
|
+
"\u67E5\u8BE2"
|
|
4136
|
+
),
|
|
4137
|
+
h4(
|
|
4138
|
+
"button",
|
|
4139
|
+
{ type: "button", style: s4.secondaryBtn, onClick: handleReset },
|
|
4140
|
+
"\u91CD\u7F6E"
|
|
4141
|
+
)
|
|
4142
|
+
]),
|
|
4143
|
+
error.value ? h4("div", { style: s4.error }, error.value) : null,
|
|
4144
|
+
h4("div", { style: s4.tableWrap }, [
|
|
4145
|
+
h4("table", { style: s4.table }, [
|
|
4146
|
+
h4("thead", [
|
|
4147
|
+
h4("tr", [
|
|
4148
|
+
h4("th", { style: s4.th }, "\u8D26\u53F7"),
|
|
4149
|
+
h4("th", { style: s4.th }, "\u7528\u6237\u540D"),
|
|
4150
|
+
h4("th", { style: s4.th }, "\u5F52\u5C5E\u90E8\u95E8"),
|
|
4151
|
+
h4("th", { style: s4.th }, "\u7528\u6237\u89D2\u8272"),
|
|
4152
|
+
h4("th", { style: { ...s4.th, width: "90px" } }, "\u72B6\u6001"),
|
|
4153
|
+
h4("th", { style: { ...s4.th, width: "140px" } }, "\u64CD\u4F5C")
|
|
4154
|
+
])
|
|
4155
|
+
]),
|
|
4156
|
+
h4(
|
|
4157
|
+
"tbody",
|
|
4158
|
+
loading.value ? [
|
|
4159
|
+
h4("tr", [
|
|
4160
|
+
h4("td", { colspan: 6, style: s4.empty }, "\u52A0\u8F7D\u4E2D\u2026")
|
|
4161
|
+
])
|
|
4162
|
+
] : records.value.length === 0 ? [
|
|
4163
|
+
h4("tr", [
|
|
4164
|
+
h4("td", { colspan: 6, style: s4.empty }, "\u6682\u65E0\u6570\u636E")
|
|
4165
|
+
])
|
|
4166
|
+
] : records.value.map(
|
|
4167
|
+
(row) => h4("tr", { key: row.userId }, [
|
|
4168
|
+
h4("td", { style: s4.td }, row.username),
|
|
4169
|
+
h4("td", { style: s4.td }, row.name),
|
|
4170
|
+
h4("td", { style: s4.td }, groupLabel(row)),
|
|
4171
|
+
h4("td", { style: s4.td }, roleLabel(row)),
|
|
4172
|
+
h4("td", { style: s4.td }, [
|
|
4173
|
+
h4(
|
|
4174
|
+
"span",
|
|
4175
|
+
{
|
|
4176
|
+
style: {
|
|
4177
|
+
...s4.badge,
|
|
4178
|
+
...row.enabled ? s4.badgeOn : s4.badgeOff
|
|
4179
|
+
}
|
|
4180
|
+
},
|
|
4181
|
+
row.enabled ? "\u542F\u7528" : "\u7981\u7528"
|
|
4182
|
+
)
|
|
4183
|
+
]),
|
|
4184
|
+
h4("td", { style: s4.td }, [
|
|
4185
|
+
h4(
|
|
4186
|
+
"button",
|
|
4187
|
+
{
|
|
4188
|
+
type: "button",
|
|
4189
|
+
style: s4.linkBtn,
|
|
4190
|
+
onClick: () => openEdit(row)
|
|
4191
|
+
},
|
|
4192
|
+
"\u7F16\u8F91"
|
|
4193
|
+
),
|
|
4194
|
+
h4(
|
|
4195
|
+
"button",
|
|
4196
|
+
{
|
|
4197
|
+
type: "button",
|
|
4198
|
+
style: { ...s4.linkBtn, color: "#d92d20" },
|
|
4199
|
+
onClick: () => askDelete(row)
|
|
4200
|
+
},
|
|
4201
|
+
"\u5220\u9664"
|
|
4202
|
+
)
|
|
4203
|
+
])
|
|
4204
|
+
])
|
|
4205
|
+
)
|
|
4206
|
+
)
|
|
4207
|
+
])
|
|
4208
|
+
]),
|
|
4209
|
+
h4("div", { style: s4.pagination }, [
|
|
4210
|
+
h4("label", { style: s4.pageSize }, [
|
|
4211
|
+
"\u6BCF\u9875",
|
|
4212
|
+
h4(
|
|
4213
|
+
"select",
|
|
4214
|
+
{
|
|
4215
|
+
style: s4.select,
|
|
4216
|
+
value: pageSize.value,
|
|
4217
|
+
onChange: (e) => {
|
|
4218
|
+
pageSize.value = e.target.value;
|
|
4219
|
+
}
|
|
4220
|
+
},
|
|
4221
|
+
PAGE_SIZE_OPTIONS4.map(
|
|
4222
|
+
(size) => h4("option", { key: size, value: size }, size)
|
|
4223
|
+
)
|
|
4224
|
+
)
|
|
4225
|
+
]),
|
|
4226
|
+
h4("div", { style: s4.pageBtns }, [
|
|
4227
|
+
h4(
|
|
4228
|
+
"button",
|
|
4229
|
+
{
|
|
4230
|
+
type: "button",
|
|
4231
|
+
style: s4.secondaryBtn,
|
|
4232
|
+
disabled: !hasPreviousPage.value || loading.value,
|
|
4233
|
+
onClick: () => void loadList("previous")
|
|
4234
|
+
},
|
|
4235
|
+
"\u4E0A\u4E00\u9875"
|
|
4236
|
+
),
|
|
4237
|
+
h4(
|
|
4238
|
+
"button",
|
|
4239
|
+
{
|
|
4240
|
+
type: "button",
|
|
4241
|
+
style: s4.secondaryBtn,
|
|
4242
|
+
disabled: !hasNextPage.value || loading.value,
|
|
4243
|
+
onClick: () => void loadList("next")
|
|
4244
|
+
},
|
|
4245
|
+
"\u4E0B\u4E00\u9875"
|
|
4246
|
+
)
|
|
4247
|
+
])
|
|
4248
|
+
]),
|
|
4249
|
+
dialogOpen.value ? h4("div", { style: s4.mask, onClick: closeDialog }, [
|
|
4250
|
+
h4(
|
|
4251
|
+
"div",
|
|
4252
|
+
{
|
|
4253
|
+
style: { ...s4.dialog, maxWidth: "560px" },
|
|
4254
|
+
role: "dialog",
|
|
4255
|
+
"aria-modal": "true",
|
|
4256
|
+
onClick: (e) => e.stopPropagation()
|
|
4257
|
+
},
|
|
4258
|
+
[
|
|
4259
|
+
h4("div", { style: s4.dialogHeader }, [
|
|
4260
|
+
h4(
|
|
4261
|
+
"h3",
|
|
4262
|
+
{ style: s4.dialogTitle },
|
|
4263
|
+
editing.value ? "\u7F16\u8F91\u7528\u6237" : "\u65B0\u589E\u7528\u6237"
|
|
4264
|
+
),
|
|
4265
|
+
h4(
|
|
4266
|
+
"button",
|
|
4267
|
+
{
|
|
4268
|
+
type: "button",
|
|
4269
|
+
style: s4.iconBtn,
|
|
4270
|
+
"aria-label": "\u5173\u95ED",
|
|
4271
|
+
onClick: closeDialog
|
|
4272
|
+
},
|
|
4273
|
+
"\xD7"
|
|
4274
|
+
)
|
|
4275
|
+
]),
|
|
4276
|
+
h4(
|
|
4277
|
+
"form",
|
|
4278
|
+
{
|
|
4279
|
+
style: s4.form,
|
|
4280
|
+
onSubmit: (e) => void handleSubmit(e)
|
|
4281
|
+
},
|
|
4282
|
+
[
|
|
4283
|
+
formError.value ? h4("div", { style: s4.error }, formError.value) : null,
|
|
4284
|
+
h4("label", { style: s4.field }, [
|
|
4285
|
+
h4("span", { style: s4.label }, "\u8D26\u53F7"),
|
|
4286
|
+
h4("input", {
|
|
4287
|
+
style: s4.input,
|
|
4288
|
+
value: form.username,
|
|
4289
|
+
placeholder: "\u81F3\u5C116\u4F4D\uFF0C\u9700\u542B\u5B57\u6BCD\u548C\u6570\u5B57",
|
|
4290
|
+
required: true,
|
|
4291
|
+
onInput: (e) => {
|
|
4292
|
+
form.username = e.target.value;
|
|
4293
|
+
}
|
|
4294
|
+
})
|
|
4295
|
+
]),
|
|
4296
|
+
h4("label", { style: s4.field }, [
|
|
4297
|
+
h4("span", { style: s4.label }, "\u7528\u6237\u540D"),
|
|
4298
|
+
h4("input", {
|
|
4299
|
+
style: s4.input,
|
|
4300
|
+
value: form.name,
|
|
4301
|
+
placeholder: "\u8BF7\u8F93\u5165\u7528\u6237\u540D",
|
|
4302
|
+
required: true,
|
|
4303
|
+
onInput: (e) => {
|
|
4304
|
+
form.name = e.target.value;
|
|
4305
|
+
}
|
|
4306
|
+
})
|
|
4307
|
+
]),
|
|
4308
|
+
h4("label", { style: s4.field }, [
|
|
4309
|
+
h4(
|
|
4310
|
+
"span",
|
|
4311
|
+
{ style: s4.label },
|
|
4312
|
+
editing.value ? "\u5BC6\u7801\uFF08\u7559\u7A7A\u5219\u4E0D\u4FEE\u6539\uFF09" : "\u521D\u59CB\u5BC6\u7801"
|
|
4313
|
+
),
|
|
4314
|
+
h4("input", {
|
|
4315
|
+
style: s4.input,
|
|
4316
|
+
type: "password",
|
|
4317
|
+
value: form.password,
|
|
4318
|
+
placeholder: editing.value ? "\u7559\u7A7A\u8868\u793A\u4E0D\u4FEE\u6539\u5BC6\u7801" : "\u8BF7\u8F93\u5165\u521D\u59CB\u5BC6\u7801",
|
|
4319
|
+
required: !editing.value,
|
|
4320
|
+
autocomplete: "new-password",
|
|
4321
|
+
onInput: (e) => {
|
|
4322
|
+
form.password = e.target.value;
|
|
4323
|
+
}
|
|
4324
|
+
})
|
|
4325
|
+
]),
|
|
4326
|
+
h4("fieldset", { style: s4.fieldset }, [
|
|
4327
|
+
h4("legend", { style: s4.label }, [
|
|
4328
|
+
"\u5F52\u5C5E\u90E8\u95E8 ",
|
|
4329
|
+
h4("span", { style: s4.required }, "*")
|
|
4330
|
+
]),
|
|
4331
|
+
h4(
|
|
4332
|
+
"button",
|
|
4333
|
+
{
|
|
4334
|
+
type: "button",
|
|
4335
|
+
style: s4.selectTrigger,
|
|
4336
|
+
"aria-expanded": groupsOpen.value,
|
|
4337
|
+
onClick: toggleGroupsPanel
|
|
4338
|
+
},
|
|
4339
|
+
[
|
|
4340
|
+
h4("span", {
|
|
4341
|
+
style: {
|
|
4342
|
+
...s4.selectTriggerText,
|
|
4343
|
+
...form.groupIds.length ? {} : s4.selectPlaceholder
|
|
4344
|
+
}
|
|
4345
|
+
}, selectedGroupSummary()),
|
|
4346
|
+
h4(
|
|
4347
|
+
"span",
|
|
4348
|
+
{ style: s4.selectChevron },
|
|
4349
|
+
groupsOpen.value ? "\u25B2" : "\u25BC"
|
|
4350
|
+
)
|
|
4351
|
+
]
|
|
4352
|
+
),
|
|
4353
|
+
groupsOpen.value ? h4("div", { style: s4.multiSelect }, [
|
|
4354
|
+
groupsLoading.value ? h4("div", { style: s4.hint }, "\u52A0\u8F7D\u4E2D\u2026") : groups.value.length === 0 ? h4("div", { style: s4.hint }, "\u6682\u65E0\u90E8\u95E8\u6570\u636E") : groups.value.map(
|
|
4355
|
+
(g) => h4(
|
|
4356
|
+
"label",
|
|
4357
|
+
{
|
|
4358
|
+
key: g.groupId,
|
|
4359
|
+
style: s4.checkItem
|
|
4360
|
+
},
|
|
4361
|
+
[
|
|
4362
|
+
h4("input", {
|
|
4363
|
+
type: "checkbox",
|
|
4364
|
+
style: s4.control,
|
|
4365
|
+
checked: form.groupIds.includes(
|
|
4366
|
+
g.groupId
|
|
4367
|
+
),
|
|
4368
|
+
onChange: () => toggleId("groupIds", g.groupId)
|
|
4369
|
+
}),
|
|
4370
|
+
h4("span", g.name || g.groupId)
|
|
4371
|
+
]
|
|
4372
|
+
)
|
|
4373
|
+
)
|
|
4374
|
+
]) : null
|
|
4375
|
+
]),
|
|
4376
|
+
h4("fieldset", { style: s4.fieldset }, [
|
|
4377
|
+
h4("legend", { style: s4.label }, "\u7528\u6237\u89D2\u8272"),
|
|
4378
|
+
h4("div", { style: s4.multiSelect }, [
|
|
4379
|
+
rolesLoading.value ? h4("div", { style: s4.hint }, "\u52A0\u8F7D\u4E2D\u2026") : roles.value.length === 0 ? h4("div", { style: s4.hint }, "\u6682\u65E0\u89D2\u8272\u6570\u636E") : roles.value.map(
|
|
4380
|
+
(r) => h4(
|
|
4381
|
+
"label",
|
|
4382
|
+
{
|
|
4383
|
+
key: r.roleId,
|
|
4384
|
+
style: s4.checkItem
|
|
4385
|
+
},
|
|
4386
|
+
[
|
|
4387
|
+
h4("input", {
|
|
4388
|
+
type: "checkbox",
|
|
4389
|
+
style: s4.control,
|
|
4390
|
+
checked: form.roleIds.includes(
|
|
4391
|
+
r.roleId
|
|
4392
|
+
),
|
|
4393
|
+
onChange: () => toggleId("roleIds", r.roleId)
|
|
4394
|
+
}),
|
|
4395
|
+
h4("span", r.name || r.roleId)
|
|
4396
|
+
]
|
|
4397
|
+
)
|
|
4398
|
+
)
|
|
4399
|
+
])
|
|
4400
|
+
]),
|
|
4401
|
+
h4("div", { style: s4.switchRow }, [
|
|
4402
|
+
h4("span", { style: s4.label }, "\u662F\u5426\u542F\u7528"),
|
|
4403
|
+
h4(
|
|
4404
|
+
"button",
|
|
4405
|
+
{
|
|
4406
|
+
type: "button",
|
|
4407
|
+
role: "switch",
|
|
4408
|
+
"aria-checked": form.enabled,
|
|
4409
|
+
style: {
|
|
4410
|
+
...s4.switchTrack,
|
|
4411
|
+
...form.enabled ? s4.switchTrackOn : {}
|
|
4412
|
+
},
|
|
4413
|
+
onClick: () => {
|
|
4414
|
+
form.enabled = !form.enabled;
|
|
4415
|
+
}
|
|
4416
|
+
},
|
|
4417
|
+
[
|
|
4418
|
+
h4("span", {
|
|
4419
|
+
style: {
|
|
4420
|
+
...s4.switchThumb,
|
|
4421
|
+
...form.enabled ? s4.switchThumbOn : {}
|
|
4422
|
+
}
|
|
4423
|
+
})
|
|
4424
|
+
]
|
|
4425
|
+
)
|
|
4426
|
+
]),
|
|
4427
|
+
h4("div", { style: s4.dialogFooter }, [
|
|
4428
|
+
h4(
|
|
4429
|
+
"button",
|
|
4430
|
+
{
|
|
4431
|
+
type: "button",
|
|
4432
|
+
style: s4.secondaryBtn,
|
|
4433
|
+
onClick: closeDialog
|
|
4434
|
+
},
|
|
4435
|
+
"\u53D6\u6D88"
|
|
4436
|
+
),
|
|
4437
|
+
h4(
|
|
4438
|
+
"button",
|
|
4439
|
+
{
|
|
4440
|
+
type: "submit",
|
|
4441
|
+
style: s4.primaryBtn,
|
|
4442
|
+
disabled: saving.value
|
|
4443
|
+
},
|
|
4444
|
+
saving.value ? "\u4FDD\u5B58\u4E2D\u2026" : "\u4FDD\u5B58"
|
|
4445
|
+
)
|
|
4446
|
+
])
|
|
4447
|
+
]
|
|
4448
|
+
)
|
|
4449
|
+
]
|
|
4450
|
+
)
|
|
4451
|
+
]) : null,
|
|
4452
|
+
deletingRow.value ? h4("div", { style: s4.mask, onClick: closeDeleteDialog }, [
|
|
4453
|
+
h4(
|
|
4454
|
+
"div",
|
|
4455
|
+
{
|
|
4456
|
+
style: { ...s4.dialog, maxWidth: "420px" },
|
|
4457
|
+
role: "dialog",
|
|
4458
|
+
"aria-modal": "true",
|
|
4459
|
+
onClick: (e) => e.stopPropagation()
|
|
4460
|
+
},
|
|
4461
|
+
[
|
|
4462
|
+
h4("div", { style: s4.dialogHeader }, [
|
|
4463
|
+
h4("h3", { style: s4.dialogTitle }, "\u786E\u8BA4\u5220\u9664"),
|
|
4464
|
+
h4(
|
|
4465
|
+
"button",
|
|
4466
|
+
{
|
|
4467
|
+
type: "button",
|
|
4468
|
+
style: s4.iconBtn,
|
|
4469
|
+
"aria-label": "\u5173\u95ED",
|
|
4470
|
+
onClick: closeDeleteDialog
|
|
4471
|
+
},
|
|
4472
|
+
"\xD7"
|
|
4473
|
+
)
|
|
4474
|
+
]),
|
|
4475
|
+
h4("div", { style: s4.confirmBody }, [
|
|
4476
|
+
h4("p", { style: s4.confirmText }, [
|
|
4477
|
+
"\u786E\u8BA4\u5220\u9664\u7528\u6237\u300C",
|
|
4478
|
+
h4("strong", deletingRow.value.name),
|
|
4479
|
+
"\u300D\uFF08",
|
|
4480
|
+
deletingRow.value.username,
|
|
4481
|
+
"\uFF09\u5417\uFF1F\u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002"
|
|
4482
|
+
]),
|
|
4483
|
+
h4("div", { style: s4.dialogFooter }, [
|
|
4484
|
+
h4(
|
|
4485
|
+
"button",
|
|
4486
|
+
{
|
|
4487
|
+
type: "button",
|
|
4488
|
+
style: s4.secondaryBtn,
|
|
4489
|
+
disabled: deleting.value,
|
|
4490
|
+
onClick: closeDeleteDialog
|
|
4491
|
+
},
|
|
4492
|
+
"\u53D6\u6D88"
|
|
4493
|
+
),
|
|
4494
|
+
h4(
|
|
4495
|
+
"button",
|
|
4496
|
+
{
|
|
4497
|
+
type: "button",
|
|
4498
|
+
style: s4.dangerBtn,
|
|
4499
|
+
disabled: deleting.value,
|
|
4500
|
+
onClick: () => void confirmDelete()
|
|
4501
|
+
},
|
|
4502
|
+
deleting.value ? "\u5220\u9664\u4E2D\u2026" : "\u786E\u8BA4\u5220\u9664"
|
|
4503
|
+
)
|
|
4504
|
+
])
|
|
4505
|
+
])
|
|
4506
|
+
]
|
|
4507
|
+
)
|
|
4508
|
+
]) : null
|
|
4509
|
+
]);
|
|
4510
|
+
}
|
|
4511
|
+
});
|
|
4512
|
+
|
|
3378
4513
|
// src/vue/SystemAdmin.ts
|
|
3379
|
-
import { computed as computed4, defineComponent as
|
|
4514
|
+
import { computed as computed4, defineComponent as defineComponent6, h as h5, ref as ref5, watch as watch5 } from "vue";
|
|
3380
4515
|
|
|
3381
4516
|
// src/admin/menu.ts
|
|
3382
4517
|
var SYSTEM_ADMIN_MENU = {
|
|
3383
4518
|
key: "system",
|
|
3384
4519
|
label: "\u7CFB\u7EDF\u7BA1\u7406",
|
|
3385
4520
|
children: [
|
|
4521
|
+
{ key: "user", label: "\u7528\u6237\u7BA1\u7406" },
|
|
4522
|
+
{ key: "role", label: "\u89D2\u8272\u7BA1\u7406" },
|
|
3386
4523
|
{ key: "menu", label: "\u83DC\u5355\u7BA1\u7406" },
|
|
3387
|
-
{ key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
|
|
3388
|
-
{ key: "role", label: "\u89D2\u8272\u7BA1\u7406" }
|
|
4524
|
+
{ key: "resource", label: "\u6743\u9650\u70B9\u7BA1\u7406" }
|
|
3389
4525
|
]
|
|
3390
4526
|
};
|
|
3391
4527
|
var SYSTEM_ADMIN_DEFAULT_KEY = "menu";
|
|
3392
4528
|
|
|
3393
4529
|
// src/vue/SystemAdmin.ts
|
|
3394
|
-
var
|
|
4530
|
+
var s5 = {
|
|
3395
4531
|
root: {
|
|
3396
4532
|
display: "flex",
|
|
3397
4533
|
minHeight: "560px",
|
|
@@ -3465,7 +4601,7 @@ var s4 = {
|
|
|
3465
4601
|
overflow: "auto"
|
|
3466
4602
|
}
|
|
3467
4603
|
};
|
|
3468
|
-
var SystemAdmin =
|
|
4604
|
+
var SystemAdmin = defineComponent6({
|
|
3469
4605
|
name: "SystemAdmin",
|
|
3470
4606
|
props: {
|
|
3471
4607
|
menuApi: {
|
|
@@ -3480,6 +4616,10 @@ var SystemAdmin = defineComponent5({
|
|
|
3480
4616
|
type: Object,
|
|
3481
4617
|
required: true
|
|
3482
4618
|
},
|
|
4619
|
+
userApi: {
|
|
4620
|
+
type: Object,
|
|
4621
|
+
required: true
|
|
4622
|
+
},
|
|
3483
4623
|
defaultActiveKey: {
|
|
3484
4624
|
type: String,
|
|
3485
4625
|
default: SYSTEM_ADMIN_DEFAULT_KEY
|
|
@@ -3498,8 +4638,8 @@ var SystemAdmin = defineComponent5({
|
|
|
3498
4638
|
activeKeyChange: (_key) => true
|
|
3499
4639
|
},
|
|
3500
4640
|
setup(props, { emit, slots }) {
|
|
3501
|
-
const innerKey =
|
|
3502
|
-
|
|
4641
|
+
const innerKey = ref5(props.defaultActiveKey);
|
|
4642
|
+
watch5(
|
|
3503
4643
|
() => props.defaultActiveKey,
|
|
3504
4644
|
(value) => {
|
|
3505
4645
|
if (props.activeKey === void 0) innerKey.value = value;
|
|
@@ -3516,22 +4656,22 @@ var SystemAdmin = defineComponent5({
|
|
|
3516
4656
|
emit("update:activeKey", key);
|
|
3517
4657
|
emit("activeKeyChange", key);
|
|
3518
4658
|
}
|
|
3519
|
-
return () =>
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
4659
|
+
return () => h5("div", { style: s5.root }, [
|
|
4660
|
+
h5("aside", { style: s5.sidebar }, [
|
|
4661
|
+
h5("div", { style: s5.sidebarTitle }, props.title),
|
|
4662
|
+
h5(
|
|
3523
4663
|
"nav",
|
|
3524
|
-
{ style:
|
|
4664
|
+
{ style: s5.nav },
|
|
3525
4665
|
SYSTEM_ADMIN_MENU.children.map((item) => {
|
|
3526
4666
|
const active = item.key === activeKey.value;
|
|
3527
|
-
return
|
|
4667
|
+
return h5(
|
|
3528
4668
|
"button",
|
|
3529
4669
|
{
|
|
3530
4670
|
key: item.key,
|
|
3531
4671
|
type: "button",
|
|
3532
4672
|
style: {
|
|
3533
|
-
...
|
|
3534
|
-
...active ?
|
|
4673
|
+
...s5.navItem,
|
|
4674
|
+
...active ? s5.navItemActive : {}
|
|
3535
4675
|
},
|
|
3536
4676
|
onClick: () => setActiveKey(item.key)
|
|
3537
4677
|
},
|
|
@@ -3540,20 +4680,20 @@ var SystemAdmin = defineComponent5({
|
|
|
3540
4680
|
})
|
|
3541
4681
|
)
|
|
3542
4682
|
]),
|
|
3543
|
-
|
|
3544
|
-
|
|
3545
|
-
|
|
3546
|
-
|
|
3547
|
-
|
|
3548
|
-
|
|
4683
|
+
h5("main", { style: s5.content }, [
|
|
4684
|
+
h5("div", { style: s5.contentHeader }, [
|
|
4685
|
+
h5("div", { style: s5.breadcrumb }, [
|
|
4686
|
+
h5("span", { style: s5.breadcrumbParent }, props.title),
|
|
4687
|
+
h5("span", { style: s5.breadcrumbSep }, "/"),
|
|
4688
|
+
h5("span", { style: s5.breadcrumbCurrent }, activeLabel.value)
|
|
3549
4689
|
]),
|
|
3550
4690
|
slots.toolbarExtra?.()
|
|
3551
4691
|
]),
|
|
3552
|
-
|
|
3553
|
-
activeKey.value === "menu" ?
|
|
4692
|
+
h5("div", { style: s5.panel }, [
|
|
4693
|
+
activeKey.value === "menu" ? h5(MenuManager, { api: props.menuApi, title: "\u83DC\u5355\u7BA1\u7406" }) : activeKey.value === "resource" ? h5(ResourceManager, {
|
|
3554
4694
|
api: props.resourceApi,
|
|
3555
4695
|
title: "\u6743\u9650\u70B9\u7BA1\u7406"
|
|
3556
|
-
}) :
|
|
4696
|
+
}) : activeKey.value === "role" ? h5(RoleManager, { api: props.roleApi, title: "\u89D2\u8272\u7BA1\u7406" }) : h5(UserManager, { api: props.userApi, title: "\u7528\u6237\u7BA1\u7406" })
|
|
3557
4697
|
])
|
|
3558
4698
|
])
|
|
3559
4699
|
]);
|
|
@@ -3585,15 +4725,18 @@ export {
|
|
|
3585
4725
|
SYSTEM_ADMIN_DEFAULT_KEY,
|
|
3586
4726
|
SYSTEM_ADMIN_MENU,
|
|
3587
4727
|
SystemAdmin,
|
|
4728
|
+
UserManager,
|
|
3588
4729
|
appendQueryParam,
|
|
3589
4730
|
buildCreateBody,
|
|
3590
4731
|
buildCreateMenuBody,
|
|
3591
4732
|
buildCreateRoleBody,
|
|
4733
|
+
buildCreateUserBody,
|
|
3592
4734
|
buildPermissionTreeIndex,
|
|
3593
4735
|
buildSavePermissionsBody,
|
|
3594
4736
|
buildUpdateBody,
|
|
3595
4737
|
buildUpdateMenuBody,
|
|
3596
4738
|
buildUpdateRoleBody,
|
|
4739
|
+
buildUpdateUserBody,
|
|
3597
4740
|
collectTreeResourceIds,
|
|
3598
4741
|
countCheckedDescendants,
|
|
3599
4742
|
createAuthorizationResourceApi,
|
|
@@ -3602,6 +4745,7 @@ export {
|
|
|
3602
4745
|
createPermissionPlugin,
|
|
3603
4746
|
createPermissionStore,
|
|
3604
4747
|
createSystemRoleApi,
|
|
4748
|
+
createSystemUserApi,
|
|
3605
4749
|
createVPermission,
|
|
3606
4750
|
extractPagination,
|
|
3607
4751
|
extractRecords,
|
|
@@ -3614,12 +4758,16 @@ export {
|
|
|
3614
4758
|
mapMenuResource,
|
|
3615
4759
|
mapPermissionTreeNode,
|
|
3616
4760
|
mapRolePermissions,
|
|
4761
|
+
mapSystemGroupOption,
|
|
3617
4762
|
mapSystemRole,
|
|
4763
|
+
mapSystemRoleOption,
|
|
4764
|
+
mapSystemUser,
|
|
3618
4765
|
resolveMenuDepth,
|
|
3619
4766
|
snowyflake,
|
|
3620
4767
|
togglePermissionCheck,
|
|
3621
4768
|
useHasPermission,
|
|
3622
4769
|
useHasRole,
|
|
3623
|
-
usePermission
|
|
4770
|
+
usePermission,
|
|
4771
|
+
validateUsername
|
|
3624
4772
|
};
|
|
3625
4773
|
//# sourceMappingURL=index.js.map
|