create-yoya-ui 0.2.1 → 0.2.3
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 +11 -10
- package/bin/create-yoya-ui.js +1 -1
- package/package.json +1 -1
- package/templates/admin/README.md +59 -47
- package/templates/admin/RULES.md +105 -0
- package/templates/admin/src/features/dashboard/todos/pages/todo-approval-page.js +5 -0
- package/templates/admin/src/features/ops/deploys/pages/deploy-list-page.js +5 -0
- package/templates/admin/src/features/ops/services/pages/service-list-page.js +5 -0
- package/templates/admin/src/features/{dicts → system/dicts}/api/dict.mgr.d.ts +24 -17
- package/templates/admin/src/features/{dicts → system/dicts}/api/dict.mgr.js +24 -14
- package/templates/admin/src/features/{dicts → system/dicts}/api/dict.mock.js +22 -4
- package/templates/admin/src/features/{dicts → system/dicts}/api/dict.state.d.ts +5 -0
- package/templates/admin/src/features/{dicts → system/dicts}/api/dict.state.js +39 -8
- package/templates/admin/src/features/{dicts → system/dicts}/components/dict-editor-dialog.js +1 -1
- package/templates/admin/src/features/{dicts → system/dicts}/pages/dict-list-page.js +41 -21
- package/templates/admin/src/features/{members → system/members}/api/member.mgr.d.ts +10 -9
- package/templates/admin/src/features/{members → system/members}/api/member.mgr.js +8 -3
- package/templates/admin/src/features/{members → system/members}/api/member.mock.js +1 -1
- package/templates/admin/src/features/{members → system/members}/api/member.req.d.ts +1 -1
- package/templates/admin/src/features/{members → system/members}/api/member.req.js +3 -1
- package/templates/admin/src/features/{members → system/members}/api/member.state.js +4 -4
- package/templates/admin/src/features/{members → system/members}/components/member-table.js +1 -1
- package/templates/admin/src/features/{permissions → system/permissions}/api/permission.mgr.d.ts +11 -9
- package/templates/admin/src/features/{permissions → system/permissions}/api/permission.mgr.js +10 -5
- package/templates/admin/src/features/{permissions → system/permissions}/api/permission.mock.js +1 -1
- package/templates/admin/src/features/{permissions → system/permissions}/api/permission.state.js +4 -4
- package/templates/admin/src/features/{permissions → system/permissions}/pages/permission-list-page.js +1 -1
- package/templates/admin/src/features/{roles → system/roles}/api/role.mgr.d.ts +19 -6
- package/templates/admin/src/features/{roles → system/roles}/api/role.mgr.js +8 -3
- package/templates/admin/src/features/{roles → system/roles}/api/role.mock.js +1 -1
- package/templates/admin/src/features/{roles → system/roles}/api/role.state.js +4 -4
- package/templates/admin/src/features/{roles → system/roles}/components/role-table.js +1 -1
- package/templates/admin/src/main.js +16 -12
- package/templates/admin/src/{ui/row-action-button.js → shared/ui.buttons.js} +1 -0
- package/templates/admin/src/{ui/placeholder-page.js → shared/ui.pages.js} +1 -0
- package/templates/admin/src/shell/api/shell.mock.js +42 -0
- package/templates/admin/src/shell/api/shell.req.js +17 -0
- package/templates/admin/src/shell/api/shell.state.js +90 -0
- package/templates/admin/src/shell/api/shell.views.js +19 -0
- package/templates/admin/src/shell/components/admin-shell.js +42 -0
- package/templates/admin/src/{ui → shell/components}/app-navbar.js +11 -12
- package/templates/admin/src/shell/components/app-sidebar.js +44 -0
- package/templates/admin/src/{ui → shell/components}/sidebar-menu.js +3 -3
- package/templates/admin/src/shell/router.js +40 -0
- package/templates/admin/node_modules/.vite/deps/_metadata.json +0 -8
- package/templates/admin/node_modules/.vite/deps/package.json +0 -3
- package/templates/admin/src/app/admin-shell.js +0 -51
- package/templates/admin/src/app/modules.js +0 -37
- package/templates/admin/src/app/router.js +0 -20
- package/templates/admin/src/ui/app-sidebar.js +0 -27
- /package/templates/admin/src/features/dashboard/{components → overview/components}/dashboard-chart.js +0 -0
- /package/templates/admin/src/features/dashboard/{pages → overview/pages}/dashboard-overview-page.js +0 -0
- /package/templates/admin/src/features/{dicts → system/dicts}/api/dict.views.d.ts +0 -0
- /package/templates/admin/src/features/{dicts → system/dicts}/api/dict.views.js +0 -0
- /package/templates/admin/src/features/{dicts → system/dicts}/components/dict-item-form-dialog.js +0 -0
- /package/templates/admin/src/features/{dicts → system/dicts}/utils/options.js +0 -0
- /package/templates/admin/src/features/{members → system/members}/api/member.state.d.ts +0 -0
- /package/templates/admin/src/features/{members → system/members}/api/member.views.d.ts +0 -0
- /package/templates/admin/src/features/{members → system/members}/api/member.views.js +0 -0
- /package/templates/admin/src/features/{members → system/members}/components/member-form-dialog.js +0 -0
- /package/templates/admin/src/features/{members → system/members}/components/member-toolbar.js +0 -0
- /package/templates/admin/src/features/{members → system/members}/pages/member-list-page.js +0 -0
- /package/templates/admin/src/features/{members → system/members}/utils/options.d.ts +0 -0
- /package/templates/admin/src/features/{members → system/members}/utils/options.js +0 -0
- /package/templates/admin/src/features/{permissions → system/permissions}/api/permission.state.d.ts +0 -0
- /package/templates/admin/src/features/{permissions → system/permissions}/api/permission.views.d.ts +0 -0
- /package/templates/admin/src/features/{permissions → system/permissions}/api/permission.views.js +0 -0
- /package/templates/admin/src/features/{permissions → system/permissions}/components/permission-form-dialog.js +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/api/role.state.d.ts +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/api/role.views.d.ts +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/api/role.views.js +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/components/role-form-dialog.js +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/components/role-toolbar.js +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/pages/role-list-page.js +0 -0
- /package/templates/admin/src/features/{roles → system/roles}/utils/options.js +0 -0
|
@@ -6,6 +6,9 @@ export default class DictsPageState {
|
|
|
6
6
|
this._types = [];
|
|
7
7
|
this._selectedTypeId = null;
|
|
8
8
|
this._items = [];
|
|
9
|
+
this._page = 1;
|
|
10
|
+
this._pageSize = 10;
|
|
11
|
+
this._total = 0;
|
|
9
12
|
this._listeners = new Set();
|
|
10
13
|
}
|
|
11
14
|
|
|
@@ -25,14 +28,38 @@ export default class DictsPageState {
|
|
|
25
28
|
return this._items;
|
|
26
29
|
}
|
|
27
30
|
|
|
31
|
+
page() {
|
|
32
|
+
return this._page;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
pageSize() {
|
|
36
|
+
return this._pageSize;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
total() {
|
|
40
|
+
return this._total;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
setPage(value) {
|
|
44
|
+
this._page = Math.max(1, Number(value) || 1);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
setPageSize(value) {
|
|
48
|
+
this._pageSize = Math.max(1, Number(value) || 10);
|
|
49
|
+
}
|
|
50
|
+
|
|
28
51
|
subscribe(listener) {
|
|
29
52
|
this._listeners.add(listener);
|
|
30
53
|
return () => this._listeners.delete(listener);
|
|
31
54
|
}
|
|
32
55
|
|
|
33
56
|
async loadTypes() {
|
|
34
|
-
const result = await
|
|
57
|
+
const result = await DictMgr.QueryTypes({
|
|
58
|
+
page: this._page,
|
|
59
|
+
pageSize: this._pageSize
|
|
60
|
+
}).submit();
|
|
35
61
|
this._types = result.data;
|
|
62
|
+
this._total = result.total;
|
|
36
63
|
if (!this._selectedTypeId && this._types.length > 0) {
|
|
37
64
|
this._selectedTypeId = this._types[0].id;
|
|
38
65
|
}
|
|
@@ -53,46 +80,50 @@ export default class DictsPageState {
|
|
|
53
80
|
this._items = [];
|
|
54
81
|
return;
|
|
55
82
|
}
|
|
56
|
-
const result = await
|
|
83
|
+
const result = await DictMgr.QueryItems({ typeId: this._selectedTypeId }).submit();
|
|
57
84
|
this._items = result.data;
|
|
58
85
|
}
|
|
59
86
|
|
|
60
87
|
async addType(payload) {
|
|
61
|
-
await
|
|
88
|
+
await DictMgr.CreateType(payload).submit();
|
|
89
|
+
this._page = 1;
|
|
62
90
|
await this.loadTypes();
|
|
63
91
|
return payload;
|
|
64
92
|
}
|
|
65
93
|
|
|
66
94
|
async editType(id, payload) {
|
|
67
|
-
await
|
|
95
|
+
await DictMgr.UpdateType({ id, ...payload }).submit();
|
|
68
96
|
await this.loadTypes();
|
|
69
97
|
return payload;
|
|
70
98
|
}
|
|
71
99
|
|
|
72
100
|
async removeType(id) {
|
|
73
|
-
await
|
|
101
|
+
await DictMgr.RemoveType({ id }).submit();
|
|
74
102
|
if (this._selectedTypeId === id) {
|
|
75
103
|
this._selectedTypeId = null;
|
|
76
104
|
}
|
|
105
|
+
if (this._types.length === 1 && this._page > 1) {
|
|
106
|
+
this._page -= 1;
|
|
107
|
+
}
|
|
77
108
|
await this.loadTypes();
|
|
78
109
|
}
|
|
79
110
|
|
|
80
111
|
async addItem(payload) {
|
|
81
|
-
await
|
|
112
|
+
await DictMgr.CreateItem({ typeId: this._selectedTypeId, ...payload }).submit();
|
|
82
113
|
await this.loadItems();
|
|
83
114
|
this._emit();
|
|
84
115
|
return payload;
|
|
85
116
|
}
|
|
86
117
|
|
|
87
118
|
async editItem(id, payload) {
|
|
88
|
-
await
|
|
119
|
+
await DictMgr.UpdateItem({ id, ...payload }).submit();
|
|
89
120
|
await this.loadItems();
|
|
90
121
|
this._emit();
|
|
91
122
|
return payload;
|
|
92
123
|
}
|
|
93
124
|
|
|
94
125
|
async removeItem(id) {
|
|
95
|
-
await
|
|
126
|
+
await DictMgr.RemoveItem({ id }).submit();
|
|
96
127
|
await this.loadItems();
|
|
97
128
|
this._emit();
|
|
98
129
|
}
|
package/templates/admin/src/features/{dicts → system/dicts}/components/dict-editor-dialog.js
RENAMED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toast, vDialog, vTable } from '@yoyaflow/yoya-ui';
|
|
2
|
-
import { RowActionButton } from '
|
|
2
|
+
import { RowActionButton } from '../../../../shared/ui.buttons.js';
|
|
3
3
|
import { DictItemFormDialog } from './dict-item-form-dialog.js';
|
|
4
4
|
import { statusOptions, statusText } from '../utils/options.js';
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { toast, vDialog, vTable, vstack } from '@yoyaflow/yoya-ui';
|
|
2
|
-
import { RowActionButton } from '
|
|
1
|
+
import { toast, vDialog, vPagination, vTable, vstack } from '@yoyaflow/yoya-ui';
|
|
2
|
+
import { RowActionButton } from '../../../../shared/ui.buttons.js';
|
|
3
3
|
import DictsPageState from '../api/dict.state.js';
|
|
4
4
|
import { DictEditorDialog } from '../components/dict-editor-dialog.js';
|
|
5
5
|
import { statusText } from '../utils/options.js';
|
|
@@ -8,13 +8,30 @@ export function DictListPage() {
|
|
|
8
8
|
const state = new DictsPageState();
|
|
9
9
|
const editorDialog = DictEditorDialog({ state, onSubmit: saveType });
|
|
10
10
|
const confirmDialog = vDialog();
|
|
11
|
+
const pagination = vPagination({
|
|
12
|
+
pageSize: 10,
|
|
13
|
+
pageSizes: [10, 20, 50],
|
|
14
|
+
onChange({ page: nextPage, pageSize: nextSize }) {
|
|
15
|
+
state.setPage(nextPage);
|
|
16
|
+
state.setPageSize(nextSize);
|
|
17
|
+
state.loadTypes();
|
|
18
|
+
}
|
|
19
|
+
});
|
|
11
20
|
let typesBody = null;
|
|
12
21
|
|
|
13
|
-
state.subscribe(
|
|
22
|
+
state.subscribe(() => {
|
|
23
|
+
renderTypes();
|
|
24
|
+
syncPagination();
|
|
25
|
+
});
|
|
14
26
|
state.loadTypes();
|
|
15
27
|
|
|
16
|
-
function
|
|
17
|
-
|
|
28
|
+
function syncPagination() {
|
|
29
|
+
pagination.update({
|
|
30
|
+
page: state.page(),
|
|
31
|
+
pageSize: state.pageSize(),
|
|
32
|
+
total: state.total(),
|
|
33
|
+
totalPages: Math.max(1, Math.ceil(state.total() / state.pageSize()))
|
|
34
|
+
});
|
|
18
35
|
}
|
|
19
36
|
|
|
20
37
|
function renderTypes() {
|
|
@@ -93,23 +110,26 @@ export function DictListPage() {
|
|
|
93
110
|
});
|
|
94
111
|
});
|
|
95
112
|
card.vCardBody((body) => {
|
|
96
|
-
body.
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
body.vstack({ gap: '12px' }, (content) => {
|
|
114
|
+
content.child(
|
|
115
|
+
vTable((table) => {
|
|
116
|
+
table.vThead((head) => {
|
|
117
|
+
head.vTr((row) => {
|
|
118
|
+
row.vTh('名称');
|
|
119
|
+
row.vTh('编码');
|
|
120
|
+
row.vTh('状态');
|
|
121
|
+
row.vTh('备注');
|
|
122
|
+
row.vTh('操作');
|
|
123
|
+
});
|
|
105
124
|
});
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
|
|
125
|
+
table.vTbody((bodyNode) => {
|
|
126
|
+
typesBody = bodyNode;
|
|
127
|
+
renderTypes();
|
|
128
|
+
});
|
|
129
|
+
})
|
|
130
|
+
);
|
|
131
|
+
content.child(pagination);
|
|
132
|
+
});
|
|
113
133
|
});
|
|
114
134
|
});
|
|
115
135
|
stack.child(editorDialog);
|
|
@@ -21,10 +21,7 @@ declare class Create extends RequestBase {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
declare class Update extends RequestBase {
|
|
24
|
-
constructor(
|
|
25
|
-
id: number,
|
|
26
|
-
init?: { name?: string; email?: string; role?: string; status?: string }
|
|
27
|
-
);
|
|
24
|
+
constructor(init?: { id: number; name?: string; email?: string; role?: string; status?: string });
|
|
28
25
|
method(): 'PUT';
|
|
29
26
|
address(): string;
|
|
30
27
|
body(): { name: string; email: string; role: string; status: string };
|
|
@@ -32,16 +29,20 @@ declare class Update extends RequestBase {
|
|
|
32
29
|
}
|
|
33
30
|
|
|
34
31
|
declare class Remove extends RequestBase {
|
|
35
|
-
constructor(id: number);
|
|
32
|
+
constructor(init?: { id: number });
|
|
36
33
|
method(): 'DELETE';
|
|
37
34
|
address(): string;
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
declare const MemberMgr: {
|
|
41
|
-
Query:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
38
|
+
Query: (
|
|
39
|
+
init?: { page?: number; pageSize?: number; keyword?: string; status?: string }
|
|
40
|
+
) => Query;
|
|
41
|
+
Create: (init?: { name?: string; email?: string; role?: string; status?: string }) => Create;
|
|
42
|
+
Update: (
|
|
43
|
+
init?: { id: number; name?: string; email?: string; role?: string; status?: string }
|
|
44
|
+
) => Update;
|
|
45
|
+
Remove: (init?: { id: number }) => Remove;
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
export default MemberMgr;
|
|
@@ -51,7 +51,7 @@ class Create extends RequestBase {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
class Update extends RequestBase {
|
|
54
|
-
constructor(id,
|
|
54
|
+
constructor({ id, name = '', email = '', role = 'viewer', status = 'active' } = {}) {
|
|
55
55
|
super();
|
|
56
56
|
this.id = id;
|
|
57
57
|
this.name = name;
|
|
@@ -78,7 +78,7 @@ class Update extends RequestBase {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
class Remove extends RequestBase {
|
|
81
|
-
constructor(id) {
|
|
81
|
+
constructor({ id } = {}) {
|
|
82
82
|
super();
|
|
83
83
|
this.id = id;
|
|
84
84
|
}
|
|
@@ -92,4 +92,9 @@ class Remove extends RequestBase {
|
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
export default {
|
|
95
|
+
export default {
|
|
96
|
+
Query: (init) => new Query(init),
|
|
97
|
+
Create: (init) => new Create(init),
|
|
98
|
+
Update: (init) => new Update(init),
|
|
99
|
+
Remove: (init) => new Remove(init)
|
|
100
|
+
};
|
|
@@ -58,7 +58,7 @@ export default class MembersPageState {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async load() {
|
|
61
|
-
const result = await
|
|
61
|
+
const result = await MemberMgr.Query({
|
|
62
62
|
page: this._page,
|
|
63
63
|
pageSize: this._pageSize,
|
|
64
64
|
keyword: this._keyword,
|
|
@@ -71,20 +71,20 @@ export default class MembersPageState {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
async add(payload) {
|
|
74
|
-
await
|
|
74
|
+
await MemberMgr.Create(payload).submit();
|
|
75
75
|
this._page = 1;
|
|
76
76
|
await this.load();
|
|
77
77
|
return payload;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async edit(id, patch) {
|
|
81
|
-
await
|
|
81
|
+
await MemberMgr.Update({ id, ...patch }).submit();
|
|
82
82
|
await this.load();
|
|
83
83
|
return patch;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async remove(id) {
|
|
87
|
-
await
|
|
87
|
+
await MemberMgr.Remove({ id }).submit();
|
|
88
88
|
if (this._items.length === 1 && this._page > 1) {
|
|
89
89
|
this._page -= 1;
|
|
90
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { vTable } from '@yoyaflow/yoya-ui';
|
|
2
|
-
import { RowActionButton } from '
|
|
2
|
+
import { RowActionButton } from '../../../../shared/ui.buttons.js';
|
|
3
3
|
import { statusText } from '../utils/options.js';
|
|
4
4
|
|
|
5
5
|
export function MemberTable({ rows, onEdit, onRemove }) {
|
package/templates/admin/src/features/{permissions → system/permissions}/api/permission.mgr.d.ts
RENAMED
|
@@ -11,8 +11,7 @@ declare class QueryTree extends RequestBase {
|
|
|
11
11
|
|
|
12
12
|
declare class Create extends RequestBase {
|
|
13
13
|
constructor(
|
|
14
|
-
parentId: number | null
|
|
15
|
-
init?: { name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
14
|
+
init?: { parentId: number | null; name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
16
15
|
);
|
|
17
16
|
method(): 'POST';
|
|
18
17
|
address(): string;
|
|
@@ -21,8 +20,7 @@ declare class Create extends RequestBase {
|
|
|
21
20
|
|
|
22
21
|
declare class Update extends RequestBase {
|
|
23
22
|
constructor(
|
|
24
|
-
id: number
|
|
25
|
-
init?: { name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
23
|
+
init?: { id: number; name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
26
24
|
);
|
|
27
25
|
method(): 'PUT';
|
|
28
26
|
address(): string;
|
|
@@ -30,16 +28,20 @@ declare class Update extends RequestBase {
|
|
|
30
28
|
}
|
|
31
29
|
|
|
32
30
|
declare class Remove extends RequestBase {
|
|
33
|
-
constructor(id: number);
|
|
31
|
+
constructor(init?: { id: number });
|
|
34
32
|
method(): 'DELETE';
|
|
35
33
|
address(): string;
|
|
36
34
|
}
|
|
37
35
|
|
|
38
36
|
declare const PermissionMgr: {
|
|
39
|
-
QueryTree:
|
|
40
|
-
Create:
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
QueryTree: (init?: unknown) => QueryTree;
|
|
38
|
+
Create: (
|
|
39
|
+
init?: { parentId: number | null; name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
40
|
+
) => Create;
|
|
41
|
+
Update: (
|
|
42
|
+
init?: { id: number; name?: string; code?: string; type?: PermissionType; sort?: number }
|
|
43
|
+
) => Update;
|
|
44
|
+
Remove: (init?: { id: number }) => Remove;
|
|
43
45
|
};
|
|
44
46
|
|
|
45
47
|
export default PermissionMgr;
|
package/templates/admin/src/features/{permissions → system/permissions}/api/permission.mgr.js
RENAMED
|
@@ -16,9 +16,9 @@ class QueryTree extends RequestBase {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
class Create extends RequestBase {
|
|
19
|
-
constructor(parentId,
|
|
19
|
+
constructor({ parentId = null, name = '', code = '', type = 'menu', sort = 0 } = {}) {
|
|
20
20
|
super();
|
|
21
|
-
this.parentId = parentId
|
|
21
|
+
this.parentId = parentId;
|
|
22
22
|
this.name = name;
|
|
23
23
|
this.code = code;
|
|
24
24
|
this.type = type;
|
|
@@ -39,7 +39,7 @@ class Create extends RequestBase {
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
class Update extends RequestBase {
|
|
42
|
-
constructor(id,
|
|
42
|
+
constructor({ id, name = '', code = '', type = 'menu', sort = 0 } = {}) {
|
|
43
43
|
super();
|
|
44
44
|
this.id = id;
|
|
45
45
|
this.name = name;
|
|
@@ -62,7 +62,7 @@ class Update extends RequestBase {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
class Remove extends RequestBase {
|
|
65
|
-
constructor(id) {
|
|
65
|
+
constructor({ id } = {}) {
|
|
66
66
|
super();
|
|
67
67
|
this.id = id;
|
|
68
68
|
}
|
|
@@ -76,4 +76,9 @@ class Remove extends RequestBase {
|
|
|
76
76
|
}
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
-
export default {
|
|
79
|
+
export default {
|
|
80
|
+
QueryTree: (init) => new QueryTree(init),
|
|
81
|
+
Create: (init) => new Create(init),
|
|
82
|
+
Update: (init) => new Update(init),
|
|
83
|
+
Remove: (init) => new Remove(init)
|
|
84
|
+
};
|
package/templates/admin/src/features/{permissions → system/permissions}/api/permission.state.js
RENAMED
|
@@ -17,26 +17,26 @@ export default class PermissionsPageState {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
async load() {
|
|
20
|
-
const result = await
|
|
20
|
+
const result = await PermissionMgr.QueryTree().submit();
|
|
21
21
|
this._tree = result.data;
|
|
22
22
|
this._emit();
|
|
23
23
|
return result;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
async add(parentId, payload) {
|
|
27
|
-
await
|
|
27
|
+
await PermissionMgr.Create({ parentId, ...payload }).submit();
|
|
28
28
|
await this.load();
|
|
29
29
|
return payload;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
async edit(id, payload) {
|
|
33
|
-
await
|
|
33
|
+
await PermissionMgr.Update({ id, ...payload }).submit();
|
|
34
34
|
await this.load();
|
|
35
35
|
return payload;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
async remove(id) {
|
|
39
|
-
await
|
|
39
|
+
await PermissionMgr.Remove({ id }).submit();
|
|
40
40
|
await this.load();
|
|
41
41
|
}
|
|
42
42
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toast, vDialog, vTree, vstack } from '@yoyaflow/yoya-ui';
|
|
2
|
-
import { RowActionButton } from '
|
|
2
|
+
import { RowActionButton } from '../../../../shared/ui.buttons.js';
|
|
3
3
|
import PermissionsPageState from '../api/permission.state.js';
|
|
4
4
|
import { PermissionFormDialog } from '../components/permission-form-dialog.js';
|
|
5
5
|
|
|
@@ -27,8 +27,8 @@ declare class Create extends RequestBase {
|
|
|
27
27
|
|
|
28
28
|
declare class Update extends RequestBase {
|
|
29
29
|
constructor(
|
|
30
|
-
id: number,
|
|
31
30
|
init?: {
|
|
31
|
+
id: number;
|
|
32
32
|
name?: string;
|
|
33
33
|
code?: string;
|
|
34
34
|
description?: string;
|
|
@@ -42,16 +42,29 @@ declare class Update extends RequestBase {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
declare class Remove extends RequestBase {
|
|
45
|
-
constructor(id: number);
|
|
45
|
+
constructor(init?: { id: number });
|
|
46
46
|
method(): 'DELETE';
|
|
47
47
|
address(): string;
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
declare const RoleMgr: {
|
|
51
|
-
Query:
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
Query: (
|
|
52
|
+
init?: { page?: number; pageSize?: number; keyword?: string; status?: string }
|
|
53
|
+
) => Query;
|
|
54
|
+
Create: (
|
|
55
|
+
init?: { name?: string; code?: string; description?: string; status?: RoleStatus; sort?: number }
|
|
56
|
+
) => Create;
|
|
57
|
+
Update: (
|
|
58
|
+
init?: {
|
|
59
|
+
id: number;
|
|
60
|
+
name?: string;
|
|
61
|
+
code?: string;
|
|
62
|
+
description?: string;
|
|
63
|
+
status?: RoleStatus;
|
|
64
|
+
sort?: number;
|
|
65
|
+
}
|
|
66
|
+
) => Update;
|
|
67
|
+
Remove: (init?: { id: number }) => Remove;
|
|
55
68
|
};
|
|
56
69
|
|
|
57
70
|
export default RoleMgr;
|
|
@@ -54,7 +54,7 @@ class Create extends RequestBase {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
class Update extends RequestBase {
|
|
57
|
-
constructor(id,
|
|
57
|
+
constructor({ id, name = '', code = '', description = '', status = 'active', sort = 0 } = {}) {
|
|
58
58
|
super();
|
|
59
59
|
this.id = id;
|
|
60
60
|
this.name = name;
|
|
@@ -84,7 +84,7 @@ class Update extends RequestBase {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
class Remove extends RequestBase {
|
|
87
|
-
constructor(id) {
|
|
87
|
+
constructor({ id } = {}) {
|
|
88
88
|
super();
|
|
89
89
|
this.id = id;
|
|
90
90
|
}
|
|
@@ -98,4 +98,9 @@ class Remove extends RequestBase {
|
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export default {
|
|
101
|
+
export default {
|
|
102
|
+
Query: (init) => new Query(init),
|
|
103
|
+
Create: (init) => new Create(init),
|
|
104
|
+
Update: (init) => new Update(init),
|
|
105
|
+
Remove: (init) => new Remove(init)
|
|
106
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// 角色演示用内存 mock(接入真实后端后删除本文件)。
|
|
2
|
-
import { mockRequest } from '
|
|
2
|
+
import { mockRequest } from '../../../../api/domain.api.js';
|
|
3
3
|
|
|
4
4
|
let roles = [
|
|
5
5
|
{ id: 1, name: '超级管理员', code: 'super_admin', description: '拥有全部权限', status: 'active', sort: 1 },
|
|
@@ -58,7 +58,7 @@ export default class RolesPageState {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
async load() {
|
|
61
|
-
const result = await
|
|
61
|
+
const result = await RoleMgr.Query({
|
|
62
62
|
page: this._page,
|
|
63
63
|
pageSize: this._pageSize,
|
|
64
64
|
keyword: this._keyword,
|
|
@@ -71,20 +71,20 @@ export default class RolesPageState {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
async add(payload) {
|
|
74
|
-
await
|
|
74
|
+
await RoleMgr.Create(payload).submit();
|
|
75
75
|
this._page = 1;
|
|
76
76
|
await this.load();
|
|
77
77
|
return payload;
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
async edit(id, patch) {
|
|
81
|
-
await
|
|
81
|
+
await RoleMgr.Update({ id, ...patch }).submit();
|
|
82
82
|
await this.load();
|
|
83
83
|
return patch;
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
async remove(id) {
|
|
87
|
-
await
|
|
87
|
+
await RoleMgr.Remove({ id }).submit();
|
|
88
88
|
if (this._items.length === 1 && this._page > 1) {
|
|
89
89
|
this._page -= 1;
|
|
90
90
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { vTable } from '@yoyaflow/yoya-ui';
|
|
2
|
-
import { RowActionButton } from '
|
|
2
|
+
import { RowActionButton } from '../../../../shared/ui.buttons.js';
|
|
3
3
|
import { statusText } from '../utils/options.js';
|
|
4
4
|
|
|
5
5
|
export function RoleTable({ rows, onEdit, onRemove }) {
|
|
@@ -1,18 +1,22 @@
|
|
|
1
1
|
import { initYoyaTheme } from '@yoyaflow/yoya-ui';
|
|
2
2
|
import '@yoyaflow/yoya-ui/ui.css';
|
|
3
3
|
import './api/domain.api.js';
|
|
4
|
-
import './features/members/api/member.mock.js';
|
|
5
|
-
import './features/permissions/api/permission.mock.js';
|
|
6
|
-
import './features/roles/api/role.mock.js';
|
|
7
|
-
import './features/dicts/api/dict.mock.js';
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { AdminShell } from './
|
|
4
|
+
import './features/system/members/api/member.mock.js';
|
|
5
|
+
import './features/system/permissions/api/permission.mock.js';
|
|
6
|
+
import './features/system/roles/api/role.mock.js';
|
|
7
|
+
import './features/system/dicts/api/dict.mock.js';
|
|
8
|
+
import './shell/api/shell.mock.js';
|
|
9
|
+
import ShellState from './shell/api/shell.state.js';
|
|
10
|
+
import { AdminShell } from './shell/components/admin-shell.js';
|
|
11
11
|
|
|
12
12
|
initYoyaTheme();
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
shell.
|
|
14
|
+
async function bootstrap() {
|
|
15
|
+
const state = new ShellState();
|
|
16
|
+
await state.load();
|
|
17
|
+
const shell = AdminShell({ state });
|
|
18
|
+
shell.render().bindTo('#app');
|
|
19
|
+
state.start();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
bootstrap();
|