@iservice365/layer-common 0.1.0 → 0.2.0
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/.playground/app.vue +7 -2
- package/.playground/pages/feedback.vue +30 -0
- package/CHANGELOG.md +6 -0
- package/components/Chat/Bubbles.vue +53 -0
- package/components/Chat/Information.vue +187 -0
- package/components/Chat/ListCard.vue +62 -0
- package/components/Chat/Message.vue +149 -0
- package/components/Chat/Navigation.vue +150 -0
- package/components/ConfirmDialog.vue +66 -0
- package/components/Container/Standard.vue +33 -0
- package/components/Feedback/Form.vue +136 -0
- package/components/FeedbackDetail.vue +465 -0
- package/components/FeedbackMain.vue +454 -0
- package/components/FormDialog.vue +65 -0
- package/components/Input/File.vue +203 -0
- package/components/Input/ListGroupSelection.vue +96 -0
- package/components/Input/NewDate.vue +123 -0
- package/components/Input/Number.vue +124 -0
- package/components/InvitationMain.vue +284 -0
- package/components/Layout/Header.vue +14 -4
- package/components/ListView.vue +87 -0
- package/components/MemberMain.vue +459 -0
- package/components/RolePermissionFormCreate.vue +161 -0
- package/components/RolePermissionFormPreviewUpdate.vue +183 -0
- package/components/RolePermissionMain.vue +361 -0
- package/components/ServiceProviderFormCreate.vue +154 -0
- package/components/ServiceProviderMain.vue +195 -0
- package/components/SignaturePad.vue +73 -0
- package/components/SpecificAttr.vue +53 -0
- package/components/SwitchContext.vue +26 -5
- package/components/TableList.vue +150 -0
- package/components/TableListSecondary.vue +164 -0
- package/components/WorkOrder/Create.vue +197 -0
- package/components/WorkOrder/ListView.vue +96 -0
- package/components/WorkOrder/Main.vue +308 -0
- package/components/Workorder.vue +1 -0
- package/composables/useAddress.ts +107 -0
- package/composables/useCommonPermission.ts +130 -0
- package/composables/useCustomer.ts +113 -0
- package/composables/useFeedback.ts +117 -0
- package/composables/useFile.ts +40 -0
- package/composables/useInvoice.ts +18 -0
- package/composables/useLocal.ts +24 -4
- package/composables/useLocalAuth.ts +58 -14
- package/composables/useLocalSetup.ts +52 -0
- package/composables/useMember.ts +104 -0
- package/composables/useOrg.ts +76 -92
- package/composables/usePaymentMethod.ts +101 -0
- package/composables/usePrice.ts +15 -0
- package/composables/usePromoCode.ts +36 -0
- package/composables/useRole.ts +38 -7
- package/composables/useServiceProvider.ts +218 -0
- package/composables/useSite.ts +108 -0
- package/composables/useSubscription.ts +149 -0
- package/composables/useUser.ts +38 -14
- package/composables/useUtils.ts +218 -6
- package/composables/useVerification.ts +33 -0
- package/composables/useWorkOrder.ts +68 -0
- package/middleware/01.auth.ts +11 -0
- package/middleware/02.org.ts +18 -0
- package/middleware/03.customer.ts +13 -0
- package/nuxt.config.ts +2 -1
- package/package.json +7 -3
- package/pages/index.vue +3 -0
- package/pages/payment-method-linked.vue +31 -0
- package/pages/require-customer.vue +56 -0
- package/pages/require-organization-membership.vue +47 -0
- package/pages/unauthorized.vue +29 -0
- package/plugins/API.ts +1 -3
- package/plugins/iconify.client.ts +5 -0
- package/plugins/vuetify.ts +2 -0
- package/public/bg-camera.jpg +0 -0
- package/public/bg-city.jpg +0 -0
- package/public/bg-condo.jpg +0 -0
- package/public/images/icons/delete-icon.png +0 -0
- package/public/sprite.svg +1 -0
- package/types/address.d.ts +13 -0
- package/types/customer.d.ts +15 -0
- package/types/feedback.d.ts +63 -0
- package/types/local.d.ts +46 -38
- package/types/member.d.ts +21 -0
- package/types/org.d.ts +13 -0
- package/types/permission.d.ts +1 -0
- package/types/price.d.ts +17 -0
- package/types/promo-code.d.ts +19 -0
- package/types/service-provider.d.ts +15 -0
- package/types/site.d.ts +13 -0
- package/types/subscription.d.ts +23 -0
- package/types/user.d.ts +19 -0
- package/types/verification.d.ts +20 -0
- package/types/work-order.d.ts +40 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export default function useMember() {
|
|
2
|
+
const members = useState<Array<TMember>>("members", () => []);
|
|
3
|
+
const page = useState("page", () => 1);
|
|
4
|
+
const pages = useState("pages", () => 0);
|
|
5
|
+
const pageRange = useState("pageRange", () => "-- - -- of --");
|
|
6
|
+
|
|
7
|
+
const member = useState<TMember>("member", () => ({
|
|
8
|
+
_id: "",
|
|
9
|
+
org: "",
|
|
10
|
+
orgName: "",
|
|
11
|
+
roleName: "",
|
|
12
|
+
name: "",
|
|
13
|
+
user: "",
|
|
14
|
+
role: "",
|
|
15
|
+
type: "",
|
|
16
|
+
customerOrgId: "",
|
|
17
|
+
customerSiteId: "",
|
|
18
|
+
status: "",
|
|
19
|
+
createdAt: "",
|
|
20
|
+
updatedAt: "",
|
|
21
|
+
deletedAt: "",
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function getByUserId(user: string) {
|
|
25
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}`);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function getByUserIdType(user: string, type: string) {
|
|
29
|
+
return useNuxtApp().$api<TMember>(`/api/members/user/${user}/app/${type}`);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
async function getAll({
|
|
33
|
+
page = 1,
|
|
34
|
+
search = "",
|
|
35
|
+
limit = 10,
|
|
36
|
+
user = "",
|
|
37
|
+
org = "",
|
|
38
|
+
type = "",
|
|
39
|
+
status = "active",
|
|
40
|
+
} = {}) {
|
|
41
|
+
return useNuxtApp().$api<Record<string, any>>("/api/members", {
|
|
42
|
+
method: "GET",
|
|
43
|
+
query: { page, limit, search, user, org, type, status },
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function createUserByVerification(
|
|
47
|
+
verificationId: string,
|
|
48
|
+
payload: TMemberUserCreateVerification
|
|
49
|
+
) {
|
|
50
|
+
return useNuxtApp().$api<TMemberUserCreateVerification>(
|
|
51
|
+
`/api/users/invite/${verificationId}`,
|
|
52
|
+
{
|
|
53
|
+
method: "POST",
|
|
54
|
+
body: payload,
|
|
55
|
+
}
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function createMemberInvite(verificatonId: string) {
|
|
60
|
+
return useNuxtApp().$api<TMember>(
|
|
61
|
+
`/api/members/verification/${verificatonId}`,
|
|
62
|
+
{
|
|
63
|
+
method: "POST",
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
function updateMemberStatus(id: string, status: string) {
|
|
68
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
69
|
+
`/api/members/${id}/${status}`,
|
|
70
|
+
{
|
|
71
|
+
method: "PUT",
|
|
72
|
+
}
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function updateMemberRole(
|
|
77
|
+
id: string,
|
|
78
|
+
role: string,
|
|
79
|
+
type: string,
|
|
80
|
+
org: string
|
|
81
|
+
) {
|
|
82
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
83
|
+
`/api/members/id/${id}/role/${role}/type/${type}/org/${org}`,
|
|
84
|
+
{
|
|
85
|
+
method: "PUT",
|
|
86
|
+
}
|
|
87
|
+
);
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
members,
|
|
91
|
+
member,
|
|
92
|
+
page,
|
|
93
|
+
pages,
|
|
94
|
+
pageRange,
|
|
95
|
+
|
|
96
|
+
getAll,
|
|
97
|
+
getByUserId,
|
|
98
|
+
createUserByVerification,
|
|
99
|
+
createMemberInvite,
|
|
100
|
+
getByUserIdType,
|
|
101
|
+
updateMemberStatus,
|
|
102
|
+
updateMemberRole,
|
|
103
|
+
};
|
|
104
|
+
}
|
package/composables/useOrg.ts
CHANGED
|
@@ -1,127 +1,111 @@
|
|
|
1
|
-
import useUtils from "./useUtils";
|
|
2
|
-
|
|
3
1
|
export default function useOrg() {
|
|
4
|
-
|
|
2
|
+
function getOrgs({ page = 1, search = "", user = "", limit = 20 } = {}) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
4
|
+
`/api/organizations/user/${user}`,
|
|
5
|
+
{
|
|
6
|
+
method: "GET",
|
|
7
|
+
query: {
|
|
8
|
+
page,
|
|
9
|
+
search,
|
|
10
|
+
limit,
|
|
11
|
+
},
|
|
12
|
+
}
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const org = useState("org", (): TOrg => {
|
|
5
17
|
return {
|
|
6
18
|
_id: "",
|
|
7
19
|
name: "",
|
|
8
20
|
email: "",
|
|
21
|
+
contact: "",
|
|
9
22
|
busInst: "",
|
|
10
|
-
owner: "",
|
|
11
23
|
type: "",
|
|
12
|
-
createdAt: "",
|
|
13
|
-
updatedAt: "",
|
|
14
24
|
status: "",
|
|
15
|
-
deletedAt: "",
|
|
16
25
|
};
|
|
17
26
|
});
|
|
18
27
|
|
|
19
|
-
function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
type: "",
|
|
28
|
-
createdAt: "",
|
|
29
|
-
updatedAt: "",
|
|
30
|
-
status: "",
|
|
31
|
-
deletedAt: "",
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
org.value._id = value._id;
|
|
36
|
-
org.value.name = value.name ?? "";
|
|
37
|
-
org.value.email = value.email ?? "";
|
|
38
|
-
org.value.busInst = value.busInst ?? "";
|
|
39
|
-
org.value.owner = value.owner ?? "";
|
|
40
|
-
org.value.type = value.type ?? "";
|
|
41
|
-
org.value.createdAt = value.createdAt;
|
|
42
|
-
org.value.updatedAt = value.updatedAt;
|
|
43
|
-
org.value.status = value.status ?? "";
|
|
44
|
-
org.value.deletedAt = value.deletedAt ?? "";
|
|
28
|
+
function reset() {
|
|
29
|
+
org.value._id = "";
|
|
30
|
+
org.value.name = "";
|
|
31
|
+
org.value.email = "";
|
|
32
|
+
org.value.contact = "";
|
|
33
|
+
org.value.busInst = "";
|
|
34
|
+
org.value.type = "";
|
|
35
|
+
org.value.status = "";
|
|
45
36
|
}
|
|
46
37
|
|
|
47
|
-
function
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
38
|
+
function set({
|
|
39
|
+
_id = "",
|
|
40
|
+
name = "",
|
|
41
|
+
email = "",
|
|
42
|
+
contact = "",
|
|
43
|
+
busInst = "",
|
|
44
|
+
type = "",
|
|
45
|
+
status = "",
|
|
46
|
+
} = {}) {
|
|
47
|
+
org.value._id = _id;
|
|
48
|
+
org.value.name = name;
|
|
49
|
+
org.value.email = email;
|
|
50
|
+
org.value.contact = contact;
|
|
51
|
+
org.value.busInst = busInst;
|
|
52
|
+
org.value.type = type;
|
|
53
|
+
org.value.status = status;
|
|
57
54
|
}
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
query: { search, page },
|
|
63
|
-
});
|
|
64
|
-
}
|
|
56
|
+
const perSeatPrice = 8;
|
|
57
|
+
const seats = useState("seats", () => 0);
|
|
58
|
+
const total = computed(() => seats.value * perSeatPrice);
|
|
65
59
|
|
|
66
|
-
function
|
|
67
|
-
return useNuxtApp().$api<
|
|
68
|
-
method: "
|
|
69
|
-
body: { field, value },
|
|
60
|
+
function getByName(name = "") {
|
|
61
|
+
return useNuxtApp().$api<TOrg>(`/api/organizations/name/${name}`, {
|
|
62
|
+
method: "GET",
|
|
70
63
|
});
|
|
71
64
|
}
|
|
72
65
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
const pageRange = useState("orgPageRange", () => "0-0 of 0");
|
|
76
|
-
|
|
77
|
-
function getOrgById(id = "") {
|
|
78
|
-
return useNuxtApp().$api<TOrg>(`/api/orgs/id/${id}`, {
|
|
66
|
+
function getById(id = "") {
|
|
67
|
+
return useNuxtApp().$api<TOrg>(`/api/organizations/id/${id}`, {
|
|
79
68
|
method: "GET",
|
|
80
69
|
});
|
|
81
70
|
}
|
|
82
71
|
|
|
83
|
-
const
|
|
72
|
+
const { currentUser } = useLocalAuth();
|
|
84
73
|
|
|
85
|
-
const
|
|
74
|
+
const currentOrg = useState("currentOrg", () => "");
|
|
86
75
|
|
|
87
|
-
|
|
76
|
+
currentOrg.value =
|
|
77
|
+
(useRoute().params.organization as string) ??
|
|
78
|
+
currentUser.value?.defaultOrg ??
|
|
79
|
+
"unknown";
|
|
88
80
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
`/api/orgs/user/${user}`,
|
|
93
|
-
{
|
|
94
|
-
method: "GET",
|
|
95
|
-
}
|
|
96
|
-
);
|
|
97
|
-
myOrgs.value = res;
|
|
98
|
-
} catch (error) {
|
|
99
|
-
throw error;
|
|
81
|
+
watch(currentUser, () => {
|
|
82
|
+
if (!currentOrg.value) {
|
|
83
|
+
currentOrg.value = currentUser.value?.defaultOrg ?? "unknown";
|
|
100
84
|
}
|
|
101
|
-
}, 1000);
|
|
102
|
-
|
|
103
|
-
const theOrg = computed(() => {
|
|
104
|
-
return myOrgs.value.find((i) => i.value === selectedOrg.value);
|
|
105
85
|
});
|
|
106
86
|
|
|
107
|
-
|
|
108
|
-
return
|
|
109
|
-
|
|
87
|
+
function getAll({ page = 1, search = "", limit = 20 } = {}) {
|
|
88
|
+
return useNuxtApp().$api<Record<string, any>>("/api/organizations", {
|
|
89
|
+
method: "GET",
|
|
90
|
+
query: {
|
|
91
|
+
page,
|
|
92
|
+
search,
|
|
93
|
+
limit,
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
}
|
|
110
97
|
|
|
111
98
|
return {
|
|
112
99
|
org,
|
|
113
|
-
setOrg,
|
|
114
|
-
createOrg,
|
|
115
100
|
getOrgs,
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
updateOrgField,
|
|
101
|
+
reset,
|
|
102
|
+
set,
|
|
103
|
+
perSeatPrice,
|
|
104
|
+
seats,
|
|
105
|
+
total,
|
|
106
|
+
getByName,
|
|
107
|
+
currentOrg,
|
|
108
|
+
getById,
|
|
109
|
+
getAll,
|
|
126
110
|
};
|
|
127
111
|
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
export default function usePaymentMethod() {
|
|
2
|
+
function linkEWallet({
|
|
3
|
+
type = "GCASH",
|
|
4
|
+
customer_id = "",
|
|
5
|
+
success_return_url = "",
|
|
6
|
+
failure_return_url = "",
|
|
7
|
+
cancel_return_url = "",
|
|
8
|
+
category = "individual",
|
|
9
|
+
} = {}) {
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>(
|
|
11
|
+
"/api/payment-methods/e-wallet",
|
|
12
|
+
{
|
|
13
|
+
method: "POST",
|
|
14
|
+
body: {
|
|
15
|
+
customer_id,
|
|
16
|
+
type,
|
|
17
|
+
success_return_url,
|
|
18
|
+
failure_return_url,
|
|
19
|
+
cancel_return_url,
|
|
20
|
+
category,
|
|
21
|
+
},
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function linkCard({
|
|
27
|
+
cardType = "",
|
|
28
|
+
cardNumber = "",
|
|
29
|
+
expiryMonth = "",
|
|
30
|
+
expiryYear = "",
|
|
31
|
+
cvv = "",
|
|
32
|
+
cardholderName = "",
|
|
33
|
+
currency = "",
|
|
34
|
+
success_return_url = "",
|
|
35
|
+
failure_return_url = "",
|
|
36
|
+
subscriptionData = {},
|
|
37
|
+
} = {}) {
|
|
38
|
+
return useNuxtApp().$api<Record<string, any>>("/api/payment-methods/card", {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: {
|
|
41
|
+
cardType,
|
|
42
|
+
cardNumber,
|
|
43
|
+
expiryMonth,
|
|
44
|
+
expiryYear,
|
|
45
|
+
cvv,
|
|
46
|
+
cardholderName,
|
|
47
|
+
currency,
|
|
48
|
+
success_return_url,
|
|
49
|
+
failure_return_url,
|
|
50
|
+
subscriptionData,
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function getByUser(user = "") {
|
|
56
|
+
return useNuxtApp().$api<Array<Record<string, any>>>(
|
|
57
|
+
`/api/payment-methods/user/${user}`,
|
|
58
|
+
{
|
|
59
|
+
method: "GET",
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getByOrg(org = "") {
|
|
65
|
+
return useNuxtApp().$api<Array<Record<string, any>>>(
|
|
66
|
+
`/api/payment-methods/org/${org}`,
|
|
67
|
+
{
|
|
68
|
+
method: "GET",
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const eWalletNumber = useState("eWalletNumber", () => "");
|
|
74
|
+
const cardNumber = useState("cardNumber", () => "");
|
|
75
|
+
const cardExpiration = useState("cardExpiration", () => "");
|
|
76
|
+
const cardSecurityCode = useState("cardSecurityCode", () => "");
|
|
77
|
+
const cardholderName = useState("cardholderName", () => "");
|
|
78
|
+
const selectedPaymentMethod = useState("selectedPaymentMethod", () => "");
|
|
79
|
+
|
|
80
|
+
function reset() {
|
|
81
|
+
eWalletNumber.value = "";
|
|
82
|
+
cardNumber.value = "";
|
|
83
|
+
cardExpiration.value = "";
|
|
84
|
+
cardSecurityCode.value = "";
|
|
85
|
+
cardholderName.value = "";
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return {
|
|
89
|
+
linkEWallet,
|
|
90
|
+
linkCard,
|
|
91
|
+
getByUser,
|
|
92
|
+
getByOrg,
|
|
93
|
+
eWalletNumber,
|
|
94
|
+
cardNumber,
|
|
95
|
+
cardExpiration,
|
|
96
|
+
cardSecurityCode,
|
|
97
|
+
cardholderName,
|
|
98
|
+
selectedPaymentMethod,
|
|
99
|
+
reset,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export default function usePrice() {
|
|
2
|
+
function getByNameType(name: string, type: string) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/prices/price", {
|
|
4
|
+
method: "GET",
|
|
5
|
+
params: {
|
|
6
|
+
name,
|
|
7
|
+
type,
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return {
|
|
13
|
+
getByNameType,
|
|
14
|
+
};
|
|
15
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export default function usePromoCode() {
|
|
2
|
+
function add(value: TPromoCode) {
|
|
3
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
|
|
4
|
+
method: "POST",
|
|
5
|
+
body: value,
|
|
6
|
+
});
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function getPromoCodes({ search = "", page = 1, status = "active" } = {}) {
|
|
10
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes", {
|
|
11
|
+
method: "GET",
|
|
12
|
+
query: {
|
|
13
|
+
search,
|
|
14
|
+
page,
|
|
15
|
+
status,
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function getByCode(code: string, type?: string, assigned?: boolean) {
|
|
21
|
+
return useNuxtApp().$api<Record<string, any>>("/api/promo-codes/code", {
|
|
22
|
+
method: "GET",
|
|
23
|
+
params: {
|
|
24
|
+
code,
|
|
25
|
+
type,
|
|
26
|
+
assigned,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
add,
|
|
33
|
+
getPromoCodes,
|
|
34
|
+
getByCode,
|
|
35
|
+
};
|
|
36
|
+
}
|
package/composables/useRole.ts
CHANGED
|
@@ -1,26 +1,33 @@
|
|
|
1
1
|
export default function useRole() {
|
|
2
2
|
function createRole(
|
|
3
|
-
{ name, permissions, type } = {} as {
|
|
3
|
+
{ name, permissions, type, org } = {} as {
|
|
4
4
|
name: string;
|
|
5
5
|
permissions: Array<string>;
|
|
6
6
|
type: string;
|
|
7
|
+
org?: string;
|
|
7
8
|
}
|
|
8
9
|
) {
|
|
9
10
|
return useNuxtApp().$api("/api/roles", {
|
|
10
11
|
method: "POST",
|
|
11
|
-
body: { name, permissions, type },
|
|
12
|
+
body: { name, permissions, type, org },
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
|
|
15
|
-
function getRoles({
|
|
16
|
-
|
|
16
|
+
function getRoles({
|
|
17
|
+
search = "",
|
|
18
|
+
page = 1,
|
|
19
|
+
limit = 20,
|
|
20
|
+
type = "",
|
|
21
|
+
org = "",
|
|
22
|
+
} = {}) {
|
|
23
|
+
return useNuxtApp().$api<Record<string, any>>("/api/roles", {
|
|
17
24
|
method: "GET",
|
|
18
|
-
query: { search, page, limit, type },
|
|
25
|
+
query: { search, page, limit, type, org },
|
|
19
26
|
});
|
|
20
27
|
}
|
|
21
28
|
|
|
22
29
|
function getRoleById(id: string) {
|
|
23
|
-
return useNuxtApp().$api<
|
|
30
|
+
return useNuxtApp().$api<TRole>(`/api/roles/id/${id}`, {
|
|
24
31
|
method: "GET",
|
|
25
32
|
});
|
|
26
33
|
}
|
|
@@ -36,6 +43,13 @@ export default function useRole() {
|
|
|
36
43
|
});
|
|
37
44
|
}
|
|
38
45
|
|
|
46
|
+
function updatePermissionById(_id: string, permissions?: Array<string>) {
|
|
47
|
+
return useNuxtApp().$api(`/api/roles/permissions/id/${_id}`, {
|
|
48
|
+
method: "PATCH",
|
|
49
|
+
body: { permissions },
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
39
53
|
function updateRoleFieldById(_id: string, field: string, value: string) {
|
|
40
54
|
return useNuxtApp().$api(`/api/roles/${_id}`, {
|
|
41
55
|
method: "PATCH",
|
|
@@ -44,7 +58,7 @@ export default function useRole() {
|
|
|
44
58
|
}
|
|
45
59
|
|
|
46
60
|
function deleteRole(_id: string) {
|
|
47
|
-
return useNuxtApp().$api(`/api/roles/${_id}`, {
|
|
61
|
+
return useNuxtApp().$api<Record<string, any>>(`/api/roles/${_id}`, {
|
|
48
62
|
method: "DELETE",
|
|
49
63
|
});
|
|
50
64
|
}
|
|
@@ -61,6 +75,21 @@ export default function useRole() {
|
|
|
61
75
|
};
|
|
62
76
|
});
|
|
63
77
|
|
|
78
|
+
const { getByUserId } = useMember();
|
|
79
|
+
|
|
80
|
+
async function getRoleByUserId(user: string) {
|
|
81
|
+
const member = ref<TMember | null>(null);
|
|
82
|
+
|
|
83
|
+
try {
|
|
84
|
+
const res = await getByUserId(user);
|
|
85
|
+
member.value = res;
|
|
86
|
+
const _role = await getRoleById(res.role);
|
|
87
|
+
Object.assign(role.value, _role);
|
|
88
|
+
} catch (error) {
|
|
89
|
+
console.log(error);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
64
93
|
return {
|
|
65
94
|
role,
|
|
66
95
|
createRole,
|
|
@@ -69,5 +98,7 @@ export default function useRole() {
|
|
|
69
98
|
updateRoleById,
|
|
70
99
|
updateRoleFieldById,
|
|
71
100
|
deleteRole,
|
|
101
|
+
updatePermissionById,
|
|
102
|
+
getRoleByUserId,
|
|
72
103
|
};
|
|
73
104
|
}
|