@befly-addon/admin 1.0.54 → 1.0.56

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.
Files changed (82) hide show
  1. package/apis/admin/cacheRefresh.ts +17 -14
  2. package/apis/admin/ins.ts +11 -15
  3. package/apis/admin/upd.ts +1 -13
  4. package/apis/api/all.ts +1 -1
  5. package/apis/api/list.ts +30 -0
  6. package/apis/auth/login.ts +51 -7
  7. package/apis/dashboard/serviceStatus.ts +2 -2
  8. package/apis/dashboard/systemResources.ts +1 -1
  9. package/apis/dict/all.ts +1 -1
  10. package/apis/dict/del.ts +1 -1
  11. package/apis/dict/detail.ts +2 -2
  12. package/apis/dict/ins.ts +1 -1
  13. package/apis/dict/upd.ts +1 -1
  14. package/apis/email/config.ts +16 -0
  15. package/apis/email/logList.ts +13 -0
  16. package/apis/email/send.ts +42 -0
  17. package/apis/email/verify.ts +12 -0
  18. package/apis/loginLog/list.ts +13 -0
  19. package/apis/menu/all.ts +2 -2
  20. package/apis/menu/list.ts +1 -1
  21. package/apis/operateLog/list.ts +13 -0
  22. package/apis/role/del.ts +2 -2
  23. package/apis/role/save.ts +2 -2
  24. package/apis/sysConfig/all.ts +12 -0
  25. package/apis/sysConfig/del.ts +30 -0
  26. package/apis/sysConfig/get.ts +31 -0
  27. package/apis/sysConfig/ins.ts +38 -0
  28. package/apis/sysConfig/list.ts +14 -0
  29. package/apis/sysConfig/upd.ts +50 -0
  30. package/package.json +14 -3
  31. package/plugins/email.ts +206 -0
  32. package/styles/variables.scss +121 -60
  33. package/tables/admin.json +0 -15
  34. package/tables/emailLog.json +69 -0
  35. package/tables/loginLog.json +96 -0
  36. package/tables/operateLog.json +82 -0
  37. package/tables/role.json +1 -1
  38. package/tables/sysConfig.json +53 -0
  39. package/views/403_1/meta.json +4 -0
  40. package/views/{dict → config/dict}/components/edit.vue +7 -5
  41. package/views/config/dict/index.vue +205 -0
  42. package/views/config/dict/meta.json +4 -0
  43. package/views/config/meta.json +4 -0
  44. package/views/config/system/components/edit.vue +179 -0
  45. package/views/config/system/index.vue +256 -0
  46. package/views/config/system/meta.json +4 -0
  47. package/views/index/index.vue +46 -9
  48. package/views/index/meta.json +4 -0
  49. package/views/log/email/index.vue +285 -0
  50. package/views/log/email/meta.json +4 -0
  51. package/views/log/login/index.vue +180 -0
  52. package/views/log/login/meta.json +4 -0
  53. package/views/log/meta.json +4 -0
  54. package/views/log/operate/index.vue +242 -0
  55. package/views/log/operate/meta.json +4 -0
  56. package/views/login_1/meta.json +4 -0
  57. package/views/{admin → people/admin}/components/edit.vue +23 -35
  58. package/views/{admin → people/admin}/index.vue +37 -96
  59. package/views/people/admin/meta.json +4 -0
  60. package/views/people/meta.json +4 -0
  61. package/views/permission/api/index.vue +143 -0
  62. package/views/permission/api/meta.json +4 -0
  63. package/views/permission/menu/index.vue +146 -0
  64. package/views/permission/menu/meta.json +4 -0
  65. package/views/permission/meta.json +4 -0
  66. package/views/{role → permission/role}/components/api.vue +22 -51
  67. package/views/{role → permission/role}/components/edit.vue +14 -15
  68. package/views/{role → permission/role}/components/menu.vue +11 -38
  69. package/views/permission/role/index.vue +227 -0
  70. package/views/permission/role/meta.json +4 -0
  71. package/apis/menu/del.ts +0 -31
  72. package/apis/menu/ins.ts +0 -19
  73. package/apis/menu/upd.ts +0 -27
  74. package/views/dict/index.vue +0 -162
  75. package/views/menu/components/edit.vue +0 -145
  76. package/views/menu/index.vue +0 -173
  77. package/views/role/index.vue +0 -184
  78. /package/views/{403 → 403_1}/index.vue +0 -0
  79. /package/views/{login → login_1}/components/emailLoginForm.vue +0 -0
  80. /package/views/{login → login_1}/components/registerForm.vue +0 -0
  81. /package/views/{login → login_1}/components/welcomePanel.vue +0 -0
  82. /package/views/{login/index_1.vue → login_1/index.vue} +0 -0
