@liujitcn/kratos-admin-system 0.0.28 → 0.0.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/README.md +19 -2
- package/dist/package/declarations/src/api/base/notification.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_audit_log.d.ts +55 -0
- package/dist/package/declarations/src/api/system/base_dashboard.d.ts +14 -0
- package/dist/package/declarations/src/api/system/base_file.d.ts +13 -0
- package/dist/package/declarations/src/api/system/base_i18n.d.ts +5 -5
- package/dist/package/declarations/src/api/system/base_login_policy.d.ts +10 -0
- package/dist/package/declarations/src/api/system/base_message.d.ts +24 -0
- package/dist/package/declarations/src/api/system/base_message_category.d.ts +21 -0
- package/dist/package/declarations/src/api/system/base_session.d.ts +11 -0
- package/dist/package/declarations/src/api/system/oauth_client.d.ts +24 -0
- package/dist/package/declarations/src/components/AuditLogTable.vue.d.ts +45 -0
- package/dist/package/declarations/src/components/DynamicI18nCell.vue.d.ts +16 -0
- package/dist/package/declarations/src/components/DynamicI18nEditor.vue.d.ts +20 -0
- package/dist/package/declarations/src/components/auditLog.d.ts +9 -0
- package/dist/package/declarations/src/components/dynamicI18n.d.ts +38 -0
- package/dist/package/declarations/src/locales/generated.d.ts +1364 -68
- package/dist/package/declarations/src/rpc/base/v1/login.d.ts +149 -0
- package/dist/package/declarations/src/rpc/base/v1/notification.d.ts +281 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth.d.ts +25 -0
- package/dist/package/declarations/src/rpc/base/v1/oauth_client.d.ts +23 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_audit_log.d.ts +640 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dashboard.d.ts +60 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +4 -4
- package/dist/package/declarations/src/rpc/system/admin/v1/base_file.d.ts +73 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_i18n.d.ts +27 -23
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +5 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_login_policy.d.ts +51 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +2 -2
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message.d.ts +193 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_message_category.d.ts +125 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_session.d.ts +33 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +3 -3
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +1 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/oauth_client.d.ts +145 -0
- package/dist/package/declarations/src/views/base/api-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/dashboard/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/data-access-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/file/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/login-policy/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/message-category/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/oauth-client/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/operation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/permission-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/base/policy-evaluation-log/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/message/inbox/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/profile/components/session.vue.d.ts +3 -0
- package/dist/package/src/api/base/notification.ts +69 -0
- package/dist/package/src/api/base/sse.ts +4 -4
- package/dist/package/src/api/system/auth.ts +1 -0
- package/dist/package/src/api/system/base_audit_log.ts +168 -0
- package/dist/package/src/api/system/base_dashboard.ts +55 -0
- package/dist/package/src/api/system/base_file.ts +43 -0
- package/dist/package/src/api/system/base_i18n.ts +12 -12
- package/dist/package/src/api/system/base_login_policy.ts +32 -0
- package/dist/package/src/api/system/base_message.ts +70 -0
- package/dist/package/src/api/system/base_message_category.ts +57 -0
- package/dist/package/src/api/system/base_session.ts +33 -0
- package/dist/package/src/api/system/oauth_client.ts +102 -0
- package/dist/package/src/components/AuditLogTable.vue +105 -0
- package/dist/package/src/components/{DynamicTranslationCell.vue → DynamicI18nCell.vue} +50 -50
- package/dist/package/src/components/{DynamicTranslationEditor.vue → DynamicI18nEditor.vue} +45 -45
- package/dist/package/src/components/Notification.vue +196 -0
- package/dist/package/src/components/auditLog.ts +46 -0
- package/dist/package/src/components/{dynamicTranslation.ts → dynamicI18n.ts} +15 -15
- package/dist/package/src/locales/README.md +5 -3
- package/dist/package/src/locales/en-US.json +345 -21
- package/dist/package/src/locales/ja-JP.json +347 -23
- package/dist/package/src/locales/zh-CN.json +343 -19
- package/dist/package/src/locales/zh-TW.json +346 -22
- package/dist/package/src/module.ts +5 -2
- package/dist/package/src/rpc/base/v1/login.ts +172 -0
- package/dist/package/src/rpc/base/v1/notification.ts +315 -0
- package/dist/package/src/rpc/base/v1/oauth.ts +25 -0
- package/dist/package/src/rpc/base/v1/oauth_client.ts +33 -0
- package/dist/package/src/rpc/system/admin/v1/base_audit_log.ts +737 -0
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/base_dashboard.ts +81 -0
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +4 -4
- package/dist/package/src/rpc/system/admin/v1/base_file.ts +88 -0
- package/dist/package/src/rpc/system/admin/v1/base_i18n.ts +27 -23
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +5 -0
- package/dist/package/src/rpc/system/admin/v1/base_login_policy.ts +63 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +2 -2
- package/dist/package/src/rpc/system/admin/v1/base_message.ts +236 -0
- package/dist/package/src/rpc/system/admin/v1/base_message_category.ts +149 -0
- package/dist/package/src/rpc/system/admin/v1/base_session.ts +44 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +3 -3
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +1 -1
- package/dist/package/src/rpc/system/admin/v1/oauth_client.ts +174 -0
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +2 -2
- package/dist/package/src/views/ai/chat/message.ts +7 -3
- package/dist/package/src/views/base/api-log/index.vue +83 -0
- package/dist/package/src/views/base/config/index.vue +41 -41
- package/dist/package/src/views/base/dashboard/index.vue +200 -0
- package/dist/package/src/views/base/data-access-log/index.vue +84 -0
- package/dist/package/src/views/base/dict/index.vue +23 -23
- package/dist/package/src/views/base/dict/item.vue +25 -25
- package/dist/package/src/views/base/file/index.vue +119 -0
- package/dist/package/src/views/base/job/index.vue +62 -7
- package/dist/package/src/views/base/language/index.vue +2 -1
- package/dist/package/src/views/base/login-log/index.vue +92 -0
- package/dist/package/src/views/base/login-policy/index.vue +219 -0
- package/dist/package/src/views/base/menu/index.vue +23 -23
- package/dist/package/src/views/base/message/index.vue +582 -0
- package/dist/package/src/views/base/message-category/index.vue +356 -0
- package/dist/package/src/views/base/oauth-client/index.vue +411 -0
- package/dist/package/src/views/base/operation-log/index.vue +82 -0
- package/dist/package/src/views/base/permission-log/index.vue +85 -0
- package/dist/package/src/views/base/policy-evaluation-log/index.vue +82 -0
- package/dist/package/src/views/message/inbox/index.vue +249 -0
- package/dist/package/src/views/profile/components/base.vue +6 -5
- package/dist/package/src/views/profile/components/password.vue +2 -2
- package/dist/package/src/views/profile/components/security.vue +475 -62
- package/dist/package/src/views/profile/components/session.vue +153 -0
- package/dist/package/src/views/profile/index.vue +35 -22
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +9 -9
- package/dist/package/src/views/tool/code-gen/columns/index.vue +1 -1
- package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +8 -8
- package/dist/package/src/views/tool/code-gen/config.ts +1 -0
- package/dist/package/src/views/tool/code-gen/table/index.vue +7 -7
- package/dist/package/src/views/tool/ops-monitoring/index.vue +25 -21
- package/package.json +2 -2
- package/dist/package/declarations/src/api/system/base_log.d.ts +0 -9
- package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +0 -16
- package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +0 -20
- package/dist/package/declarations/src/components/dynamicTranslation.d.ts +0 -38
- package/dist/package/declarations/src/rpc/system/admin/v1/base_log.d.ts +0 -87
- package/dist/package/src/api/system/base_log.ts +0 -32
- package/dist/package/src/rpc/system/admin/v1/base_log.ts +0 -101
- package/dist/package/src/views/base/log/index.vue +0 -339
- /package/dist/package/declarations/src/{views/base/log/index.vue.d.ts → components/Notification.vue.d.ts} +0 -0
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="table-box">
|
|
3
|
+
<ProTable ref="proTable" row-key="id" :columns="columns" :header-actions="headerActions" :request-api="requestTable" />
|
|
4
|
+
<FormDialog
|
|
5
|
+
v-model="dialog.visible"
|
|
6
|
+
ref="formDialogRef"
|
|
7
|
+
:title="t(dialog.titleKey)"
|
|
8
|
+
width="680px"
|
|
9
|
+
:model="formData"
|
|
10
|
+
:fields="formFields"
|
|
11
|
+
:rules="rules"
|
|
12
|
+
@confirm="handleSubmit"
|
|
13
|
+
@close="handleClose"
|
|
14
|
+
/>
|
|
15
|
+
</div>
|
|
16
|
+
</template>
|
|
17
|
+
|
|
18
|
+
<script setup lang="ts">
|
|
19
|
+
import { computed, h, reactive, ref, type Component } from "vue";
|
|
20
|
+
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
21
|
+
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
22
|
+
import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
23
|
+
import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
24
|
+
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
25
|
+
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
26
|
+
import { DEFAULT_TENANT_CODE } from "@liujitcn/kratos-admin-core/tenant";
|
|
27
|
+
import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
|
|
28
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
29
|
+
import { defBaseMessageCategoryService } from "@liujitcn/kratos-admin-system/api/system/base_message_category";
|
|
30
|
+
import type {
|
|
31
|
+
BaseMessageCategory,
|
|
32
|
+
BaseMessageCategoryForm,
|
|
33
|
+
PageBaseMessageCategoryRequest
|
|
34
|
+
} from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_message_category";
|
|
35
|
+
import { MessagePriority } from "@liujitcn/kratos-admin-system/rpc/base/v1/notification";
|
|
36
|
+
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
37
|
+
|
|
38
|
+
defineOptions({ name: "BaseMessageCategory", inheritAttrs: false });
|
|
39
|
+
|
|
40
|
+
/** 消息分类页面表单状态。 */
|
|
41
|
+
const { BUTTONS } = useAuthButtons();
|
|
42
|
+
const userStore = useUserStore();
|
|
43
|
+
const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
|
|
44
|
+
const proTable = ref<ProTableInstance>();
|
|
45
|
+
const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
46
|
+
const dialog = reactive({ visible: false, titleKey: "common.action.create" });
|
|
47
|
+
const formData = reactive<BaseMessageCategoryForm>(defaultForm());
|
|
48
|
+
|
|
49
|
+
const statusOptions = computed<ProFormOption[]>(() => [
|
|
50
|
+
{ label: t("common.status.enabled"), value: Status.STATUS_ENABLE },
|
|
51
|
+
{ label: t("common.status.disabled"), value: Status.STATUS_DISABLE }
|
|
52
|
+
]);
|
|
53
|
+
const priorityOptions = computed<ProFormOption[]>(() => [
|
|
54
|
+
{ label: t("system.base.message.priority.normal"), value: MessagePriority.MESSAGE_PRIORITY_NORMAL },
|
|
55
|
+
{ label: t("system.base.message.priority.important"), value: MessagePriority.MESSAGE_PRIORITY_IMPORTANT },
|
|
56
|
+
{ label: t("system.base.message.priority.urgent"), value: MessagePriority.MESSAGE_PRIORITY_URGENT }
|
|
57
|
+
]);
|
|
58
|
+
const iconOptions = computed<ProFormOption[]>(() => {
|
|
59
|
+
const options: ProFormOption[] = [
|
|
60
|
+
{ label: `${t("system.base.message_category.icon.bell")} (Bell)`, value: "Bell", icon: Bell },
|
|
61
|
+
{ label: `${t("system.base.message_category.icon.lock")} (Lock)`, value: "Lock", icon: Lock },
|
|
62
|
+
{ label: `${t("system.base.message_category.icon.list")} (List)`, value: "List", icon: List },
|
|
63
|
+
{ label: `${t("system.base.message_category.icon.message")} (Message)`, value: "Message", icon: Message },
|
|
64
|
+
{ label: `${t("system.base.message_category.icon.info")} (InfoFilled)`, value: "InfoFilled", icon: InfoFilled },
|
|
65
|
+
{ label: `${t("system.base.message_category.icon.warning")} (WarningFilled)`, value: "WarningFilled", icon: WarningFilled },
|
|
66
|
+
{
|
|
67
|
+
label: `${t("system.base.message_category.icon.success")} (CircleCheckFilled)`,
|
|
68
|
+
value: "CircleCheckFilled",
|
|
69
|
+
icon: CircleCheckFilled
|
|
70
|
+
},
|
|
71
|
+
{ label: `${t("system.base.message_category.icon.promotion")} (Promotion)`, value: "Promotion", icon: Promotion },
|
|
72
|
+
{ label: `${t("system.base.message_category.icon.setting")} (Setting)`, value: "Setting", icon: Setting },
|
|
73
|
+
{ label: `${t("system.base.message_category.icon.user")} (User)`, value: "User", icon: User },
|
|
74
|
+
{ label: `${t("system.base.message_category.icon.calendar")} (Calendar)`, value: "Calendar", icon: Calendar },
|
|
75
|
+
{ label: `${t("system.base.message_category.icon.chat")} (ChatDotRound)`, value: "ChatDotRound", icon: ChatDotRound },
|
|
76
|
+
{ label: `${t("system.base.message_category.icon.analysis")} (DataAnalysis)`, value: "DataAnalysis", icon: DataAnalysis }
|
|
77
|
+
];
|
|
78
|
+
if (formData.icon && !options.some(option => option.value === formData.icon)) {
|
|
79
|
+
options.push({ label: formData.icon, value: formData.icon, icon: CollectionTag });
|
|
80
|
+
}
|
|
81
|
+
return options;
|
|
82
|
+
});
|
|
83
|
+
const presetColors = ["#3a7afe", "#e5484d", "#f59e0b", "#16a34a", "#8b5cf6", "#0ea5e9", "#64748b"];
|
|
84
|
+
const categoryIcons: Record<string, Component> = {
|
|
85
|
+
Bell,
|
|
86
|
+
Calendar,
|
|
87
|
+
ChatDotRound,
|
|
88
|
+
CircleCheckFilled,
|
|
89
|
+
CollectionTag,
|
|
90
|
+
DataAnalysis,
|
|
91
|
+
InfoFilled,
|
|
92
|
+
List,
|
|
93
|
+
Lock,
|
|
94
|
+
Message,
|
|
95
|
+
Promotion,
|
|
96
|
+
Setting,
|
|
97
|
+
User,
|
|
98
|
+
WarningFilled
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const rules = computed(() => ({
|
|
102
|
+
code: [
|
|
103
|
+
{
|
|
104
|
+
required: true,
|
|
105
|
+
message: t("common.validation.required_input", { field: t("system.base.message_category.field.code") }),
|
|
106
|
+
trigger: "blur"
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
name: [
|
|
110
|
+
{
|
|
111
|
+
required: true,
|
|
112
|
+
message: t("common.validation.required_input", { field: t("system.base.message_category.field.name") }),
|
|
113
|
+
trigger: "blur"
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}));
|
|
117
|
+
|
|
118
|
+
const formFields = computed<ProFormField[]>(() => [
|
|
119
|
+
{
|
|
120
|
+
prop: "code",
|
|
121
|
+
label: t("system.base.message_category.field.code"),
|
|
122
|
+
labelTooltip: t("system.base.message_category.tooltip.code"),
|
|
123
|
+
component: "input",
|
|
124
|
+
props: { maxlength: 50, placeholder: t("system.base.message_category.placeholder.code") }
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
prop: "name",
|
|
128
|
+
label: t("system.base.message_category.field.name"),
|
|
129
|
+
labelTooltip: t("system.base.message_category.tooltip.name"),
|
|
130
|
+
component: "input",
|
|
131
|
+
props: { maxlength: 50, placeholder: t("system.base.message_category.placeholder.name") }
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
prop: "icon",
|
|
135
|
+
label: t("system.base.message_category.field.icon"),
|
|
136
|
+
labelTooltip: t("system.base.message_category.tooltip.icon"),
|
|
137
|
+
component: "select",
|
|
138
|
+
options: iconOptions.value,
|
|
139
|
+
props: { filterable: true, clearable: true, placeholder: t("system.base.message_category.placeholder.icon") }
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
prop: "color",
|
|
143
|
+
label: t("system.base.message_category.field.color"),
|
|
144
|
+
labelTooltip: t("system.base.message_category.tooltip.color"),
|
|
145
|
+
component: "color-picker",
|
|
146
|
+
props: { showAlpha: false, predefine: presetColors }
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
prop: "sort",
|
|
150
|
+
label: t("common.field.sort"),
|
|
151
|
+
component: "input-number",
|
|
152
|
+
props: { min: 0, precision: 0, placeholder: t("system.base.message_category.placeholder.sort") }
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
prop: "default_priority",
|
|
156
|
+
label: t("system.base.message_category.field.default_priority"),
|
|
157
|
+
labelTooltip: t("system.base.message_category.tooltip.default_priority"),
|
|
158
|
+
component: "select",
|
|
159
|
+
options: priorityOptions.value
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
prop: "retention_days",
|
|
163
|
+
label: t("system.base.message_category.field.retention_days"),
|
|
164
|
+
labelTooltip: t("system.base.message_category.tooltip.retention_days"),
|
|
165
|
+
component: "input-number",
|
|
166
|
+
props: { min: 0, precision: 0, placeholder: t("system.base.message_category.placeholder.retention_days") }
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
prop: "allow_archive",
|
|
170
|
+
label: t("system.base.message_category.field.allow_archive"),
|
|
171
|
+
labelTooltip: t("system.base.message_category.tooltip.allow_archive"),
|
|
172
|
+
component: "switch"
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
prop: "allow_delete",
|
|
176
|
+
label: t("system.base.message_category.field.allow_delete"),
|
|
177
|
+
labelTooltip: t("system.base.message_category.tooltip.allow_delete"),
|
|
178
|
+
component: "switch"
|
|
179
|
+
},
|
|
180
|
+
{ prop: "status", label: t("common.field.status"), component: "radio-group", options: statusOptions.value }
|
|
181
|
+
]);
|
|
182
|
+
|
|
183
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
184
|
+
{ type: "selection", width: 55 },
|
|
185
|
+
{ prop: "name", label: t("system.base.message_category.field.name"), minWidth: 150, search: { el: "input" } },
|
|
186
|
+
{ prop: "code", label: t("system.base.message_category.field.code"), minWidth: 130, search: { el: "input" } },
|
|
187
|
+
{
|
|
188
|
+
prop: "icon",
|
|
189
|
+
label: t("system.base.message_category.field.icon"),
|
|
190
|
+
width: 90,
|
|
191
|
+
align: "center",
|
|
192
|
+
render: scope => {
|
|
193
|
+
const row = scope.row as BaseMessageCategory;
|
|
194
|
+
return h(resolveCategoryIcon(row.icon), {
|
|
195
|
+
style: { color: row.color || "var(--el-text-color-secondary)", width: "18px", height: "18px" }
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
prop: "color",
|
|
201
|
+
label: t("system.base.message_category.field.color"),
|
|
202
|
+
width: 90,
|
|
203
|
+
align: "center",
|
|
204
|
+
render: scope =>
|
|
205
|
+
h("span", {
|
|
206
|
+
style: {
|
|
207
|
+
display: "inline-block",
|
|
208
|
+
width: "18px",
|
|
209
|
+
height: "18px",
|
|
210
|
+
borderRadius: "4px",
|
|
211
|
+
backgroundColor: (scope.row as BaseMessageCategory).color || "var(--el-fill-color-light)"
|
|
212
|
+
}
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
prop: "default_priority",
|
|
217
|
+
label: t("system.base.message_category.field.default_priority"),
|
|
218
|
+
minWidth: 120,
|
|
219
|
+
render: scope => priorityLabel((scope.row as BaseMessageCategory).default_priority)
|
|
220
|
+
},
|
|
221
|
+
{ prop: "retention_days", label: t("system.base.message_category.field.retention_days"), minWidth: 100, align: "right" },
|
|
222
|
+
{
|
|
223
|
+
prop: "status",
|
|
224
|
+
label: t("common.field.status"),
|
|
225
|
+
width: 110,
|
|
226
|
+
search: { el: "select", enum: statusOptions.value },
|
|
227
|
+
cellType: "status",
|
|
228
|
+
statusProps: {
|
|
229
|
+
activeValue: Status.STATUS_ENABLE,
|
|
230
|
+
inactiveValue: Status.STATUS_DISABLE,
|
|
231
|
+
activeText: t("common.status.enabled"),
|
|
232
|
+
inactiveText: t("common.status.disabled"),
|
|
233
|
+
disabled: () => !isDefaultTenant.value || !BUTTONS.value["base:message-category:status"],
|
|
234
|
+
beforeChange: scope => handleSetStatus(scope.row as BaseMessageCategory)
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
{ prop: "created_at", label: t("common.field.created_at"), minWidth: 180 },
|
|
238
|
+
{
|
|
239
|
+
prop: "operation",
|
|
240
|
+
label: t("common.field.operation"),
|
|
241
|
+
width: 180,
|
|
242
|
+
fixed: "right",
|
|
243
|
+
cellType: "actions",
|
|
244
|
+
actions: [
|
|
245
|
+
{
|
|
246
|
+
label: t("common.action.edit"),
|
|
247
|
+
link: true,
|
|
248
|
+
icon: EditPen,
|
|
249
|
+
hidden: () => !isDefaultTenant.value || !BUTTONS.value["base:message-category:update"],
|
|
250
|
+
onClick: scope => openDialog((scope.row as BaseMessageCategory).id)
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
label: t("common.action.delete"),
|
|
254
|
+
type: "danger",
|
|
255
|
+
link: true,
|
|
256
|
+
icon: Delete,
|
|
257
|
+
hidden: () => !isDefaultTenant.value || !BUTTONS.value["base:message-category:delete"],
|
|
258
|
+
onClick: scope => handleDelete(scope.row as BaseMessageCategory)
|
|
259
|
+
}
|
|
260
|
+
]
|
|
261
|
+
}
|
|
262
|
+
]);
|
|
263
|
+
|
|
264
|
+
const headerActions = computed<HeaderActionProps[]>(() => [
|
|
265
|
+
{
|
|
266
|
+
label: t("common.action.create"),
|
|
267
|
+
type: "primary",
|
|
268
|
+
icon: CirclePlus,
|
|
269
|
+
hidden: !isDefaultTenant.value || !BUTTONS.value["base:message-category:create"],
|
|
270
|
+
onClick: () => openDialog()
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
label: t("common.action.batch_delete"),
|
|
274
|
+
type: "danger",
|
|
275
|
+
icon: Delete,
|
|
276
|
+
hidden: !isDefaultTenant.value || !BUTTONS.value["base:message-category:delete"],
|
|
277
|
+
disabled: scope => !scope.isSelected,
|
|
278
|
+
onClick: scope => handleDelete(scope.selectedListIds as number[])
|
|
279
|
+
}
|
|
280
|
+
]);
|
|
281
|
+
|
|
282
|
+
/** 创建默认消息分类表单。 */
|
|
283
|
+
function defaultForm(): BaseMessageCategoryForm {
|
|
284
|
+
return {
|
|
285
|
+
id: 0,
|
|
286
|
+
code: "",
|
|
287
|
+
name: "",
|
|
288
|
+
icon: "Bell",
|
|
289
|
+
color: "#3a7afe",
|
|
290
|
+
sort: 0,
|
|
291
|
+
default_priority: MessagePriority.MESSAGE_PRIORITY_NORMAL,
|
|
292
|
+
retention_days: 180,
|
|
293
|
+
allow_archive: true,
|
|
294
|
+
allow_delete: true,
|
|
295
|
+
status: Status.STATUS_ENABLE
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/** 请求消息分类表格数据。 */
|
|
300
|
+
async function requestTable(params: Record<string, unknown>) {
|
|
301
|
+
const data = await defBaseMessageCategoryService.PageBaseMessageCategory(
|
|
302
|
+
buildPageRequest<PageBaseMessageCategoryRequest>(params as unknown as PageBaseMessageCategoryRequest)
|
|
303
|
+
);
|
|
304
|
+
return { data: { list: data.base_message_categories ?? [], total: data.total } };
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/** 打开消息分类表单。 */
|
|
308
|
+
async function openDialog(id?: number) {
|
|
309
|
+
Object.assign(formData, defaultForm());
|
|
310
|
+
dialog.titleKey = id ? "common.action.edit" : "common.action.create";
|
|
311
|
+
if (id) Object.assign(formData, await defBaseMessageCategoryService.GetBaseMessageCategory({ id }));
|
|
312
|
+
dialog.visible = true;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/** 提交消息分类表单。 */
|
|
316
|
+
async function handleSubmit() {
|
|
317
|
+
const payload = formData as BaseMessageCategoryForm;
|
|
318
|
+
if (payload.id) await defBaseMessageCategoryService.UpdateBaseMessageCategory({ base_message_category: payload });
|
|
319
|
+
else await defBaseMessageCategoryService.CreateBaseMessageCategory({ base_message_category: payload });
|
|
320
|
+
ElMessage.success(t("common.message.operation_success"));
|
|
321
|
+
dialog.visible = false;
|
|
322
|
+
proTable.value?.getTableList();
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/** 删除消息分类。 */
|
|
326
|
+
async function handleDelete(value: BaseMessageCategory | BaseMessageCategory[] | number | number[]) {
|
|
327
|
+
const ids = normalizeSelectedIds(value as Parameters<typeof normalizeSelectedIds>[0]);
|
|
328
|
+
await ElMessageBox.confirm(t("common.confirm.delete"), t("common.tips"), { type: "warning" });
|
|
329
|
+
await defBaseMessageCategoryService.DeleteBaseMessageCategory({ id: ids.join(",") });
|
|
330
|
+
ElMessage.success(t("common.message.operation_success"));
|
|
331
|
+
proTable.value?.getTableList();
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** 设置消息分类状态。 */
|
|
335
|
+
async function handleSetStatus(row: BaseMessageCategory) {
|
|
336
|
+
const status = row.status === Status.STATUS_ENABLE ? Status.STATUS_DISABLE : Status.STATUS_ENABLE;
|
|
337
|
+
await defBaseMessageCategoryService.SetBaseMessageCategoryStatus({ id: row.id, status });
|
|
338
|
+
return true;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/** 关闭消息分类表单。 */
|
|
342
|
+
function handleClose() {
|
|
343
|
+
Object.assign(formData, defaultForm());
|
|
344
|
+
formDialogRef.value?.resetFields();
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/** 格式化消息优先级。 */
|
|
348
|
+
function priorityLabel(priority: MessagePriority) {
|
|
349
|
+
return priorityOptions.value.find(item => item.value === priority)?.label ?? "";
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/** 解析消息分类图标,兼容历史数据中的未知图标名。 */
|
|
353
|
+
function resolveCategoryIcon(icon: string) {
|
|
354
|
+
return categoryIcons[icon] ?? CollectionTag;
|
|
355
|
+
}
|
|
356
|
+
</script>
|