@befly-addon/admin 1.8.2 → 1.8.4
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/adminViews/config/dict/components/edit.vue +12 -6
- package/adminViews/config/dict/index.vue +97 -177
- package/adminViews/config/dictType/components/edit.vue +12 -7
- package/adminViews/config/dictType/index.vue +93 -185
- package/adminViews/config/system/components/edit.vue +7 -4
- package/adminViews/config/system/index.vue +122 -213
- package/adminViews/log/email/index.vue +92 -157
- package/adminViews/log/login/index.vue +44 -121
- package/adminViews/log/operate/index.vue +82 -153
- package/adminViews/login_1/index.vue +6 -9
- package/adminViews/people/admin/components/edit.vue +5 -2
- package/adminViews/people/admin/index.vue +77 -192
- package/adminViews/permission/role/components/api.vue +4 -1
- package/adminViews/permission/role/components/edit.vue +4 -1
- package/adminViews/permission/role/components/menu.vue +4 -1
- package/adminViews/permission/role/index.vue +118 -213
- package/package.json +3 -3
|
@@ -1,85 +1,75 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
</DetailPanel>
|
|
63
|
-
</div>
|
|
64
|
-
</div>
|
|
65
|
-
|
|
66
|
-
<div class="main-page">
|
|
67
|
-
<TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.limit" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @page-size-change="$Method.handleSizeChange" />
|
|
68
|
-
</div>
|
|
69
|
-
</div>
|
|
2
|
+
<PagedTableDetailPage class="page-operate-log page-table" :columns="$Data.columns" :endpoints="$Data.endpoints" :table-slot-names="['result', 'operateTime', 'duration', 'action']">
|
|
3
|
+
<template #toolLeft="scope">
|
|
4
|
+
<TSelect v-model="$Data.filter.module" placeholder="操作模块" clearable style="width: 150px" @change="$Method.handleFilter(scope.reload)">
|
|
5
|
+
<TOption v-for="item in $Data.moduleOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
6
|
+
</TSelect>
|
|
7
|
+
<TSelect v-model="$Data.filter.action" placeholder="操作类型" clearable style="width: 150px" @change="$Method.handleFilter(scope.reload)">
|
|
8
|
+
<TOption v-for="item in $Data.actionOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
9
|
+
</TSelect>
|
|
10
|
+
<TSelect v-model="$Data.filter.result" placeholder="操作结果" clearable style="width: 120px" @change="$Method.handleFilter(scope.reload)">
|
|
11
|
+
<TOption label="成功" :value="1" />
|
|
12
|
+
<TOption label="失败" :value="0" />
|
|
13
|
+
</TSelect>
|
|
14
|
+
</template>
|
|
15
|
+
|
|
16
|
+
<template #toolRight="scope">
|
|
17
|
+
<TButton shape="circle" @click="$Method.onReload(scope.reload)">
|
|
18
|
+
<template #icon>
|
|
19
|
+
<ILucideRotateCw />
|
|
20
|
+
</template>
|
|
21
|
+
</TButton>
|
|
22
|
+
</template>
|
|
23
|
+
|
|
24
|
+
<template #result="{ row }">
|
|
25
|
+
<TTag v-if="row.result === 1" shape="round" theme="success" variant="light-outline">成功</TTag>
|
|
26
|
+
<TTag v-else shape="round" theme="danger" variant="light-outline">失败</TTag>
|
|
27
|
+
</template>
|
|
28
|
+
|
|
29
|
+
<template #operateTime="{ row }">
|
|
30
|
+
{{ $Method.formatTime(row.operateTime) }}
|
|
31
|
+
</template>
|
|
32
|
+
|
|
33
|
+
<template #duration="{ row }">
|
|
34
|
+
<TTag shape="round" :theme="row.duration > 1000 ? 'warning' : 'default'" variant="light-outline">{{ row.duration }}ms</TTag>
|
|
35
|
+
</template>
|
|
36
|
+
|
|
37
|
+
<template #action="{ row }">
|
|
38
|
+
<TTag shape="round" variant="light-outline">{{ row.action }}</TTag>
|
|
39
|
+
</template>
|
|
40
|
+
|
|
41
|
+
<template #detail="scope">
|
|
42
|
+
<DetailPanel :data="scope.currentRow" :fields="$Data.detailFields">
|
|
43
|
+
<template #result="slotScope">
|
|
44
|
+
<TTag v-if="slotScope.value === 1" shape="round" theme="success" variant="light-outline">成功</TTag>
|
|
45
|
+
<TTag v-else shape="round" theme="danger" variant="light-outline">失败</TTag>
|
|
46
|
+
</template>
|
|
47
|
+
<template #operateTime="slotScope">
|
|
48
|
+
{{ $Method.formatTime(slotScope.value) }}
|
|
49
|
+
</template>
|
|
50
|
+
<template #duration="slotScope">
|
|
51
|
+
<TTag shape="round" :theme="slotScope.value > 1000 ? 'warning' : 'default'" variant="light-outline">{{ slotScope.value }}ms</TTag>
|
|
52
|
+
</template>
|
|
53
|
+
<template #params="slotScope">
|
|
54
|
+
<pre class="json-content">{{ $Method.formatJson(slotScope.value) }}</pre>
|
|
55
|
+
</template>
|
|
56
|
+
<template #response="slotScope">
|
|
57
|
+
<pre class="json-content">{{ $Method.formatJson(slotScope.value) }}</pre>
|
|
58
|
+
</template>
|
|
59
|
+
</DetailPanel>
|
|
60
|
+
</template>
|
|
61
|
+
</PagedTableDetailPage>
|
|
70
62
|
</template>
|
|
71
63
|
|
|
72
64
|
<script setup lang="ts">
|
|
73
|
-
import { Button as TButton,
|
|
65
|
+
import { Button as TButton, Option as TOption, Select as TSelect, Tag as TTag } from "tdesign-vue-next";
|
|
74
66
|
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
75
67
|
import DetailPanel from "@/components/DetailPanel.vue";
|
|
76
|
-
import
|
|
68
|
+
import PagedTableDetailPage from "@/components/PagedTableDetailPage.vue";
|
|
77
69
|
import { withDefaultColumns } from "befly-shared/utils/withDefaultColumns";
|
|
78
70
|
|
|
79
71
|
// 响应式数据
|
|
80
72
|
const $Data = $ref({
|
|
81
|
-
tableData: [],
|
|
82
|
-
loading: false,
|
|
83
73
|
columns: withDefaultColumns([
|
|
84
74
|
{ colKey: "username", title: "操作人", fixed: "left", width: 100 },
|
|
85
75
|
{ colKey: "module", title: "模块", width: 100 },
|
|
@@ -105,13 +95,23 @@ const $Data = $ref({
|
|
|
105
95
|
{ colKey: "result", title: "操作结果" },
|
|
106
96
|
{ colKey: "remark", title: "备注" }
|
|
107
97
|
],
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
98
|
+
endpoints: {
|
|
99
|
+
list: {
|
|
100
|
+
path: "/addon/admin/operateLog/list",
|
|
101
|
+
dropValues: [""],
|
|
102
|
+
dropKeyValue: {
|
|
103
|
+
module: [""],
|
|
104
|
+
action: [""]
|
|
105
|
+
},
|
|
106
|
+
buildData: () => {
|
|
107
|
+
return {
|
|
108
|
+
module: $Data.filter.module,
|
|
109
|
+
action: $Data.filter.action,
|
|
110
|
+
result: $Data.filter.result
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
}
|
|
112
114
|
},
|
|
113
|
-
currentRow: null,
|
|
114
|
-
activeRowKeys: [],
|
|
115
115
|
filter: {
|
|
116
116
|
module: "",
|
|
117
117
|
action: "",
|
|
@@ -134,81 +134,12 @@ const $Data = $ref({
|
|
|
134
134
|
|
|
135
135
|
// 方法
|
|
136
136
|
const $Method = {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
},
|
|
140
|
-
|
|
141
|
-
// 加载操作日志列表
|
|
142
|
-
async apiOperateLogList() {
|
|
143
|
-
$Data.loading = true;
|
|
144
|
-
try {
|
|
145
|
-
const res = await $Http.post(
|
|
146
|
-
"/addon/admin/operateLog/list",
|
|
147
|
-
{
|
|
148
|
-
page: $Data.pagerConfig.currentPage,
|
|
149
|
-
limit: $Data.pagerConfig.limit,
|
|
150
|
-
module: $Data.filter.module,
|
|
151
|
-
action: $Data.filter.action,
|
|
152
|
-
result: $Data.filter.result
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
dropValues: [""],
|
|
156
|
-
dropKeyValue: {
|
|
157
|
-
module: [""],
|
|
158
|
-
action: [""]
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
);
|
|
162
|
-
$Data.tableData = res.data.lists || [];
|
|
163
|
-
$Data.pagerConfig.total = res.data.total || 0;
|
|
164
|
-
|
|
165
|
-
if ($Data.tableData.length > 0) {
|
|
166
|
-
$Data.currentRow = $Data.tableData[0];
|
|
167
|
-
$Data.activeRowKeys = [$Data.tableData[0].id];
|
|
168
|
-
} else {
|
|
169
|
-
$Data.currentRow = null;
|
|
170
|
-
$Data.activeRowKeys = [];
|
|
171
|
-
}
|
|
172
|
-
} catch (error) {
|
|
173
|
-
MessagePlugin.error("加载数据失败");
|
|
174
|
-
} finally {
|
|
175
|
-
$Data.loading = false;
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
|
|
179
|
-
// 筛选
|
|
180
|
-
handleFilter() {
|
|
181
|
-
$Data.pagerConfig.currentPage = 1;
|
|
182
|
-
$Method.apiOperateLogList();
|
|
183
|
-
},
|
|
184
|
-
|
|
185
|
-
// 刷新
|
|
186
|
-
handleRefresh() {
|
|
187
|
-
$Method.apiOperateLogList();
|
|
137
|
+
handleFilter(reload) {
|
|
138
|
+
reload({ keepSelection: false, resetPage: true });
|
|
188
139
|
},
|
|
189
140
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
$Data.pagerConfig.currentPage = currentPage;
|
|
193
|
-
$Method.apiOperateLogList();
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
// 每页条数改变
|
|
197
|
-
handleSizeChange(pageSize) {
|
|
198
|
-
$Data.pagerConfig.limit = pageSize;
|
|
199
|
-
$Data.pagerConfig.currentPage = 1;
|
|
200
|
-
$Method.apiOperateLogList();
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
// 高亮行变化
|
|
204
|
-
onActiveChange(value, context) {
|
|
205
|
-
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
206
|
-
return;
|
|
207
|
-
}
|
|
208
|
-
$Data.activeRowKeys = value;
|
|
209
|
-
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
210
|
-
$Data.currentRow = context.activeRowList[0].row;
|
|
211
|
-
}
|
|
141
|
+
onReload(reload) {
|
|
142
|
+
reload({ keepSelection: true });
|
|
212
143
|
},
|
|
213
144
|
|
|
214
145
|
// 格式化时间
|
|
@@ -235,8 +166,6 @@ const $Method = {
|
|
|
235
166
|
}
|
|
236
167
|
}
|
|
237
168
|
};
|
|
238
|
-
|
|
239
|
-
$Method.initData();
|
|
240
169
|
</script>
|
|
241
170
|
|
|
242
171
|
<style scoped lang="scss">
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
<p class="login-subtitle">请登录您的账户</p>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
|
-
<TForm :model="$Data.formData" :rules="$
|
|
24
|
+
<TForm :model="$Data.formData" :rules="$Data.formRules" :ref="(el) => ($From.form = el)" class="login-form" :show-message="false" label-width="0">
|
|
25
25
|
<TFormItem prop="account">
|
|
26
26
|
<TInputAdornment>
|
|
27
27
|
<template #prepend>
|
|
@@ -83,6 +83,10 @@ const $From = $shallowRef({
|
|
|
83
83
|
const $Data = $ref({
|
|
84
84
|
loading: false,
|
|
85
85
|
rememberMe: false,
|
|
86
|
+
formRules: {
|
|
87
|
+
account: [{ required: true, message: "请输入账号", trigger: "blur" }],
|
|
88
|
+
password: [{ required: true, message: "请输入密码", trigger: "blur" }]
|
|
89
|
+
},
|
|
86
90
|
formData: {
|
|
87
91
|
loginType: "username",
|
|
88
92
|
account: "",
|
|
@@ -90,18 +94,11 @@ const $Data = $ref({
|
|
|
90
94
|
}
|
|
91
95
|
});
|
|
92
96
|
|
|
93
|
-
const $Data2 = $shallowRef({
|
|
94
|
-
formRules: {
|
|
95
|
-
account: [{ required: true, message: "请输入账号", trigger: "blur" }],
|
|
96
|
-
password: [{ required: true, message: "请输入密码", trigger: "blur" }]
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
|
|
100
97
|
// 方法定义
|
|
101
98
|
const $Method = {
|
|
102
99
|
async apiLogin() {
|
|
103
100
|
try {
|
|
104
|
-
|
|
101
|
+
await $From.form.validate();
|
|
105
102
|
|
|
106
103
|
$Data.loading = true;
|
|
107
104
|
|
|
@@ -65,7 +65,10 @@ const $Prop = defineProps({
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
|
|
68
|
-
const $Emit = defineEmits
|
|
68
|
+
const $Emit = defineEmits<{
|
|
69
|
+
(e: "update:modelValue", value: boolean): void;
|
|
70
|
+
(e: "success"): void;
|
|
71
|
+
}>();
|
|
69
72
|
|
|
70
73
|
// 表单引用
|
|
71
74
|
const $From = $shallowRef({
|
|
@@ -108,7 +111,7 @@ const $Method = {
|
|
|
108
111
|
$Method.onShow();
|
|
109
112
|
await $Method.apiRoleLists();
|
|
110
113
|
if ($Prop.actionType === "upd" && $Prop.rowData.id) {
|
|
111
|
-
$Data.formData = {
|
|
114
|
+
$Data.formData = Object.assign({}, $Prop.rowData);
|
|
112
115
|
}
|
|
113
116
|
},
|
|
114
117
|
|
|
@@ -1,90 +1,65 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
<
|
|
6
|
-
<
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
<PagedTableDetailPage class="page-admin" :columns="$Data.columns" :endpoints="$Data.endpoints">
|
|
3
|
+
<template #toolLeft>
|
|
4
|
+
<TButton theme="primary" @click="$Method.onAdd">
|
|
5
|
+
<template #icon>
|
|
6
|
+
<ILucidePlus />
|
|
7
|
+
</template>
|
|
8
|
+
</TButton>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<template #toolRight="scope">
|
|
12
|
+
<TButton shape="circle" @click="$Method.onReload(scope.reload)">
|
|
13
|
+
<template #icon>
|
|
14
|
+
<ILucideRotateCw />
|
|
15
|
+
</template>
|
|
16
|
+
</TButton>
|
|
17
|
+
</template>
|
|
18
|
+
|
|
19
|
+
<template #state="{ row }">
|
|
20
|
+
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
21
|
+
<TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
|
|
22
|
+
<TTag v-else-if="row.state === 0" shape="round" theme="danger" variant="light-outline">删除</TTag>
|
|
23
|
+
</template>
|
|
24
|
+
|
|
25
|
+
<template #operation="{ row, deleteRow }">
|
|
26
|
+
<TDropdown trigger="click" placement="bottom-right" @click="$Method.onDropdownAction($event, row, deleteRow)">
|
|
27
|
+
<TButton theme="primary" size="small">
|
|
28
|
+
操作
|
|
29
|
+
<template #suffix> <ILucideChevronDown /></template>
|
|
9
30
|
</TButton>
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
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
|
-
>
|
|
32
|
-
<template #state="{ row }">
|
|
33
|
-
<TTag v-if="row.state === 1" shape="round" theme="success" variant="light-outline">正常</TTag>
|
|
34
|
-
<TTag v-else-if="row.state === 2" shape="round" theme="warning" variant="light-outline">禁用</TTag>
|
|
35
|
-
<TTag v-else-if="row.state === 0" shape="round" theme="danger" variant="light-outline">删除</TTag>
|
|
36
|
-
</template>
|
|
37
|
-
<template #operation="{ row }">
|
|
38
|
-
<TDropdown trigger="click" placement="bottom-right" @click="(data) => $Method.onAction(data.value, row)">
|
|
39
|
-
<TButton theme="primary" size="small">
|
|
40
|
-
操作
|
|
41
|
-
<template #suffix> <ILucideChevronDown /></template>
|
|
42
|
-
</TButton>
|
|
43
|
-
<TDropdownMenu slot="dropdown">
|
|
44
|
-
<TDropdownItem value="upd">
|
|
45
|
-
<ILucidePencil />
|
|
46
|
-
编辑
|
|
47
|
-
</TDropdownItem>
|
|
48
|
-
<TDropdownItem value="del" :divider="true">
|
|
49
|
-
<ILucideTrash2 />
|
|
50
|
-
删除
|
|
51
|
-
</TDropdownItem>
|
|
52
|
-
</TDropdownMenu>
|
|
53
|
-
</TDropdown>
|
|
54
|
-
</template>
|
|
55
|
-
</TTable>
|
|
56
|
-
</div>
|
|
57
|
-
|
|
58
|
-
<div class="main-detail">
|
|
59
|
-
<DetailPanel :data="$Data.currentRow" :fields="$Data.columns" />
|
|
60
|
-
</div>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<div class="main-page">
|
|
64
|
-
<TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.limit" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @page-size-change="$Method.handleSizeChange" />
|
|
65
|
-
</div>
|
|
66
|
-
|
|
67
|
-
<!-- 编辑对话框组件 -->
|
|
68
|
-
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiAdminList" />
|
|
69
|
-
</div>
|
|
31
|
+
<TDropdownMenu slot="dropdown">
|
|
32
|
+
<TDropdownItem value="upd">
|
|
33
|
+
<ILucidePencil />
|
|
34
|
+
编辑
|
|
35
|
+
</TDropdownItem>
|
|
36
|
+
<TDropdownItem value="del" :divider="true">
|
|
37
|
+
<ILucideTrash2 />
|
|
38
|
+
删除
|
|
39
|
+
</TDropdownItem>
|
|
40
|
+
</TDropdownMenu>
|
|
41
|
+
</TDropdown>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
<template #dialogs="scope">
|
|
45
|
+
<EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.onDialogSuccess(scope.reload)" />
|
|
46
|
+
</template>
|
|
47
|
+
</PagedTableDetailPage>
|
|
70
48
|
</template>
|
|
71
49
|
|
|
72
50
|
<script setup lang="ts">
|
|
73
|
-
import { Button as TButton,
|
|
51
|
+
import { Button as TButton, Dropdown as TDropdown, DropdownItem as TDropdownItem, DropdownMenu as TDropdownMenu, Tag as TTag } from "tdesign-vue-next";
|
|
74
52
|
import ILucidePlus from "~icons/lucide/plus";
|
|
75
53
|
import ILucideRotateCw from "~icons/lucide/rotate-cw";
|
|
76
54
|
import ILucidePencil from "~icons/lucide/pencil";
|
|
77
55
|
import ILucideTrash2 from "~icons/lucide/trash-2";
|
|
78
56
|
import ILucideChevronDown from "~icons/lucide/chevron-down";
|
|
79
57
|
import EditDialog from "./components/edit.vue";
|
|
80
|
-
import
|
|
81
|
-
import { $Http } from "@/plugins/http";
|
|
58
|
+
import PagedTableDetailPage from "@/components/PagedTableDetailPage.vue";
|
|
82
59
|
import { withDefaultColumns } from "befly-shared/utils/withDefaultColumns";
|
|
83
60
|
|
|
84
61
|
// 响应式数据
|
|
85
62
|
const $Data = $ref({
|
|
86
|
-
tableData: [],
|
|
87
|
-
loading: false,
|
|
88
63
|
columns: withDefaultColumns([
|
|
89
64
|
{ colKey: "username", title: "用户名", fixed: "left" },
|
|
90
65
|
{ colKey: "nickname", title: "昵称" },
|
|
@@ -92,147 +67,57 @@ const $Data = $ref({
|
|
|
92
67
|
{ colKey: "state", title: "状态" },
|
|
93
68
|
{ colKey: "operation", title: "操作" }
|
|
94
69
|
]),
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
70
|
+
endpoints: {
|
|
71
|
+
list: {
|
|
72
|
+
path: "/addon/admin/admin/list",
|
|
73
|
+
dropValues: [""]
|
|
74
|
+
},
|
|
75
|
+
delete: {
|
|
76
|
+
path: "/addon/admin/admin/del",
|
|
77
|
+
idKey: "id",
|
|
78
|
+
confirm: (row) => ({
|
|
79
|
+
header: "确认删除",
|
|
80
|
+
body: `确认删除“${row.username}”吗?`,
|
|
81
|
+
confirmBtn: "删除"
|
|
82
|
+
})
|
|
83
|
+
}
|
|
101
84
|
},
|
|
102
85
|
editVisible: false,
|
|
103
86
|
actionType: "add",
|
|
104
|
-
rowData: {}
|
|
105
|
-
currentRow: null,
|
|
106
|
-
activeRowKeys: []
|
|
87
|
+
rowData: {}
|
|
107
88
|
});
|
|
108
89
|
|
|
109
90
|
// 方法
|
|
110
91
|
const $Method = {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
// 加载管理员列表
|
|
116
|
-
async apiAdminList() {
|
|
117
|
-
$Data.loading = true;
|
|
118
|
-
try {
|
|
119
|
-
const res = await $Http.post(
|
|
120
|
-
"/addon/admin/admin/list",
|
|
121
|
-
{
|
|
122
|
-
page: $Data.pagerConfig.currentPage,
|
|
123
|
-
limit: $Data.pagerConfig.limit
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
dropValues: [""]
|
|
127
|
-
}
|
|
128
|
-
);
|
|
129
|
-
$Data.tableData = res.data.lists || [];
|
|
130
|
-
$Data.pagerConfig.total = res.data.total || 0;
|
|
131
|
-
|
|
132
|
-
// 自动高亮第一行
|
|
133
|
-
if ($Data.tableData.length > 0) {
|
|
134
|
-
$Data.currentRow = $Data.tableData[0];
|
|
135
|
-
$Data.activeRowKeys = [$Data.tableData[0].id];
|
|
136
|
-
} else {
|
|
137
|
-
$Data.currentRow = null;
|
|
138
|
-
$Data.activeRowKeys = [];
|
|
139
|
-
}
|
|
140
|
-
} catch (error) {
|
|
141
|
-
MessagePlugin.error("加载数据失败");
|
|
142
|
-
} finally {
|
|
143
|
-
$Data.loading = false;
|
|
144
|
-
}
|
|
92
|
+
onAdd() {
|
|
93
|
+
$Method.onAction("add", {});
|
|
145
94
|
},
|
|
146
95
|
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
let dialog = null;
|
|
150
|
-
let destroyed = false;
|
|
151
|
-
|
|
152
|
-
const destroy = () => {
|
|
153
|
-
if (destroyed) return;
|
|
154
|
-
destroyed = true;
|
|
155
|
-
if (dialog && typeof dialog.destroy === "function") {
|
|
156
|
-
dialog.destroy();
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
dialog = DialogPlugin.confirm({
|
|
161
|
-
header: "确认删除",
|
|
162
|
-
body: `确认删除管理员“${row.username}”吗?`,
|
|
163
|
-
status: "warning",
|
|
164
|
-
confirmBtn: "删除",
|
|
165
|
-
cancelBtn: "取消",
|
|
166
|
-
onConfirm: async () => {
|
|
167
|
-
if (dialog && typeof dialog.setConfirmLoading === "function") {
|
|
168
|
-
dialog.setConfirmLoading(true);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
try {
|
|
172
|
-
await $Http.post("/addon/admin/admin/del", {
|
|
173
|
-
id: row.id
|
|
174
|
-
});
|
|
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
|
-
}
|
|
184
|
-
}
|
|
185
|
-
},
|
|
186
|
-
onClose: () => {
|
|
187
|
-
destroy();
|
|
188
|
-
}
|
|
189
|
-
});
|
|
96
|
+
onReload(reload) {
|
|
97
|
+
reload({ keepSelection: true });
|
|
190
98
|
},
|
|
191
99
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
$Method.apiAdminList();
|
|
100
|
+
onDialogSuccess(reload) {
|
|
101
|
+
reload({ keepSelection: true });
|
|
195
102
|
},
|
|
196
103
|
|
|
197
|
-
// 分页改变
|
|
198
|
-
onPageChange({ currentPage }) {
|
|
199
|
-
$Data.pagerConfig.currentPage = currentPage;
|
|
200
|
-
$Method.apiAdminList();
|
|
201
|
-
},
|
|
202
|
-
|
|
203
|
-
// 每页条数改变
|
|
204
|
-
handleSizeChange({ pageSize }) {
|
|
205
|
-
$Data.pagerConfig.limit = pageSize;
|
|
206
|
-
$Data.pagerConfig.currentPage = 1;
|
|
207
|
-
$Method.apiAdminList();
|
|
208
|
-
},
|
|
209
|
-
|
|
210
|
-
// 高亮行变化
|
|
211
|
-
onActiveChange(value, context) {
|
|
212
|
-
// 禁止取消高亮:如果新值为空,保持当前选中
|
|
213
|
-
if (value.length === 0 && $Data.activeRowKeys.length > 0) {
|
|
214
|
-
return;
|
|
215
|
-
}
|
|
216
|
-
$Data.activeRowKeys = value;
|
|
217
|
-
// 更新当前高亮的行数据
|
|
218
|
-
if (context.activeRowList && context.activeRowList.length > 0) {
|
|
219
|
-
$Data.currentRow = context.activeRowList[0].row;
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
|
|
223
|
-
// 操作菜单点击
|
|
224
104
|
onAction(command, rowData) {
|
|
225
105
|
$Data.actionType = command;
|
|
226
106
|
$Data.rowData = rowData;
|
|
227
107
|
if (command === "add" || command === "upd") {
|
|
228
108
|
$Data.editVisible = true;
|
|
229
|
-
} else if (command === "del") {
|
|
230
|
-
$Method.apiAdminDel(rowData);
|
|
231
109
|
}
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
onDropdownAction(data, rowData, deleteRow) {
|
|
113
|
+
const cmd = data && data.value ? String(data.value) : "";
|
|
114
|
+
if (cmd === "del") {
|
|
115
|
+
deleteRow(rowData);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
$Method.onAction(cmd, rowData);
|
|
232
119
|
}
|
|
233
120
|
};
|
|
234
|
-
|
|
235
|
-
$Method.initData();
|
|
236
121
|
</script>
|
|
237
122
|
|
|
238
123
|
<style scoped lang="scss">
|