@@ -1,162 +0,0 @@
1
- <template>
2
- <div class="page-dict page-table">
3
- <div class="main-tool">
4
- <div class="left">
5
- <TButton theme="primary" @click="$Method.onAction('add', {})">
6
- <template #icon>
7
- <ILucidePlus />
8
- </template>
9
- </TButton>
10
- </div>
11
- <div class="right">
12
- <TButton @click="$Method.handleRefresh">
13
- <template #icon>
14
- <ILucideRotateCw />
15
- </template>
16
- </TButton>
17
- </div>
18
- </div>
19
- <div class="main-table">
20
- <TTable :data="$Data.dictList" :columns="$Data.columns" header-cell-class-name="custom-table-cell-class" size="small" height="100%" row-key="id">
21
- <template #state="{ row }">
22
- <TTag v-if="row.state === 1" theme="success">正常</TTag>
23
- <TTag v-else-if="row.state === 2" theme="warning">禁用</TTag>
24
- <TTag v-else theme="danger">已删除</TTag>
25
- </template>
26
- <template #operation="{ row }">
27
- <TDropdown trigger="click" min-column-width="120" @click="(data) => $Method.onAction(data.value, row)">
28
- <TButton variant="text" size="small">操作</TButton>
29
- <TDropdownMenu slot="dropdown">
30
- <TDropdownItem value="upd">
31
- <ILucidePencil />
32
- 编辑
33
- </TDropdownItem>
34
- <TDropdownItem value="del" :divider="true">
35
- <ILucideTrash2 style="width: 14px; height: 14px; margin-right: 6px" />
36
- 删除
37
- </TDropdownItem>
38
- </TDropdownMenu>
39
- </TDropdown>
40
- </template>
41
- </TTable>
42
- </div>
43
-
44
- <div class="main-page">
45
- <TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.pageSize" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @size-change="$Method.handleSizeChange" />
46
- </div>
47
-
48
- <!-- 编辑对话框组件 -->
49
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiDictList" />
50
- </div>
51
- </template>
52
-
53
- <script setup>
54
- 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';
55
- import ILucidePlus from '~icons/lucide/plus';
56
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
57
- import ILucidePencil from '~icons/lucide/pencil';
58
- import ILucideTrash2 from '~icons/lucide/trash-2';
59
- import EditDialog from './components/edit.vue';
60
- import { $Http } from '@/plugins/http';
61
-
62
- // 响应式数据
63
- const $Data = $ref({
64
- dictList: [],
65
- columns: [
66
- { colKey: 'index', title: '序号', width: 60, align: 'center' },
67
- { colKey: 'name', title: '字典名称' },
68
- { colKey: 'code', title: '字典代码', width: 150 },
69
- { colKey: 'value', title: '字典值', width: 200 },
70
- { colKey: 'pid', title: '父级ID', width: 100 },
71
- { colKey: 'sort', title: '排序', width: 80 },
72
- { colKey: 'description', title: '描述', ellipsis: true },
73
- { colKey: 'state', title: '状态', width: 100 },
74
- { colKey: 'operation', title: '操作', width: 120, align: 'right' }
75
- ],
76
- pagerConfig: {
77
- currentPage: 1,
78
- pageSize: 30,
79
- total: 0,
80
- align: 'right',
81
- layout: 'total, prev, pager, next, jumper'
82
- },
83
- editVisible: false,
84
- actionType: 'add',
85
- rowData: {}
86
- });
87
-
88
- // 方法
89
- const $Method = {
90
- async initData() {
91
- await $Method.apiDictList();
92
- },
93
-
94
- // 加载字典列表
95
- async apiDictList() {
96
- try {
97
- const res = await $Http('/addon/admin/dict/list', {
98
- page: $Data.pagerConfig.currentPage,
99
- limit: $Data.pagerConfig.pageSize
100
- });
101
- $Data.dictList = res.data.lists || [];
102
- $Data.pagerConfig.total = res.data.total || 0;
103
- } catch (error) {
104
- console.error('加载字典列表失败:', error);
105
- MessagePlugin.info({
106
- message: '加载数据失败',
107
- status: 'error'
108
- });
109
- }
110
- },
111
-
112
- // 删除字典
113
- async apiDictDel(row) {
114
- DialogPlugin.confirm({
115
- header: '确认删除',
116
- body: `确定要删除字典"${row.name}" 吗?`,
117
- status: 'warning'
118
- }).then(async () => {
119
- try {
120
- const res = await $Http('/addon/admin/dict/del', { id: row.id });
121
- if (res.code === 0) {
122
- MessagePlugin.info({ message: '删除成功', status: 'success' });
123
- $Method.apiDictList();
124
- } else {
125
- MessagePlugin.info({ message: res.msg || '删除失败', status: 'error' });
126
- }
127
- } catch (error) {
128
- console.error('删除失败:', error);
129
- MessagePlugin.info({ message: '删除失败', status: 'error' });
130
- }
131
- });
132
- },
133
-
134
- // 刷新
135
- handleRefresh() {
136
- $Method.apiDictList();
137
- },
138
-
139
- // 分页改变
140
- onPageChange({ currentPage }) {
141
- $Data.pagerConfig.currentPage = currentPage;
142
- $Method.apiDictList();
143
- },
144
-
145
- // 操作菜单点击
146
- onAction(command, rowData) {
147
- $Data.actionType = command;
148
- $Data.rowData = rowData;
149
- if (command === 'add' || command === 'upd') {
150
- $Data.editVisible = true;
151
- } else if (command === 'del') {
152
- $Method.apiDictDel(rowData);
153
- }
154
- }
155
- };
156
-
157
- $Method.initData();
158
- </script>
159
-
160
- <style scoped lang="scss">
161
- // 样式继承自全局 page-table
162
- </style>
@@ -1,145 +0,0 @@
1
- <template>
2
- <TDialog v-model:visible="$Data.visible" :title="$Prop.actionType === 'add' ? '添加菜单' : '编辑菜单'" width="600px" :append-to-body="true" :show-footer="true" top="10vh">
3
- <TForm :model="$Data.formData" label-width="120px" label-position="left" :rules="$Data2.formRules" :ref="(el) => ($From.form = el)">
4
- <TFormItem label="菜单名称" prop="name">
5
- <TInput v-model="$Data.formData.name" placeholder="请输入菜单名称" />
6
- </TFormItem>
7
- <TFormItem label="菜单路径" prop="path">
8
- <TInput v-model="$Data.formData.path" placeholder="请输入菜单路径,如:/user" />
9
- </TFormItem>
10
- <TFormItem label="图标" prop="icon">
11
- <TInput v-model="$Data.formData.icon" placeholder="请输入图标名称,如:User" />
12
- </TFormItem>
13
- <TFormItem label="排序" prop="sort">
14
- <TInputNumber v-model="$Data.formData.sort" :min="0" :max="9999" />
15
- </TFormItem>
16
- <TFormItem label="状态" prop="state">
17
- <TRadioGroup v-model="$Data.formData.state">
18
- <TRadio :label="1">正常</TRadio>
19
- <TRadio :label="2">禁用</TRadio>
20
- </TRadioGroup>
21
- </TFormItem>
22
- </TForm>
23
- <template #footer>
24
- <TButton @click="$Method.onClose">取消</TButton>
25
- <TButton theme="primary" @click="$Method.onSubmit">确定</TButton>
26
- </template>
27
- </TDialog>
28
- </template>
29
-
30
- <script setup>
31
- import { watch } from 'vue';
32
- import { Dialog as TDialog, Form as TForm, FormItem as TFormItem, Input as TInput, InputNumber as TInputNumber, RadioGroup as TRadioGroup, Radio as TRadio, Button as TButton, MessagePlugin } from 'tdesign-vue-next';
33
- import { $Http } from '@/plugins/http';
34
-
35
- const $Prop = defineProps({
36
- modelValue: {
37
- type: Boolean,
38
- default: false
39
- },
40
- actionType: {
41
- type: String,
42
- default: 'add'
43
- },
44
- rowData: {
45
- type: Object,
46
- default: {}
47
- }
48
- });
49
-
50
- const $Emit = defineEmits(['update:modelValue', 'success']);
51
-
52
- // 表单引用
53
- const $From = $shallowRef({
54
- form: null
55
- });
56
-
57
- const $Data = $ref({
58
- visible: false,
59
- formData: {
60
- id: 0,
61
- name: '',
62
- path: '',
63
- icon: '',
64
- sort: 0,
65
- pid: 0,
66
- state: 1
67
- }
68
- });
69
-
70
- const $Data2 = $shallowRef({
71
- formRules: {
72
- name: [{ required: true, message: '请输入菜单名称', trigger: 'blur' }],
73
- path: [{ required: true, message: '请输入菜单路径', trigger: 'blur' }]
74
- }
75
- });
76
-
77
- // 方法集合
78
- const $Method = {
79
- async initData() {
80
- $Method.onShow();
81
- },
82
-
83
- onShow() {
84
- $Data.visible = true;
85
- if ($Prop.actionType === 'upd' && $Prop.rowData) {
86
- $Data.formData.id = $Prop.rowData.id || 0;
87
- $Data.formData.name = $Prop.rowData.name || '';
88
- $Data.formData.path = $Prop.rowData.path ?? '';
89
- $Data.formData.icon = $Prop.rowData.icon ?? '';
90
- $Data.formData.sort = $Prop.rowData.sort ?? 0;
91
- $Data.formData.state = $Prop.rowData.state ?? 1;
92
- } else {
93
- // 重置表单
94
- $Data.formData.id = 0;
95
- $Data.formData.name = '';
96
- $Data.formData.path = '';
97
- $Data.formData.icon = '';
98
- $Data.formData.sort = 0;
99
- $Data.formData.state = 1;
100
- }
101
- },
102
-
103
- onClose() {
104
- $Data.visible = false;
105
- setTimeout(() => {
106
- $Emit('update:modelValue', false);
107
- }, 300);
108
- },
109
-
110
- async onSubmit() {
111
- try {
112
- const valid = await $From.form.validate();
113
- if (!valid) return;
114
-
115
- const res = await $Http($Prop.actionType === 'add' ? '/addon/admin/menuIns' : '/addon/admin/menuUpd', $Data.formData);
116
-
117
- MessagePlugin.info({
118
- message: $Prop.actionType === 'add' ? '添加成功' : '编辑成功',
119
- status: 'success'
120
- });
121
- $Method.onClose();
122
- $Emit('success');
123
- } catch (error) {
124
- console.error('提交失败:', error);
125
- }
126
- }
127
- };
128
-
129
- // 监听 modelValue 变化
130
- watch(
131
- () => $Prop.modelValue,
132
- (val) => {
133
- if (val && !$Data.visible) {
134
- $Method.initData();
135
- } else if (!val && $Data.visible) {
136
- $Data.visible = false;
137
- }
138
- },
139
- { immediate: true }
140
- );
141
- </script>
142
-
143
- <style scoped lang="scss">
144
- // 可根据需要添加样式
145
- </style>
@@ -1,173 +0,0 @@
1
- <template>
2
- <div class="page-menu page-table">
3
- <div class="main-tool">
4
- <div class="left">
5
- <TButton theme="primary" @click="$Method.onAction('add', {})">
6
- <template #icon>
7
- <ILucidePlus />
8
- </template>
9
- 添加菜单
10
- </TButton>
11
- </div>
12
- <div class="right">
13
- <TButton @click="$Method.handleRefresh">
14
- <template #icon>
15
- <ILucideRotateCw />
16
- </template>
17
- 刷新
18
- </TButton>
19
- </div>
20
- </div>
21
- <div class="main-table">
22
- <TTable :data="$Data.menuList" :columns="$Data.columns" header-cell-class-name="custom-table-cell-class" size="small" height="100%" row-key="id">
23
- <template #icon="{ row }">
24
- <ILucideSquare v-if="row.icon" />
25
- <span v-else>-</span>
26
- </template>
27
- <template #state="{ row }">
28
- <TTag v-if="row.state === 1" theme="success">正常</TTag>
29
- <TTag v-else-if="row.state === 2" theme="warning">禁用</TTag>
30
- <TTag v-else theme="danger">已删除</TTag>
31
- </template>
32
- <template #operation="{ row }">
33
- <TDropdown trigger="click" min-column-width="120" @click="(data) => $Method.onAction(data.value, row)">
34
- <TButton variant="text" size="small">操作</TButton>
35
- <TDropdownMenu slot="dropdown">
36
- <TDropdownItem value="upd">
37
- <ILucidePencil />
38
- 编辑
39
- </TDropdownItem>
40
- <TDropdownItem value="del" :divider="true">
41
- <ILucideTrash2 style="width: 14px; height: 14px; margin-right: 6px" />
42
- 删除
43
- </TDropdownItem>
44
- </TDropdownMenu>
45
- </TDropdown>
46
- </template>
47
- </TTable>
48
- </div>
49
-
50
- <div class="main-page">
51
- <TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.pageSize" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @size-change="$Method.handleSizeChange" />
52
- </div>
53
-
54
- <!-- 编辑对话框组件 -->
55
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiMenuList" />
56
- </div>
57
- </template>
58
-
59
- <script setup>
60
- 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';
61
- import ILucidePlus from '~icons/lucide/plus';
62
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
63
- import ILucideSquare from '~icons/lucide/square';
64
- import ILucidePencil from '~icons/lucide/pencil';
65
- import ILucideTrash2 from '~icons/lucide/trash-2';
66
- import EditDialog from './components/edit.vue';
67
- import { $Http } from '@/plugins/http';
68
-
69
- // 响应式数据
70
- const $Data = $ref({
71
- menuList: [],
72
- columns: [
73
- { colKey: 'index', title: '序号', width: 60, align: 'center' },
74
- { colKey: 'name', title: '菜单名称' },
75
- { colKey: 'path', title: '路径', width: 200 },
76
- { colKey: 'icon', title: '图标', width: 100 },
77
- { colKey: 'sort', title: '排序', width: 80 },
78
- { colKey: 'state', title: '状态', width: 100 },
79
- { colKey: 'operation', title: '操作', width: 120, align: 'right' }
80
- ],
81
- pagerConfig: {
82
- currentPage: 1,
83
- pageSize: 30,
84
- total: 0,
85
- align: 'right',
86
- layout: 'total, prev, pager, next, jumper'
87
- },
88
- editVisible: false,
89
- actionType: 'add',
90
- rowData: {}
91
- });
92
-
93
- // 方法
94
- const $Method = {
95
- async initData() {
96
- await $Method.apiMenuList();
97
- },
98
-
99
- // 加载菜单列表
100
- async apiMenuList() {
101
- try {
102
- const res = await $Http('/addon/admin/menu/list', {
103
- page: $Data.pagerConfig.currentPage,
104
- limit: $Data.pagerConfig.pageSize
105
- });
106
- $Data.menuList = res.data.lists || [];
107
- $Data.pagerConfig.total = res.data.total || 0;
108
- } catch (error) {
109
- console.error('加载菜单列表失败:', error);
110
- MessagePlugin.info({
111
- message: '加载数据失败',
112
- status: 'error'
113
- });
114
- }
115
- },
116
-
117
- // 删除菜单
118
- async apiMenuDel(row) {
119
- DialogPlugin.confirm({
120
- header: '确认删除',
121
- body: `确定要删除菜单"${row.name}" 吗?`,
122
- status: 'warning'
123
- }).then(async () => {
124
- try {
125
- const res = await $Http('/addon/admin/menu/del', { id: row.id });
126
- if (res.code === 0) {
127
- MessagePlugin.info({ message: '删除成功', status: 'success' });
128
- $Method.apiMenuList();
129
- } else {
130
- MessagePlugin.info({ message: res.msg || '删除失败', status: 'error' });
131
- }
132
- } catch (error) {
133
- console.error('删除失败:', error);
134
- MessagePlugin.info({ message: '删除失败', status: 'error' });
135
- }
136
- });
137
- },
138
-
139
- // 刷新
140
- handleRefresh() {
141
- $Method.apiMenuList();
142
- },
143
-
144
- // 分页改变
145
- onPageChange({ currentPage }) {
146
- $Data.pagerConfig.currentPage = currentPage;
147
- $Method.apiMenuList();
148
- },
149
-
150
- // 操作菜单点击
151
- onAction(command, rowData) {
152
- $Data.actionType = command;
153
- $Data.rowData = rowData;
154
- if (command === 'add' || command === 'upd') {
155
- $Data.editVisible = true;
156
- } else if (command === 'del') {
157
- $Method.apiMenuDel(rowData);
158
- }
159
- }
160
- };
161
-
162
- $Method.initData();
163
- </script>
164
-
165
- <route lang="yaml">
166
- meta:
167
- layout: default
168
- title: 菜单管理
169
- </route>
170
-
171
- <style scoped lang="scss">
172
- // 样式继承自全局 page-table
173
- </style>
@@ -1,184 +0,0 @@
1
- <template>
2
- <div class="page-role page-table">
3
- <div class="main-tool">
4
- <div class="left">
5
- <TButton theme="primary" @click="$Method.onAction('add', {})">
6
- <template #icon>
7
- <ILucidePlus />
8
- </template>
9
- </TButton>
10
- </div>
11
- <div class="right">
12
- <TButton @click="$Method.handleRefresh">
13
- <template #icon>
14
- <ILucideRotateCw />
15
- </template>
16
- </TButton>
17
- </div>
18
- </div>
19
- <div class="main-table">
20
- <TTable :data="$Data.tableData" :columns="$Data.columns" header-cell-class-name="custom-table-cell-class" size="small" height="100%" row-key="id" bordered>
21
- <template #state="{ row }">
22
- <TTag v-if="row.state === 1" theme="success">正常</TTag>
23
- <TTag v-else-if="row.state === 2" theme="warning">禁用</TTag>
24
- <TTag v-else theme="danger">已删除</TTag>
25
- </template>
26
- <template #operation="{ row }">
27
- <TDropdown trigger="click" min-column-width="120" @click="(data) => $Method.onAction(data.value, row)">
28
- <TButton variant="text" size="small">操作</TButton>
29
- <TDropdownMenu slot="dropdown">
30
- <TDropdownItem value="upd">
31
- <ILucidePencil />
32
- 编辑
33
- </TDropdownItem>
34
- <TDropdownItem value="menu">
35
- <ILucideSettings />
36
- 菜单权限
37
- </TDropdownItem>
38
- <TDropdownItem value="api">
39
- <ILucideCode />
40
- 接口权限
41
- </TDropdownItem>
42
- <TDropdownItem value="del" :divider="true">
43
- <ILucideTrash2 style="width: 14px; height: 14px; margin-right: 6px" />
44
- 删除
45
- </TDropdownItem>
46
- </TDropdownMenu>
47
- </TDropdown>
48
- </template>
49
- </TTable>
50
- </div>
51
-
52
- <div class="main-page">
53
- <TPagination :current-page="$Data.pagerConfig.currentPage" :page-size="$Data.pagerConfig.pageSize" :total="$Data.pagerConfig.total" @current-change="$Method.onPageChange" @size-change="$Method.handleSizeChange" />
54
- </div>
55
-
56
- <!-- 编辑对话框组件 -->
57
- <EditDialog v-if="$Data.editVisible" v-model="$Data.editVisible" :action-type="$Data.actionType" :row-data="$Data.rowData" @success="$Method.apiRoleList" />
58
-
59
- <!-- 菜单权限对话框组件 -->
60
- <MenuDialog v-if="$Data.menuVisible" v-model="$Data.menuVisible" :row-data="$Data.rowData" @success="$Method.apiRoleList" />
61
-
62
- <!-- 接口权限对话框组件 -->
63
- <ApiDialog v-if="$Data.apiVisible" v-model="$Data.apiVisible" :row-data="$Data.rowData" @success="$Method.apiRoleList" />
64
- </div>
65
- </template>
66
-
67
- <script setup>
68
- 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';
69
- import ILucidePlus from '~icons/lucide/plus';
70
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
71
- import ILucidePencil from '~icons/lucide/pencil';
72
- import ILucideSettings from '~icons/lucide/settings';
73
- import ILucideCode from '~icons/lucide/code';
74
- import ILucideTrash2 from '~icons/lucide/trash-2';
75
- import EditDialog from './components/edit.vue';
76
- import MenuDialog from './components/menu.vue';
77
- import ApiDialog from './components/api.vue';
78
- import { $Http } from '@/plugins/http';
79
-
80
- // 响应式数据
81
- const $Data = $ref({
82
- tableData: [],
83
- columns: [
84
- { colKey: 'index', title: '序号', width: 100, align: 'center' },
85
- { colKey: 'name', title: '角色名称', width: 150 },
86
- { colKey: 'code', title: '角色代码', width: 150 },
87
- { colKey: 'description', title: '描述', minWidth: 150, ellipsis: true },
88
- { colKey: 'sort', title: '排序', width: 80, align: 'center' },
89
- { colKey: 'state', title: '状态', width: 100, align: 'center' },
90
- { colKey: 'operation', title: '操作', width: 120, align: 'center', fixed: 'right' }
91
- ],
92
- pagerConfig: {
93
- currentPage: 1,
94
- pageSize: 30,
95
- total: 0,
96
- align: 'right',
97
- layout: 'total, prev, pager, next, jumper'
98
- },
99
- editVisible: false,
100
- menuVisible: false,
101
- apiVisible: false,
102
- actionType: 'add',
103
- rowData: {}
104
- });
105
-
106
- // 方法
107
- const $Method = {
108
- async initData() {
109
- await $Method.apiRoleList();
110
- },
111
- // 加载角色列表
112
- async apiRoleList() {
113
- try {
114
- const res = await $Http('/addon/admin/role/list', {
115
- page: $Data.pagerConfig.currentPage,
116
- limit: $Data.pagerConfig.limit
117
- });
118
- $Data.tableData = res.data.lists || [];
119
- $Data.pagerConfig.total = res.data.total || 0;
120
- } catch (error) {
121
- console.error('加载角色列表失败:', error);
122
- MessagePlugin.info({
123
- message: '加载数据失败',
124
- status: 'error'
125
- });
126
- }
127
- },
128
-
129
- // 删除角色
130
- async apiRoleDel(row) {
131
- DialogPlugin.confirm({
132
- header: '确认删除',
133
- body: `确定要删除角色"${row.name}" 吗?`,
134
- status: 'warning'
135
- }).then(async () => {
136
- try {
137
- const res = await $Http('/addon/admin/role/del', { id: row.id });
138
- if (res.code === 0) {
139
- MessagePlugin.info({ message: '删除成功', status: 'success' });
140
- $Method.apiRoleList();
141
- } else {
142
- MessagePlugin.info({ message: res.msg || '删除失败', status: 'error' });
143
- }
144
- } catch (error) {
145
- console.error('删除失败:', error);
146
- MessagePlugin.info({ message: '删除失败', status: 'error' });
147
- }
148
- });
149
- },
150
-
151
- // 刷新
152
- handleRefresh() {
153
- $Method.apiRoleList();
154
- },
155
-
156
- // 分页改变
157
- onPageChange({ currentPage }) {
158
- $Data.pagerConfig.currentPage = currentPage;
159
- $Method.apiRoleList();
160
- },
161
-
162
- // 操作菜单点击
163
- onAction(command, rowData) {
164
- $Data.actionType = command;
165
- $Data.rowData = rowData;
166
- if (command === 'add' || command === 'upd') {
167
- $Data.editVisible = true;
168
- } else if (command === 'menu') {
169
- $Data.menuVisible = true;
170
- } else if (command === 'api') {
171
- $Data.apiVisible = true;
172
- } else if (command === 'del') {
173
- $Method.apiRoleDel(rowData);
174
- }
175
- }
176
- };
177
-
178
- $Method.initData();
179
- </script>
180
-
181
- <style scoped lang="scss">
182
- .page-role {
183
- }
184
- </style>
File without changes
File without changes