v-nuxt-ui 0.1.18 → 0.1.19
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/dist/module.json +1 -1
- package/dist/runtime/components/layout/Login.d.vue.ts +20 -0
- package/dist/runtime/components/layout/Login.vue +36 -0
- package/dist/runtime/components/layout/Login.vue.d.ts +20 -0
- package/dist/runtime/components/layout/default.vue +3 -3
- package/dist/runtime/components/sys/company/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/company/CreateModal.vue +23 -0
- package/dist/runtime/components/sys/company/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/company/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/company/Table.vue +53 -0
- package/dist/runtime/components/sys/company/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/department/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/department/CreateModal.vue +77 -0
- package/dist/runtime/components/sys/department/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/department/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/department/Table.vue +61 -0
- package/dist/runtime/components/sys/department/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/job-title/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/job-title/CreateModal.vue +26 -0
- package/dist/runtime/components/sys/job-title/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/job-title/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/job-title/Table.vue +67 -0
- package/dist/runtime/components/sys/job-title/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/menu/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/menu/CreateModal.vue +58 -0
- package/dist/runtime/components/sys/menu/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/menu/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/menu/Table.vue +96 -0
- package/dist/runtime/components/sys/menu/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/role/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/role/CreateModal.vue +86 -0
- package/dist/runtime/components/sys/role/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/role/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/role/Table.vue +68 -0
- package/dist/runtime/components/sys/role/Table.vue.d.ts +3 -0
- package/dist/runtime/components/sys/user/CreateModal.d.vue.ts +13 -0
- package/dist/runtime/components/sys/user/CreateModal.vue +179 -0
- package/dist/runtime/components/sys/user/CreateModal.vue.d.ts +13 -0
- package/dist/runtime/components/sys/user/Table.d.vue.ts +3 -0
- package/dist/runtime/components/sys/user/Table.vue +168 -0
- package/dist/runtime/components/sys/user/Table.vue.d.ts +3 -0
- package/package.json +1 -1
- /package/dist/runtime/components/layout/{ModuleMenu.d.vue.ts → button/ModuleMenu.d.vue.ts} +0 -0
- /package/dist/runtime/components/layout/{ModuleMenu.vue → button/ModuleMenu.vue} +0 -0
- /package/dist/runtime/components/layout/{ModuleMenu.vue.d.ts → button/ModuleMenu.vue.d.ts} +0 -0
- /package/dist/runtime/components/layout/{ThemePicker.d.vue.ts → button/ThemePicker.d.vue.ts} +0 -0
- /package/dist/runtime/components/layout/{ThemePicker.vue → button/ThemePicker.vue} +0 -0
- /package/dist/runtime/components/layout/{ThemePicker.vue.d.ts → button/ThemePicker.vue.d.ts} +0 -0
- /package/dist/runtime/components/layout/{UserMenu.d.vue.ts → button/UserMenu.d.vue.ts} +0 -0
- /package/dist/runtime/components/layout/{UserMenu.vue → button/UserMenu.vue} +0 -0
- /package/dist/runtime/components/layout/{UserMenu.vue.d.ts → button/UserMenu.vue.d.ts} +0 -0
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useOverlay } from "@nuxt/ui/composables";
|
|
3
|
+
import { useMenuApi } from "#v/composables";
|
|
4
|
+
import SysMenusCreateModal from "./CreateModal.vue";
|
|
5
|
+
import { getOprColumns } from "#v/constants";
|
|
6
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
7
|
+
import TablePage from "#v/components/table/Page.vue";
|
|
8
|
+
import { h } from "vue";
|
|
9
|
+
const overlay = useOverlay();
|
|
10
|
+
const createModal = overlay.create(SysMenusCreateModal);
|
|
11
|
+
const columns = [
|
|
12
|
+
{
|
|
13
|
+
accessorKey: "type",
|
|
14
|
+
header: "\u83DC\u5355\u7C7B\u578B",
|
|
15
|
+
cell: ({ row }) => {
|
|
16
|
+
switch (row.original.type) {
|
|
17
|
+
case "catalog":
|
|
18
|
+
return h(UBadge, {
|
|
19
|
+
icon: "i-lucide-folder",
|
|
20
|
+
variant: "subtle",
|
|
21
|
+
color: "neutral"
|
|
22
|
+
}, {
|
|
23
|
+
default: () => "\u76EE\u5F55"
|
|
24
|
+
});
|
|
25
|
+
case "menu":
|
|
26
|
+
return h(UBadge, {
|
|
27
|
+
icon: "i-lucide-menu",
|
|
28
|
+
variant: "subtle",
|
|
29
|
+
color: "primary"
|
|
30
|
+
}, {
|
|
31
|
+
default: () => "\u83DC\u5355"
|
|
32
|
+
});
|
|
33
|
+
case "button":
|
|
34
|
+
return h(UBadge, {
|
|
35
|
+
icon: "i-lucide-mouse-pointer-click",
|
|
36
|
+
variant: "subtle",
|
|
37
|
+
color: "warning"
|
|
38
|
+
}, {
|
|
39
|
+
default: () => "\u6309\u94AE"
|
|
40
|
+
});
|
|
41
|
+
default:
|
|
42
|
+
return row.original.type;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
accessorKey: "isAdmin",
|
|
48
|
+
header: "\u662F\u5426\u662F\u7CFB\u7EDF\u83DC\u5355",
|
|
49
|
+
sortOption: true,
|
|
50
|
+
filterOption: {
|
|
51
|
+
type: "select",
|
|
52
|
+
items: [
|
|
53
|
+
{ label: "\u662F", value: true, color: "primary" },
|
|
54
|
+
{ label: "\u5426", value: false, color: "neutral" }
|
|
55
|
+
],
|
|
56
|
+
initHide: false
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
{ accessorKey: "name", header: "\u83DC\u5355\u540D\u79F0", filterOption: { type: "input" }, sortOption: true },
|
|
60
|
+
{ accessorKey: "staticRouteKeys", header: "\u9759\u6001\u8DEF\u7531\u952E\u503C", filterOption: { type: "input" }, sortOption: true },
|
|
61
|
+
{
|
|
62
|
+
accessorKey: "disabled",
|
|
63
|
+
header: "\u662F\u5426\u7981\u7528",
|
|
64
|
+
filterOption: {
|
|
65
|
+
type: "select",
|
|
66
|
+
items: [
|
|
67
|
+
{ label: "\u662F", value: true, color: "error" },
|
|
68
|
+
{ label: "\u5426", value: false, color: "neutral" }
|
|
69
|
+
]
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
{ accessorKey: "permission", header: "\u6743\u9650\u6807\u8BC6", filterOption: { type: "input" }, sortOption: true },
|
|
73
|
+
{ accessorKey: "order", header: "\u6392\u5E8F", filterOption: { type: "input" }, sortOption: true },
|
|
74
|
+
...getOprColumns(null)
|
|
75
|
+
];
|
|
76
|
+
</script>
|
|
77
|
+
|
|
78
|
+
<template>
|
|
79
|
+
<TablePage
|
|
80
|
+
name="sys-menu"
|
|
81
|
+
cn-name="菜单信息"
|
|
82
|
+
:use-api-group="useMenuApi"
|
|
83
|
+
:biz-columns="columns"
|
|
84
|
+
fetch-all
|
|
85
|
+
:extra-order-query-options="[
|
|
86
|
+
{ field: 'order', label: '\u6392\u5E8F', defaultOpr: 'asc' }
|
|
87
|
+
]"
|
|
88
|
+
treeify-col-name="parentId"
|
|
89
|
+
:extra-row-actions="[{
|
|
90
|
+
icon: 'i-lucide-clipboard-plus',
|
|
91
|
+
label: '\u4EE5\u6B64\u4F5C\u4E3A\u7236\u83DC\u5355\u590D\u5236',
|
|
92
|
+
fnWithModal: async (raw) => await createModal.open({ model: useMenuApi().copyAsParent?.(raw) ?? { id: 0 } }).result
|
|
93
|
+
}]"
|
|
94
|
+
@edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
|
|
95
|
+
/>
|
|
96
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Role } from 'v-nuxt-ui/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
model: Role;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (args_0: boolean) => any;
|
|
7
|
+
save: (args_0: Role) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
10
|
+
onSave?: ((args_0: Role) => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import * as z from "zod";
|
|
3
|
+
import FormCreateModalTemplate from "#v/components/form/create-modal-template/index.vue";
|
|
4
|
+
import { useFormSubmission, useFormValues, useMenuApi, useRoleApi } from "#v/composables";
|
|
5
|
+
import { computed, onMounted, ref, toRef } from "vue";
|
|
6
|
+
import { treeifyOptions } from "#v/utils";
|
|
7
|
+
const props = defineProps({
|
|
8
|
+
model: { type: null, required: true }
|
|
9
|
+
});
|
|
10
|
+
const emit = defineEmits(["close", "save"]);
|
|
11
|
+
const { oldValues, newValues } = useFormValues(toRef(props.model), { id: 0, disabled: false, isAdmin: false });
|
|
12
|
+
const { onSubmit } = useFormSubmission(
|
|
13
|
+
toRef(oldValues),
|
|
14
|
+
toRef(newValues),
|
|
15
|
+
(close) => emit("close", close),
|
|
16
|
+
(model) => emit("save", model),
|
|
17
|
+
useRoleApi,
|
|
18
|
+
["menus"]
|
|
19
|
+
);
|
|
20
|
+
const menus = ref([]);
|
|
21
|
+
const onFetchMenus = async () => {
|
|
22
|
+
const { data } = await useMenuApi().list({
|
|
23
|
+
pagination: { pageNum: 0, pageSize: 0 },
|
|
24
|
+
orderQuery: [
|
|
25
|
+
{ field: "order", order: "asc" }
|
|
26
|
+
]
|
|
27
|
+
});
|
|
28
|
+
if (data.value.data) {
|
|
29
|
+
menus.value = data.value.data.list;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const sourceTreeItems = computed(() => treeifyOptions(
|
|
33
|
+
menus.value,
|
|
34
|
+
() => {
|
|
35
|
+
},
|
|
36
|
+
"name",
|
|
37
|
+
"id",
|
|
38
|
+
"parentId"
|
|
39
|
+
));
|
|
40
|
+
const targetTreeItems = computed({
|
|
41
|
+
get() {
|
|
42
|
+
const sortedMenus = (newValues.value.menus || []).sort((a, b) => a.order?.localeCompare(b.order || "") || 0);
|
|
43
|
+
return treeifyOptions(
|
|
44
|
+
sortedMenus,
|
|
45
|
+
() => {
|
|
46
|
+
},
|
|
47
|
+
"name",
|
|
48
|
+
"id",
|
|
49
|
+
"parentId"
|
|
50
|
+
);
|
|
51
|
+
},
|
|
52
|
+
set(newVal) {
|
|
53
|
+
const newMenuIds = newVal.map((item) => Number(item.value));
|
|
54
|
+
newValues.value.menus = menus.value.filter((menu) => newMenuIds.includes(menu.id));
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
onMounted(async () => {
|
|
58
|
+
await onFetchMenus();
|
|
59
|
+
});
|
|
60
|
+
</script>
|
|
61
|
+
|
|
62
|
+
<template>
|
|
63
|
+
<FormCreateModalTemplate
|
|
64
|
+
title="角色信息"
|
|
65
|
+
:on-close="(ok) => emit('close', ok)"
|
|
66
|
+
:fields="[
|
|
67
|
+
{ name: 'name', type: 'input', label: '\u89D2\u8272\u540D\u79F0', colSpan: '12', zodType: z.string().min(2, '\u540D\u79F0\u5B57\u6570\u4E0D\u8DB3') },
|
|
68
|
+
{ name: 'isAdmin', type: 'button-switch', label: '\u662F\u5426\u662F\u7CFB\u7EDF\u89D2\u8272', colSpan: '12', zodType: z.boolean() },
|
|
69
|
+
{
|
|
70
|
+
name: 'menus',
|
|
71
|
+
label: '\u83DC\u5355\u6743\u9650',
|
|
72
|
+
colSpan: '24',
|
|
73
|
+
zodType: z.array(z.object({ id: z.number() })),
|
|
74
|
+
type: 'tree-select-transfer',
|
|
75
|
+
sourceTreeItems,
|
|
76
|
+
targetTreeItems,
|
|
77
|
+
onUpdateTargetTreeItems: (newVal) => targetTreeItems = newVal
|
|
78
|
+
},
|
|
79
|
+
{ name: 'disabled', type: 'button-switch', label: '\u662F\u5426\u7981\u7528', colSpan: '12', zodType: z.boolean() },
|
|
80
|
+
{ name: 'remark', type: 'input', label: '\u5907\u6CE8', colSpan: '24', zodType: z.string().optional().nullable() }
|
|
81
|
+
]"
|
|
82
|
+
:model-value="newValues"
|
|
83
|
+
@update-model-value="(newVal) => newValues = { id: 0, ...newVal }"
|
|
84
|
+
@submit="onSubmit"
|
|
85
|
+
/>
|
|
86
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Role } from 'v-nuxt-ui/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
model: Role;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (args_0: boolean) => any;
|
|
7
|
+
save: (args_0: Role) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
10
|
+
onSave?: ((args_0: Role) => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useOverlay } from "@nuxt/ui/composables";
|
|
3
|
+
import { useRoleApi } from "#v/composables";
|
|
4
|
+
import SysRolesCreateModal from "./CreateModal.vue";
|
|
5
|
+
import { getOprColumns } from "#v/constants";
|
|
6
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
7
|
+
import { h } from "vue";
|
|
8
|
+
const overlay = useOverlay();
|
|
9
|
+
const createModal = overlay.create(SysRolesCreateModal);
|
|
10
|
+
const columns = [
|
|
11
|
+
{
|
|
12
|
+
accessorKey: "name",
|
|
13
|
+
header: "\u89D2\u8272\u540D\u79F0",
|
|
14
|
+
sortOption: true,
|
|
15
|
+
filterOption: {
|
|
16
|
+
type: "input",
|
|
17
|
+
initHide: false
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
accessorKey: "isAdmin",
|
|
22
|
+
header: "\u662F\u5426\u662F\u7CFB\u7EDF\u89D2\u8272",
|
|
23
|
+
sortOption: true,
|
|
24
|
+
filterOption: {
|
|
25
|
+
type: "input",
|
|
26
|
+
initHide: false
|
|
27
|
+
},
|
|
28
|
+
cell: ({ row }) => h(
|
|
29
|
+
UBadge,
|
|
30
|
+
{
|
|
31
|
+
label: row.original.isAdmin ? "\u662F" : "\u5426",
|
|
32
|
+
variant: "soft",
|
|
33
|
+
color: row.original.isAdmin ? "primary" : "neutral"
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
accessorKey: "disabled",
|
|
39
|
+
header: "\u662F\u5426\u7981\u7528",
|
|
40
|
+
cell: ({ row }) => h(
|
|
41
|
+
UBadge,
|
|
42
|
+
{
|
|
43
|
+
variant: "soft",
|
|
44
|
+
color: row.original.disabled ? "error" : "neutral"
|
|
45
|
+
},
|
|
46
|
+
() => row.original.disabled ? "\u662F" : "\u5426"
|
|
47
|
+
)
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
accessorKey: "remark",
|
|
51
|
+
header: "\u5907\u6CE8",
|
|
52
|
+
filterOption: {
|
|
53
|
+
type: "input"
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
...getOprColumns()
|
|
57
|
+
];
|
|
58
|
+
</script>
|
|
59
|
+
|
|
60
|
+
<template>
|
|
61
|
+
<TablePage
|
|
62
|
+
name="sys-role"
|
|
63
|
+
cn-name="角色信息"
|
|
64
|
+
:use-api-group="useRoleApi"
|
|
65
|
+
:biz-columns="columns"
|
|
66
|
+
@edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
|
|
67
|
+
/>
|
|
68
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { User } from 'v-nuxt-ui/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
model: User;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (args_0: boolean) => any;
|
|
7
|
+
save: (args_0: User) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
10
|
+
onSave?: ((args_0: User) => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { useFormValues, useFormSubmission, useUserApi, useRoleApi, useMenuApi, useDepartmentApi } from "#v/composables";
|
|
3
|
+
import { treeifyOptions } from "#v/utils";
|
|
4
|
+
import { toRef, ref, computed, onMounted } from "vue";
|
|
5
|
+
import FormCreateModalTemplate from "#v/components/form/create-modal-template/index.vue";
|
|
6
|
+
import { loginTypeOptions, genderOptions, Gender } from "#v/constants";
|
|
7
|
+
import * as z from "zod";
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
model: { type: null, required: true }
|
|
10
|
+
});
|
|
11
|
+
const emit = defineEmits(["close", "save"]);
|
|
12
|
+
const { oldValues, newValues } = useFormValues(toRef(props.model), { id: 0, needFillWh: false, isAdmin: false });
|
|
13
|
+
const { onSubmit } = useFormSubmission(
|
|
14
|
+
toRef(oldValues),
|
|
15
|
+
toRef(newValues),
|
|
16
|
+
(close) => emit("close", close),
|
|
17
|
+
(model) => emit("save", model),
|
|
18
|
+
useUserApi,
|
|
19
|
+
["roles", "menus"]
|
|
20
|
+
);
|
|
21
|
+
const roles = ref([]);
|
|
22
|
+
const onFetchRoles = async () => {
|
|
23
|
+
const { data } = await useRoleApi().list({
|
|
24
|
+
pagination: { pageNum: 0, pageSize: 0 }
|
|
25
|
+
});
|
|
26
|
+
if (data.value.data) {
|
|
27
|
+
roles.value = data.value.data.list;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const roleSourceTreeItems = computed(() => treeifyOptions(
|
|
31
|
+
roles.value,
|
|
32
|
+
() => {
|
|
33
|
+
},
|
|
34
|
+
"name",
|
|
35
|
+
"id",
|
|
36
|
+
"parentId"
|
|
37
|
+
));
|
|
38
|
+
const roleTargetTreeItems = computed({
|
|
39
|
+
get() {
|
|
40
|
+
return treeifyOptions(
|
|
41
|
+
newValues.value.roles || [],
|
|
42
|
+
() => {
|
|
43
|
+
},
|
|
44
|
+
"name",
|
|
45
|
+
"id",
|
|
46
|
+
"parentId"
|
|
47
|
+
);
|
|
48
|
+
},
|
|
49
|
+
set(newVal) {
|
|
50
|
+
const newRoleIds = newVal.map((item) => Number(item.value));
|
|
51
|
+
newValues.value.roles = roles.value.filter((role) => newRoleIds.includes(role.id));
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
const menus = ref([]);
|
|
55
|
+
const onFetchMenus = async () => {
|
|
56
|
+
const { data } = await useMenuApi().list({
|
|
57
|
+
pagination: { pageNum: 0, pageSize: 0 }
|
|
58
|
+
});
|
|
59
|
+
if (data.value.data) {
|
|
60
|
+
menus.value = data.value.data.list;
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const menusFromRoles = computed(() => {
|
|
64
|
+
const dupMenusFromRoles = newValues.value.roles?.flatMap((role) => role.menus ?? []) ?? [];
|
|
65
|
+
return Array.from(new Set(dupMenusFromRoles.map((menu) => menu.id))).map(
|
|
66
|
+
(id) => dupMenusFromRoles.find((menu) => menu.id === id)
|
|
67
|
+
);
|
|
68
|
+
});
|
|
69
|
+
const menuIdsFromRoles = computed(() => menusFromRoles.value.map((menu) => menu.id));
|
|
70
|
+
const menuSourceTreeItems = computed(() => treeifyOptions(
|
|
71
|
+
menus.value,
|
|
72
|
+
() => {
|
|
73
|
+
},
|
|
74
|
+
"name",
|
|
75
|
+
"id",
|
|
76
|
+
"parentId",
|
|
77
|
+
0,
|
|
78
|
+
menuIdsFromRoles.value
|
|
79
|
+
// menu from roles cannot be selected
|
|
80
|
+
));
|
|
81
|
+
const menuTargetTreeItems = computed({
|
|
82
|
+
get() {
|
|
83
|
+
return treeifyOptions(
|
|
84
|
+
menusFromRoles.value.concat(newValues.value.menus || []),
|
|
85
|
+
() => {
|
|
86
|
+
},
|
|
87
|
+
"name",
|
|
88
|
+
"id",
|
|
89
|
+
"parentId",
|
|
90
|
+
0,
|
|
91
|
+
menuIdsFromRoles.value
|
|
92
|
+
// menu from roles cannot be removed
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
set(newVal) {
|
|
96
|
+
const newMenuIds = newVal.map((item) => Number(item.value));
|
|
97
|
+
newValues.value.menus = menus.value.filter((menu) => !menuIdsFromRoles.value.includes(menu.id)).filter((menu) => newMenuIds.includes(menu.id));
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
onMounted(async () => {
|
|
101
|
+
await onFetchRoles();
|
|
102
|
+
await onFetchMenus();
|
|
103
|
+
});
|
|
104
|
+
</script>
|
|
105
|
+
|
|
106
|
+
<template>
|
|
107
|
+
<FormCreateModalTemplate
|
|
108
|
+
title="用户信息"
|
|
109
|
+
:on-close="(ok) => emit('close', ok)"
|
|
110
|
+
:fields="[
|
|
111
|
+
{ name: 'nickname', type: 'input', label: '\u540D\u79F0', colSpan: '12', zodType: z.string().min(2, '\u540D\u79F0\u5B57\u6570\u4E0D\u8DB3') },
|
|
112
|
+
{
|
|
113
|
+
name: 'gender',
|
|
114
|
+
icon: 'i-lucide-venus-and-mars',
|
|
115
|
+
type: 'select',
|
|
116
|
+
label: '\u6027\u522B',
|
|
117
|
+
items: genderOptions,
|
|
118
|
+
colSpan: '12',
|
|
119
|
+
zodType: z.enum(Gender)
|
|
120
|
+
},
|
|
121
|
+
{ name: 'username', type: 'input', label: '\u7528\u6237\u540D', colSpan: '12', zodType: z.string().nullable().optional() },
|
|
122
|
+
{ name: 'loginType', type: 'multiple-select-string', items: loginTypeOptions, label: '\u767B\u5F55\u65B9\u5F0F', colSpan: '12', zodType: z.string() },
|
|
123
|
+
{
|
|
124
|
+
name: 'departmentId',
|
|
125
|
+
label: '\u90E8\u95E8',
|
|
126
|
+
colSpan: '12',
|
|
127
|
+
type: 'async-tree-select',
|
|
128
|
+
labelField: 'name',
|
|
129
|
+
searchFields: ['name'],
|
|
130
|
+
listApi: useDepartmentApi().list,
|
|
131
|
+
fetchAll: true,
|
|
132
|
+
initModelValues: newValues.department,
|
|
133
|
+
onUpdateInitModelValues: (newInitModelValues) => newValues.department = newInitModelValues,
|
|
134
|
+
zodType: z.number().min(0)
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: 'supervisorId',
|
|
138
|
+
label: '\u76F4\u5C5E\u9886\u5BFC',
|
|
139
|
+
colSpan: '12',
|
|
140
|
+
type: 'async-select',
|
|
141
|
+
labelField: 'nickname',
|
|
142
|
+
searchFields: ['nickname'],
|
|
143
|
+
listApi: useUserApi().list,
|
|
144
|
+
initModelValues: newValues.supervisor,
|
|
145
|
+
onUpdateInitModelValues: (newInitModelValues) => newValues.supervisor = newInitModelValues,
|
|
146
|
+
enableEmptyOption: true,
|
|
147
|
+
zodType: z.number().min(0).optional()
|
|
148
|
+
},
|
|
149
|
+
{ name: 'email', type: 'input', label: '\u90AE\u7BB1', colSpan: '24', zodType: z.string().optional().nullable() },
|
|
150
|
+
{ name: 'entryDate', type: 'date-picker', label: '\u5165\u804C\u65F6\u95F4', colSpan: '12', zodType: z.string().optional().nullable() },
|
|
151
|
+
{ name: 'resignDate', type: 'date-picker', label: '\u79BB\u804C\u65F6\u95F4', colSpan: '12', zodType: z.string().optional().nullable() },
|
|
152
|
+
{ name: 'needFillWh', type: 'button-switch', label: '\u662F\u5426\u9700\u8981\u586B\u5199\u5DE5\u65F6', colSpan: '12', zodType: z.boolean() },
|
|
153
|
+
{ name: 'isAdmin', type: 'button-switch', label: '\u662F\u5426\u662F\u7CFB\u7EDF\u7BA1\u7406\u5458', colSpan: '12', zodType: z.boolean() },
|
|
154
|
+
{
|
|
155
|
+
name: 'roles',
|
|
156
|
+
label: '\u89D2\u8272\u6743\u9650',
|
|
157
|
+
colSpan: '24',
|
|
158
|
+
zodType: z.array(z.object({ id: z.number() })).optional(),
|
|
159
|
+
type: 'tree-select-transfer',
|
|
160
|
+
sourceTreeItems: roleSourceTreeItems,
|
|
161
|
+
targetTreeItems: roleTargetTreeItems,
|
|
162
|
+
onUpdateTargetTreeItems: (newVal) => roleTargetTreeItems = newVal
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
name: 'menus',
|
|
166
|
+
label: '\u83DC\u5355\u6743\u9650',
|
|
167
|
+
colSpan: '24',
|
|
168
|
+
zodType: z.array(z.object({ id: z.number() })).optional(),
|
|
169
|
+
type: 'tree-select-transfer',
|
|
170
|
+
sourceTreeItems: menuSourceTreeItems,
|
|
171
|
+
targetTreeItems: menuTargetTreeItems,
|
|
172
|
+
onUpdateTargetTreeItems: (newVal) => menuTargetTreeItems = newVal
|
|
173
|
+
}
|
|
174
|
+
]"
|
|
175
|
+
:model-value="newValues"
|
|
176
|
+
@update-model-value="(newVal) => newValues = { id: 0, ...newVal }"
|
|
177
|
+
@submit="onSubmit"
|
|
178
|
+
/>
|
|
179
|
+
</template>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { User } from 'v-nuxt-ui/types';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
model: User;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
6
|
+
close: (args_0: boolean) => any;
|
|
7
|
+
save: (args_0: User) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onClose?: ((args_0: boolean) => any) | undefined;
|
|
10
|
+
onSave?: ((args_0: User) => any) | undefined;
|
|
11
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
12
|
+
declare const _default: typeof __VLS_export;
|
|
13
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import dayjs from "dayjs";
|
|
3
|
+
import { useOverlay } from "@nuxt/ui/composables";
|
|
4
|
+
import { isEmptyString } from "#v/utils";
|
|
5
|
+
import { useDepartmentApi, useUserApi } from "#v/composables";
|
|
6
|
+
import { booleanOptions, dateFormat, genderOptions, loginTypeOptions } from "#v/constants";
|
|
7
|
+
import SysUsersCreateModal from "./CreateModal.vue";
|
|
8
|
+
import UBadge from "@nuxt/ui/components/Badge.vue";
|
|
9
|
+
import TablePage from "#v/components/table/Page.vue";
|
|
10
|
+
import { h } from "vue";
|
|
11
|
+
const overlay = useOverlay();
|
|
12
|
+
const createModal = overlay.create(SysUsersCreateModal);
|
|
13
|
+
const columns = [
|
|
14
|
+
{
|
|
15
|
+
accessorKey: "isResigned",
|
|
16
|
+
header: "\u662F\u5426\u79BB\u804C",
|
|
17
|
+
sortOption: true,
|
|
18
|
+
filterOption: {
|
|
19
|
+
type: "input",
|
|
20
|
+
initHide: false
|
|
21
|
+
},
|
|
22
|
+
cell: ({ row }) => h(
|
|
23
|
+
UBadge,
|
|
24
|
+
{
|
|
25
|
+
label: isEmptyString(row.original.resignDate) ? "\u5426" : "\u662F",
|
|
26
|
+
variant: "soft",
|
|
27
|
+
color: isEmptyString(row.original.resignDate) ? "neutral" : "error"
|
|
28
|
+
}
|
|
29
|
+
)
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
accessorKey: "nickname",
|
|
33
|
+
header: "\u59D3\u540D",
|
|
34
|
+
sortOption: true,
|
|
35
|
+
filterOption: {
|
|
36
|
+
type: "input",
|
|
37
|
+
initHide: false
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
accessorKey: "departmentId",
|
|
42
|
+
header: "\u90E8\u95E8",
|
|
43
|
+
sortOption: true,
|
|
44
|
+
cell: ({ row }) => row.original.department?.name,
|
|
45
|
+
filterOption: {
|
|
46
|
+
type: "async-select",
|
|
47
|
+
listApi: useDepartmentApi().list,
|
|
48
|
+
searchFields: ["name"],
|
|
49
|
+
labelField: "name",
|
|
50
|
+
multiple: true,
|
|
51
|
+
defaultOpr: "in"
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
accessorKey: "supervisorId",
|
|
56
|
+
header: "\u76F4\u5C5E\u4E0A\u7EA7",
|
|
57
|
+
sortOption: true,
|
|
58
|
+
cell: ({ row }) => row.original.supervisor?.nickname
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
accessorKey: "roles",
|
|
62
|
+
header: "\u7CFB\u7EDF\u6743\u9650\u89D2\u8272",
|
|
63
|
+
cell: ({ row }) => row.original.roles?.map((role) => role.name).join(", ")
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
accessorKey: "username",
|
|
67
|
+
header: "\u7528\u6237\u540D",
|
|
68
|
+
meta: {
|
|
69
|
+
class: {
|
|
70
|
+
td: "min-w-24"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
accessorKey: "loginType",
|
|
76
|
+
header: "\u767B\u5F55\u65B9\u5F0F",
|
|
77
|
+
meta: {
|
|
78
|
+
class: {
|
|
79
|
+
td: "min-w-24"
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
cell: ({ row }) => {
|
|
83
|
+
const loginTypes = row.original.loginType?.split(",");
|
|
84
|
+
return h(
|
|
85
|
+
"div",
|
|
86
|
+
{ class: "flex flex-wrap items-center gap-1" },
|
|
87
|
+
[loginTypes?.map((loginType) => h(UBadge, { variant: "outline" }, () => loginTypeOptions.find((opt) => opt.value === loginType)?.label))]
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
accessorKey: "email",
|
|
93
|
+
header: "\u90AE\u7BB1"
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
accessorKey: "needFillWh",
|
|
97
|
+
header: "\u662F\u5426\u9700\u8981\u586B\u5199\u5DE5\u65F6",
|
|
98
|
+
filterOption: {
|
|
99
|
+
type: "select",
|
|
100
|
+
items: booleanOptions
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
accessorKey: "gender",
|
|
105
|
+
header: "\u6027\u522B",
|
|
106
|
+
filterOption: {
|
|
107
|
+
type: "select",
|
|
108
|
+
items: genderOptions
|
|
109
|
+
},
|
|
110
|
+
meta: {
|
|
111
|
+
class: {
|
|
112
|
+
td: "min-w-16"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
accessorKey: "entryDate",
|
|
118
|
+
header: "\u5165\u804C\u65F6\u95F4",
|
|
119
|
+
sortOption: true,
|
|
120
|
+
cell: ({ row }) => dayjs(row.getValue("entryDate")).format(dateFormat)
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
accessorKey: "resignDate",
|
|
124
|
+
header: "\u79BB\u804C\u65F6\u95F4",
|
|
125
|
+
sortOption: true,
|
|
126
|
+
cell: ({ row }) => dayjs(row.getValue("resignDate")).format(dateFormat)
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
accessorKey: "telNo",
|
|
130
|
+
header: "\u7535\u8BDD",
|
|
131
|
+
meta: {
|
|
132
|
+
class: {
|
|
133
|
+
td: "min-w-24"
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
accessorKey: "isAdmin",
|
|
139
|
+
header: "\u662F\u5426\u662F\u7CFB\u7EDF\u7BA1\u7406\u5458",
|
|
140
|
+
sortOption: true,
|
|
141
|
+
filterOption: {
|
|
142
|
+
type: "input",
|
|
143
|
+
initHide: false
|
|
144
|
+
},
|
|
145
|
+
cell: ({ row }) => h(
|
|
146
|
+
UBadge,
|
|
147
|
+
{
|
|
148
|
+
label: row.original.isAdmin ? "\u662F" : "\u5426",
|
|
149
|
+
variant: "soft",
|
|
150
|
+
color: row.original.isAdmin ? "primary" : "neutral"
|
|
151
|
+
}
|
|
152
|
+
)
|
|
153
|
+
}
|
|
154
|
+
];
|
|
155
|
+
</script>
|
|
156
|
+
|
|
157
|
+
<template>
|
|
158
|
+
<TablePage
|
|
159
|
+
name="sys-users"
|
|
160
|
+
cn-name="用户信息"
|
|
161
|
+
:use-api-group="useUserApi"
|
|
162
|
+
:biz-columns="columns"
|
|
163
|
+
:extra-order-query-options="[
|
|
164
|
+
{ field: 'createdAt', label: '\u521B\u5EFA\u65F6\u95F4', defaultOpr: 'desc' }
|
|
165
|
+
]"
|
|
166
|
+
@edit-row-from-modal="async (row) => await createModal.open({ model: row }).result"
|
|
167
|
+
/>
|
|
168
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|