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