befly-admin-ui 1.10.1 → 1.10.2
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/components/detailPanel.vue +52 -54
- package/components/pageDialog.vue +131 -117
- package/components/pageTableDetail.vue +381 -402
- package/layouts/default.vue +212 -215
- package/package.json +2 -2
- package/views/config/dict/components/edit.vue +83 -60
- package/views/config/dict/index.vue +51 -55
- package/views/config/dictType/components/edit.vue +81 -57
- package/views/config/dictType/index.vue +37 -39
- package/views/config/system/components/edit.vue +97 -86
- package/views/config/system/index.vue +35 -37
- package/views/index/components/addonList.vue +14 -11
- package/views/index/components/environmentInfo.vue +25 -22
- package/views/index/components/operationLogs.vue +20 -16
- package/views/index/components/performanceMetrics.vue +24 -21
- package/views/index/components/serviceStatus.vue +26 -22
- package/views/index/components/systemNotifications.vue +24 -19
- package/views/index/components/systemOverview.vue +368 -385
- package/views/index/components/systemResources.vue +22 -19
- package/views/index/components/userInfo.vue +56 -56
- package/views/log/email/index.vue +96 -85
- package/views/log/error/index.vue +111 -117
- package/views/log/login/index.vue +15 -13
- package/views/log/operate/index.vue +31 -31
- package/views/login_1/index.vue +50 -32
- package/views/people/admin/components/edit.vue +1 -1
- package/views/people/admin/index.vue +27 -28
- package/views/permission/api/index.vue +44 -45
- package/views/permission/menu/index.vue +35 -35
- package/views/permission/role/components/api.vue +143 -144
- package/views/permission/role/components/edit.vue +74 -52
- package/views/permission/role/components/menu.vue +119 -121
- package/views/permission/role/index.vue +47 -49
- package/views/resource/gallery/index.vue +77 -78
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<PageTableDetail class="page-admin" :columns="$Data.columns" :endpoints="$Data.endpoints">
|
|
3
3
|
<template #toolLeft>
|
|
4
|
-
<TButton theme="primary" @click="onAdd">
|
|
4
|
+
<TButton theme="primary" @click="$Method.onAdd">
|
|
5
5
|
<template #icon>
|
|
6
6
|
<AddIcon />
|
|
7
7
|
</template>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
</template>
|
|
16
16
|
|
|
17
17
|
<template #operation="{ row, deleteRow }">
|
|
18
|
-
<TDropdown trigger="click" placement="bottom-right" @click="onDropdownAction($event, row, deleteRow)">
|
|
18
|
+
<TDropdown trigger="click" placement="bottom-right" @click="$Method.onDropdownAction($event, row, deleteRow)">
|
|
19
19
|
<TButton theme="primary" size="small">
|
|
20
20
|
操作
|
|
21
21
|
<template #suffix><ChevronDownIcon /></template>
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
</template>
|
|
35
35
|
|
|
36
36
|
<template #dialogs="scope">
|
|
37
|
-
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="onDialogSuccess(scope.reload)" />
|
|
37
|
+
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.onDialogSuccess(scope.reload)" />
|
|
38
38
|
</template>
|
|
39
39
|
</PageTableDetail>
|
|
40
40
|
</template>
|
|
@@ -76,32 +76,31 @@ const $Data = reactive({
|
|
|
76
76
|
rowData: {}
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
79
|
+
const $Method = {
|
|
80
|
+
onAdd() {
|
|
81
|
+
$Method.onAction("add", {});
|
|
82
|
+
},
|
|
83
|
+
onDialogSuccess(reload) {
|
|
84
|
+
reload({ keepSelection: true });
|
|
85
|
+
},
|
|
86
|
+
onAction(command, rowData) {
|
|
87
|
+
$Data.actionType = command;
|
|
88
|
+
$Data.rowData = rowData;
|
|
89
|
+
if (command === "add" || command === "upd") {
|
|
90
|
+
$Data.editVisible = true;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
onDropdownAction(data, rowData, deleteRow) {
|
|
94
|
+
const record = data;
|
|
95
|
+
const rawValue = record && record["value"] ? record["value"] : "";
|
|
96
|
+
const cmd = rawValue ? String(rawValue) : "";
|
|
97
|
+
if (cmd === "del") {
|
|
98
|
+
deleteRow(rowData);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
$Method.onAction(cmd, rowData);
|
|
102
102
|
}
|
|
103
|
-
|
|
104
|
-
}
|
|
103
|
+
};
|
|
105
104
|
</script>
|
|
106
105
|
|
|
107
106
|
<style scoped lang="scss">
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<div class="page-api page-table">
|
|
3
3
|
<div class="main-tool">
|
|
4
4
|
<div class="left">
|
|
5
|
-
<TInput v-model="$Data.searchKeyword" placeholder="搜索接口名称或路径" clearable style="width: 300px" @enter="handleSearch" @clear="handleSearch">
|
|
5
|
+
<TInput v-model="$Data.searchKeyword" placeholder="搜索接口名称或路径" clearable style="width: 300px" @enter="$Method.handleSearch" @clear="$Method.handleSearch">
|
|
6
6
|
<template #suffix-icon>
|
|
7
7
|
<SearchIcon />
|
|
8
8
|
</template>
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
|
|
14
14
|
<div class="main-content">
|
|
15
15
|
<div class="main-table">
|
|
16
|
-
<TTable :data="$Data.tableData" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" row-key="id" height="calc(100vh - var(--search-height) - var(--layout-gap) * 2)" active-row-type="single" @active-change="onActiveChange">
|
|
16
|
+
<TTable :data="$Data.tableData" :columns="$Data.columns" :loading="$Data.loading" :active-row-keys="$Data.activeRowKeys" row-key="id" height="calc(100vh - var(--search-height) - var(--layout-gap) * 2)" active-row-type="single" @active-change="$Method.onActiveChange">
|
|
17
17
|
<template #method="{ row }">
|
|
18
18
|
<TTag v-if="row.method === 'GET'" shape="round" theme="success" variant="light-outline">GET</TTag>
|
|
19
19
|
<TTag v-else-if="row.method === 'POST'" shape="round" theme="primary" variant="light-outline">POST</TTag>
|
|
@@ -56,7 +56,7 @@ import { reactive } from "vue";
|
|
|
56
56
|
import { Table as TTable, Tag as TTag, Input as TInput, MessagePlugin } from "tdesign-vue-next";
|
|
57
57
|
import { SearchIcon } from "tdesign-icons-vue-next";
|
|
58
58
|
import DetailPanel from "befly-admin-ui/components/detailPanel.vue";
|
|
59
|
-
import { $Http } from "@/plugins/http";
|
|
59
|
+
import { $Http } from "@/plugins/http.js";
|
|
60
60
|
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
61
61
|
|
|
62
62
|
// 响应式数据
|
|
@@ -76,52 +76,51 @@ const $Data = reactive({
|
|
|
76
76
|
activeRowKeys: []
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
79
|
+
const $Method = {
|
|
80
|
+
async initData() {
|
|
81
|
+
await $Method.loadApiAll();
|
|
82
|
+
},
|
|
83
|
+
async loadApiAll() {
|
|
84
|
+
$Data.loading = true;
|
|
85
|
+
try {
|
|
86
|
+
const res = await $Http("/core/api/all", {}, [""]);
|
|
87
|
+
const list = res.data?.lists || [];
|
|
88
|
+
$Data.allData = list;
|
|
89
|
+
$Data.tableData = list;
|
|
82
90
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
$Data.
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
91
|
+
if ($Data.tableData.length > 0) {
|
|
92
|
+
$Data.currentRow = $Data.tableData[0];
|
|
93
|
+
$Data.activeRowKeys = [$Data.tableData[0].id];
|
|
94
|
+
} else {
|
|
95
|
+
$Data.currentRow = null;
|
|
96
|
+
$Data.activeRowKeys = [];
|
|
97
|
+
}
|
|
98
|
+
} catch (error) {
|
|
99
|
+
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
100
|
+
} finally {
|
|
101
|
+
$Data.loading = false;
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
handleSearch() {
|
|
105
|
+
if (!$Data.searchKeyword) {
|
|
106
|
+
$Data.tableData = $Data.allData;
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
const keyword = String($Data.searchKeyword).toLowerCase();
|
|
110
|
+
$Data.tableData = $Data.allData.filter((item) => item.name?.toLowerCase().includes(keyword) || item.path?.toLowerCase().includes(keyword));
|
|
111
|
+
},
|
|
112
|
+
onActiveChange(value, context) {
|
|
113
|
+
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
$Data.activeRowKeys = value;
|
|
117
|
+
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
118
|
+
$Data.currentRow = context.activeRowList[0].row;
|
|
97
119
|
}
|
|
98
|
-
} catch (error) {
|
|
99
|
-
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
100
|
-
} finally {
|
|
101
|
-
$Data.loading = false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
function handleSearch() {
|
|
106
|
-
if (!$Data.searchKeyword) {
|
|
107
|
-
$Data.tableData = $Data.allData;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
const keyword = String($Data.searchKeyword).toLowerCase();
|
|
111
|
-
$Data.tableData = $Data.allData.filter((item) => item.name?.toLowerCase().includes(keyword) || item.path?.toLowerCase().includes(keyword));
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
function onActiveChange(value, context) {
|
|
115
|
-
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
$Data.activeRowKeys = value;
|
|
119
|
-
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
120
|
-
$Data.currentRow = context.activeRowList[0].row;
|
|
121
120
|
}
|
|
122
|
-
}
|
|
121
|
+
};
|
|
123
122
|
|
|
124
|
-
initData();
|
|
123
|
+
$Method.initData();
|
|
125
124
|
</script>
|
|
126
125
|
|
|
127
126
|
<style scoped lang="scss">
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
height="calc(100vh - var(--layout-gap) * 2)"
|
|
12
12
|
active-row-type="single"
|
|
13
13
|
:tree="{ childrenKey: 'children', treeNodeColumnIndex: 0, defaultExpandAll: true }"
|
|
14
|
-
@active-change="onActiveChange"
|
|
14
|
+
@active-change="$Method.onActiveChange"
|
|
15
15
|
>
|
|
16
16
|
<template #state="{ row }">
|
|
17
17
|
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
import { reactive } from "vue";
|
|
33
33
|
import { Table as TTable, Tag as TTag, MessagePlugin } from "tdesign-vue-next";
|
|
34
34
|
import DetailPanel from "befly-admin-ui/components/detailPanel.vue";
|
|
35
|
-
import { $Http } from "@/plugins/http";
|
|
35
|
+
import { $Http } from "@/plugins/http.js";
|
|
36
36
|
import { arrayToTree } from "befly-admin-ui/utils/arrayToTree";
|
|
37
37
|
import { withDefaultColumns } from "befly-admin-ui/utils/withDefaultColumns";
|
|
38
38
|
|
|
@@ -51,45 +51,45 @@ const $Data = reactive({
|
|
|
51
51
|
activeRowKeys: []
|
|
52
52
|
});
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
const $Method = {
|
|
55
|
+
async initData() {
|
|
56
|
+
await $Method.apiMenuList();
|
|
57
|
+
},
|
|
58
|
+
async apiMenuList() {
|
|
59
|
+
$Data.loading = true;
|
|
60
|
+
try {
|
|
61
|
+
const res = await $Http("/core/menu/all", {}, [""]);
|
|
62
|
+
const lists = Array.isArray(res?.data?.lists) ? res.data.lists : [];
|
|
57
63
|
|
|
58
|
-
|
|
59
|
-
$Data.loading = true;
|
|
60
|
-
try {
|
|
61
|
-
const res = await $Http("/core/menu/all", {}, [""]);
|
|
62
|
-
const lists = Array.isArray(res?.data?.lists) ? res.data.lists : [];
|
|
64
|
+
const treeResult = arrayToTree(lists, "path", "parentPath", "children", "sort");
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
$Data.tableData = treeResult.tree;
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
68
|
+
if ($Data.tableData.length > 0) {
|
|
69
|
+
$Data.currentRow = $Data.tableData[0];
|
|
70
|
+
$Data.activeRowKeys = [$Data.tableData[0].id];
|
|
71
|
+
} else {
|
|
72
|
+
$Data.currentRow = null;
|
|
73
|
+
$Data.activeRowKeys = [];
|
|
74
|
+
}
|
|
75
|
+
} catch (error) {
|
|
76
|
+
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
77
|
+
} finally {
|
|
78
|
+
$Data.loading = false;
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
onActiveChange(value, context) {
|
|
82
|
+
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
$Data.activeRowKeys = value;
|
|
86
|
+
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
87
|
+
$Data.currentRow = context.activeRowList[0].row;
|
|
74
88
|
}
|
|
75
|
-
} catch (error) {
|
|
76
|
-
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
77
|
-
} finally {
|
|
78
|
-
$Data.loading = false;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
function onActiveChange(value, context) {
|
|
83
|
-
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
84
|
-
return;
|
|
85
|
-
}
|
|
86
|
-
$Data.activeRowKeys = value;
|
|
87
|
-
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
88
|
-
$Data.currentRow = context.activeRowList[0].row;
|
|
89
89
|
}
|
|
90
|
-
}
|
|
90
|
+
};
|
|
91
91
|
|
|
92
|
-
initData();
|
|
92
|
+
$Method.initData();
|
|
93
93
|
</script>
|
|
94
94
|
|
|
95
95
|
<style scoped lang="scss">
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<PageDialog v-model="dialogVisible" title="接口权限" width="900px" :confirm-loading="$Data.submitting" @confirm="onSubmit">
|
|
2
|
+
<PageDialog v-model="$Computed.dialogVisible" title="接口权限" width="900px" :confirm-loading="$Data.submitting" @confirm="$Method.onSubmit">
|
|
3
3
|
<div class="comp-role-api">
|
|
4
4
|
<!-- 搜索框 -->
|
|
5
5
|
<div class="search-box">
|
|
6
|
-
<TInput v-model="$Data.searchText" placeholder="搜索接口名称或路径" clearable @change="onSearch">
|
|
6
|
+
<TInput v-model="$Data.searchText" placeholder="搜索接口名称或路径" clearable @change="$Method.onSearch">
|
|
7
7
|
<template #prefix-icon>
|
|
8
8
|
<SearchIcon />
|
|
9
9
|
</template>
|
|
@@ -37,7 +37,7 @@ import { computed, reactive } from "vue";
|
|
|
37
37
|
import { Input as TInput, CheckboxGroup as TCheckboxGroup, Checkbox as TCheckbox, MessagePlugin } from "tdesign-vue-next";
|
|
38
38
|
import { SearchIcon } from "tdesign-icons-vue-next";
|
|
39
39
|
import PageDialog from "befly-admin-ui/components/pageDialog.vue";
|
|
40
|
-
import { $Http } from "@/plugins/http";
|
|
40
|
+
import { $Http } from "@/plugins/http.js";
|
|
41
41
|
|
|
42
42
|
const $Prop = defineProps({
|
|
43
43
|
modelValue: {
|
|
@@ -52,13 +52,6 @@ const $Prop = defineProps({
|
|
|
52
52
|
|
|
53
53
|
const $Emit = defineEmits(["update:modelValue", "success"]);
|
|
54
54
|
|
|
55
|
-
const dialogVisible = computed({
|
|
56
|
-
get: () => $Prop.modelValue,
|
|
57
|
-
set: (value) => {
|
|
58
|
-
$Emit("update:modelValue", value);
|
|
59
|
-
}
|
|
60
|
-
});
|
|
61
|
-
|
|
62
55
|
const $Data = reactive({
|
|
63
56
|
submitting: false,
|
|
64
57
|
apiData: [],
|
|
@@ -67,164 +60,170 @@ const $Data = reactive({
|
|
|
67
60
|
checkedApiPaths: []
|
|
68
61
|
});
|
|
69
62
|
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
const $Computed = reactive({
|
|
64
|
+
dialogVisible: computed({
|
|
65
|
+
get: () => $Prop.modelValue,
|
|
66
|
+
set: (value) => {
|
|
67
|
+
$Emit("update:modelValue", value);
|
|
68
|
+
}
|
|
69
|
+
})
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
const $Method = {
|
|
73
|
+
async initData() {
|
|
74
|
+
await Promise.all([$Method.apiApiAll(), $Method.apiRoleApiDetail()]);
|
|
72
75
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
const merged = new Set();
|
|
77
|
+
const current = Array.isArray($Data.checkedApiPaths) ? $Data.checkedApiPaths : [];
|
|
78
|
+
for (const path of current) {
|
|
79
|
+
if (typeof path === "string") {
|
|
80
|
+
merged.add(path);
|
|
81
|
+
}
|
|
78
82
|
}
|
|
79
|
-
}
|
|
80
83
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
const groups = Array.isArray($Data.apiData) ? $Data.apiData : [];
|
|
85
|
+
for (const group of groups) {
|
|
86
|
+
const groupRecord = group && typeof group === "object" ? group : null;
|
|
87
|
+
const apis = groupRecord && Array.isArray(groupRecord["apis"]) ? groupRecord["apis"] : [];
|
|
88
|
+
for (const api of apis) {
|
|
89
|
+
const apiRecord = api && typeof api === "object" ? api : null;
|
|
90
|
+
const authValue = apiRecord ? apiRecord["auth"] : undefined;
|
|
91
|
+
const isPublic = authValue === 0 || authValue === "0" || authValue === false;
|
|
92
|
+
const value = apiRecord && typeof apiRecord["value"] === "string" ? String(apiRecord["value"]) : "";
|
|
93
|
+
if (isPublic && value) {
|
|
94
|
+
merged.add(value);
|
|
95
|
+
}
|
|
92
96
|
}
|
|
93
97
|
}
|
|
94
|
-
}
|
|
95
98
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
+
$Data.checkedApiPaths = Array.from(merged);
|
|
100
|
+
$Data.filteredApiData = $Data.apiData;
|
|
101
|
+
},
|
|
102
|
+
async apiApiAll() {
|
|
103
|
+
try {
|
|
104
|
+
const res = await $Http("/core/api/all", {}, [""]);
|
|
105
|
+
|
|
106
|
+
const apiMap = new Map();
|
|
107
|
+
const resRecord = res && typeof res === "object" ? res : null;
|
|
108
|
+
const resData = resRecord && resRecord["data"] && typeof resRecord["data"] === "object" ? resRecord["data"] : null;
|
|
109
|
+
const lists = resData && Array.isArray(resData["lists"]) ? resData["lists"] : [];
|
|
110
|
+
for (const api of lists) {
|
|
111
|
+
const apiRecord = api && typeof api === "object" ? api : null;
|
|
112
|
+
const apiPath = apiRecord && typeof apiRecord["path"] === "string" ? String(apiRecord["path"]) : "";
|
|
113
|
+
if (!apiPath) {
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
99
116
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
const res = await $Http("/core/api/all", {}, [""]);
|
|
117
|
+
const parentPath = apiRecord && typeof apiRecord["parentPath"] === "string" ? String(apiRecord["parentPath"]) : "";
|
|
118
|
+
const groupKey = parentPath || "(未分组)";
|
|
103
119
|
|
|
104
|
-
|
|
120
|
+
if (!apiMap.has(groupKey)) {
|
|
121
|
+
apiMap.set(groupKey, {
|
|
122
|
+
name: groupKey,
|
|
123
|
+
title: groupKey,
|
|
124
|
+
apis: []
|
|
125
|
+
});
|
|
126
|
+
}
|
|
105
127
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
128
|
+
apiMap.get(groupKey)?.apis.push({
|
|
129
|
+
value: apiPath,
|
|
130
|
+
name: (apiRecord && typeof apiRecord["name"] === "string" ? String(apiRecord["name"]) : "") || apiPath,
|
|
131
|
+
path: apiPath,
|
|
132
|
+
label: `${(apiRecord && typeof apiRecord["name"] === "string" ? String(apiRecord["name"]) : "") || ""} ${apiPath ? `(${apiPath})` : ""}`.trim(),
|
|
133
|
+
description: apiRecord ? apiRecord["description"] : undefined,
|
|
134
|
+
auth: apiRecord ? apiRecord["auth"] : undefined,
|
|
135
|
+
parentPath: parentPath
|
|
136
|
+
});
|
|
114
137
|
}
|
|
115
138
|
|
|
116
|
-
const
|
|
117
|
-
const
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
title: groupKey,
|
|
123
|
-
apis: []
|
|
139
|
+
const groups = Array.from(apiMap.values());
|
|
140
|
+
for (const group of groups) {
|
|
141
|
+
group.apis.sort((a, b) => {
|
|
142
|
+
const ap = typeof a.path === "string" ? a.path : "";
|
|
143
|
+
const bp = typeof b.path === "string" ? b.path : "";
|
|
144
|
+
return ap.localeCompare(bp);
|
|
124
145
|
});
|
|
125
146
|
}
|
|
126
147
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
label: `${(apiRecord && typeof apiRecord["name"] === "string" ? String(apiRecord["name"]) : "") || ""} ${apiPath ? `(${apiPath})` : ""}`.trim(),
|
|
132
|
-
description: apiRecord ? apiRecord["description"] : undefined,
|
|
133
|
-
auth: apiRecord ? apiRecord["auth"] : undefined,
|
|
134
|
-
parentPath: parentPath
|
|
148
|
+
groups.sort((a, b) => {
|
|
149
|
+
const at = typeof a.title === "string" ? a.title : "";
|
|
150
|
+
const bt = typeof b.title === "string" ? b.title : "";
|
|
151
|
+
return at.localeCompare(bt);
|
|
135
152
|
});
|
|
136
|
-
}
|
|
137
153
|
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
154
|
+
$Data.apiData = groups;
|
|
155
|
+
} catch (error) {
|
|
156
|
+
MessagePlugin.error(error.msg || error.message || "加载接口失败");
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
async apiRoleApiDetail() {
|
|
160
|
+
if (!$Prop.rowData.id) return;
|
|
161
|
+
|
|
162
|
+
try {
|
|
163
|
+
const res = await $Http(
|
|
164
|
+
"/core/role/apis",
|
|
165
|
+
{
|
|
166
|
+
roleCode: $Prop.rowData.code
|
|
167
|
+
},
|
|
168
|
+
[""]
|
|
169
|
+
);
|
|
170
|
+
|
|
171
|
+
const resRecord = res && typeof res === "object" ? res : null;
|
|
172
|
+
const resData = resRecord && resRecord["data"] && typeof resRecord["data"] === "object" ? resRecord["data"] : null;
|
|
173
|
+
$Data.checkedApiPaths = resData && Array.isArray(resData["apiPaths"]) ? resData["apiPaths"] : [];
|
|
174
|
+
} catch (error) {
|
|
175
|
+
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
176
|
+
}
|
|
177
|
+
},
|
|
178
|
+
onSearch() {
|
|
179
|
+
if (!$Data.searchText) {
|
|
180
|
+
$Data.filteredApiData = $Data.apiData;
|
|
181
|
+
return;
|
|
145
182
|
}
|
|
146
183
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
const resRecord = res && typeof res === "object" ? res : null;
|
|
172
|
-
const resData = resRecord && resRecord["data"] && typeof resRecord["data"] === "object" ? resRecord["data"] : null;
|
|
173
|
-
$Data.checkedApiPaths = resData && Array.isArray(resData["apiPaths"]) ? resData["apiPaths"] : [];
|
|
174
|
-
} catch (error) {
|
|
175
|
-
MessagePlugin.error(error.msg || error.message || "加载数据失败");
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function onSearch() {
|
|
180
|
-
if (!$Data.searchText) {
|
|
181
|
-
$Data.filteredApiData = $Data.apiData;
|
|
182
|
-
return;
|
|
183
|
-
}
|
|
184
|
+
const searchLower = String($Data.searchText).toLowerCase();
|
|
185
|
+
$Data.filteredApiData = $Data.apiData
|
|
186
|
+
.map((group) => {
|
|
187
|
+
const groupRecord = group && typeof group === "object" ? group : null;
|
|
188
|
+
const groupApis = groupRecord && Array.isArray(groupRecord["apis"]) ? groupRecord["apis"] : [];
|
|
189
|
+
const apis = groupApis.filter((api) => {
|
|
190
|
+
const apiRecord = api && typeof api === "object" ? api : null;
|
|
191
|
+
const label = apiRecord && typeof apiRecord["label"] === "string" ? String(apiRecord["label"]) : "";
|
|
192
|
+
const name = apiRecord && typeof apiRecord["name"] === "string" ? String(apiRecord["name"]) : "";
|
|
193
|
+
const path = apiRecord && typeof apiRecord["path"] === "string" ? String(apiRecord["path"]) : "";
|
|
194
|
+
return label.toLowerCase().includes(searchLower) || name.toLowerCase().includes(searchLower) || path.toLowerCase().includes(searchLower);
|
|
195
|
+
});
|
|
196
|
+
return {
|
|
197
|
+
name: groupRecord && typeof groupRecord["name"] === "string" ? String(groupRecord["name"]) : "",
|
|
198
|
+
title: groupRecord && typeof groupRecord["title"] === "string" ? String(groupRecord["title"]) : "",
|
|
199
|
+
apis: apis
|
|
200
|
+
};
|
|
201
|
+
})
|
|
202
|
+
.filter((group) => group.apis.length > 0);
|
|
203
|
+
},
|
|
204
|
+
async onSubmit(context) {
|
|
205
|
+
try {
|
|
206
|
+
$Data.submitting = true;
|
|
184
207
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
const groupRecord = group && typeof group === "object" ? group : null;
|
|
189
|
-
const groupApis = groupRecord && Array.isArray(groupRecord["apis"]) ? groupRecord["apis"] : [];
|
|
190
|
-
const apis = groupApis.filter((api) => {
|
|
191
|
-
const apiRecord = api && typeof api === "object" ? api : null;
|
|
192
|
-
const label = apiRecord && typeof apiRecord["label"] === "string" ? String(apiRecord["label"]) : "";
|
|
193
|
-
const name = apiRecord && typeof apiRecord["name"] === "string" ? String(apiRecord["name"]) : "";
|
|
194
|
-
const path = apiRecord && typeof apiRecord["path"] === "string" ? String(apiRecord["path"]) : "";
|
|
195
|
-
return label.toLowerCase().includes(searchLower) || name.toLowerCase().includes(searchLower) || path.toLowerCase().includes(searchLower);
|
|
208
|
+
await $Http("/core/role/apiSave", {
|
|
209
|
+
roleCode: $Prop.rowData.code,
|
|
210
|
+
apiPaths: $Data.checkedApiPaths
|
|
196
211
|
});
|
|
197
|
-
return {
|
|
198
|
-
name: groupRecord && typeof groupRecord["name"] === "string" ? String(groupRecord["name"]) : "",
|
|
199
|
-
title: groupRecord && typeof groupRecord["title"] === "string" ? String(groupRecord["title"]) : "",
|
|
200
|
-
apis: apis
|
|
201
|
-
};
|
|
202
|
-
})
|
|
203
|
-
.filter((group) => group.apis.length > 0);
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
async function onSubmit(context) {
|
|
207
|
-
try {
|
|
208
|
-
$Data.submitting = true;
|
|
209
|
-
|
|
210
|
-
const res = await $Http("/core/role/apiSave", {
|
|
211
|
-
roleCode: $Prop.rowData.code,
|
|
212
|
-
apiPaths: $Data.checkedApiPaths
|
|
213
|
-
});
|
|
214
212
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
213
|
+
MessagePlugin.success("保存成功");
|
|
214
|
+
$Emit("success");
|
|
215
|
+
if (context && typeof context.close === "function") {
|
|
216
|
+
context.close();
|
|
217
|
+
}
|
|
218
|
+
} catch (error) {
|
|
219
|
+
MessagePlugin.error(error.msg || error.message || "保存失败");
|
|
220
|
+
} finally {
|
|
221
|
+
$Data.submitting = false;
|
|
219
222
|
}
|
|
220
|
-
} catch (error) {
|
|
221
|
-
MessagePlugin.error(error.msg || error.message || "保存失败");
|
|
222
|
-
} finally {
|
|
223
|
-
$Data.submitting = false;
|
|
224
223
|
}
|
|
225
|
-
}
|
|
224
|
+
};
|
|
226
225
|
|
|
227
|
-
initData();
|
|
226
|
+
$Method.initData();
|
|
228
227
|
</script>
|
|
229
228
|
|
|
230
229
|
<style scoped lang="scss">
|