@befly-addon/admin 1.1.30 → 1.1.32

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 (111) hide show
  1. package/apis/admin/cacheRefresh.ts +29 -21
  2. package/apis/admin/del.ts +10 -10
  3. package/apis/admin/detail.ts +7 -7
  4. package/apis/admin/ins.ts +11 -11
  5. package/apis/admin/list.ts +10 -10
  6. package/apis/admin/upd.ts +14 -14
  7. package/apis/api/all.ts +8 -8
  8. package/apis/api/list.ts +10 -10
  9. package/apis/auth/login.ts +43 -43
  10. package/apis/auth/sendSmsCode.ts +6 -6
  11. package/apis/dashboard/configStatus.ts +18 -18
  12. package/apis/dashboard/environmentInfo.ts +12 -12
  13. package/apis/dashboard/performanceMetrics.ts +5 -5
  14. package/apis/dashboard/permissionStats.ts +7 -7
  15. package/apis/dashboard/serviceStatus.ts +29 -29
  16. package/apis/dashboard/systemInfo.ts +5 -5
  17. package/apis/dashboard/systemOverview.ts +7 -7
  18. package/apis/dashboard/systemResources.ts +8 -8
  19. package/apis/dict/all.ts +16 -16
  20. package/apis/dict/del.ts +6 -6
  21. package/apis/dict/detail.ts +19 -19
  22. package/apis/dict/ins.ts +9 -9
  23. package/apis/dict/items.ts +8 -8
  24. package/apis/dict/list.ts +22 -22
  25. package/apis/dict/upd.ts +11 -11
  26. package/apis/dictType/all.ts +5 -5
  27. package/apis/dictType/del.ts +8 -8
  28. package/apis/dictType/detail.ts +6 -6
  29. package/apis/dictType/ins.ts +7 -7
  30. package/apis/dictType/list.ts +8 -10
  31. package/apis/dictType/upd.ts +8 -8
  32. package/apis/email/config.ts +4 -4
  33. package/apis/email/logList.ts +8 -8
  34. package/apis/email/send.ts +18 -18
  35. package/apis/email/verify.ts +5 -5
  36. package/apis/loginLog/list.ts +8 -8
  37. package/apis/menu/all.ts +16 -18
  38. package/apis/menu/list.ts +12 -12
  39. package/apis/operateLog/list.ts +8 -8
  40. package/apis/role/all.ts +7 -7
  41. package/apis/role/apiSave.ts +10 -13
  42. package/apis/role/apis.ts +7 -12
  43. package/apis/role/del.ts +14 -14
  44. package/apis/role/detail.ts +6 -6
  45. package/apis/role/ins.ts +10 -10
  46. package/apis/role/list.ts +11 -11
  47. package/apis/role/menuSave.ts +8 -11
  48. package/apis/role/menus.ts +7 -12
  49. package/apis/role/save.ts +12 -12
  50. package/apis/role/upd.ts +10 -10
  51. package/apis/sysConfig/all.ts +5 -5
  52. package/apis/sysConfig/del.ts +9 -9
  53. package/apis/sysConfig/get.ts +9 -9
  54. package/apis/sysConfig/ins.ts +11 -11
  55. package/apis/sysConfig/list.ts +9 -9
  56. package/apis/sysConfig/upd.ts +10 -10
  57. package/libs/emailHelper.ts +7 -7
  58. package/package.json +46 -34
  59. package/plugins/email.ts +9 -9
  60. package/tables/role.json +4 -2
  61. package/views/403_1/index.vue +19 -3
  62. package/views/config/dict/components/edit.vue +26 -28
  63. package/views/config/dict/index.vue +88 -52
  64. package/views/config/dictType/components/edit.vue +22 -23
  65. package/views/config/dictType/index.vue +82 -46
  66. package/views/config/index.vue +12 -0
  67. package/views/config/system/components/edit.vue +36 -36
  68. package/views/config/system/index.vue +79 -50
  69. package/views/index/components/addonList.vue +3 -3
  70. package/views/index/components/environmentInfo.vue +10 -10
  71. package/views/index/components/operationLogs.vue +10 -10
  72. package/views/index/components/performanceMetrics.vue +8 -8
  73. package/views/index/components/quickActions.vue +3 -3
  74. package/views/index/components/serviceStatus.vue +19 -19
  75. package/views/index/components/systemNotifications.vue +12 -12
  76. package/views/index/components/systemOverview.vue +7 -7
  77. package/views/index/components/systemResources.vue +11 -11
  78. package/views/index/components/userInfo.vue +20 -19
  79. package/views/index/index.vue +12 -5
  80. package/views/log/email/index.vue +58 -51
  81. package/views/log/index.vue +12 -0
  82. package/views/log/login/index.vue +45 -38
  83. package/views/log/operate/index.vue +55 -48
  84. package/views/login_1/index.vue +25 -18
  85. package/views/people/admin/components/edit.vue +25 -26
  86. package/views/people/admin/index.vue +76 -40
  87. package/views/people/index.vue +12 -0
  88. package/views/permission/api/index.vue +21 -15
  89. package/views/permission/index.vue +12 -0
  90. package/views/permission/menu/index.vue +31 -16
  91. package/views/permission/role/components/api.vue +21 -21
  92. package/views/permission/role/components/edit.vue +18 -18
  93. package/views/permission/role/components/menu.vue +14 -16
  94. package/views/permission/role/index.vue +84 -49
  95. package/views/403_1/meta.json +0 -4
  96. package/views/config/dict/meta.json +0 -4
  97. package/views/config/dictType/meta.json +0 -4
  98. package/views/config/meta.json +0 -4
  99. package/views/config/system/meta.json +0 -4
  100. package/views/index/meta.json +0 -4
  101. package/views/log/email/meta.json +0 -4
  102. package/views/log/login/meta.json +0 -4
  103. package/views/log/meta.json +0 -4
  104. package/views/log/operate/meta.json +0 -4
  105. package/views/login_1/meta.json +0 -4
  106. package/views/people/admin/meta.json +0 -4
  107. package/views/people/meta.json +0 -4
  108. package/views/permission/api/meta.json +0 -4
  109. package/views/permission/menu/meta.json +0 -4
  110. package/views/permission/meta.json +0 -4
  111. package/views/permission/role/meta.json +0 -4
