@befly-addon/admin 1.1.29 → 1.1.31
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/apis/admin/cacheRefresh.ts +29 -24
- package/apis/admin/del.ts +12 -12
- package/apis/admin/detail.ts +9 -41
- package/apis/admin/ins.ts +28 -21
- package/apis/admin/list.ts +12 -12
- package/apis/admin/upd.ts +49 -14
- package/apis/api/all.ts +14 -10
- package/apis/api/list.ts +16 -25
- package/apis/auth/login.ts +55 -52
- package/apis/auth/sendSmsCode.ts +6 -6
- package/apis/dashboard/configStatus.ts +18 -18
- package/apis/dashboard/environmentInfo.ts +12 -12
- package/apis/dashboard/performanceMetrics.ts +5 -5
- package/apis/dashboard/permissionStats.ts +7 -7
- package/apis/dashboard/serviceStatus.ts +29 -29
- package/apis/dashboard/systemInfo.ts +5 -5
- package/apis/dashboard/systemOverview.ts +7 -7
- package/apis/dashboard/systemResources.ts +8 -8
- package/apis/dict/all.ts +24 -7
- package/apis/dict/del.ts +9 -17
- package/apis/dict/detail.ts +30 -16
- package/apis/dict/ins.ts +36 -18
- package/apis/dict/items.ts +27 -0
- package/apis/dict/list.ts +35 -10
- package/apis/dict/upd.ts +54 -20
- package/apis/dictType/all.ts +11 -0
- package/apis/dictType/del.ts +32 -0
- package/apis/dictType/detail.ts +17 -0
- package/apis/dictType/ins.ts +30 -0
- package/apis/dictType/list.ts +22 -0
- package/apis/dictType/upd.ts +42 -0
- package/apis/email/config.ts +4 -4
- package/apis/email/logList.ts +10 -10
- package/apis/email/send.ts +18 -18
- package/apis/email/verify.ts +5 -5
- package/apis/loginLog/list.ts +10 -10
- package/apis/menu/all.ts +17 -20
- package/apis/menu/list.ts +12 -13
- package/apis/operateLog/list.ts +10 -10
- package/apis/role/all.ts +7 -7
- package/apis/role/apiSave.ts +14 -16
- package/apis/role/apis.ts +24 -0
- package/apis/role/del.ts +27 -19
- package/apis/role/detail.ts +6 -7
- package/apis/role/ins.ts +10 -10
- package/apis/role/list.ts +11 -11
- package/apis/role/menuSave.ts +12 -14
- package/apis/role/menus.ts +24 -0
- package/apis/role/save.ts +14 -15
- package/apis/role/upd.ts +10 -10
- package/apis/sysConfig/all.ts +5 -6
- package/apis/sysConfig/del.ts +10 -10
- package/apis/sysConfig/get.ts +10 -11
- package/apis/sysConfig/ins.ts +11 -11
- package/apis/sysConfig/list.ts +9 -9
- package/apis/sysConfig/upd.ts +11 -11
- package/libs/emailHelper.ts +7 -7
- package/package.json +46 -34
- package/plugins/email.ts +9 -9
- package/tables/admin.json +0 -6
- package/tables/dict.json +13 -19
- package/tables/dictType.json +28 -0
- package/tables/role.json +4 -2
- package/views/403_1/index.vue +19 -3
- package/views/config/dict/components/edit.vue +76 -124
- package/views/config/dict/index.vue +142 -84
- package/views/config/dictType/components/edit.vue +105 -0
- package/views/config/dictType/index.vue +242 -0
- package/views/config/index.vue +12 -0
- package/views/config/system/components/edit.vue +36 -36
- package/views/config/system/index.vue +79 -50
- package/views/index/components/addonList.vue +3 -3
- package/views/index/components/environmentInfo.vue +10 -10
- package/views/index/components/operationLogs.vue +10 -10
- package/views/index/components/performanceMetrics.vue +8 -8
- package/views/index/components/quickActions.vue +3 -3
- package/views/index/components/serviceStatus.vue +19 -19
- package/views/index/components/systemNotifications.vue +12 -12
- package/views/index/components/systemOverview.vue +7 -7
- package/views/index/components/systemResources.vue +11 -11
- package/views/index/components/userInfo.vue +20 -19
- package/views/index/index.vue +12 -5
- package/views/log/email/index.vue +58 -51
- package/views/log/index.vue +12 -0
- package/views/log/login/index.vue +45 -38
- package/views/log/operate/index.vue +55 -48
- package/views/login_1/index.vue +191 -2
- package/views/people/admin/components/edit.vue +28 -29
- package/views/people/admin/index.vue +76 -40
- package/views/people/index.vue +12 -0
- package/views/permission/api/index.vue +21 -15
- package/views/permission/index.vue +12 -0
- package/views/permission/menu/index.vue +31 -16
- package/views/permission/role/components/api.vue +23 -23
- package/views/permission/role/components/edit.vue +18 -18
- package/views/permission/role/components/menu.vue +17 -19
- package/views/permission/role/index.vue +84 -49
- package/apis/admin/roleDetail.ts +0 -29
- package/apis/admin/roleSave.ts +0 -39
- package/apis/auth/logout.ts +0 -17
- package/apis/auth/register.ts +0 -43
- package/apis/dashboard/changelog.ts +0 -31
- package/apis/role/apiDetail.ts +0 -24
- package/apis/role/menuDetail.ts +0 -24
- package/views/403_1/meta.json +0 -4
- package/views/config/dict/meta.json +0 -4
- package/views/config/meta.json +0 -4
- package/views/config/system/meta.json +0 -4
- package/views/index/meta.json +0 -4
- package/views/log/email/meta.json +0 -4
- package/views/log/login/meta.json +0 -4
- package/views/log/meta.json +0 -4
- package/views/log/operate/meta.json +0 -4
- package/views/login_1/components/emailLoginForm.vue +0 -174
- package/views/login_1/components/registerForm.vue +0 -175
- package/views/login_1/components/welcomePanel.vue +0 -61
- package/views/login_1/meta.json +0 -4
- package/views/people/admin/meta.json +0 -4
- package/views/people/meta.json +0 -4
- package/views/permission/api/meta.json +0 -4
- package/views/permission/menu/meta.json +0 -4
- package/views/permission/meta.json +0 -4
- package/views/permission/role/meta.json +0 -4
|
@@ -19,7 +19,16 @@
|
|
|
19
19
|
|
|
20
20
|
<div class="main-content">
|
|
21
21
|
<div class="main-table">
|
|
22
|
-
<TTable
|
|
22
|
+
<TTable
|
|
23
|
+
:data="$Data.tableData"
|
|
24
|
+
:columns="$Data.columns"
|
|
25
|
+
:loading="$Data.loading"
|
|
26
|
+
:active-row-keys="$Data.activeRowKeys"
|
|
27
|
+
row-key="id"
|
|
28
|
+
height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)"
|
|
29
|
+
active-row-type="single"
|
|
30
|
+
@active-change="$Method.onActiveChange"
|
|
31
|
+
>
|
|
23
32
|
<template #state="{ row }">
|
|
24
33
|
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
25
34
|
<TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
|
|
@@ -61,38 +70,45 @@
|
|
|
61
70
|
</template>
|
|
62
71
|
|
|
63
72
|
<script setup>
|
|
64
|
-
import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from
|
|
65
|
-
import ILucidePlus from
|
|
66
|
-
import ILucideRotateCw from
|
|
67
|
-
import ILucidePencil from
|
|
68
|
-
import ILucideTrash2 from
|
|
69
|
-
import ILucideChevronDown from
|
|
70
|
-
import EditDialog from
|
|
71
|
-
import DetailPanel from
|
|
72
|
-
import { $Http } from
|
|
73
|
-
import { withDefaultColumns } from
|
|
73
|
+
import { Button as TButton, Table as TTable, Tag as TTag, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from "tdesign-vue-next";
|
|
74
|
+
import ILucidePlus from "~icons/lucide/plus";
|
|
75
|
+
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
76
|
+
import ILucidePencil from "~icons/lucide/pencil";
|
|
77
|
+
import ILucideTrash2 from "~icons/lucide/trash-2";
|
|
78
|
+
import ILucideChevronDown from "~icons/lucide/chevron-down";
|
|
79
|
+
import EditDialog from "./components/edit.vue";
|
|
80
|
+
import DetailPanel from "@/components/DetailPanel.vue";
|
|
81
|
+
import { $Http } from "@/plugins/http";
|
|
82
|
+
import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
|
|
83
|
+
|
|
84
|
+
definePage({
|
|
85
|
+
meta: {
|
|
86
|
+
title: "管理员",
|
|
87
|
+
order: 1
|
|
88
|
+
}
|
|
89
|
+
});
|
|
74
90
|
|
|
75
91
|
// 响应式数据
|
|
76
92
|
const $Data = $ref({
|
|
77
93
|
tableData: [],
|
|
78
94
|
loading: false,
|
|
79
95
|
columns: withDefaultColumns([
|
|
80
|
-
{ colKey:
|
|
81
|
-
{ colKey:
|
|
82
|
-
{ colKey:
|
|
83
|
-
{ colKey:
|
|
84
|
-
{ colKey:
|
|
85
|
-
{ colKey:
|
|
96
|
+
{ colKey: "username", title: "用户名", fixed: "left" },
|
|
97
|
+
{ colKey: "id", title: "序号" },
|
|
98
|
+
{ colKey: "nickname", title: "昵称" },
|
|
99
|
+
{ colKey: "roleCode", title: "角色" },
|
|
100
|
+
{ colKey: "state", title: "状态" },
|
|
101
|
+
{ colKey: "operation", title: "操作" }
|
|
86
102
|
]),
|
|
87
103
|
pagerConfig: {
|
|
88
104
|
currentPage: 1,
|
|
89
105
|
limit: 30,
|
|
90
106
|
total: 0,
|
|
91
|
-
align:
|
|
92
|
-
layout:
|
|
107
|
+
align: "right",
|
|
108
|
+
layout: "total, prev, pager, next, jumper"
|
|
93
109
|
},
|
|
94
110
|
editVisible: false,
|
|
95
|
-
actionType:
|
|
111
|
+
actionType: "add",
|
|
96
112
|
rowData: {},
|
|
97
113
|
currentRow: null,
|
|
98
114
|
activeRowKeys: []
|
|
@@ -108,7 +124,7 @@ const $Method = {
|
|
|
108
124
|
async apiAdminList() {
|
|
109
125
|
$Data.loading = true;
|
|
110
126
|
try {
|
|
111
|
-
const res = await $Http(
|
|
127
|
+
const res = await $Http("/addon/admin/admin/list", {
|
|
112
128
|
page: $Data.pagerConfig.currentPage,
|
|
113
129
|
limit: $Data.pagerConfig.limit
|
|
114
130
|
});
|
|
@@ -124,8 +140,7 @@ const $Method = {
|
|
|
124
140
|
$Data.activeRowKeys = [];
|
|
125
141
|
}
|
|
126
142
|
} catch (error) {
|
|
127
|
-
|
|
128
|
-
MessagePlugin.error('加载数据失败');
|
|
143
|
+
MessagePlugin.error("加载数据失败");
|
|
129
144
|
} finally {
|
|
130
145
|
$Data.loading = false;
|
|
131
146
|
}
|
|
@@ -133,22 +148,43 @@ const $Method = {
|
|
|
133
148
|
|
|
134
149
|
// 删除管理员
|
|
135
150
|
async apiAdminDel(row) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
151
|
+
let dialog = null;
|
|
152
|
+
let destroyed = false;
|
|
153
|
+
|
|
154
|
+
const destroy = () => {
|
|
155
|
+
if (destroyed) return;
|
|
156
|
+
destroyed = true;
|
|
157
|
+
if (dialog && typeof dialog.destroy === "function") {
|
|
158
|
+
dialog.destroy();
|
|
159
|
+
}
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
dialog = DialogPlugin.confirm({
|
|
163
|
+
header: "确认删除",
|
|
164
|
+
body: `确认删除管理员“${row.username}”吗?`,
|
|
165
|
+
status: "warning",
|
|
166
|
+
confirmBtn: "删除",
|
|
167
|
+
cancelBtn: "取消",
|
|
168
|
+
onConfirm: async () => {
|
|
169
|
+
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
170
|
+
dialog.setConfirmLoading(true);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
await $Http("/addon/admin/admin/del", { id: row.id });
|
|
175
|
+
MessagePlugin.success("删除成功");
|
|
176
|
+
destroy();
|
|
177
|
+
await $Method.apiAdminList();
|
|
178
|
+
} catch (error) {
|
|
179
|
+
MessagePlugin.error("删除失败");
|
|
180
|
+
} finally {
|
|
181
|
+
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
182
|
+
dialog.setConfirmLoading(false);
|
|
183
|
+
}
|
|
148
184
|
}
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
|
|
185
|
+
},
|
|
186
|
+
onClose: () => {
|
|
187
|
+
destroy();
|
|
152
188
|
}
|
|
153
189
|
});
|
|
154
190
|
},
|
|
@@ -188,9 +224,9 @@ const $Method = {
|
|
|
188
224
|
onAction(command, rowData) {
|
|
189
225
|
$Data.actionType = command;
|
|
190
226
|
$Data.rowData = rowData;
|
|
191
|
-
if (command ===
|
|
227
|
+
if (command === "add" || command === "upd") {
|
|
192
228
|
$Data.editVisible = true;
|
|
193
|
-
} else if (command ===
|
|
229
|
+
} else if (command === "del") {
|
|
194
230
|
$Method.apiAdminDel(rowData);
|
|
195
231
|
}
|
|
196
232
|
}
|
|
@@ -51,25 +51,32 @@
|
|
|
51
51
|
</template>
|
|
52
52
|
|
|
53
53
|
<script setup>
|
|
54
|
-
import { Button as TButton, Table as TTable, Tag as TTag, Input as TInput, MessagePlugin } from
|
|
55
|
-
import ILucideRotateCw from
|
|
56
|
-
import ILucideSearch from
|
|
57
|
-
import { $Http } from
|
|
58
|
-
import { withDefaultColumns } from
|
|
59
|
-
import DetailPanel from
|
|
54
|
+
import { Button as TButton, Table as TTable, Tag as TTag, Input as TInput, MessagePlugin } from "tdesign-vue-next";
|
|
55
|
+
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
56
|
+
import ILucideSearch from "~icons/lucide/search";
|
|
57
|
+
import { $Http } from "@/plugins/http";
|
|
58
|
+
import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
|
|
59
|
+
import DetailPanel from "@/components/DetailPanel.vue";
|
|
60
|
+
|
|
61
|
+
definePage({
|
|
62
|
+
meta: {
|
|
63
|
+
title: "接口列表",
|
|
64
|
+
order: 3
|
|
65
|
+
}
|
|
66
|
+
});
|
|
60
67
|
|
|
61
68
|
// 响应式数据
|
|
62
69
|
const $Data = $ref({
|
|
63
70
|
tableData: [],
|
|
64
71
|
allData: [],
|
|
65
72
|
loading: false,
|
|
66
|
-
searchKeyword:
|
|
73
|
+
searchKeyword: "",
|
|
67
74
|
columns: withDefaultColumns([
|
|
68
|
-
{ colKey:
|
|
69
|
-
{ colKey:
|
|
70
|
-
{ colKey:
|
|
71
|
-
{ colKey:
|
|
72
|
-
{ colKey:
|
|
75
|
+
{ colKey: "name", title: "接口名称" },
|
|
76
|
+
{ colKey: "id", title: "序号" },
|
|
77
|
+
{ colKey: "path", title: "接口路径" },
|
|
78
|
+
{ colKey: "method", title: "请求方法" },
|
|
79
|
+
{ colKey: "addonName", title: "所属组件" }
|
|
73
80
|
]),
|
|
74
81
|
currentRow: null,
|
|
75
82
|
activeRowKeys: []
|
|
@@ -85,7 +92,7 @@ const $Method = {
|
|
|
85
92
|
async loadApiAll() {
|
|
86
93
|
$Data.loading = true;
|
|
87
94
|
try {
|
|
88
|
-
const res = await $Http(
|
|
95
|
+
const res = await $Http("/addon/admin/api/all");
|
|
89
96
|
const list = res.data?.lists || [];
|
|
90
97
|
$Data.allData = list;
|
|
91
98
|
$Data.tableData = list;
|
|
@@ -99,8 +106,7 @@ const $Method = {
|
|
|
99
106
|
$Data.activeRowKeys = [];
|
|
100
107
|
}
|
|
101
108
|
} catch (error) {
|
|
102
|
-
|
|
103
|
-
MessagePlugin.error('加载数据失败');
|
|
109
|
+
MessagePlugin.error("加载数据失败");
|
|
104
110
|
} finally {
|
|
105
111
|
$Data.loading = false;
|
|
106
112
|
}
|
|
@@ -13,7 +13,17 @@
|
|
|
13
13
|
|
|
14
14
|
<div class="main-content">
|
|
15
15
|
<div class="main-table">
|
|
16
|
-
<TTable
|
|
16
|
+
<TTable
|
|
17
|
+
:data="$Data.tableData"
|
|
18
|
+
:columns="$Data.columns"
|
|
19
|
+
:loading="$Data.loading"
|
|
20
|
+
:active-row-keys="$Data.activeRowKeys"
|
|
21
|
+
row-key="id"
|
|
22
|
+
height="calc(100vh - var(--search-height) - var(--layout-gap) * 2)"
|
|
23
|
+
active-row-type="single"
|
|
24
|
+
:tree="{ childrenKey: 'children', treeNodeColumnIndex: 0, defaultExpandAll: true }"
|
|
25
|
+
@active-change="$Method.onActiveChange"
|
|
26
|
+
>
|
|
17
27
|
<template #state="{ row }">
|
|
18
28
|
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
19
29
|
<TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
|
|
@@ -30,24 +40,30 @@
|
|
|
30
40
|
</template>
|
|
31
41
|
|
|
32
42
|
<script setup>
|
|
33
|
-
import { Button as TButton, Table as TTable, Tag as TTag, MessagePlugin } from
|
|
34
|
-
import ILucideRotateCw from
|
|
35
|
-
import DetailPanel from
|
|
36
|
-
import { $Http } from
|
|
37
|
-
import { withDefaultColumns } from
|
|
38
|
-
|
|
43
|
+
import { Button as TButton, Table as TTable, Tag as TTag, MessagePlugin } from "tdesign-vue-next";
|
|
44
|
+
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
45
|
+
import DetailPanel from "@/components/DetailPanel.vue";
|
|
46
|
+
import { $Http } from "@/plugins/http";
|
|
47
|
+
import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
|
|
48
|
+
|
|
49
|
+
definePage({
|
|
50
|
+
meta: {
|
|
51
|
+
title: "菜单列表",
|
|
52
|
+
order: 2
|
|
53
|
+
}
|
|
54
|
+
});
|
|
39
55
|
|
|
40
56
|
// 响应式数据
|
|
41
57
|
const $Data = $ref({
|
|
42
58
|
tableData: [],
|
|
43
59
|
loading: false,
|
|
44
60
|
columns: withDefaultColumns([
|
|
45
|
-
{ colKey:
|
|
46
|
-
{ colKey:
|
|
47
|
-
{ colKey:
|
|
48
|
-
{ colKey:
|
|
49
|
-
{ colKey:
|
|
50
|
-
{ colKey:
|
|
61
|
+
{ colKey: "name", title: "菜单名称", fixed: "left" },
|
|
62
|
+
{ colKey: "id", title: "序号" },
|
|
63
|
+
{ colKey: "path", title: "路由路径" },
|
|
64
|
+
{ colKey: "icon", title: "图标" },
|
|
65
|
+
{ colKey: "sort", title: "排序" },
|
|
66
|
+
{ colKey: "state", title: "状态" }
|
|
51
67
|
]),
|
|
52
68
|
currentRow: null,
|
|
53
69
|
activeRowKeys: []
|
|
@@ -63,7 +79,7 @@ const $Method = {
|
|
|
63
79
|
async apiMenuList() {
|
|
64
80
|
$Data.loading = true;
|
|
65
81
|
try {
|
|
66
|
-
const res = await $Http(
|
|
82
|
+
const res = await $Http("/addon/admin/menu/list");
|
|
67
83
|
// 构建树形结构
|
|
68
84
|
$Data.tableData = $Method.buildTree(res.data || []);
|
|
69
85
|
|
|
@@ -76,8 +92,7 @@ const $Method = {
|
|
|
76
92
|
$Data.activeRowKeys = [];
|
|
77
93
|
}
|
|
78
94
|
} catch (error) {
|
|
79
|
-
|
|
80
|
-
MessagePlugin.error('加载数据失败');
|
|
95
|
+
MessagePlugin.error("加载数据失败");
|
|
81
96
|
} finally {
|
|
82
97
|
$Data.loading = false;
|
|
83
98
|
}
|
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
<div class="group-header">{{ group.title }}</div>
|
|
17
17
|
<div class="api-checkbox-list">
|
|
18
18
|
<TCheckboxGroup v-model="$Data.checkedApiIds">
|
|
19
|
-
<TCheckbox v-for="api in group.apis" :key="api.id" :value="api.id">
|
|
19
|
+
<TCheckbox v-for="api in group.apis" :key="api.id" :value="api.id">
|
|
20
|
+
{{ api.label }}
|
|
21
|
+
</TCheckbox>
|
|
20
22
|
</TCheckboxGroup>
|
|
21
23
|
</div>
|
|
22
24
|
</div>
|
|
@@ -35,9 +37,9 @@
|
|
|
35
37
|
</template>
|
|
36
38
|
|
|
37
39
|
<script setup>
|
|
38
|
-
import { Dialog as TDialog, Input as TInput, CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, Button as TButton, MessagePlugin } from
|
|
39
|
-
import ILucideSearch from
|
|
40
|
-
import { $Http } from
|
|
40
|
+
import { Dialog as TDialog, Input as TInput, CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, Button as TButton, MessagePlugin } from "tdesign-vue-next";
|
|
41
|
+
import ILucideSearch from "~icons/lucide/search";
|
|
42
|
+
import { $Http } from "@/plugins/http";
|
|
41
43
|
|
|
42
44
|
const $Prop = defineProps({
|
|
43
45
|
modelValue: {
|
|
@@ -50,14 +52,14 @@ const $Prop = defineProps({
|
|
|
50
52
|
}
|
|
51
53
|
});
|
|
52
54
|
|
|
53
|
-
const $Emit = defineEmits([
|
|
55
|
+
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
54
56
|
|
|
55
57
|
const $Data = $ref({
|
|
56
58
|
visible: false,
|
|
57
59
|
submitting: false,
|
|
58
60
|
apiData: [],
|
|
59
61
|
filteredApiData: [],
|
|
60
|
-
searchText:
|
|
62
|
+
searchText: "",
|
|
61
63
|
checkedApiIds: []
|
|
62
64
|
});
|
|
63
65
|
|
|
@@ -78,21 +80,21 @@ const $Method = {
|
|
|
78
80
|
onClose() {
|
|
79
81
|
$Data.visible = false;
|
|
80
82
|
setTimeout(() => {
|
|
81
|
-
$Emit(
|
|
83
|
+
$Emit("update:modelValue", false);
|
|
82
84
|
}, 300);
|
|
83
85
|
},
|
|
84
86
|
|
|
85
87
|
// 加载所有接口
|
|
86
88
|
async apiApiAll() {
|
|
87
89
|
try {
|
|
88
|
-
const res = await $Http(
|
|
90
|
+
const res = await $Http("/addon/admin/api/all");
|
|
89
91
|
|
|
90
92
|
// 将接口列表按 addonTitle 分组
|
|
91
93
|
const apiMap = new Map();
|
|
92
94
|
|
|
93
95
|
res.data.lists.forEach((api) => {
|
|
94
|
-
const addonTitle = api.addonTitle || api.addonName ||
|
|
95
|
-
const addonName = api.addonName ||
|
|
96
|
+
const addonTitle = api.addonTitle || api.addonName || "项目接口";
|
|
97
|
+
const addonName = api.addonName || "project";
|
|
96
98
|
|
|
97
99
|
if (!apiMap.has(addonName)) {
|
|
98
100
|
apiMap.set(addonName, {
|
|
@@ -111,8 +113,7 @@ const $Method = {
|
|
|
111
113
|
|
|
112
114
|
$Data.apiData = Array.from(apiMap.values());
|
|
113
115
|
} catch (error) {
|
|
114
|
-
|
|
115
|
-
MessagePlugin.error('加载接口失败');
|
|
116
|
+
MessagePlugin.error("加载接口失败");
|
|
116
117
|
}
|
|
117
118
|
},
|
|
118
119
|
|
|
@@ -121,13 +122,13 @@ const $Method = {
|
|
|
121
122
|
if (!$Prop.rowData.id) return;
|
|
122
123
|
|
|
123
124
|
try {
|
|
124
|
-
const res = await $Http(
|
|
125
|
-
|
|
125
|
+
const res = await $Http("/addon/admin/role/apis", {
|
|
126
|
+
roleCode: $Prop.rowData.code
|
|
126
127
|
});
|
|
127
128
|
|
|
128
129
|
$Data.checkedApiIds = res.data.apiIds || [];
|
|
129
130
|
} catch (error) {
|
|
130
|
-
|
|
131
|
+
MessagePlugin.error("加载数据失败");
|
|
131
132
|
}
|
|
132
133
|
},
|
|
133
134
|
|
|
@@ -152,21 +153,20 @@ const $Method = {
|
|
|
152
153
|
try {
|
|
153
154
|
$Data.submitting = true;
|
|
154
155
|
|
|
155
|
-
const res = await $Http(
|
|
156
|
-
|
|
156
|
+
const res = await $Http("/addon/admin/role/apiSave", {
|
|
157
|
+
roleCode: $Prop.rowData.code,
|
|
157
158
|
apiIds: $Data.checkedApiIds
|
|
158
159
|
});
|
|
159
160
|
|
|
160
161
|
if (res.code === 0) {
|
|
161
|
-
MessagePlugin.success(
|
|
162
|
+
MessagePlugin.success("保存成功");
|
|
162
163
|
$Data.visible = false;
|
|
163
|
-
$Emit(
|
|
164
|
+
$Emit("success");
|
|
164
165
|
} else {
|
|
165
|
-
MessagePlugin.error(res.msg ||
|
|
166
|
+
MessagePlugin.error(res.msg || "保存失败");
|
|
166
167
|
}
|
|
167
168
|
} catch (error) {
|
|
168
|
-
|
|
169
|
-
MessagePlugin.error('保存失败');
|
|
169
|
+
MessagePlugin.error("保存失败");
|
|
170
170
|
} finally {
|
|
171
171
|
$Data.submitting = false;
|
|
172
172
|
}
|
|
@@ -215,7 +215,7 @@ $Method.initData();
|
|
|
215
215
|
gap: 8px;
|
|
216
216
|
|
|
217
217
|
&::before {
|
|
218
|
-
content:
|
|
218
|
+
content: "";
|
|
219
219
|
width: 8px;
|
|
220
220
|
height: 8px;
|
|
221
221
|
border-radius: 50%;
|
|
@@ -41,9 +41,9 @@ import {
|
|
|
41
41
|
Radio as TRadio,
|
|
42
42
|
Button as TButton,
|
|
43
43
|
MessagePlugin
|
|
44
|
-
} from
|
|
45
|
-
import { fieldClear } from
|
|
46
|
-
import { $Http } from
|
|
44
|
+
} from "tdesign-vue-next";
|
|
45
|
+
import { fieldClear } from "befly-vite/utils/fieldClear";
|
|
46
|
+
import { $Http } from "@/plugins/http";
|
|
47
47
|
|
|
48
48
|
const $Prop = defineProps({
|
|
49
49
|
modelValue: {
|
|
@@ -52,7 +52,7 @@ const $Prop = defineProps({
|
|
|
52
52
|
},
|
|
53
53
|
actionType: {
|
|
54
54
|
type: String,
|
|
55
|
-
default:
|
|
55
|
+
default: "add"
|
|
56
56
|
},
|
|
57
57
|
rowData: {
|
|
58
58
|
type: Object,
|
|
@@ -60,7 +60,7 @@ const $Prop = defineProps({
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
-
const $Emit = defineEmits([
|
|
63
|
+
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
64
64
|
|
|
65
65
|
// 表单引用
|
|
66
66
|
const $From = $shallowRef({
|
|
@@ -74,9 +74,9 @@ const $Data = $ref({
|
|
|
74
74
|
submitting: false,
|
|
75
75
|
formData: {
|
|
76
76
|
id: 0,
|
|
77
|
-
name:
|
|
78
|
-
code:
|
|
79
|
-
description:
|
|
77
|
+
name: "",
|
|
78
|
+
code: "",
|
|
79
|
+
description: "",
|
|
80
80
|
sort: 0,
|
|
81
81
|
state: 1
|
|
82
82
|
}
|
|
@@ -84,19 +84,19 @@ const $Data = $ref({
|
|
|
84
84
|
|
|
85
85
|
const $Data2 = $shallowRef({
|
|
86
86
|
formRules: {
|
|
87
|
-
name: [{ required: true, message:
|
|
87
|
+
name: [{ required: true, message: "请输入角色名称", trigger: "blur" }],
|
|
88
88
|
code: [
|
|
89
|
-
{ required: true, message:
|
|
90
|
-
{ pattern: /^[a-zA-Z0-9_]+$/, message:
|
|
89
|
+
{ required: true, message: "请输入角色代码", trigger: "blur" },
|
|
90
|
+
{ pattern: /^[a-zA-Z0-9_]+$/, message: "角色代码只能包含字母、数字和下划线", trigger: "blur" }
|
|
91
91
|
],
|
|
92
|
-
sort: [{ type:
|
|
92
|
+
sort: [{ type: "number", message: "排序必须是数字", trigger: "blur" }]
|
|
93
93
|
}
|
|
94
94
|
});
|
|
95
95
|
|
|
96
96
|
// 方法集合
|
|
97
97
|
const $Method = {
|
|
98
98
|
async initData() {
|
|
99
|
-
if ($Prop.actionType ===
|
|
99
|
+
if ($Prop.actionType === "upd" && $Prop.rowData.id) {
|
|
100
100
|
$Data.formData = Object.assign({}, $Prop.rowData);
|
|
101
101
|
}
|
|
102
102
|
$Method.onShow();
|
|
@@ -110,7 +110,7 @@ const $Method = {
|
|
|
110
110
|
onClose() {
|
|
111
111
|
$Data.visible = false;
|
|
112
112
|
setTimeout(() => {
|
|
113
|
-
$Emit(
|
|
113
|
+
$Emit("update:modelValue", false);
|
|
114
114
|
}, 300);
|
|
115
115
|
},
|
|
116
116
|
async onSubmit() {
|
|
@@ -119,14 +119,14 @@ const $Method = {
|
|
|
119
119
|
if (!valid) return;
|
|
120
120
|
|
|
121
121
|
$Data.submitting = true;
|
|
122
|
-
const formData = $Prop.actionType ===
|
|
123
|
-
const res = await $Http($Prop.actionType ===
|
|
122
|
+
const formData = $Prop.actionType === "add" ? fieldClear($Data.formData, { omitKeys: ["id", "state"] }) : $Data.formData;
|
|
123
|
+
const res = await $Http($Prop.actionType === "upd" ? "/addon/admin/role/upd" : "/addon/admin/role/ins", formData);
|
|
124
124
|
|
|
125
125
|
MessagePlugin.success(res.msg);
|
|
126
|
-
$Emit(
|
|
126
|
+
$Emit("success");
|
|
127
127
|
$Method.onClose();
|
|
128
128
|
} catch (error) {
|
|
129
|
-
MessagePlugin.error(error.msg ||
|
|
129
|
+
MessagePlugin.error(error.msg || "提交失败");
|
|
130
130
|
} finally {
|
|
131
131
|
$Data.submitting = false;
|
|
132
132
|
}
|