@befly-addon/admin 1.1.30 → 1.1.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apis/admin/cacheRefresh.ts +29 -21
- package/apis/admin/del.ts +10 -10
- package/apis/admin/detail.ts +7 -7
- package/apis/admin/ins.ts +11 -11
- package/apis/admin/list.ts +10 -10
- package/apis/admin/upd.ts +14 -14
- package/apis/api/all.ts +8 -8
- package/apis/api/list.ts +10 -10
- package/apis/auth/login.ts +43 -43
- package/apis/auth/sendSmsCode.ts +6 -6
- package/apis/dashboard/configStatus.ts +18 -18
- package/apis/dashboard/environmentInfo.ts +12 -12
- package/apis/dashboard/performanceMetrics.ts +5 -5
- package/apis/dashboard/permissionStats.ts +7 -7
- package/apis/dashboard/serviceStatus.ts +29 -29
- package/apis/dashboard/systemInfo.ts +5 -5
- package/apis/dashboard/systemOverview.ts +7 -7
- package/apis/dashboard/systemResources.ts +8 -8
- package/apis/dict/all.ts +16 -16
- package/apis/dict/del.ts +6 -6
- package/apis/dict/detail.ts +19 -19
- package/apis/dict/ins.ts +9 -9
- package/apis/dict/items.ts +8 -8
- package/apis/dict/list.ts +22 -22
- package/apis/dict/upd.ts +11 -11
- package/apis/dictType/all.ts +5 -5
- package/apis/dictType/del.ts +8 -8
- package/apis/dictType/detail.ts +6 -6
- package/apis/dictType/ins.ts +7 -7
- package/apis/dictType/list.ts +8 -10
- package/apis/dictType/upd.ts +8 -8
- package/apis/email/config.ts +4 -4
- package/apis/email/logList.ts +8 -8
- package/apis/email/send.ts +18 -18
- package/apis/email/verify.ts +5 -5
- package/apis/loginLog/list.ts +8 -8
- package/apis/menu/all.ts +16 -18
- package/apis/menu/list.ts +12 -12
- package/apis/operateLog/list.ts +8 -8
- package/apis/role/all.ts +7 -7
- package/apis/role/apiSave.ts +10 -13
- package/apis/role/apis.ts +7 -12
- package/apis/role/del.ts +14 -14
- package/apis/role/detail.ts +6 -6
- package/apis/role/ins.ts +10 -10
- package/apis/role/list.ts +11 -11
- package/apis/role/menuSave.ts +8 -11
- package/apis/role/menus.ts +7 -12
- package/apis/role/save.ts +12 -12
- package/apis/role/upd.ts +10 -10
- package/apis/sysConfig/all.ts +5 -5
- package/apis/sysConfig/del.ts +9 -9
- package/apis/sysConfig/get.ts +9 -9
- package/apis/sysConfig/ins.ts +11 -11
- package/apis/sysConfig/list.ts +9 -9
- package/apis/sysConfig/upd.ts +10 -10
- package/libs/emailHelper.ts +7 -7
- package/package.json +46 -34
- package/plugins/email.ts +9 -9
- package/tables/role.json +4 -2
- package/views/403_1/index.vue +19 -3
- package/views/config/dict/components/edit.vue +26 -28
- package/views/config/dict/index.vue +88 -52
- package/views/config/dictType/components/edit.vue +22 -23
- package/views/config/dictType/index.vue +82 -46
- package/views/config/index.vue +12 -0
- package/views/config/system/components/edit.vue +36 -36
- package/views/config/system/index.vue +79 -50
- package/views/index/components/addonList.vue +3 -3
- package/views/index/components/environmentInfo.vue +10 -10
- package/views/index/components/operationLogs.vue +10 -10
- package/views/index/components/performanceMetrics.vue +8 -8
- package/views/index/components/quickActions.vue +3 -3
- package/views/index/components/serviceStatus.vue +19 -19
- package/views/index/components/systemNotifications.vue +12 -12
- package/views/index/components/systemOverview.vue +7 -7
- package/views/index/components/systemResources.vue +11 -11
- package/views/index/components/userInfo.vue +20 -19
- package/views/index/index.vue +12 -5
- package/views/log/email/index.vue +58 -51
- package/views/log/index.vue +12 -0
- package/views/log/login/index.vue +45 -38
- package/views/log/operate/index.vue +55 -48
- package/views/login_1/index.vue +25 -18
- package/views/people/admin/components/edit.vue +25 -26
- package/views/people/admin/index.vue +76 -40
- package/views/people/index.vue +12 -0
- package/views/permission/api/index.vue +21 -15
- package/views/permission/index.vue +12 -0
- package/views/permission/menu/index.vue +31 -16
- package/views/permission/role/components/api.vue +21 -21
- package/views/permission/role/components/edit.vue +18 -18
- package/views/permission/role/components/menu.vue +14 -16
- package/views/permission/role/index.vue +84 -49
- package/views/403_1/meta.json +0 -4
- package/views/config/dict/meta.json +0 -4
- package/views/config/dictType/meta.json +0 -4
- package/views/config/meta.json +0 -4
- package/views/config/system/meta.json +0 -4
- package/views/index/meta.json +0 -4
- package/views/log/email/meta.json +0 -4
- package/views/log/login/meta.json +0 -4
- package/views/log/meta.json +0 -4
- package/views/log/operate/meta.json +0 -4
- package/views/login_1/meta.json +0 -4
- package/views/people/admin/meta.json +0 -4
- package/views/people/meta.json +0 -4
- package/views/permission/api/meta.json +0 -4
- package/views/permission/menu/meta.json +0 -4
- package/views/permission/meta.json +0 -4
- package/views/permission/role/meta.json +0 -4
package/apis/sysConfig/upd.ts
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import sysConfigTable from
|
|
1
|
+
import sysConfigTable from "../../tables/sysConfig.json";
|
|
2
2
|
|
|
3
3
|
export default {
|
|
4
|
-
name:
|
|
4
|
+
name: "更新系统配置",
|
|
5
5
|
fields: {
|
|
6
|
-
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:
|
|
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:
|
|
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:
|
|
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
|
};
|
package/libs/emailHelper.ts
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
* 提供邮件发送功能,支持 SMTP 配置
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import
|
|
6
|
+
import type { BeflyContext } from "befly/types/befly";
|
|
7
|
+
import type { Transporter } from "nodemailer";
|
|
7
8
|
|
|
8
|
-
import
|
|
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:
|
|
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,
|
|
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.
|
|
4
|
-
"title": "管理后台",
|
|
5
|
-
"description": "Befly - 管理后台功能组件",
|
|
6
|
-
"type": "module",
|
|
3
|
+
"version": "1.1.31",
|
|
7
4
|
"private": false,
|
|
8
|
-
"
|
|
9
|
-
|
|
10
|
-
"
|
|
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
|
-
"
|
|
33
|
-
"
|
|
34
|
-
"
|
|
35
|
-
"
|
|
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.
|
|
50
|
-
"befly-
|
|
43
|
+
"befly": "^3.9.39",
|
|
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": "d42bf60ba6b8b11fef7e759fa008ada075829772",
|
|
69
|
+
"title": "管理后台"
|
|
58
70
|
}
|
package/plugins/email.ts
CHANGED
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
* 提供邮件发送功能,支持 SMTP 配置
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
|
-
import {
|
|
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
|
|
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:
|
|
14
|
+
host: "smtp.qq.com",
|
|
15
15
|
port: 465,
|
|
16
16
|
secure: true,
|
|
17
|
-
user:
|
|
18
|
-
pass:
|
|
19
|
-
fromName:
|
|
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: [
|
|
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": "
|
|
24
|
+
"type": "array_number_text",
|
|
25
|
+
"detail": "菜单ID数组,如 [1,2,3]"
|
|
25
26
|
},
|
|
26
27
|
"apis": {
|
|
27
28
|
"name": "接口权限",
|
|
28
|
-
"type": "
|
|
29
|
+
"type": "array_number_text",
|
|
30
|
+
"detail": "接口ID数组,如 [1,2,3]"
|
|
29
31
|
},
|
|
30
32
|
"sort": {
|
|
31
33
|
"name": "排序",
|
package/views/403_1/index.vue
CHANGED
|
@@ -13,14 +13,21 @@
|
|
|
13
13
|
</template>
|
|
14
14
|
|
|
15
15
|
<script setup>
|
|
16
|
-
import { useRouter } from
|
|
17
|
-
import { Button as TButton } from
|
|
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
|
|
27
|
-
import { $Http } from
|
|
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([
|
|
36
|
+
const emit = defineEmits(["update:modelValue", "success"]);
|
|
37
37
|
|
|
38
38
|
const visible = computed({
|
|
39
39
|
get: () => props.modelValue,
|
|
40
|
-
set: (val) => emit(
|
|
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 ===
|
|
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 ===
|
|
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 ===
|
|
78
|
+
MessagePlugin.success(props.actionType === "add" ? "添加成功" : "更新成功");
|
|
80
79
|
visible.value = false;
|
|
81
|
-
emit(
|
|
80
|
+
emit("success");
|
|
82
81
|
} else {
|
|
83
|
-
MessagePlugin.error(res.msg ||
|
|
82
|
+
MessagePlugin.error(res.msg || "操作失败");
|
|
84
83
|
}
|
|
85
84
|
} catch (error) {
|
|
86
|
-
|
|
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 ===
|
|
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
|
|
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
|
|
66
|
-
import ILucidePlus from
|
|
67
|
-
import ILucideRotateCw from
|
|
68
|
-
import ILucideSearch from
|
|
69
|
-
import ILucidePencil from
|
|
70
|
-
import ILucideTrash2 from
|
|
71
|
-
import ILucideChevronDown from
|
|
72
|
-
import EditDialog from
|
|
73
|
-
import DetailPanel from
|
|
74
|
-
import { $Http } from
|
|
75
|
-
import { withDefaultColumns } from
|
|
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:
|
|
87
|
-
{ colKey:
|
|
88
|
-
{ colKey:
|
|
89
|
-
{ colKey:
|
|
90
|
-
{ colKey:
|
|
91
|
-
{ colKey:
|
|
92
|
-
{ colKey:
|
|
93
|
-
{ colKey:
|
|
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:
|
|
100
|
-
layout:
|
|
115
|
+
align: "right",
|
|
116
|
+
layout: "total, prev, pager, next, jumper"
|
|
101
117
|
},
|
|
102
118
|
editVisible: false,
|
|
103
|
-
actionType:
|
|
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(
|
|
130
|
+
const res = await $Http("/addon/admin/dictType/all");
|
|
115
131
|
$Data.typeList = res.data.lists || [];
|
|
116
132
|
} catch (error) {
|
|
117
|
-
|
|
133
|
+
MessagePlugin.error("加载数据失败");
|
|
118
134
|
}
|
|
119
135
|
},
|
|
120
136
|
async apiDictList() {
|
|
121
137
|
$Data.loading = true;
|
|
122
138
|
try {
|
|
123
|
-
const res = await $Http(
|
|
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
|
-
|
|
141
|
-
MessagePlugin.error('加载数据失败');
|
|
156
|
+
MessagePlugin.error("加载数据失败");
|
|
142
157
|
} finally {
|
|
143
158
|
$Data.loading = false;
|
|
144
159
|
}
|
|
145
160
|
},
|
|
146
161
|
async apiDictDel(row) {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
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
|
-
}
|
|
161
|
-
|
|
162
|
-
|
|
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 ===
|
|
194
|
-
$Data.actionType =
|
|
229
|
+
if (type === "add") {
|
|
230
|
+
$Data.actionType = "add";
|
|
195
231
|
$Data.rowData = {};
|
|
196
232
|
$Data.editVisible = true;
|
|
197
|
-
} else if (type ===
|
|
198
|
-
$Data.actionType =
|
|
233
|
+
} else if (type === "upd") {
|
|
234
|
+
$Data.actionType = "upd";
|
|
199
235
|
$Data.rowData = { ...row };
|
|
200
236
|
$Data.editVisible = true;
|
|
201
|
-
} else if (type ===
|
|
237
|
+
} else if (type === "del") {
|
|
202
238
|
$Method.apiDictDel(row);
|
|
203
239
|
}
|
|
204
240
|
}
|