@@ -1,27 +1,27 @@
1
- import sysConfigTable from '../../tables/sysConfig.json';
1
+ import sysConfigTable from "../../tables/sysConfig.json";
2
2
 
3
3
  export default {
4
- name: '更新系统配置',
4
+ name: "更新系统配置",
5
5
  fields: {
6
- id: '@id',
6
+ id: "@id",
7
7
  ...sysConfigTable
8
8
  },
9
9
  handler: async (befly, ctx) => {
10
10
  try {
11
11
  // 检查是否为系统配置
12
12
  const config = await befly.db.getDetail({
13
- table: 'addon_admin_sys_config',
13
+ table: "addon_admin_sys_config",
14
14
  where: { id: ctx.body.id }
15
15
  });
16
16
 
17
17
  if (!config?.id) {
18
- return befly.tool.No('配置不存在');
18
+ return befly.tool.No("配置不存在");
19
19
  }
20
20
 
21
21
  // 系统配置只能修改 value
22
22
  if (config.isSystem === 1) {
23
23
  await befly.db.updData({
24
- table: 'addon_admin_sys_config',
24
+ table: "addon_admin_sys_config",
25
25
  data: {
26
26
  value: ctx.body.value
27
27
  },
@@ -29,7 +29,7 @@ export default {
29
29
  });
30
30
  } else {
31
31
  await befly.db.updData({
32
- table: 'addon_admin_sys_config',
32
+ table: "addon_admin_sys_config",
33
33
  data: {
34
34
  name: ctx.body.name,
35
35
  code: ctx.body.code,
@@ -44,10 +44,10 @@ export default {
44
44
  });
45
45
  }
46
46
 
47
- return befly.tool.Yes('操作成功');
47
+ return befly.tool.Yes("操作成功");
48
48
  } catch (error) {
49
- befly.logger.error({ err: error }, '更新系统配置失败');
50
- return befly.tool.No('操作失败');
49
+ befly.logger.error({ err: error }, "更新系统配置失败");
50
+ return befly.tool.No("操作失败");
51
51
  }
52
52
  }
53
53
  };
@@ -3,10 +3,10 @@
3
3
  * 提供邮件发送功能,支持 SMTP 配置
4
4
  */
5
5
 
6
- import nodemailer from 'nodemailer';
6
+ import type { BeflyContext } from "befly/types/befly";
7
+ import type { Transporter } from "nodemailer";
7
8
 
8
- import type { Transporter } from 'nodemailer';
9
- import type { BeflyContext } from 'befly/types/befly.js';
9
+ import nodemailer from "nodemailer";
10
10
 
11
11
  /** 邮件配置 */
12
12
  export interface EmailConfig {
@@ -80,7 +80,7 @@ export class EmailHelper {
80
80
  if (!this.transporter) {
81
81
  return {
82
82
  success: false,
83
- error: '邮件服务未配置,请检查 SMTP 配置'
83
+ error: "邮件服务未配置,请检查 SMTP 配置"
84
84
  };
85
85
  }
86
86
 
@@ -104,7 +104,7 @@ export class EmailHelper {
104
104
  } catch (error: any) {
105
105
  return {
106
106
  success: false,
107
- error: error.message || '发送失败'
107
+ error: error.message || "发送失败"
108
108
  };
109
109
  }
110
110
  }
@@ -128,10 +128,10 @@ export class EmailHelper {
128
128
  /**
129
129
  * 获取当前配置(隐藏密码)
130
130
  */
131
- getConfig(): Omit<EmailConfig, 'pass'> & { pass: string } {
131
+ getConfig(): Omit<EmailConfig, "pass"> & { pass: string } {
132
132
  return {
133
133
  ...this.config,
134
- pass: this.config.pass ? '******' : ''
134
+ pass: this.config.pass ? "******" : ""
135
135
  };
136
136
  }
137
137
  }
package/package.json CHANGED
@@ -1,58 +1,70 @@
1
1
  {
2
2
  "name": "@befly-addon/admin",
3
- "version": "1.1.30",
4
- "title": "管理后台",
5
- "description": "Befly - 管理后台功能组件",
6
- "type": "module",
3
+ "version": "1.1.32",
7
4
  "private": false,
8
- "publishConfig": {
9
- "access": "public",
10
- "registry": "https://registry.npmjs.org"
5
+ "description": "Befly - 管理后台功能组件",
6
+ "keywords": [
7
+ "addon",
8
+ "admin",
9
+ "auth",
10
+ "befly",
11
+ "rbac",
12
+ "typescript"
13
+ ],
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "https://github.com/chenbimo/befly.git",
17
+ "directory": "packages/addon-admin"
11
18
  },
19
+ "author": "chenbimo",
20
+ "license": "Apache-2.0",
21
+ "type": "module",
12
22
  "main": "package.json",
13
23
  "exports": {
14
24
  ".": "./package.json",
15
25
  "./styles/*": "./styles/*"
16
26
  },
17
- "scripts": {
18
- "dev": "vite",
19
- "build": "vite build",
20
- "preview": "vite preview"
21
- },
22
27
  "files": [
28
+ "README.md",
23
29
  "apis",
24
30
  "libs",
31
+ "package.json",
25
32
  "plugins",
26
33
  "styles",
27
34
  "tables",
28
- "views",
29
- "package.json",
30
- "README.md"
35
+ "views"
31
36
  ],
32
- "keywords": [
33
- "befly",
34
- "addon",
35
- "admin",
36
- "rbac",
37
- "auth",
38
- "typescript"
39
- ],
40
- "author": "chenbimo",
41
- "license": "Apache-2.0",
42
- "repository": {
43
- "type": "git",
44
- "url": "https://github.com/chenbimo/befly.git",
45
- "directory": "packages/addon-admin"
37
+ "scripts": {
38
+ "dev": "vite",
39
+ "build": "vite build",
40
+ "preview": "vite preview"
46
41
  },
47
- "gitHead": "8cb371928961c63d6c3c416c6dd667f8fe285376",
48
42
  "dependencies": {
49
- "befly": "^3.9.38",
50
- "befly-shared": "^1.2.8",
43
+ "befly": "^3.9.40",
44
+ "befly-vite": "^1.1.12",
51
45
  "nodemailer": "^7.0.11",
52
46
  "ua-parser-js": "^2.0.7"
53
47
  },
54
48
  "devDependencies": {
49
+ "@iconify-json/lucide": "^1.2.80",
55
50
  "@types/nodemailer": "^7.0.4",
56
- "@types/ua-parser-js": "^0.7.39"
57
- }
51
+ "@types/ua-parser-js": "^0.7.39",
52
+ "pinia": "^3.0.4",
53
+ "tdesign-vue-next": "^1.17.7",
54
+ "vue": "^3.5.26",
55
+ "vue-router": "^4.6.4"
56
+ },
57
+ "peerDependencies": {
58
+ "@iconify-json/lucide": "^1.2.80",
59
+ "pinia": "^3.0.4",
60
+ "tdesign-vue-next": "^1.17.7",
61
+ "vue": "^3.5.26",
62
+ "vue-router": "^4.6.4"
63
+ },
64
+ "publishConfig": {
65
+ "access": "public",
66
+ "registry": "https://registry.npmjs.org"
67
+ },
68
+ "gitHead": "0ba53d2bbdc6a7f2659ef60256cda7302fe585b0",
69
+ "title": "管理后台"
58
70
  }
package/plugins/email.ts CHANGED
@@ -3,27 +3,27 @@
3
3
  * 提供邮件发送功能,支持 SMTP 配置
4
4
  */
5
5
 
6
- import { EmailHelper } from '../libs/emailHelper.js';
6
+ import type { EmailConfig } from "../libs/emailHelper.js";
7
+ import type { BeflyContext } from "befly/types/befly";
8
+ import type { Plugin } from "befly/types/plugin";
7
9
 
8
- import type { EmailConfig } from '../libs/emailHelper.js';
9
- import type { Plugin } from 'befly/types/plugin.js';
10
- import type { BeflyContext } from 'befly/types/befly.js';
10
+ import { EmailHelper } from "../libs/emailHelper.js";
11
11
 
12
12
  /** 默认配置 */
13
13
  const defaultConfig: EmailConfig = {
14
- host: 'smtp.qq.com',
14
+ host: "smtp.qq.com",
15
15
  port: 465,
16
16
  secure: true,
17
- user: '',
18
- pass: '',
19
- fromName: 'Befly System'
17
+ user: "",
18
+ pass: "",
19
+ fromName: "Befly System"
20
20
  };
21
21
 
22
22
  /**
23
23
  * 邮件插件
24
24
  */
25
25
  const emailPlugin: Plugin = {
26
- after: ['db', 'logger', 'config'],
26
+ after: ["db", "logger", "config"],
27
27
  async handler(befly: BeflyContext): Promise<EmailHelper> {
28
28
  // 从 befly.config.addons.admin.email 获取配置
29
29
  const addonEmailConfig = befly.config?.addons?.admin?.email || {};
package/tables/role.json CHANGED
@@ -21,11 +21,13 @@
21
21
  },
22
22
  "menus": {
23
23
  "name": "菜单权限",
24
- "type": "array_text"
24
+ "type": "array_number_text",
25
+ "detail": "菜单ID数组,如 [1,2,3]"
25
26
  },
26
27
  "apis": {
27
28
  "name": "接口权限",
28
- "type": "array_text"
29
+ "type": "array_number_text",
30
+ "detail": "接口ID数组,如 [1,2,3]"
29
31
  },
30
32
  "sort": {
31
33
  "name": "排序",
@@ -13,14 +13,21 @@
13
13
  </template>
14
14
 
15
15
  <script setup>
16
- import { useRouter } from 'vue-router';
17
- import { Button as TButton } from 'tdesign-vue-next';
16
+ import { useRouter } from "vue-router";
17
+ import { Button as TButton } from "tdesign-vue-next";
18
+
19
+ definePage({
20
+ meta: {
21
+ title: "403",
22
+ order: 101
23
+ }
24
+ });
18
25
 
19
26
  const router = useRouter();
20
27
 
21
28
  const $Method = {
22
29
  goHome() {
23
- router.push('/');
30
+ router.push("/");
24
31
  },
25
32
  goBack() {
26
33
  router.back();
@@ -56,4 +63,13 @@ const $Method = {
56
63
  .error-description {
57
64
  font-size: 16px;
58
65
  color: var(--text-secondary);
66
+ margin: 8px 0 24px;
67
+ }
68
+
69
+ .error-actions {
70
+ display: flex;
71
+ gap: 12px;
72
+ justify-content: center;
73
+ }
74
+ }
59
75
  </style>
@@ -23,8 +23,8 @@
23
23
  </template>
24
24
 
25
25
  <script setup>
26
- import { Dialog as TDialog, Form as TForm, FormItem as TFormItem, Input as TInput, Select as TSelect, Option as TOption, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from 'tdesign-vue-next';
27
- import { $Http } from '@/plugins/http';
26
+ import { Dialog as TDialog, Form as TForm, FormItem as TFormItem, Input as TInput, Select as TSelect, Option as TOption, Textarea as TTextarea, InputNumber as TInputNumber, MessagePlugin } from "tdesign-vue-next";
27
+ import { $Http } from "@/plugins/http";
28
28
 
29
29
  const props = defineProps({
30
30
  modelValue: Boolean,
@@ -33,27 +33,27 @@ const props = defineProps({
33
33
  typeList: Array
34
34
  });
35
35
 
36
- const emit = defineEmits(['update:modelValue', 'success']);
36
+ const emit = defineEmits(["update:modelValue", "success"]);
37
37
 
38
38
  const visible = computed({
39
39
  get: () => props.modelValue,
40
- set: (val) => emit('update:modelValue', val)
40
+ set: (val) => emit("update:modelValue", val)
41
41
  });
42
42
 
43
43
  const formRef = $ref(null);
44
44
 
45
45
  const $Data = $ref({
46
46
  formData: {
47
- typeCode: '',
48
- key: '',
49
- label: '',
47
+ typeCode: "",
48
+ key: "",
49
+ label: "",
50
50
  sort: 0,
51
- remark: ''
51
+ remark: ""
52
52
  },
53
53
  rules: {
54
- typeCode: [{ required: true, message: '请选择字典类型' }],
55
- key: [{ required: true, message: '请输入键值' }],
56
- label: [{ required: true, message: '请输入标签' }]
54
+ typeCode: [{ required: true, message: "请选择字典类型" }],
55
+ key: [{ required: true, message: "请输入键值" }],
56
+ label: [{ required: true, message: "请输入标签" }]
57
57
  }
58
58
  });
59
59
 
@@ -61,7 +61,7 @@ const $Method = {
61
61
  async handleSubmit() {
62
62
  try {
63
63
  const valid = await formRef.validate();
64
- const apiUrl = props.actionType === 'add' ? '/addon/admin/dict/ins' : '/addon/admin/dict/upd';
64
+ const apiUrl = props.actionType === "add" ? "/addon/admin/dict/ins" : "/addon/admin/dict/upd";
65
65
  const params = {
66
66
  typeCode: $Data.formData.typeCode,
67
67
  key: $Data.formData.key,
@@ -69,22 +69,20 @@ const $Method = {
69
69
  sort: $Data.formData.sort,
70
70
  remark: $Data.formData.remark
71
71
  };
72
- if (props.actionType === 'upd') {
72
+ if (props.actionType === "upd") {
73
73
  params.id = props.rowData.id;
74
74
  }
75
75
 
76
76
  const res = await $Http(apiUrl, params);
77
- console.log('🔥[ res ]-79', res);
78
77
  if (res.code === 0) {
79
- MessagePlugin.success(props.actionType === 'add' ? '添加成功' : '更新成功');
78
+ MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
80
79
  visible.value = false;
81
- emit('success');
80
+ emit("success");
82
81
  } else {
83
- MessagePlugin.error(res.msg || '操作失败');
82
+ MessagePlugin.error(res.msg || "操作失败");
84
83
  }
85
84
  } catch (error) {
86
- console.error('提交失败:', error);
87
- MessagePlugin.error('操作失败');
85
+ MessagePlugin.error("操作失败");
88
86
  }
89
87
  },
90
88
  handleClose() {
@@ -96,18 +94,18 @@ watch(
96
94
  () => props.modelValue,
97
95
  (val) => {
98
96
  if (val) {
99
- if (props.actionType === 'upd' && props.rowData) {
100
- $Data.formData.typeCode = props.rowData.typeCode || '';
101
- $Data.formData.key = props.rowData.key || '';
102
- $Data.formData.label = props.rowData.label || '';
97
+ if (props.actionType === "upd" && props.rowData) {
98
+ $Data.formData.typeCode = props.rowData.typeCode || "";
99
+ $Data.formData.key = props.rowData.key || "";
100
+ $Data.formData.label = props.rowData.label || "";
103
101
  $Data.formData.sort = props.rowData.sort || 0;
104
- $Data.formData.remark = props.rowData.remark || '';
102
+ $Data.formData.remark = props.rowData.remark || "";
105
103
  } else {
106
- $Data.formData.typeCode = '';
107
- $Data.formData.key = '';
108
- $Data.formData.label = '';
104
+ $Data.formData.typeCode = "";
105
+ $Data.formData.key = "";
106
+ $Data.formData.label = "";
109
107
  $Data.formData.sort = 0;
110
- $Data.formData.remark = '';
108
+ $Data.formData.remark = "";
111
109
  }
112
110
  }
113
111
  },
@@ -26,7 +26,16 @@
26
26
  </div>
27
27
  <div class="main-content">
28
28
  <div class="main-table">
29
- <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(--pagination-height) - var(--layout-gap) * 4)" active-row-type="single" @active-change="$Method.onActiveChange">
29
+ <TTable
30
+ :data="$Data.tableData"
31
+ :columns="$Data.columns"
32
+ :loading="$Data.loading"
33
+ :active-row-keys="$Data.activeRowKeys"
34
+ row-key="id"
35
+ height="calc(100vh - var(--search-height) - var(--pagination-height) - var(--layout-gap) * 4)"
36
+ active-row-type="single"
37
+ @active-change="$Method.onActiveChange"
38
+ >
30
39
  <template #operation="{ row }">
31
40
  <TDropdown trigger="click" placement="bottom-right" @click="(data) => $Method.onAction(data.value, row)">
32
41
  <TButton theme="primary" size="small">
@@ -62,17 +71,24 @@
62
71
  </template>
63
72
 
64
73
  <script setup>
65
- import { Button as TButton, Table as TTable, Input as TInput, Select as TSelect, Option as TOption, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from 'tdesign-vue-next';
66
- import ILucidePlus from '~icons/lucide/plus';
67
- import ILucideRotateCw from '~icons/lucide/rotate-cw';
68
- import ILucideSearch from '~icons/lucide/search';
69
- import ILucidePencil from '~icons/lucide/pencil';
70
- import ILucideTrash2 from '~icons/lucide/trash-2';
71
- import ILucideChevronDown from '~icons/lucide/chevron-down';
72
- import EditDialog from './components/edit.vue';
73
- import DetailPanel from '@/components/DetailPanel.vue';
74
- import { $Http } from '@/plugins/http';
75
- import { withDefaultColumns } from 'befly-shared/withDefaultColumns';
74
+ import { Button as TButton, Table as TTable, Input as TInput, Select as TSelect, Option as TOption, Dropdown as TDropdown, DropdownMenu as TDropdownMenu, DropdownItem as TDropdownItem, Pagination as TPagination, MessagePlugin, DialogPlugin } from "tdesign-vue-next";
75
+ import ILucidePlus from "~icons/lucide/plus";
76
+ import ILucideRotateCw from "~icons/lucide/rotate-cw";
77
+ import ILucideSearch from "~icons/lucide/search";
78
+ import ILucidePencil from "~icons/lucide/pencil";
79
+ import ILucideTrash2 from "~icons/lucide/trash-2";
80
+ import ILucideChevronDown from "~icons/lucide/chevron-down";
81
+ import EditDialog from "./components/edit.vue";
82
+ import DetailPanel from "@/components/DetailPanel.vue";
83
+ import { $Http } from "@/plugins/http";
84
+ import { withDefaultColumns } from "befly-vite/utils/withDefaultColumns";
85
+
86
+ definePage({
87
+ meta: {
88
+ title: "字典列表",
89
+ order: 1
90
+ }
91
+ });
76
92
 
77
93
  const $Data = $ref({
78
94
  tableData: [],
@@ -80,27 +96,27 @@ const $Data = $ref({
80
96
  loading: false,
81
97
  activeRowKeys: [],
82
98
  currentRow: null,
83
- searchTypeCode: '',
84
- searchKeyword: '',
99
+ searchTypeCode: "",
100
+ searchKeyword: "",
85
101
  columns: withDefaultColumns([
86
- { colKey: 'id', title: 'ID' },
87
- { colKey: 'typeName', title: '类型名称' },
88
- { colKey: 'typeCode', title: '类型代码' },
89
- { colKey: 'label', title: '标签' },
90
- { colKey: 'key', title: '键值' },
91
- { colKey: 'sort', title: '排序', width: 100 },
92
- { colKey: 'remark', title: '备注' },
93
- { colKey: 'operation', title: '操作' }
102
+ { colKey: "id", title: "ID" },
103
+ { colKey: "typeName", title: "类型名称" },
104
+ { colKey: "typeCode", title: "类型代码" },
105
+ { colKey: "label", title: "标签" },
106
+ { colKey: "key", title: "键值" },
107
+ { colKey: "sort", title: "排序", width: 100 },
108
+ { colKey: "remark", title: "备注" },
109
+ { colKey: "operation", title: "操作" }
94
110
  ]),
95
111
  pagerConfig: {
96
112
  currentPage: 1,
97
113
  limit: 30,
98
114
  total: 0,
99
- align: 'right',
100
- layout: 'total, prev, pager, next, jumper'
115
+ align: "right",
116
+ layout: "total, prev, pager, next, jumper"
101
117
  },
102
118
  editVisible: false,
103
- actionType: 'add',
119
+ actionType: "add",
104
120
  rowData: {}
105
121
  });
106
122
 
@@ -111,16 +127,16 @@ const $Method = {
111
127
  },
112
128
  async apiDictTypeAll() {
113
129
  try {
114
- const res = await $Http('/addon/admin/dictType/all');
130
+ const res = await $Http("/addon/admin/dictType/all");
115
131
  $Data.typeList = res.data.lists || [];
116
132
  } catch (error) {
117
- console.error('加载字典类型列表失败:', error);
133
+ MessagePlugin.error("加载数据失败");
118
134
  }
119
135
  },
120
136
  async apiDictList() {
121
137
  $Data.loading = true;
122
138
  try {
123
- const res = await $Http('/addon/admin/dict/list', {
139
+ const res = await $Http("/addon/admin/dict/list", {
124
140
  page: $Data.pagerConfig.currentPage,
125
141
  limit: $Data.pagerConfig.limit,
126
142
  typeCode: $Data.searchTypeCode,
@@ -137,29 +153,49 @@ const $Method = {
137
153
  $Data.activeRowKeys = [];
138
154
  }
139
155
  } catch (error) {
140
- console.error('加载字典列表失败:', error);
141
- MessagePlugin.error('加载数据失败');
156
+ MessagePlugin.error("加载数据失败");
142
157
  } finally {
143
158
  $Data.loading = false;
144
159
  }
145
160
  },
146
161
  async apiDictDel(row) {
147
- DialogPlugin.confirm({
148
- header: '确认删除',
149
- body: `确定要删除字典项"${row.label}"吗?`,
150
- status: 'warning'
151
- }).then(async () => {
152
- try {
153
- const res = await $Http('/addon/admin/dict/del', { id: row.id });
154
- if (res.code === 0) {
155
- MessagePlugin.success('删除成功');
156
- $Method.apiDictList();
157
- } else {
158
- MessagePlugin.error(res.msg || '删除失败');
162
+ let dialog = null;
163
+ let destroyed = false;
164
+
165
+ const destroy = () => {
166
+ if (destroyed) return;
167
+ destroyed = true;
168
+ if (dialog && typeof dialog.destroy === "function") {
169
+ dialog.destroy();
170
+ }
171
+ };
172
+
173
+ dialog = DialogPlugin.confirm({
174
+ header: "确认删除",
175
+ body: `确认删除字典项“${row.label}”吗?`,
176
+ status: "warning",
177
+ confirmBtn: "删除",
178
+ cancelBtn: "取消",
179
+ onConfirm: async () => {
180
+ if (dialog && typeof dialog.setConfirmLoading === "function") {
181
+ dialog.setConfirmLoading(true);
182
+ }
183
+
184
+ try {
185
+ await $Http("/addon/admin/dict/del", { id: row.id });
186
+ MessagePlugin.success("删除成功");
187
+ destroy();
188
+ await $Method.apiDictList();
189
+ } catch (error) {
190
+ MessagePlugin.error("删除失败");
191
+ } finally {
192
+ if (dialog && typeof dialog.setConfirmLoading === "function") {
193
+ dialog.setConfirmLoading(false);
194
+ }
159
195
  }
160
- } catch (error) {
161
- console.error('删除失败:', error);
162
- MessagePlugin.error('删除失败');
196
+ },
197
+ onClose: () => {
198
+ destroy();
163
199
  }
164
200
  });
165
201
  },
@@ -168,8 +204,8 @@ const $Method = {
168
204
  $Method.apiDictList();
169
205
  },
170
206
  handleRefresh() {
171
- $Data.searchTypeCode = '';
172
- $Data.searchKeyword = '';
207
+ $Data.searchTypeCode = "";
208
+ $Data.searchKeyword = "";
173
209
  $Data.pagerConfig.currentPage = 1;
174
210
  $Method.apiDictList();
175
211
  },
@@ -190,15 +226,15 @@ const $Method = {
190
226
  $Data.currentRow = context.currentRowData;
191
227
  },
192
228
  onAction(type, row) {
193
- if (type === 'add') {
194
- $Data.actionType = 'add';
229
+ if (type === "add") {
230
+ $Data.actionType = "add";
195
231
  $Data.rowData = {};
196
232
  $Data.editVisible = true;
197
- } else if (type === 'upd') {
198
- $Data.actionType = 'upd';
233
+ } else if (type === "upd") {
234
+ $Data.actionType = "upd";
199
235
  $Data.rowData = { ...row };
200
236
  $Data.editVisible = true;
201
- } else if (type === 'del') {
237
+ } else if (type === "del") {
202
238
  $Method.apiDictDel(row);
203
239
  }
204
240
  }