@liujitcn/kratos-admin-system 0.0.1
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/README.md +137 -0
- package/dist/package/declarations/index.d.ts +1 -0
- package/dist/package/declarations/src/ai.d.ts +10 -0
- package/dist/package/declarations/src/api/base/ai_message.d.ts +27 -0
- package/dist/package/declarations/src/api/base/ai_session.d.ts +17 -0
- package/dist/package/declarations/src/api/base/ai_tool.d.ts +7 -0
- package/dist/package/declarations/src/api/base/oauth.d.ts +13 -0
- package/dist/package/declarations/src/api/base/sse.d.ts +31 -0
- package/dist/package/declarations/src/api/system/auth.d.ts +17 -0
- package/dist/package/declarations/src/api/system/base_api.d.ts +22 -0
- package/dist/package/declarations/src/api/system/base_area.d.ts +19 -0
- package/dist/package/declarations/src/api/system/base_config.d.ts +20 -0
- package/dist/package/declarations/src/api/system/base_dept.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_dict.d.ts +32 -0
- package/dist/package/declarations/src/api/system/base_job.d.ts +28 -0
- package/dist/package/declarations/src/api/system/base_log.d.ts +9 -0
- package/dist/package/declarations/src/api/system/base_menu.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_migration.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_post.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_role.d.ts +23 -0
- package/dist/package/declarations/src/api/system/base_tenant.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_user.d.ts +23 -0
- package/dist/package/declarations/src/api/system/code_gen.d.ts +14 -0
- package/dist/package/declarations/src/api/system/code_gen_column.d.ts +12 -0
- package/dist/package/declarations/src/api/system/code_gen_proto.d.ts +10 -0
- package/dist/package/declarations/src/api/system/code_gen_sse.d.ts +8 -0
- package/dist/package/declarations/src/api/system/code_gen_table.d.ts +18 -0
- package/dist/package/declarations/src/api/system/project_document.d.ts +9 -0
- package/dist/package/declarations/src/components/Ai.vue.d.ts +3 -0
- package/dist/package/declarations/src/index.d.ts +3 -0
- package/dist/package/declarations/src/module.d.ts +2 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_message.d.ts +82 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +176 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +59 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +167 -0
- package/dist/package/declarations/src/rpc/base/v1/sse.d.ts +13 -0
- package/dist/package/declarations/src/rpc/common/v1/common.d.ts +57 -0
- package/dist/package/declarations/src/rpc/common/v1/enum.d.ts +58 -0
- package/dist/package/declarations/src/rpc/common/v1/types.d.ts +60 -0
- package/dist/package/declarations/src/rpc/google/protobuf/empty.d.ts +11 -0
- package/dist/package/declarations/src/rpc/google/protobuf/timestamp.d.ts +107 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +156 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_api.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_area.d.ts +82 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dept.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +215 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +177 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +87 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +151 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_post.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +128 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +112 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +161 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +155 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +143 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_proto.d.ts +86 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +149 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/project_document.d.ts +64 -0
- package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +67 -0
- package/dist/package/declarations/src/views/ai/chat/attachment.d.ts +14 -0
- package/dist/package/declarations/src/views/ai/chat/components/AiMarkdown.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/ai/chat/components/ChatPanel.vue.d.ts +45 -0
- package/dist/package/declarations/src/views/ai/chat/components/SessionPanel.vue.d.ts +34 -0
- package/dist/package/declarations/src/views/ai/chat/components/XSender.vue.d.ts +12 -0
- package/dist/package/declarations/src/views/ai/chat/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/ai/chat/message.d.ts +59 -0
- package/dist/package/declarations/src/views/ai/chat/stream.d.ts +10 -0
- package/dist/package/declarations/src/views/ai/chat/types.d.ts +115 -0
- package/dist/package/declarations/src/views/base/api/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/area/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/config/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dept/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dict/item.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/job/log.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/menu/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/migration/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/base/post/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/role/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/tenant/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/user/components/dept-tree.vue.d.ts +19 -0
- package/dist/package/declarations/src/views/base/user/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/base.vue.d.ts +13 -0
- package/dist/package/declarations/src/views/profile/components/password.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/security.vue.d.ts +15 -0
- package/dist/package/declarations/src/views/profile/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/api-doc/index.vue.d.ts +4 -0
- package/dist/package/declarations/src/views/tool/code-gen/code-preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/columns/option-copy.d.ts +25 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenProgressDialog.vue.d.ts +16 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodePreviewPane.vue.d.ts +9 -0
- package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +32 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/capabilities.d.ts +20 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/data.d.ts +42 -0
- package/dist/package/declarations/src/views/tool/code-gen/preview/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/proto/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/table/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/project-doc/index.vue.d.ts +4 -0
- package/dist/package/src/ai.ts +16 -0
- package/dist/package/src/api/base/ai_message.ts +139 -0
- package/dist/package/src/api/base/ai_session.ts +77 -0
- package/dist/package/src/api/base/ai_tool.ts +22 -0
- package/dist/package/src/api/base/oauth.ts +47 -0
- package/dist/package/src/api/base/sse.ts +192 -0
- package/dist/package/src/api/system/auth.ts +65 -0
- package/dist/package/src/api/system/base_api.ts +95 -0
- package/dist/package/src/api/system/base_area.ts +73 -0
- package/dist/package/src/api/system/base_config.ts +82 -0
- package/dist/package/src/api/system/base_dept.ts +83 -0
- package/dist/package/src/api/system/base_dict.ts +144 -0
- package/dist/package/src/api/system/base_job.ts +125 -0
- package/dist/package/src/api/system/base_log.ts +32 -0
- package/dist/package/src/api/system/base_menu.ts +83 -0
- package/dist/package/src/api/system/base_migration.ts +35 -0
- package/dist/package/src/api/system/base_post.ts +83 -0
- package/dist/package/src/api/system/base_role.ts +93 -0
- package/dist/package/src/api/system/base_tenant.ts +83 -0
- package/dist/package/src/api/system/base_user.ts +93 -0
- package/dist/package/src/api/system/code_gen.ts +56 -0
- package/dist/package/src/api/system/code_gen_column.ts +43 -0
- package/dist/package/src/api/system/code_gen_proto.ts +32 -0
- package/dist/package/src/api/system/code_gen_sse.ts +33 -0
- package/dist/package/src/api/system/code_gen_table.ts +74 -0
- package/dist/package/src/api/system/project_document.ts +33 -0
- package/dist/package/src/components/Ai.vue +57 -0
- package/dist/package/src/index.ts +3 -0
- package/dist/package/src/module.ts +17 -0
- package/dist/package/src/rpc/base/v1/ai_message.ts +98 -0
- package/dist/package/src/rpc/base/v1/ai_session.ts +214 -0
- package/dist/package/src/rpc/base/v1/ai_tool.ts +74 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +199 -0
- package/dist/package/src/rpc/base/v1/sse.ts +22 -0
- package/dist/package/src/rpc/common/v1/common.ts +71 -0
- package/dist/package/src/rpc/common/v1/enum.ts +71 -0
- package/dist/package/src/rpc/common/v1/types.ts +77 -0
- package/dist/package/src/rpc/google/protobuf/empty.ts +19 -0
- package/dist/package/src/rpc/google/protobuf/timestamp.ts +115 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +208 -0
- package/dist/package/src/rpc/system/admin/v1/base_api.ts +241 -0
- package/dist/package/src/rpc/system/admin/v1/base_area.ts +105 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dept.ts +140 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +249 -0
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +206 -0
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +101 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +195 -0
- package/dist/package/src/rpc/system/admin/v1/base_migration.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_post.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_role.ts +151 -0
- package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +134 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +190 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +176 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +170 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_proto.ts +104 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +179 -0
- package/dist/package/src/rpc/system/admin/v1/project_document.ts +79 -0
- package/dist/package/src/rpc/system/common/v1/enum.ts +80 -0
- package/dist/package/src/typings/swagger-ui-dist.d.ts +28 -0
- package/dist/package/src/typings/x-markdown-vue.d.ts +1 -0
- package/dist/package/src/views/ai/chat/attachment.ts +65 -0
- package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +162 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +1861 -0
- package/dist/package/src/views/ai/chat/components/SessionPanel.vue +316 -0
- package/dist/package/src/views/ai/chat/components/XSender.vue +554 -0
- package/dist/package/src/views/ai/chat/index.vue +848 -0
- package/dist/package/src/views/ai/chat/message.ts +416 -0
- package/dist/package/src/views/ai/chat/stream.ts +115 -0
- package/dist/package/src/views/ai/chat/types.ts +126 -0
- package/dist/package/src/views/base/api/index.vue +455 -0
- package/dist/package/src/views/base/area/index.vue +269 -0
- package/dist/package/src/views/base/config/index.vue +530 -0
- package/dist/package/src/views/base/dept/index.vue +461 -0
- package/dist/package/src/views/base/dict/index.vue +304 -0
- package/dist/package/src/views/base/dict/item.vue +373 -0
- package/dist/package/src/views/base/job/index.vue +535 -0
- package/dist/package/src/views/base/job/log.vue +202 -0
- package/dist/package/src/views/base/log/index.vue +317 -0
- package/dist/package/src/views/base/menu/index.vue +944 -0
- package/dist/package/src/views/base/migration/index.vue +791 -0
- package/dist/package/src/views/base/post/index.vue +324 -0
- package/dist/package/src/views/base/role/index.vue +684 -0
- package/dist/package/src/views/base/tenant/index.vue +328 -0
- package/dist/package/src/views/base/user/components/dept-tree.vue +75 -0
- package/dist/package/src/views/base/user/index.vue +783 -0
- package/dist/package/src/views/profile/components/base.vue +320 -0
- package/dist/package/src/views/profile/components/password.vue +269 -0
- package/dist/package/src/views/profile/components/security.vue +443 -0
- package/dist/package/src/views/profile/index.vue +199 -0
- package/dist/package/src/views/tool/api-doc/index.vue +275 -0
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +233 -0
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1456 -0
- package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +125 -0
- package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +328 -0
- package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +42 -0
- package/dist/package/src/views/tool/code-gen/config.ts +175 -0
- package/dist/package/src/views/tool/code-gen/preview/capabilities.ts +34 -0
- package/dist/package/src/views/tool/code-gen/preview/data.ts +331 -0
- package/dist/package/src/views/tool/code-gen/preview/index.vue +831 -0
- package/dist/package/src/views/tool/code-gen/proto/index.vue +703 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +864 -0
- package/dist/package/src/views/tool/project-doc/index.vue +561 -0
- package/package.json +60 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,530 @@
|
|
|
1
|
+
<!-- 系统配置 -->
|
|
2
|
+
<template>
|
|
3
|
+
<div class="table-box">
|
|
4
|
+
<ProTable
|
|
5
|
+
ref="proTable"
|
|
6
|
+
row-key="id"
|
|
7
|
+
:columns="columns"
|
|
8
|
+
:header-actions="headerActions"
|
|
9
|
+
:request-api="requestBaseConfigTable"
|
|
10
|
+
/>
|
|
11
|
+
|
|
12
|
+
<FormDialog
|
|
13
|
+
v-model="dialog.visible"
|
|
14
|
+
ref="formDialogRef"
|
|
15
|
+
:title="dialog.title"
|
|
16
|
+
width="1200px"
|
|
17
|
+
:model="formData"
|
|
18
|
+
:fields="formFields"
|
|
19
|
+
:rules="rules"
|
|
20
|
+
label-width="100px"
|
|
21
|
+
@confirm="handleSubmit"
|
|
22
|
+
@close="handleCloseDialog"
|
|
23
|
+
>
|
|
24
|
+
<template #textValue>
|
|
25
|
+
<el-input v-model="formData.value" placeholder="请输入配置值" />
|
|
26
|
+
</template>
|
|
27
|
+
<template #imageValue>
|
|
28
|
+
<UploadImg v-model:image-url="formData.value" upload-type="config" />
|
|
29
|
+
</template>
|
|
30
|
+
<template #richTextValue>
|
|
31
|
+
<WangEditor v-model:value="formData.value" />
|
|
32
|
+
</template>
|
|
33
|
+
<template #dictValue>
|
|
34
|
+
<Dict v-if="dictValueCode" v-model="formData.value" :code="dictValueCode" code-type="string" placeholder="请选择字典配置值" />
|
|
35
|
+
<el-input v-else v-model="formData.value" placeholder="请输入配置值" />
|
|
36
|
+
</template>
|
|
37
|
+
<template #booleanValue>
|
|
38
|
+
<el-switch
|
|
39
|
+
v-model="formData.value"
|
|
40
|
+
active-value="true"
|
|
41
|
+
inactive-value="false"
|
|
42
|
+
active-text="true"
|
|
43
|
+
inactive-text="false"
|
|
44
|
+
inline-prompt
|
|
45
|
+
/>
|
|
46
|
+
</template>
|
|
47
|
+
</FormDialog>
|
|
48
|
+
</div>
|
|
49
|
+
</template>
|
|
50
|
+
|
|
51
|
+
<script setup lang="ts">
|
|
52
|
+
import { computed, h, reactive, ref } from "vue";
|
|
53
|
+
import { useDebounceFn } from "@vueuse/core";
|
|
54
|
+
import { ElImage, ElMessage, ElMessageBox, ElTag, ElTooltip } from "element-plus";
|
|
55
|
+
import { CirclePlus, Delete, EditPen, RefreshLeft } from "@element-plus/icons-vue";
|
|
56
|
+
import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
57
|
+
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
58
|
+
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
59
|
+
import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
60
|
+
import DictLabel from "@liujitcn/kratos-admin-core/components/Dict/DictLabel.vue";
|
|
61
|
+
import UploadImg from "@liujitcn/kratos-admin-core/components/Upload/Img.vue";
|
|
62
|
+
import WangEditor from "@liujitcn/kratos-admin-core/components/WangEditor/index.vue";
|
|
63
|
+
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
64
|
+
import { defBaseConfigService } from "@liujitcn/kratos-admin-system/api/system/base_config";
|
|
65
|
+
import type { BaseConfig, BaseConfigForm, PageBaseConfigRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_config";
|
|
66
|
+
import { BaseConfigSite, Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
67
|
+
import { BaseConfigType } from "@liujitcn/kratos-admin-system/rpc/system/common/v1/enum";
|
|
68
|
+
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
69
|
+
|
|
70
|
+
defineOptions({
|
|
71
|
+
name: "BaseConfig",
|
|
72
|
+
inheritAttrs: false
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const { BUTTONS } = useAuthButtons();
|
|
76
|
+
const proTable = ref<ProTableInstance>();
|
|
77
|
+
const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
78
|
+
|
|
79
|
+
const dialog = reactive({
|
|
80
|
+
title: "",
|
|
81
|
+
visible: false
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
const formData = reactive<BaseConfigForm>({
|
|
85
|
+
/** 配置ID */
|
|
86
|
+
id: 0,
|
|
87
|
+
/** 位置:枚举【BaseConfigSite】 */
|
|
88
|
+
site: BaseConfigSite.UNKNOWN_BCS,
|
|
89
|
+
/** 配置名称 */
|
|
90
|
+
name: "",
|
|
91
|
+
/** 配置类型:枚举【BaseConfigType】 */
|
|
92
|
+
type: BaseConfigType.UNKNOWN_BCT,
|
|
93
|
+
/** 配置key */
|
|
94
|
+
key: "",
|
|
95
|
+
/** 配置value */
|
|
96
|
+
value: "",
|
|
97
|
+
/** 状态 */
|
|
98
|
+
status: Status.ENABLE
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
const rules = reactive({
|
|
102
|
+
site: [{ required: true, message: "请选择系统配置位置", trigger: "change" }],
|
|
103
|
+
name: [
|
|
104
|
+
{ required: true, message: "请输入系统配置名称", trigger: "blur" },
|
|
105
|
+
{ max: 50, message: "配置名称不能超过 50 个字符", trigger: "blur" }
|
|
106
|
+
],
|
|
107
|
+
type: [{ required: true, message: "请选择系统配置类型", trigger: "change" }],
|
|
108
|
+
key: [
|
|
109
|
+
{ required: true, message: "请输入系统配置编码", trigger: "blur" },
|
|
110
|
+
{ max: 50, message: "配置key不能超过 50 个字符", trigger: "blur" }
|
|
111
|
+
],
|
|
112
|
+
value: [{ required: true, message: "配置值不能为空", trigger: "blur" }],
|
|
113
|
+
status: [{ required: true, message: "请选择状态", trigger: "change" }]
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
const statusOptions: ProFormOption[] = [
|
|
117
|
+
{ label: "启用", value: Status.ENABLE },
|
|
118
|
+
{ label: "禁用", value: Status.DISABLE }
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
/** 字典类系统配置与字典编码的映射关系。 */
|
|
122
|
+
const BASE_CONFIG_DICT_CODE_MAP: Record<string, string> = {
|
|
123
|
+
captchaType: "captcha_type"
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
/** 当前字典类配置对应的字典编码,未配置映射时允许退回手动输入。 */
|
|
127
|
+
const dictValueCode = computed(() => BASE_CONFIG_DICT_CODE_MAP[formData.key] ?? "");
|
|
128
|
+
|
|
129
|
+
/** 系统配置表单字段配置。 */
|
|
130
|
+
const formFields = computed<ProFormField[]>(() => [
|
|
131
|
+
{
|
|
132
|
+
prop: "name",
|
|
133
|
+
label: "配置名称",
|
|
134
|
+
component: "input",
|
|
135
|
+
props: { placeholder: "请输入配置名称", disabled: formData.id > 0 }
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
prop: "site",
|
|
139
|
+
label: "配置位置",
|
|
140
|
+
component: "dict",
|
|
141
|
+
props: { code: "base_config_site", disabled: formData.id > 0 }
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
prop: "key",
|
|
145
|
+
label: "配置键",
|
|
146
|
+
component: "input",
|
|
147
|
+
props: { placeholder: "请输入配置键", disabled: formData.id > 0 }
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
prop: "type",
|
|
151
|
+
label: "配置类型",
|
|
152
|
+
component: "dict",
|
|
153
|
+
props: { code: "base_config_type", disabled: formData.id > 0 }
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
prop: "value",
|
|
157
|
+
label: "配置值",
|
|
158
|
+
component: "slot",
|
|
159
|
+
slotName: "textValue",
|
|
160
|
+
visible: model => model.type == BaseConfigType.TEXT
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
prop: "value",
|
|
164
|
+
label: "配置值",
|
|
165
|
+
component: "slot",
|
|
166
|
+
slotName: "imageValue",
|
|
167
|
+
visible: model => model.type == BaseConfigType.IMAGE
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
prop: "value",
|
|
171
|
+
label: "配置值",
|
|
172
|
+
component: "slot",
|
|
173
|
+
slotName: "richTextValue",
|
|
174
|
+
visible: model => model.type == BaseConfigType.RICH_TEXT,
|
|
175
|
+
colSpan: 24
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
prop: "value",
|
|
179
|
+
label: "配置值",
|
|
180
|
+
component: "slot",
|
|
181
|
+
slotName: "dictValue",
|
|
182
|
+
visible: model => model.type == BaseConfigType.DICT
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
prop: "value",
|
|
186
|
+
label: "配置值",
|
|
187
|
+
component: "slot",
|
|
188
|
+
slotName: "booleanValue",
|
|
189
|
+
visible: model => model.type == BaseConfigType.BOOLEAN
|
|
190
|
+
},
|
|
191
|
+
{ prop: "status", label: "状态", component: "radio-group", options: statusOptions }
|
|
192
|
+
]);
|
|
193
|
+
|
|
194
|
+
/** 系统配置表格列配置。 */
|
|
195
|
+
const columns: ColumnProps[] = [
|
|
196
|
+
{ type: "selection", width: 55 },
|
|
197
|
+
{ prop: "site", label: "配置位置", minWidth: 120, dictCode: "base_config_site", search: { el: "select" } },
|
|
198
|
+
{ prop: "name", label: "配置名称", minWidth: 140, search: { el: "input" } },
|
|
199
|
+
{ prop: "type", label: "配置类型", minWidth: 120, dictCode: "base_config_type", search: { el: "select" } },
|
|
200
|
+
{
|
|
201
|
+
prop: "key",
|
|
202
|
+
label: "配置键",
|
|
203
|
+
minWidth: 160,
|
|
204
|
+
search: { el: "input" },
|
|
205
|
+
render: scope => renderConfigKeyCell(scope.row as BaseConfig)
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
prop: "status",
|
|
209
|
+
label: "状态",
|
|
210
|
+
minWidth: 100,
|
|
211
|
+
search: { el: "select" },
|
|
212
|
+
cellType: "status",
|
|
213
|
+
statusProps: {
|
|
214
|
+
activeValue: Status.ENABLE,
|
|
215
|
+
inactiveValue: Status.DISABLE,
|
|
216
|
+
activeText: "启用",
|
|
217
|
+
inactiveText: "禁用",
|
|
218
|
+
disabled: () => !BUTTONS.value["base:config:status"],
|
|
219
|
+
beforeChange: scope => handleBeforeSetStatus(scope.row as BaseConfig)
|
|
220
|
+
}
|
|
221
|
+
},
|
|
222
|
+
{ prop: "created_at", label: "创建时间", minWidth: 180 },
|
|
223
|
+
{ prop: "updated_at", label: "更新时间", minWidth: 180 },
|
|
224
|
+
{
|
|
225
|
+
prop: "operation",
|
|
226
|
+
label: "操作",
|
|
227
|
+
width: 150,
|
|
228
|
+
fixed: "right",
|
|
229
|
+
cellType: "actions",
|
|
230
|
+
actions: [
|
|
231
|
+
{
|
|
232
|
+
label: "编辑",
|
|
233
|
+
type: "primary",
|
|
234
|
+
link: true,
|
|
235
|
+
icon: EditPen,
|
|
236
|
+
hidden: () => !BUTTONS.value["base:config:update"],
|
|
237
|
+
params: scope => ({ configId: scope.row.id }),
|
|
238
|
+
onClick: (scope, params) => handleOpenDialog((params?.configId as number | undefined) ?? (scope.row as BaseConfig).id)
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
label: "删除",
|
|
242
|
+
type: "danger",
|
|
243
|
+
link: true,
|
|
244
|
+
icon: Delete,
|
|
245
|
+
hidden: () => !BUTTONS.value["base:config:delete"],
|
|
246
|
+
onClick: scope => handleDelete(scope.row as BaseConfig)
|
|
247
|
+
}
|
|
248
|
+
]
|
|
249
|
+
}
|
|
250
|
+
];
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* 将配置键渲染为可悬停查看配置值的单元格。
|
|
254
|
+
*/
|
|
255
|
+
function renderConfigKeyCell(row: BaseConfig) {
|
|
256
|
+
return h(
|
|
257
|
+
ElTooltip,
|
|
258
|
+
{
|
|
259
|
+
placement: "top-start",
|
|
260
|
+
effect: "light",
|
|
261
|
+
showAfter: 200,
|
|
262
|
+
enterable: true,
|
|
263
|
+
maxWidth: 420
|
|
264
|
+
},
|
|
265
|
+
{
|
|
266
|
+
default: () => h("span", { class: "config-key-cell" }, row.key),
|
|
267
|
+
content: () => renderConfigValuePreview(row)
|
|
268
|
+
}
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
/**
|
|
273
|
+
* 根据配置类型渲染悬停预览内容。
|
|
274
|
+
*/
|
|
275
|
+
function renderConfigValuePreview(row: BaseConfig) {
|
|
276
|
+
if (row.type === BaseConfigType.IMAGE) {
|
|
277
|
+
return row.value
|
|
278
|
+
? h(ElImage, {
|
|
279
|
+
src: row.value,
|
|
280
|
+
previewSrcList: [row.value],
|
|
281
|
+
previewTeleported: true,
|
|
282
|
+
fit: "contain",
|
|
283
|
+
style: { width: "180px", height: "120px", borderRadius: "4px" }
|
|
284
|
+
})
|
|
285
|
+
: h("span", { class: "config-value-preview" }, "未配置图片");
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (row.type === BaseConfigType.BOOLEAN) {
|
|
289
|
+
const value = row.value === "true" ? "true" : "false";
|
|
290
|
+
return h(ElTag, { type: value === "true" ? "success" : "info" }, () => value);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
if (row.type === BaseConfigType.DICT && BASE_CONFIG_DICT_CODE_MAP[row.key]) {
|
|
294
|
+
return h(DictLabel, {
|
|
295
|
+
code: BASE_CONFIG_DICT_CODE_MAP[row.key],
|
|
296
|
+
modelValue: row.value,
|
|
297
|
+
class: "config-value-preview"
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (row.type === BaseConfigType.RICH_TEXT) {
|
|
302
|
+
return row.value
|
|
303
|
+
? h("div", { class: "config-rich-text-preview", innerHTML: row.value })
|
|
304
|
+
: h("span", { class: "config-value-preview" }, "未配置富文本");
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const value = row.value;
|
|
308
|
+
return h("span", { class: "config-value-preview" }, value || "未配置");
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/** 系统配置顶部按钮配置。 */
|
|
312
|
+
const headerActions: HeaderActionProps[] = [
|
|
313
|
+
{
|
|
314
|
+
label: "新增",
|
|
315
|
+
type: "success",
|
|
316
|
+
icon: CirclePlus,
|
|
317
|
+
hidden: () => !BUTTONS.value["base:config:create"],
|
|
318
|
+
onClick: () => handleOpenDialog()
|
|
319
|
+
},
|
|
320
|
+
{
|
|
321
|
+
label: "删除",
|
|
322
|
+
type: "danger",
|
|
323
|
+
icon: Delete,
|
|
324
|
+
hidden: () => !BUTTONS.value["base:config:delete"],
|
|
325
|
+
disabled: scope => !scope.selectedList.length,
|
|
326
|
+
onClick: scope => handleDelete(scope.selectedList as BaseConfig[])
|
|
327
|
+
},
|
|
328
|
+
{
|
|
329
|
+
label: "刷新缓存",
|
|
330
|
+
type: "primary",
|
|
331
|
+
icon: RefreshLeft,
|
|
332
|
+
hidden: () => !BUTTONS.value["base:config:refresh"],
|
|
333
|
+
onClick: () => handleRefreshCache()
|
|
334
|
+
}
|
|
335
|
+
];
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* 请求系统配置列表,并由 ProTable 统一维护分页与搜索参数。
|
|
339
|
+
*/
|
|
340
|
+
async function requestBaseConfigTable(params: PageBaseConfigRequest) {
|
|
341
|
+
const data = await defBaseConfigService.PageBaseConfig(buildPageRequest(params));
|
|
342
|
+
return { data: { list: data.base_configs ?? [], total: data.total } };
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/**
|
|
346
|
+
* 刷新系统配置表格。
|
|
347
|
+
*/
|
|
348
|
+
function refreshTable() {
|
|
349
|
+
proTable.value?.getTableList();
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* 打开系统配置弹窗。
|
|
354
|
+
*/
|
|
355
|
+
function handleOpenDialog(configId?: number) {
|
|
356
|
+
resetForm();
|
|
357
|
+
dialog.title = configId ? "修改系统配置" : "新增系统配置";
|
|
358
|
+
dialog.visible = true;
|
|
359
|
+
if (!configId) return;
|
|
360
|
+
|
|
361
|
+
defBaseConfigService.GetBaseConfig({ id: configId }).then(data => {
|
|
362
|
+
Object.assign(formData, data);
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/**
|
|
367
|
+
* 关闭系统配置弹窗并恢复默认表单值。
|
|
368
|
+
*/
|
|
369
|
+
function handleCloseDialog() {
|
|
370
|
+
dialog.visible = false;
|
|
371
|
+
resetForm();
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/**
|
|
375
|
+
* 重置系统配置表单,避免新增时保留旧值。
|
|
376
|
+
*/
|
|
377
|
+
function resetForm() {
|
|
378
|
+
formDialogRef.value?.resetFields();
|
|
379
|
+
formDialogRef.value?.clearValidate();
|
|
380
|
+
formData.id = 0;
|
|
381
|
+
formData.site = BaseConfigSite.UNKNOWN_BCS;
|
|
382
|
+
formData.name = "";
|
|
383
|
+
formData.type = BaseConfigType.UNKNOWN_BCT;
|
|
384
|
+
formData.key = "";
|
|
385
|
+
formData.value = "";
|
|
386
|
+
formData.status = Status.ENABLE;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* 提交系统配置表单。
|
|
391
|
+
*/
|
|
392
|
+
function handleSubmit() {
|
|
393
|
+
if (formData.type === BaseConfigType.BOOLEAN) {
|
|
394
|
+
formData.value = formData.value === "true" ? "true" : "false";
|
|
395
|
+
}
|
|
396
|
+
formDialogRef.value?.validate()?.then(valid => {
|
|
397
|
+
if (!valid) return;
|
|
398
|
+
|
|
399
|
+
const submitData = JSON.parse(JSON.stringify(formData)) as BaseConfigForm;
|
|
400
|
+
const request = submitData.id
|
|
401
|
+
? defBaseConfigService.UpdateBaseConfig({ base_config: submitData })
|
|
402
|
+
: defBaseConfigService.CreateBaseConfig({ base_config: submitData });
|
|
403
|
+
request.then(() => {
|
|
404
|
+
ElMessage.success(submitData.id ? "修改系统配置成功" : "新增系统配置成功");
|
|
405
|
+
handleCloseDialog();
|
|
406
|
+
refreshTable();
|
|
407
|
+
});
|
|
408
|
+
});
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
/**
|
|
412
|
+
* 刷新服务端配置缓存,使用防抖避免重复点击。
|
|
413
|
+
*/
|
|
414
|
+
const handleRefreshCache = useDebounceFn(() => {
|
|
415
|
+
defBaseConfigService.RefreshBaseConfigCache({}).then(() => {
|
|
416
|
+
ElMessage.success("刷新成功");
|
|
417
|
+
});
|
|
418
|
+
}, 1000);
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* 在系统配置状态切换前先完成确认与接口调用,避免首屏渲染触发误操作。
|
|
422
|
+
*/
|
|
423
|
+
async function handleBeforeSetStatus(row: BaseConfig) {
|
|
424
|
+
const nextStatus = row.status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
425
|
+
const text = nextStatus === Status.ENABLE ? "启用" : "禁用";
|
|
426
|
+
const configName = row.name || row.key || `ID:${row.id}`;
|
|
427
|
+
try {
|
|
428
|
+
await ElMessageBox.confirm(`是否确定${text}配置?\n配置名称:${configName}`, "提示", {
|
|
429
|
+
confirmButtonText: "确认",
|
|
430
|
+
cancelButtonText: "取消",
|
|
431
|
+
type: "warning"
|
|
432
|
+
});
|
|
433
|
+
await defBaseConfigService.SetBaseConfigStatus({ id: row.id, status: nextStatus });
|
|
434
|
+
ElMessage.success(`${text}成功`);
|
|
435
|
+
refreshTable();
|
|
436
|
+
return true;
|
|
437
|
+
} catch {
|
|
438
|
+
return false;
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* 删除系统配置,兼容单项删除与多选删除。
|
|
444
|
+
*/
|
|
445
|
+
function handleDelete(selected?: number | string | Array<number | string> | BaseConfig | BaseConfig[]) {
|
|
446
|
+
const configList = Array.isArray(selected)
|
|
447
|
+
? (selected.filter(item => typeof item === "object") as BaseConfig[])
|
|
448
|
+
: selected && typeof selected === "object"
|
|
449
|
+
? [selected as BaseConfig]
|
|
450
|
+
: [];
|
|
451
|
+
const configIds = (
|
|
452
|
+
configList.length
|
|
453
|
+
? configList.map(item => item.id)
|
|
454
|
+
: normalizeSelectedIds(selected as number | string | Array<number | string>)
|
|
455
|
+
).join(",");
|
|
456
|
+
if (!configIds) {
|
|
457
|
+
ElMessage.warning("请勾选删除项");
|
|
458
|
+
return;
|
|
459
|
+
}
|
|
460
|
+
|
|
461
|
+
const confirmMessage = configList.length
|
|
462
|
+
? configList.length === 1
|
|
463
|
+
? `是否确定删除配置?\n配置名称:${configList[0].name || configList[0].key || `ID:${configList[0].id}`}`
|
|
464
|
+
: `确认删除已选中的 ${configList.length} 项系统配置吗?`
|
|
465
|
+
: "确认删除已选中的系统配置吗?";
|
|
466
|
+
|
|
467
|
+
ElMessageBox.confirm(confirmMessage, "警告", {
|
|
468
|
+
confirmButtonText: "确定",
|
|
469
|
+
cancelButtonText: "取消",
|
|
470
|
+
type: "warning"
|
|
471
|
+
}).then(
|
|
472
|
+
() => {
|
|
473
|
+
defBaseConfigService.DeleteBaseConfig({ id: configIds }).then(() => {
|
|
474
|
+
ElMessage.success("删除系统配置成功");
|
|
475
|
+
refreshTable();
|
|
476
|
+
});
|
|
477
|
+
},
|
|
478
|
+
() => {
|
|
479
|
+
ElMessage.info("已取消删除系统配置");
|
|
480
|
+
}
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
</script>
|
|
484
|
+
|
|
485
|
+
<style scoped lang="scss">
|
|
486
|
+
.config-key-cell {
|
|
487
|
+
cursor: pointer;
|
|
488
|
+
border-bottom: 1px dashed var(--el-color-info);
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
.config-value-preview {
|
|
492
|
+
display: inline-block;
|
|
493
|
+
max-width: 380px;
|
|
494
|
+
white-space: pre-wrap;
|
|
495
|
+
word-break: break-word;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
.config-rich-text-preview {
|
|
499
|
+
max-width: 520px;
|
|
500
|
+
max-height: 360px;
|
|
501
|
+
overflow: auto;
|
|
502
|
+
line-height: 1.6;
|
|
503
|
+
word-break: break-word;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
.config-rich-text-preview :deep(p) {
|
|
507
|
+
margin: 0 0 8px;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
.config-rich-text-preview :deep(h1),
|
|
511
|
+
.config-rich-text-preview :deep(h2),
|
|
512
|
+
.config-rich-text-preview :deep(h3),
|
|
513
|
+
.config-rich-text-preview :deep(h4),
|
|
514
|
+
.config-rich-text-preview :deep(h5),
|
|
515
|
+
.config-rich-text-preview :deep(h6) {
|
|
516
|
+
margin: 0 0 8px;
|
|
517
|
+
line-height: 1.35;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
.config-rich-text-preview :deep(ul),
|
|
521
|
+
.config-rich-text-preview :deep(ol) {
|
|
522
|
+
margin: 0 0 8px;
|
|
523
|
+
padding-left: 24px;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
.config-rich-text-preview :deep(img) {
|
|
527
|
+
max-width: 100%;
|
|
528
|
+
height: auto;
|
|
529
|
+
}
|
|
530
|
+
</style>
|