@liujitcn/kratos-admin-system 0.0.20 → 0.0.23
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 +51 -50
- package/dist/package/declarations/src/api/system/base_language.d.ts +52 -0
- package/dist/package/declarations/src/api/system/base_translation.d.ts +10 -0
- package/dist/package/declarations/src/api/system/code_gen_i18n.d.ts +8 -0
- package/dist/package/declarations/src/api/system/ops_monitoring.d.ts +19 -0
- package/dist/package/declarations/src/api/system/ops_monitoring_sse.d.ts +12 -0
- package/dist/package/declarations/src/components/DynamicTranslationCell.vue.d.ts +16 -0
- package/dist/package/declarations/src/components/DynamicTranslationEditor.vue.d.ts +20 -0
- package/dist/package/declarations/src/components/dynamicTranslation.d.ts +38 -0
- package/dist/package/declarations/src/locales/generated.d.ts +6536 -0
- package/dist/package/declarations/src/rpc/base/v1/ai_session.d.ts +12 -2
- package/dist/package/declarations/src/rpc/base/v1/ai_tool.d.ts +9 -1
- package/dist/package/declarations/src/rpc/base/v1/config.d.ts +35 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/auth.d.ts +1 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/base_config.d.ts +23 -2
- package/dist/package/declarations/src/rpc/system/admin/v1/base_dict.d.ts +9 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_job.d.ts +9 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/base_language.d.ts +119 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_menu.d.ts +6 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/base_migration.d.ts +6 -6
- package/dist/package/declarations/src/rpc/system/admin/v1/base_role.d.ts +13 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/base_translation.d.ts +75 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/base_user.d.ts +11 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen.d.ts +13 -11
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_column.d.ts +7 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/code_gen_table.d.ts +24 -1
- package/dist/package/declarations/src/rpc/system/admin/v1/common.d.ts +13 -0
- package/dist/package/declarations/src/rpc/system/admin/v1/ops_monitoring.d.ts +222 -0
- package/dist/package/declarations/src/views/base/language/index.vue.d.ts +3 -0
- package/dist/package/declarations/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue.d.ts +23 -0
- package/dist/package/declarations/src/views/tool/code-gen/config.d.ts +7 -7
- package/dist/package/declarations/src/views/tool/ops-monitoring/index.vue.d.ts +3 -0
- package/dist/package/src/api/base/ai_message.ts +7 -12
- package/dist/package/src/api/base/sse.ts +3 -1
- package/dist/package/src/api/system/base_language.ts +135 -0
- package/dist/package/src/api/system/base_translation.ts +33 -0
- package/dist/package/src/api/system/code_gen_column.ts +17 -3
- package/dist/package/src/api/system/code_gen_i18n.ts +18 -0
- package/dist/package/src/api/system/code_gen_table.ts +12 -4
- package/dist/package/src/api/system/ops_monitoring.ts +88 -0
- package/dist/package/src/api/system/ops_monitoring_sse.ts +49 -0
- package/dist/package/src/components/DynamicTranslationCell.vue +249 -0
- package/dist/package/src/components/DynamicTranslationEditor.vue +197 -0
- package/dist/package/src/components/dynamicTranslation.ts +66 -0
- package/dist/package/src/locales/README.md +30 -0
- package/dist/package/src/locales/en-US.json +933 -0
- package/dist/package/src/locales/es-ES.json +933 -0
- package/dist/package/src/locales/fr-FR.json +933 -0
- package/dist/package/src/locales/generated.ts +22 -0
- package/dist/package/src/locales/ja-JP.json +933 -0
- package/dist/package/src/locales/ko-KR.json +933 -0
- package/dist/package/src/locales/zh-CN.json +933 -0
- package/dist/package/src/locales/zh-TW.json +933 -0
- package/dist/package/src/module.ts +6 -2
- package/dist/package/src/rpc/base/v1/ai_session.ts +13 -2
- package/dist/package/src/rpc/base/v1/ai_tool.ts +10 -1
- package/dist/package/src/rpc/base/v1/config.ts +47 -0
- package/dist/package/src/rpc/system/admin/v1/auth.ts +1 -1
- package/dist/package/src/rpc/system/admin/v1/base_config.ts +24 -2
- package/dist/package/src/rpc/system/admin/v1/base_dict.ts +9 -0
- package/dist/package/src/rpc/system/admin/v1/base_job.ts +10 -1
- package/dist/package/src/rpc/system/admin/v1/base_language.ts +141 -0
- package/dist/package/src/rpc/system/admin/v1/base_menu.ts +6 -1
- package/dist/package/src/rpc/system/admin/v1/base_migration.ts +8 -8
- package/dist/package/src/rpc/system/admin/v1/base_role.ts +14 -1
- package/dist/package/src/rpc/system/admin/v1/base_translation.ts +90 -0
- package/dist/package/src/rpc/system/admin/v1/base_user.ts +12 -1
- package/dist/package/src/rpc/system/admin/v1/code_gen.ts +16 -12
- package/dist/package/src/rpc/system/admin/v1/code_gen_column.ts +8 -0
- package/dist/package/src/rpc/system/admin/v1/code_gen_table.ts +27 -1
- package/dist/package/src/rpc/system/admin/v1/common.ts +21 -0
- package/dist/package/src/rpc/system/admin/v1/ops_monitoring.ts +255 -0
- package/dist/package/src/views/ai/chat/components/AiMarkdown.vue +1 -6
- package/dist/package/src/views/ai/chat/components/ChatPanel.vue +75 -58
- package/dist/package/src/views/ai/chat/components/SessionPanel.vue +20 -9
- package/dist/package/src/views/ai/chat/components/XSender.vue +36 -23
- package/dist/package/src/views/ai/chat/index.vue +58 -41
- package/dist/package/src/views/ai/chat/message.ts +29 -27
- package/dist/package/src/views/base/api/index.vue +121 -84
- package/dist/package/src/views/base/area/index.vue +81 -32
- package/dist/package/src/views/base/config/index.vue +300 -96
- package/dist/package/src/views/base/dept/index.vue +110 -62
- package/dist/package/src/views/base/dict/index.vue +145 -62
- package/dist/package/src/views/base/dict/item.vue +155 -64
- package/dist/package/src/views/base/job/index.vue +134 -82
- package/dist/package/src/views/base/job/log.vue +24 -25
- package/dist/package/src/views/base/language/index.vue +260 -0
- package/dist/package/src/views/base/log/index.vue +68 -46
- package/dist/package/src/views/base/menu/index.vue +344 -200
- package/dist/package/src/views/base/migration/index.vue +49 -29
- package/dist/package/src/views/base/post/index.vue +128 -60
- package/dist/package/src/views/base/role/index.vue +145 -79
- package/dist/package/src/views/base/tenant/index.vue +132 -64
- package/dist/package/src/views/base/user/components/dept-tree.vue +2 -1
- package/dist/package/src/views/base/user/index.vue +194 -116
- package/dist/package/src/views/profile/components/base.vue +45 -28
- package/dist/package/src/views/profile/components/password.vue +45 -30
- package/dist/package/src/views/profile/components/security.vue +90 -54
- package/dist/package/src/views/profile/index.vue +10 -9
- package/dist/package/src/views/tool/api-doc/index.vue +6 -2
- package/dist/package/src/views/tool/code-gen/code-preview/index.vue +32 -16
- package/dist/package/src/views/tool/code-gen/columns/index.vue +382 -273
- package/dist/package/src/views/tool/code-gen/columns/option-copy.ts +1 -6
- package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +118 -0
- package/dist/package/src/views/tool/code-gen/components/CodeGenProgressDialog.vue +65 -36
- package/dist/package/src/views/tool/code-gen/components/CodePreviewPane.vue +8 -5
- package/dist/package/src/views/tool/code-gen/config.ts +116 -79
- package/dist/package/src/views/tool/code-gen/preview/data.ts +19 -17
- package/dist/package/src/views/tool/code-gen/preview/index.vue +96 -59
- package/dist/package/src/views/tool/code-gen/proto/index.vue +110 -62
- package/dist/package/src/views/tool/code-gen/table/index.vue +201 -121
- package/dist/package/src/views/tool/ops-monitoring/index.vue +1175 -0
- package/dist/package/src/views/tool/project-doc/index.vue +17 -15
- package/package.json +6 -2
- package/dist/package/declarations/src/rpc/base/v1/enum.d.ts +0 -43
- package/dist/package/declarations/src/rpc/system/common/v1/enum.d.ts +0 -67
- package/dist/package/src/rpc/base/v1/enum.ts +0 -54
- package/dist/package/src/rpc/system/common/v1/enum.ts +0 -80
|
@@ -12,19 +12,18 @@
|
|
|
12
12
|
<FormDialog
|
|
13
13
|
v-model="dialog.visible"
|
|
14
14
|
ref="formDialogRef"
|
|
15
|
-
:title="dialog.
|
|
15
|
+
:title="t(dialog.editing ? 'system.base.dict.item.action.edit' : 'system.base.dict.item.action.create')"
|
|
16
16
|
width="820px"
|
|
17
17
|
:model="formData"
|
|
18
18
|
:fields="formFields"
|
|
19
19
|
:rules="rules"
|
|
20
|
-
label-width="100px"
|
|
21
20
|
@confirm="handleSubmit"
|
|
22
21
|
@close="handleCloseDialog"
|
|
23
22
|
>
|
|
24
23
|
<template #tagTypeField>
|
|
25
24
|
<div class="dict-item-tag-type">
|
|
26
25
|
<el-tag v-if="formData.tag_type" :type="formatTagType(formData.tag_type)" class="mr-2">
|
|
27
|
-
{{ formData.label || "
|
|
26
|
+
{{ formData.label || t("system.base.dict.item.value.tag_preview") }}
|
|
28
27
|
</el-tag>
|
|
29
28
|
<el-radio-group v-model="formData.tag_type">
|
|
30
29
|
<el-radio value="success" border size="small">success</el-radio>
|
|
@@ -32,10 +31,17 @@
|
|
|
32
31
|
<el-radio value="info" border size="small">info</el-radio>
|
|
33
32
|
<el-radio value="primary" border size="small">primary</el-radio>
|
|
34
33
|
<el-radio value="danger" border size="small">danger</el-radio>
|
|
35
|
-
<el-radio value="" border size="small"
|
|
34
|
+
<el-radio value="" border size="small">{{ t("system.base.dict.item.action.clear_tag") }}</el-radio>
|
|
36
35
|
</el-radio-group>
|
|
37
36
|
</div>
|
|
38
37
|
</template>
|
|
38
|
+
<template #translations>
|
|
39
|
+
<DynamicTranslationEditor
|
|
40
|
+
v-model="translationValues"
|
|
41
|
+
:source="formData.label"
|
|
42
|
+
:maxlength="100"
|
|
43
|
+
/>
|
|
44
|
+
</template>
|
|
39
45
|
</FormDialog>
|
|
40
46
|
</div>
|
|
41
47
|
</template>
|
|
@@ -45,15 +51,35 @@ import { computed, h, reactive, ref, watch } from "vue";
|
|
|
45
51
|
import { useRoute } from "vue-router";
|
|
46
52
|
import { ElMessage, ElMessageBox, ElTag } from "element-plus";
|
|
47
53
|
import { CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
|
|
48
|
-
import type {
|
|
54
|
+
import type {
|
|
55
|
+
ColumnProps,
|
|
56
|
+
HeaderActionProps,
|
|
57
|
+
ProTableInstance,
|
|
58
|
+
RenderScope
|
|
59
|
+
} from "@liujitcn/kratos-admin-core/components/ProTable/interface";
|
|
49
60
|
import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
|
|
50
61
|
import FormDialog from "@liujitcn/kratos-admin-core/components/Dialog/FormDialog.vue";
|
|
51
62
|
import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
|
|
52
63
|
import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
|
|
53
64
|
import { defBaseDictService } from "@liujitcn/kratos-admin-system/api/system/base_dict";
|
|
54
|
-
import
|
|
65
|
+
import { loadEnabledBaseLanguages } from "@liujitcn/kratos-admin-system/api/system/base_language";
|
|
66
|
+
import type {
|
|
67
|
+
BaseDictItem,
|
|
68
|
+
BaseDictItemForm,
|
|
69
|
+
PageBaseDictItemRequest
|
|
70
|
+
} from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_dict";
|
|
55
71
|
import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
72
|
+
import { TranslationTargetType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_translation";
|
|
56
73
|
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
74
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
75
|
+
import DynamicTranslationEditor from "@liujitcn/kratos-admin-system/components/DynamicTranslationEditor.vue";
|
|
76
|
+
import DynamicTranslationCell from "@liujitcn/kratos-admin-system/components/DynamicTranslationCell.vue";
|
|
77
|
+
import {
|
|
78
|
+
normalizeDynamicTranslations,
|
|
79
|
+
serializeDynamicTranslations,
|
|
80
|
+
type DynamicTranslationRecord,
|
|
81
|
+
type DynamicTranslationValue
|
|
82
|
+
} from "@liujitcn/kratos-admin-system/components/dynamicTranslation";
|
|
57
83
|
|
|
58
84
|
defineOptions({
|
|
59
85
|
name: "BaseDictItem",
|
|
@@ -64,11 +90,12 @@ const route = useRoute();
|
|
|
64
90
|
const { BUTTONS } = useAuthButtons();
|
|
65
91
|
const proTable = ref<ProTableInstance>();
|
|
66
92
|
const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
93
|
+
const translationValues = ref<DynamicTranslationValue[]>(normalizeDynamicTranslations(undefined, "label"));
|
|
67
94
|
|
|
68
95
|
const dictId = ref(Number(route.query.dictId ?? 0));
|
|
69
96
|
|
|
70
97
|
const dialog = reactive({
|
|
71
|
-
|
|
98
|
+
editing: false,
|
|
72
99
|
visible: false
|
|
73
100
|
});
|
|
74
101
|
|
|
@@ -81,6 +108,8 @@ const formData = reactive<BaseDictItemForm>({
|
|
|
81
108
|
value: "",
|
|
82
109
|
/** 字典项标签 */
|
|
83
110
|
label: "",
|
|
111
|
+
/** 非主语言翻译 */
|
|
112
|
+
translations: [],
|
|
84
113
|
/** 标签类型 */
|
|
85
114
|
tag_type: "",
|
|
86
115
|
/** 排序 */
|
|
@@ -90,31 +119,60 @@ const formData = reactive<BaseDictItemForm>({
|
|
|
90
119
|
});
|
|
91
120
|
|
|
92
121
|
const rules = computed(() => ({
|
|
93
|
-
value: [{ required: true, max: 50, message: "
|
|
94
|
-
label: [{ required: true, max: 100, message: "
|
|
95
|
-
tag_type: [
|
|
96
|
-
|
|
97
|
-
|
|
122
|
+
value: [{ required: true, max: 50, message: t("system.base.dict.item.validation.value"), trigger: "blur" }],
|
|
123
|
+
label: [{ required: true, max: 100, message: t("system.base.dict.item.validation.label"), trigger: "blur" }],
|
|
124
|
+
tag_type: [
|
|
125
|
+
{
|
|
126
|
+
max: 50,
|
|
127
|
+
message: t("common.validation.max_length", { field: t("system.base.dict.item.field.tag_type"), max: 50 }),
|
|
128
|
+
trigger: "blur"
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
sort: [{ required: true, message: t("common.validation.sort_positive"), trigger: "blur" }],
|
|
132
|
+
status: [
|
|
133
|
+
{
|
|
134
|
+
required: true,
|
|
135
|
+
message: t("common.validation.required_select", { field: t("common.field.status") }),
|
|
136
|
+
trigger: "change"
|
|
137
|
+
}
|
|
138
|
+
]
|
|
98
139
|
}));
|
|
99
140
|
|
|
100
|
-
const statusOptions
|
|
101
|
-
{ label: "
|
|
102
|
-
{ label: "
|
|
103
|
-
];
|
|
141
|
+
const statusOptions = computed<ProFormOption[]>(() => [
|
|
142
|
+
{ label: t("common.status.enabled"), value: Status.ENABLE },
|
|
143
|
+
{ label: t("common.status.disabled"), value: Status.DISABLE }
|
|
144
|
+
]);
|
|
104
145
|
|
|
105
146
|
/** 字典项表单字段配置。 */
|
|
106
|
-
const formFields
|
|
107
|
-
{
|
|
108
|
-
|
|
147
|
+
const formFields = computed<ProFormField[]>(() => [
|
|
148
|
+
{
|
|
149
|
+
prop: "label",
|
|
150
|
+
label: t("system.base.dict.item.field.label"),
|
|
151
|
+
component: "input",
|
|
152
|
+
props: { placeholder: t("system.base.dict.item.placeholder.label") }
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
prop: "value",
|
|
156
|
+
label: t("system.base.dict.item.field.value"),
|
|
157
|
+
component: "input",
|
|
158
|
+
props: { placeholder: t("system.base.dict.item.placeholder.value") }
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
prop: "translations",
|
|
162
|
+
label: t("system.base.translation.field.translations"),
|
|
163
|
+
component: "slot",
|
|
164
|
+
slotName: "translations",
|
|
165
|
+
colSpan: 24
|
|
166
|
+
},
|
|
109
167
|
{
|
|
110
168
|
prop: "sort",
|
|
111
|
-
label: "
|
|
169
|
+
label: t("common.field.sort"),
|
|
112
170
|
component: "input-number",
|
|
113
171
|
props: { min: 1, precision: 0, step: 1, controlsPosition: "right", style: { width: "100%" } }
|
|
114
172
|
},
|
|
115
|
-
{ prop: "status", label: "
|
|
116
|
-
{ prop: "tag_type", label: "
|
|
117
|
-
];
|
|
173
|
+
{ prop: "status", label: t("common.field.status"), component: "radio-group", options: statusOptions.value },
|
|
174
|
+
{ prop: "tag_type", label: t("system.base.dict.item.field.tag_type"), component: "slot", slotName: "tagTypeField", colSpan: 24 }
|
|
175
|
+
]);
|
|
118
176
|
|
|
119
177
|
/**
|
|
120
178
|
* 规范化标签类型,兼容 Element Plus Tag 的可选值。
|
|
@@ -130,7 +188,7 @@ function formatTagType(tag_type: string) {
|
|
|
130
188
|
* 渲染标签类型列,统一复用字典项标签的展示方式。
|
|
131
189
|
*/
|
|
132
190
|
function renderTagTypeCell(scope: RenderScope<BaseDictItem>) {
|
|
133
|
-
if (!scope.row.tag_type) return "
|
|
191
|
+
if (!scope.row.tag_type) return t("common.value.none");
|
|
134
192
|
return h(
|
|
135
193
|
ElTag,
|
|
136
194
|
{
|
|
@@ -141,44 +199,62 @@ function renderTagTypeCell(scope: RenderScope<BaseDictItem>) {
|
|
|
141
199
|
);
|
|
142
200
|
}
|
|
143
201
|
|
|
202
|
+
/** 渲染字典项标签翻译预览,并复用当前页面的编辑弹窗。 */
|
|
203
|
+
function renderDictItemLabelCell(scope: RenderScope<BaseDictItem>) {
|
|
204
|
+
const row = scope.row;
|
|
205
|
+
return h(DynamicTranslationCell, {
|
|
206
|
+
source: row.label,
|
|
207
|
+
targetType: TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM,
|
|
208
|
+
targetId: row.id,
|
|
209
|
+
translations: row.translations
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
|
|
144
213
|
/** 字典项表格列配置。 */
|
|
145
|
-
const columns
|
|
214
|
+
const columns = computed<ColumnProps[]>(() => [
|
|
146
215
|
{ type: "selection", width: 55 },
|
|
147
|
-
{
|
|
148
|
-
|
|
149
|
-
|
|
216
|
+
{
|
|
217
|
+
prop: "label",
|
|
218
|
+
label: t("system.base.dict.item.field.label"),
|
|
219
|
+
minWidth: 140,
|
|
220
|
+
search: { el: "input" },
|
|
221
|
+
showOverflowTooltip: false,
|
|
222
|
+
render: scope => renderDictItemLabelCell(scope as unknown as RenderScope<BaseDictItem>)
|
|
223
|
+
},
|
|
224
|
+
{ prop: "value", label: t("system.base.dict.item.field.value"), minWidth: 140 },
|
|
225
|
+
{ prop: "sort", label: t("common.field.sort"), minWidth: 90, align: "right" },
|
|
150
226
|
{
|
|
151
227
|
prop: "tag_type",
|
|
152
|
-
label: "
|
|
228
|
+
label: t("system.base.dict.item.field.tag_type"),
|
|
153
229
|
minWidth: 120,
|
|
154
230
|
render: scope => renderTagTypeCell(scope as unknown as RenderScope<BaseDictItem>)
|
|
155
231
|
},
|
|
156
232
|
{
|
|
157
233
|
prop: "status",
|
|
158
|
-
label: "
|
|
234
|
+
label: t("common.field.status"),
|
|
159
235
|
minWidth: 100,
|
|
160
236
|
search: { el: "select" },
|
|
161
237
|
cellType: "status",
|
|
162
238
|
statusProps: {
|
|
163
239
|
activeValue: Status.ENABLE,
|
|
164
240
|
inactiveValue: Status.DISABLE,
|
|
165
|
-
activeText: "
|
|
166
|
-
inactiveText: "
|
|
241
|
+
activeText: t("common.status.enabled"),
|
|
242
|
+
inactiveText: t("common.status.disabled"),
|
|
167
243
|
disabled: () => !BUTTONS.value["base:dict-item:status"],
|
|
168
244
|
beforeChange: scope => handleBeforeSetStatus(scope.row as BaseDictItem)
|
|
169
245
|
}
|
|
170
246
|
},
|
|
171
|
-
{ prop: "created_at", label: "
|
|
172
|
-
{ prop: "updated_at", label: "
|
|
247
|
+
{ prop: "created_at", label: t("common.field.created_at"), minWidth: 180 },
|
|
248
|
+
{ prop: "updated_at", label: t("common.field.updated_at"), minWidth: 180 },
|
|
173
249
|
{
|
|
174
250
|
prop: "operation",
|
|
175
|
-
label: "
|
|
251
|
+
label: t("common.field.action"),
|
|
176
252
|
width: 180,
|
|
177
253
|
fixed: "right",
|
|
178
254
|
cellType: "actions",
|
|
179
255
|
actions: [
|
|
180
256
|
{
|
|
181
|
-
label: "
|
|
257
|
+
label: t("common.action.edit"),
|
|
182
258
|
type: "primary",
|
|
183
259
|
link: true,
|
|
184
260
|
icon: EditPen,
|
|
@@ -187,7 +263,7 @@ const columns: ColumnProps[] = [
|
|
|
187
263
|
onClick: (scope, params) => handleOpenDialog((params?.dictItemId as number | undefined) ?? (scope.row as BaseDictItem).id)
|
|
188
264
|
},
|
|
189
265
|
{
|
|
190
|
-
label: "
|
|
266
|
+
label: t("common.action.delete"),
|
|
191
267
|
type: "danger",
|
|
192
268
|
link: true,
|
|
193
269
|
icon: Delete,
|
|
@@ -196,26 +272,26 @@ const columns: ColumnProps[] = [
|
|
|
196
272
|
}
|
|
197
273
|
]
|
|
198
274
|
}
|
|
199
|
-
];
|
|
275
|
+
]);
|
|
200
276
|
|
|
201
277
|
/** 字典项顶部按钮配置。 */
|
|
202
|
-
const headerActions
|
|
278
|
+
const headerActions = computed<HeaderActionProps[]>(() => [
|
|
203
279
|
{
|
|
204
|
-
label: "
|
|
280
|
+
label: t("common.action.create"),
|
|
205
281
|
type: "success",
|
|
206
282
|
icon: CirclePlus,
|
|
207
283
|
hidden: () => !BUTTONS.value["base:dict-item:create"],
|
|
208
284
|
onClick: () => handleOpenDialog()
|
|
209
285
|
},
|
|
210
286
|
{
|
|
211
|
-
label: "
|
|
287
|
+
label: t("common.action.delete"),
|
|
212
288
|
type: "danger",
|
|
213
289
|
icon: Delete,
|
|
214
290
|
hidden: () => !BUTTONS.value["base:dict-item:delete"],
|
|
215
291
|
disabled: scope => !scope.selectedList.length,
|
|
216
292
|
onClick: scope => handleDelete(scope.selectedList as BaseDictItem[])
|
|
217
293
|
}
|
|
218
|
-
];
|
|
294
|
+
]);
|
|
219
295
|
|
|
220
296
|
watch(
|
|
221
297
|
() => route.query.dictId,
|
|
@@ -230,6 +306,7 @@ watch(
|
|
|
230
306
|
* 请求字典项分页列表,并补充当前路由上的字典 ID。
|
|
231
307
|
*/
|
|
232
308
|
async function requestBaseDictItemTable(params: PageBaseDictItemRequest) {
|
|
309
|
+
await loadEnabledBaseLanguages();
|
|
233
310
|
const data = await defBaseDictService.PageBaseDictItem({ ...buildPageRequest(params), dict_id: dictId.value });
|
|
234
311
|
return { data: { list: data.base_dict_items ?? [], total: data.total } };
|
|
235
312
|
}
|
|
@@ -244,15 +321,16 @@ function refreshTable() {
|
|
|
244
321
|
/**
|
|
245
322
|
* 打开字典项编辑弹窗。
|
|
246
323
|
*/
|
|
247
|
-
function handleOpenDialog(dictItemId?: number) {
|
|
324
|
+
async function handleOpenDialog(dictItemId?: number) {
|
|
325
|
+
await loadEnabledBaseLanguages();
|
|
248
326
|
resetForm();
|
|
249
|
-
dialog.
|
|
327
|
+
dialog.editing = Boolean(dictItemId);
|
|
250
328
|
dialog.visible = true;
|
|
251
329
|
if (!dictItemId) return;
|
|
252
330
|
|
|
253
|
-
defBaseDictService.GetBaseDictItem({ id: dictItemId })
|
|
254
|
-
|
|
255
|
-
|
|
331
|
+
const data = await defBaseDictService.GetBaseDictItem({ id: dictItemId });
|
|
332
|
+
Object.assign(formData, data);
|
|
333
|
+
translationValues.value = normalizeDynamicTranslations(data.translations as DynamicTranslationRecord[], "label");
|
|
256
334
|
}
|
|
257
335
|
|
|
258
336
|
/**
|
|
@@ -273,9 +351,11 @@ function resetForm() {
|
|
|
273
351
|
formData.dict_id = dictId.value;
|
|
274
352
|
formData.value = "";
|
|
275
353
|
formData.label = "";
|
|
354
|
+
formData.translations = [];
|
|
276
355
|
formData.tag_type = "";
|
|
277
356
|
formData.sort = 1;
|
|
278
357
|
formData.status = Status.ENABLE;
|
|
358
|
+
translationValues.value = normalizeDynamicTranslations(undefined, "label");
|
|
279
359
|
}
|
|
280
360
|
|
|
281
361
|
/**
|
|
@@ -287,11 +367,18 @@ function handleSubmit() {
|
|
|
287
367
|
|
|
288
368
|
formData.dict_id = dictId.value;
|
|
289
369
|
const submitData = JSON.parse(JSON.stringify(formData)) as BaseDictItemForm;
|
|
370
|
+
submitData.translations = serializeDynamicTranslations(
|
|
371
|
+
translationValues.value,
|
|
372
|
+
TranslationTargetType.TRANSLATION_TARGET_TYPE_BASE_DICT_ITEM,
|
|
373
|
+
submitData.id
|
|
374
|
+
);
|
|
290
375
|
const request = submitData.id
|
|
291
376
|
? defBaseDictService.UpdateBaseDictItem({ base_dict_item: submitData })
|
|
292
377
|
: defBaseDictService.CreateBaseDictItem({ base_dict_item: submitData });
|
|
293
378
|
request.then(() => {
|
|
294
|
-
ElMessage.success(
|
|
379
|
+
ElMessage.success(
|
|
380
|
+
t(submitData.id ? "system.base.dict.item.message.update_success" : "system.base.dict.item.message.create_success")
|
|
381
|
+
);
|
|
295
382
|
handleCloseDialog();
|
|
296
383
|
refreshTable();
|
|
297
384
|
});
|
|
@@ -303,16 +390,20 @@ function handleSubmit() {
|
|
|
303
390
|
*/
|
|
304
391
|
async function handleBeforeSetStatus(row: BaseDictItem) {
|
|
305
392
|
const nextStatus = row.status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
306
|
-
const
|
|
393
|
+
const action = t(nextStatus === Status.ENABLE ? "common.status.enabled" : "common.status.disabled");
|
|
307
394
|
const itemName = row.label || row.value || `ID:${row.id}`;
|
|
308
395
|
try {
|
|
309
|
-
await ElMessageBox.confirm(
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
396
|
+
await ElMessageBox.confirm(
|
|
397
|
+
t("system.base.dict.item.message.confirm_status", { action, name: itemName }),
|
|
398
|
+
t("common.title.notice"),
|
|
399
|
+
{
|
|
400
|
+
confirmButtonText: t("common.action.confirm"),
|
|
401
|
+
cancelButtonText: t("common.action.cancel"),
|
|
402
|
+
type: "warning"
|
|
403
|
+
}
|
|
404
|
+
);
|
|
314
405
|
await defBaseDictService.SetBaseDictItemStatus({ id: row.id, status: nextStatus });
|
|
315
|
-
ElMessage.success(
|
|
406
|
+
ElMessage.success(t("common.message.status_success", { action }));
|
|
316
407
|
refreshTable();
|
|
317
408
|
return true;
|
|
318
409
|
} catch {
|
|
@@ -335,30 +426,30 @@ function handleDelete(selected?: number | string | Array<number | string> | Base
|
|
|
335
426
|
: normalizeSelectedIds(selected as number | string | Array<number | string>)
|
|
336
427
|
).join(",");
|
|
337
428
|
if (!dictItemIds) {
|
|
338
|
-
ElMessage.warning("
|
|
429
|
+
ElMessage.warning(t("common.message.select_delete_item"));
|
|
339
430
|
return;
|
|
340
431
|
}
|
|
341
432
|
|
|
342
433
|
const singleItemName = dictItemList[0]?.label || dictItemList[0]?.value || `ID:${dictItemList[0]?.id ?? ""}`;
|
|
343
434
|
const confirmMessage = dictItemList.length
|
|
344
435
|
? dictItemList.length === 1
|
|
345
|
-
?
|
|
346
|
-
:
|
|
347
|
-
: "
|
|
436
|
+
? t("system.base.dict.item.message.confirm_delete_single", { name: singleItemName })
|
|
437
|
+
: t("system.base.dict.item.message.confirm_delete_batch", { count: dictItemList.length })
|
|
438
|
+
: t("system.base.dict.item.message.confirm_delete_selected");
|
|
348
439
|
|
|
349
|
-
ElMessageBox.confirm(confirmMessage, "
|
|
350
|
-
confirmButtonText: "
|
|
351
|
-
cancelButtonText: "
|
|
440
|
+
ElMessageBox.confirm(confirmMessage, t("common.title.warning"), {
|
|
441
|
+
confirmButtonText: t("common.action.confirm"),
|
|
442
|
+
cancelButtonText: t("common.action.cancel"),
|
|
352
443
|
type: "warning"
|
|
353
444
|
}).then(
|
|
354
445
|
() => {
|
|
355
446
|
defBaseDictService.DeleteBaseDictItem({ id: dictItemIds }).then(() => {
|
|
356
|
-
ElMessage.success("
|
|
447
|
+
ElMessage.success(t("system.base.dict.item.message.delete_success"));
|
|
357
448
|
refreshTable();
|
|
358
449
|
});
|
|
359
450
|
},
|
|
360
451
|
() => {
|
|
361
|
-
ElMessage.info("
|
|
452
|
+
ElMessage.info(t("system.base.dict.item.message.delete_canceled"));
|
|
362
453
|
}
|
|
363
454
|
);
|
|
364
455
|
}
|