@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.role.action.edit' : 'system.role.action.create')"
|
|
16
16
|
width="500px"
|
|
17
17
|
:model="formData"
|
|
18
18
|
:fields="formFields"
|
|
@@ -22,9 +22,13 @@
|
|
|
22
22
|
@close="handleCloseDialog"
|
|
23
23
|
/>
|
|
24
24
|
|
|
25
|
-
<el-drawer
|
|
25
|
+
<el-drawer
|
|
26
|
+
v-model="assignPermDialogVisible"
|
|
27
|
+
:title="t('system.role.title.assignPermission', { name: checkedBaseRole.name || '' })"
|
|
28
|
+
size="500"
|
|
29
|
+
>
|
|
26
30
|
<div class="perm-toolbar">
|
|
27
|
-
<el-input v-model="permKeywords" clearable class="perm-search" placeholder="
|
|
31
|
+
<el-input v-model="permKeywords" clearable class="perm-search" :placeholder="t('system.role.placeholder.menuPermission')">
|
|
28
32
|
<template #prefix>
|
|
29
33
|
<Search />
|
|
30
34
|
</template>
|
|
@@ -32,19 +36,21 @@
|
|
|
32
36
|
|
|
33
37
|
<div class="perm-toolbar__actions">
|
|
34
38
|
<div class="perm-toolbar__group">
|
|
35
|
-
<span class="perm-toolbar__label"
|
|
39
|
+
<span class="perm-toolbar__label">{{ t("system.role.field.treeOperation") }}</span>
|
|
36
40
|
<el-button type="primary" size="small" plain class="perm-toolbar__button" @click="togglePermTree">
|
|
37
41
|
<template #icon>
|
|
38
42
|
<Switch />
|
|
39
43
|
</template>
|
|
40
|
-
{{ isExpanded ? "
|
|
44
|
+
{{ t(isExpanded ? "system.role.action.collapseNodes" : "system.role.action.expandNodes") }}
|
|
41
45
|
</el-button>
|
|
42
46
|
</div>
|
|
43
47
|
<div class="perm-toolbar__group perm-toolbar__group--linkage">
|
|
44
|
-
<span class="perm-toolbar__label"
|
|
45
|
-
<el-checkbox v-model="parentChildLinked" @change="handelParentChildLinkedChange"
|
|
48
|
+
<span class="perm-toolbar__label">{{ t("system.role.field.selectionMode") }}</span>
|
|
49
|
+
<el-checkbox v-model="parentChildLinked" @change="handelParentChildLinkedChange">{{
|
|
50
|
+
t("system.role.field.parentChildLinked")
|
|
51
|
+
}}</el-checkbox>
|
|
46
52
|
<el-tooltip placement="bottom">
|
|
47
|
-
<template #content
|
|
53
|
+
<template #content>{{ t("system.role.message.parentChildLinkedTip") }}</template>
|
|
48
54
|
<el-icon class="perm-linkage__icon">
|
|
49
55
|
<QuestionFilled />
|
|
50
56
|
</el-icon>
|
|
@@ -70,8 +76,8 @@
|
|
|
70
76
|
|
|
71
77
|
<template #footer>
|
|
72
78
|
<div class="dialog-footer">
|
|
73
|
-
<el-button type="primary" @click="handleAssignPermSubmit"
|
|
74
|
-
<el-button @click="assignPermDialogVisible = false"
|
|
79
|
+
<el-button type="primary" @click="handleAssignPermSubmit">{{ t("common.action.confirm") }}</el-button>
|
|
80
|
+
<el-button @click="assignPermDialogVisible = false">{{ t("common.action.cancel") }}</el-button>
|
|
75
81
|
</div>
|
|
76
82
|
</template>
|
|
77
83
|
</el-drawer>
|
|
@@ -97,6 +103,7 @@ import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
|
|
|
97
103
|
import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
|
|
98
104
|
import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
|
|
99
105
|
import { DEFAULT_TENANT_CODE, requestTenantOptions } from "@liujitcn/kratos-admin-core/tenant";
|
|
106
|
+
import { t } from "@liujitcn/kratos-admin-core";
|
|
100
107
|
|
|
101
108
|
defineOptions({
|
|
102
109
|
name: "BaseRole",
|
|
@@ -122,16 +129,16 @@ const formDialogRef = ref<InstanceType<typeof FormDialog>>();
|
|
|
122
129
|
const permTreeRef = ref<InstanceType<typeof ElTree>>();
|
|
123
130
|
|
|
124
131
|
const dialog = reactive({
|
|
125
|
-
|
|
132
|
+
editing: false,
|
|
126
133
|
visible: false
|
|
127
134
|
});
|
|
128
135
|
|
|
129
136
|
const menuPermOptions = ref<TreeOptionResponse_Option[]>([]);
|
|
130
137
|
const tenantOptions = ref<SelectOptionResponse_Option[]>([]);
|
|
131
|
-
const statusOptions
|
|
132
|
-
{ label: "
|
|
133
|
-
{ label: "
|
|
134
|
-
];
|
|
138
|
+
const statusOptions = computed<ProFormOption[]>(() => [
|
|
139
|
+
{ label: t("common.status.enabled"), value: Status.ENABLE },
|
|
140
|
+
{ label: t("common.status.disabled"), value: Status.DISABLE }
|
|
141
|
+
]);
|
|
135
142
|
const protectedRoleCodes = new Set(["admin", "authuser", "user"]);
|
|
136
143
|
|
|
137
144
|
const formData = reactive<BaseRoleFormState>({
|
|
@@ -153,24 +160,56 @@ const formData = reactive<BaseRoleFormState>({
|
|
|
153
160
|
remark: ""
|
|
154
161
|
});
|
|
155
162
|
|
|
156
|
-
const rules =
|
|
157
|
-
tenant_id: [
|
|
163
|
+
const rules = computed(() => ({
|
|
164
|
+
tenant_id: [
|
|
165
|
+
{
|
|
166
|
+
required: true,
|
|
167
|
+
message: t("system.common.validation.requiredSelect", { field: t("system.role.field.tenant") }),
|
|
168
|
+
trigger: "change"
|
|
169
|
+
}
|
|
170
|
+
],
|
|
158
171
|
name: [
|
|
159
|
-
{
|
|
160
|
-
|
|
172
|
+
{
|
|
173
|
+
required: true,
|
|
174
|
+
message: t("system.common.validation.requiredInput", { field: t("system.role.field.name") }),
|
|
175
|
+
trigger: "blur"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
max: 30,
|
|
179
|
+
message: t("system.common.validation.maxLength", { field: t("system.role.field.name"), max: 30 }),
|
|
180
|
+
trigger: "blur"
|
|
181
|
+
}
|
|
161
182
|
],
|
|
162
183
|
code: [
|
|
163
|
-
{
|
|
164
|
-
|
|
184
|
+
{
|
|
185
|
+
required: true,
|
|
186
|
+
message: t("system.common.validation.requiredInput", { field: t("system.role.field.code") }),
|
|
187
|
+
trigger: "blur"
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
max: 20,
|
|
191
|
+
message: t("system.common.validation.maxLength", { field: t("system.role.field.code"), max: 20 }),
|
|
192
|
+
trigger: "blur"
|
|
193
|
+
}
|
|
194
|
+
],
|
|
195
|
+
data_scope: [
|
|
196
|
+
{
|
|
197
|
+
required: true,
|
|
198
|
+
message: t("system.common.validation.requiredSelect", { field: t("system.role.field.dataScope") }),
|
|
199
|
+
trigger: "change"
|
|
200
|
+
}
|
|
165
201
|
],
|
|
166
|
-
data_scope: [{ required: true, message: "请选择数据权限", trigger: "change" }],
|
|
167
202
|
menus: [
|
|
168
|
-
{
|
|
203
|
+
{
|
|
204
|
+
required: true,
|
|
205
|
+
message: t("system.common.validation.requiredSelect", { field: t("system.role.field.menuPermission") }),
|
|
206
|
+
trigger: "change"
|
|
207
|
+
},
|
|
169
208
|
{
|
|
170
209
|
validator: (_rule: unknown, value: unknown, callback: (error?: Error) => void) => {
|
|
171
210
|
const menuIds = Array.isArray(value) ? value : [];
|
|
172
211
|
if (new Set(menuIds).size !== menuIds.length) {
|
|
173
|
-
callback(new Error("
|
|
212
|
+
callback(new Error(t("system.role.validation.menuDuplicate")));
|
|
174
213
|
return;
|
|
175
214
|
}
|
|
176
215
|
callback();
|
|
@@ -178,9 +217,21 @@ const rules = reactive({
|
|
|
178
217
|
trigger: "change"
|
|
179
218
|
}
|
|
180
219
|
],
|
|
181
|
-
status: [
|
|
182
|
-
|
|
183
|
-
|
|
220
|
+
status: [
|
|
221
|
+
{
|
|
222
|
+
required: true,
|
|
223
|
+
message: t("system.common.validation.requiredSelect", { field: t("system.common.field.status") }),
|
|
224
|
+
trigger: "change"
|
|
225
|
+
}
|
|
226
|
+
],
|
|
227
|
+
remark: [
|
|
228
|
+
{
|
|
229
|
+
max: 500,
|
|
230
|
+
message: t("system.common.validation.maxLength", { field: t("system.common.field.remark"), max: 500 }),
|
|
231
|
+
trigger: "blur"
|
|
232
|
+
}
|
|
233
|
+
]
|
|
234
|
+
}));
|
|
184
235
|
|
|
185
236
|
const checkedBaseRole = ref<CheckedBaseRole>({});
|
|
186
237
|
const assignPermDialogVisible = ref(false);
|
|
@@ -195,10 +246,10 @@ const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAUL
|
|
|
195
246
|
const formFields = computed<ProFormField[]>(() => [
|
|
196
247
|
{
|
|
197
248
|
prop: "tenant_id",
|
|
198
|
-
label: "
|
|
249
|
+
label: t("system.role.field.tenant"),
|
|
199
250
|
component: "select",
|
|
200
251
|
props: {
|
|
201
|
-
placeholder: "
|
|
252
|
+
placeholder: t("system.role.placeholder.tenant"),
|
|
202
253
|
filterable: true,
|
|
203
254
|
disabled: Boolean(formData.id),
|
|
204
255
|
onChange: handleFormTenantChange
|
|
@@ -206,17 +257,22 @@ const formFields = computed<ProFormField[]>(() => [
|
|
|
206
257
|
visible: () => isDefaultTenant.value,
|
|
207
258
|
options: tenantOptions.value
|
|
208
259
|
},
|
|
209
|
-
{
|
|
260
|
+
{
|
|
261
|
+
prop: "name",
|
|
262
|
+
label: t("system.role.field.name"),
|
|
263
|
+
component: "input",
|
|
264
|
+
props: { placeholder: t("system.role.placeholder.name") }
|
|
265
|
+
},
|
|
210
266
|
{
|
|
211
267
|
prop: "code",
|
|
212
|
-
label: "
|
|
268
|
+
label: t("system.role.field.code"),
|
|
213
269
|
component: "input",
|
|
214
|
-
props: { placeholder: "
|
|
270
|
+
props: { placeholder: t("system.role.placeholder.code"), disabled: Boolean(formData.id && formData.code === "tenant") }
|
|
215
271
|
},
|
|
216
|
-
{ prop: "data_scope", label: "
|
|
272
|
+
{ prop: "data_scope", label: t("system.role.field.dataScope"), component: "dict", props: { code: "base_role_data_scope" } },
|
|
217
273
|
{
|
|
218
274
|
prop: "menus",
|
|
219
|
-
label: "
|
|
275
|
+
label: t("system.role.field.menuPermission"),
|
|
220
276
|
component: "tree-select",
|
|
221
277
|
options: menuPermOptions.value as unknown as ProFormOption[],
|
|
222
278
|
props: {
|
|
@@ -229,12 +285,17 @@ const formFields = computed<ProFormField[]>(() => [
|
|
|
229
285
|
onCheck: handleCheck
|
|
230
286
|
}
|
|
231
287
|
},
|
|
232
|
-
{
|
|
288
|
+
{
|
|
289
|
+
prop: "remark",
|
|
290
|
+
label: t("system.common.field.remark"),
|
|
291
|
+
component: "textarea",
|
|
292
|
+
props: { placeholder: t("system.common.placeholder.remark") }
|
|
293
|
+
},
|
|
233
294
|
{
|
|
234
295
|
prop: "status",
|
|
235
|
-
label: "
|
|
296
|
+
label: t("system.common.field.status"),
|
|
236
297
|
component: "radio-group",
|
|
237
|
-
options: statusOptions,
|
|
298
|
+
options: statusOptions.value,
|
|
238
299
|
props: { disabled: isRoleProtected(formData.code) }
|
|
239
300
|
}
|
|
240
301
|
]);
|
|
@@ -246,7 +307,7 @@ const columns = computed<ColumnProps[]>(() => [
|
|
|
246
307
|
? ([
|
|
247
308
|
{
|
|
248
309
|
prop: "tenant_id",
|
|
249
|
-
label: "
|
|
310
|
+
label: t("system.role.field.tenantShort"),
|
|
250
311
|
minWidth: 140,
|
|
251
312
|
showOverflowTooltip: true,
|
|
252
313
|
search: { el: "select", key: "tenant_id", props: { filterable: true }, order: 1 },
|
|
@@ -254,36 +315,42 @@ const columns = computed<ColumnProps[]>(() => [
|
|
|
254
315
|
}
|
|
255
316
|
] satisfies ColumnProps[])
|
|
256
317
|
: []),
|
|
257
|
-
{ prop: "name", label: "
|
|
258
|
-
{ prop: "code", label: "
|
|
259
|
-
{
|
|
260
|
-
|
|
318
|
+
{ prop: "name", label: t("system.role.field.name"), minWidth: 140, search: { el: "input" } },
|
|
319
|
+
{ prop: "code", label: t("system.role.field.code"), minWidth: 160, search: { el: "input" } },
|
|
320
|
+
{
|
|
321
|
+
prop: "data_scope",
|
|
322
|
+
label: t("system.role.field.dataScope"),
|
|
323
|
+
minWidth: 120,
|
|
324
|
+
dictCode: "base_role_data_scope",
|
|
325
|
+
search: { el: "select" }
|
|
326
|
+
},
|
|
327
|
+
{ prop: "remark", label: t("system.common.field.remark"), minWidth: 160 },
|
|
261
328
|
{
|
|
262
329
|
prop: "status",
|
|
263
|
-
label: "
|
|
330
|
+
label: t("system.common.field.status"),
|
|
264
331
|
minWidth: 100,
|
|
265
332
|
search: { el: "select" },
|
|
266
333
|
cellType: "status",
|
|
267
334
|
statusProps: {
|
|
268
335
|
activeValue: Status.ENABLE,
|
|
269
336
|
inactiveValue: Status.DISABLE,
|
|
270
|
-
activeText: "
|
|
271
|
-
inactiveText: "
|
|
337
|
+
activeText: t("common.status.enabled"),
|
|
338
|
+
inactiveText: t("common.status.disabled"),
|
|
272
339
|
disabled: scope => !canChangeRoleStatus(scope.row as BaseRole) || !BUTTONS.value["base:role:status"],
|
|
273
340
|
beforeChange: scope => handleBeforeSetStatus(scope.row as BaseRole)
|
|
274
341
|
}
|
|
275
342
|
},
|
|
276
|
-
{ prop: "created_at", label: "
|
|
277
|
-
{ prop: "updated_at", label: "
|
|
343
|
+
{ prop: "created_at", label: t("system.common.field.createdAt"), minWidth: 180 },
|
|
344
|
+
{ prop: "updated_at", label: t("system.common.field.updatedAt"), minWidth: 180 },
|
|
278
345
|
{
|
|
279
346
|
prop: "operation",
|
|
280
|
-
label: "
|
|
347
|
+
label: t("system.common.field.action"),
|
|
281
348
|
width: 280,
|
|
282
349
|
fixed: "right",
|
|
283
350
|
cellType: "actions",
|
|
284
351
|
actions: [
|
|
285
352
|
{
|
|
286
|
-
label: "
|
|
353
|
+
label: t("system.role.action.assignPermission"),
|
|
287
354
|
type: "primary",
|
|
288
355
|
link: true,
|
|
289
356
|
icon: Position,
|
|
@@ -291,7 +358,7 @@ const columns = computed<ColumnProps[]>(() => [
|
|
|
291
358
|
onClick: scope => handleOpenAssignPermDialog(scope.row as BaseRole)
|
|
292
359
|
},
|
|
293
360
|
{
|
|
294
|
-
label: "
|
|
361
|
+
label: t("common.action.edit"),
|
|
295
362
|
type: "primary",
|
|
296
363
|
link: true,
|
|
297
364
|
icon: EditPen,
|
|
@@ -300,7 +367,7 @@ const columns = computed<ColumnProps[]>(() => [
|
|
|
300
367
|
onClick: (scope, params) => handleOpenDialog((params?.roleId as number | undefined) ?? (scope.row as BaseRole).id)
|
|
301
368
|
},
|
|
302
369
|
{
|
|
303
|
-
label: "
|
|
370
|
+
label: t("common.action.delete"),
|
|
304
371
|
type: "danger",
|
|
305
372
|
link: true,
|
|
306
373
|
icon: Delete,
|
|
@@ -312,23 +379,23 @@ const columns = computed<ColumnProps[]>(() => [
|
|
|
312
379
|
]);
|
|
313
380
|
|
|
314
381
|
/** 角色顶部按钮配置。 */
|
|
315
|
-
const headerActions
|
|
382
|
+
const headerActions = computed<HeaderActionProps[]>(() => [
|
|
316
383
|
{
|
|
317
|
-
label: "
|
|
384
|
+
label: t("common.action.create"),
|
|
318
385
|
type: "success",
|
|
319
386
|
icon: CirclePlus,
|
|
320
387
|
hidden: () => !BUTTONS.value["base:role:create"],
|
|
321
388
|
onClick: () => handleOpenDialog()
|
|
322
389
|
},
|
|
323
390
|
{
|
|
324
|
-
label: "
|
|
391
|
+
label: t("common.action.delete"),
|
|
325
392
|
type: "danger",
|
|
326
393
|
icon: Delete,
|
|
327
394
|
hidden: () => !BUTTONS.value["base:role:delete"],
|
|
328
395
|
disabled: scope => !scope.selectedList.length,
|
|
329
396
|
onClick: scope => handleDelete(scope.selectedList as BaseRole[])
|
|
330
397
|
}
|
|
331
|
-
];
|
|
398
|
+
]);
|
|
332
399
|
|
|
333
400
|
/**
|
|
334
401
|
* 请求角色列表,并由 ProTable 统一维护分页与搜索参数。
|
|
@@ -336,7 +403,7 @@ const headerActions: HeaderActionProps[] = [
|
|
|
336
403
|
async function requestBaseRoleTable(params: PageBaseRoleRequest) {
|
|
337
404
|
const data = await defBaseRoleService.PageBaseRole({
|
|
338
405
|
...buildPageRequest(params),
|
|
339
|
-
tenant_id: isDefaultTenant.value ? params.tenant_id : undefined
|
|
406
|
+
tenant_id: isDefaultTenant.value ? params.tenant_id : undefined
|
|
340
407
|
});
|
|
341
408
|
return { data: { list: data.base_roles ?? [], total: data.total } };
|
|
342
409
|
}
|
|
@@ -381,7 +448,7 @@ async function handleFormTenantChange() {
|
|
|
381
448
|
async function handleOpenDialog(roleId?: number) {
|
|
382
449
|
resetForm();
|
|
383
450
|
await loadTenantOptions();
|
|
384
|
-
dialog.
|
|
451
|
+
dialog.editing = Boolean(roleId);
|
|
385
452
|
dialog.visible = true;
|
|
386
453
|
if (!roleId) {
|
|
387
454
|
await loadMenuPermOptions();
|
|
@@ -437,7 +504,7 @@ function handleSubmit() {
|
|
|
437
504
|
? defBaseRoleService.UpdateBaseRole({ base_role: submitData })
|
|
438
505
|
: defBaseRoleService.CreateBaseRole({ base_role: submitData });
|
|
439
506
|
request.then(() => {
|
|
440
|
-
ElMessage.success(submitData.id ? "
|
|
507
|
+
ElMessage.success(t(submitData.id ? "system.role.message.updateSuccess" : "system.role.message.createSuccess"));
|
|
441
508
|
handleCloseDialog();
|
|
442
509
|
refreshTable();
|
|
443
510
|
});
|
|
@@ -471,21 +538,21 @@ function canDeleteRole(row?: BaseRole) {
|
|
|
471
538
|
*/
|
|
472
539
|
async function handleBeforeSetStatus(row: BaseRole) {
|
|
473
540
|
if (!canChangeRoleStatus(row)) {
|
|
474
|
-
ElMessage.warning("
|
|
541
|
+
ElMessage.warning(t("system.role.message.protectedStatus"));
|
|
475
542
|
return false;
|
|
476
543
|
}
|
|
477
544
|
|
|
478
545
|
const nextStatus = row.status === Status.ENABLE ? Status.DISABLE : Status.ENABLE;
|
|
479
|
-
const
|
|
546
|
+
const action = t(nextStatus === Status.ENABLE ? "common.status.enabled" : "common.status.disabled");
|
|
480
547
|
const roleName = row.name || row.code || `ID:${row.id}`;
|
|
481
548
|
try {
|
|
482
|
-
await ElMessageBox.confirm(
|
|
483
|
-
confirmButtonText: "
|
|
484
|
-
cancelButtonText: "
|
|
549
|
+
await ElMessageBox.confirm(t("system.role.message.confirmStatus", { action, name: roleName }), t("common.title.notice"), {
|
|
550
|
+
confirmButtonText: t("common.action.confirm"),
|
|
551
|
+
cancelButtonText: t("common.action.cancel"),
|
|
485
552
|
type: "warning"
|
|
486
553
|
});
|
|
487
554
|
await defBaseRoleService.SetBaseRoleStatus({ id: row.id, status: nextStatus });
|
|
488
|
-
ElMessage.success(
|
|
555
|
+
ElMessage.success(t("system.common.message.statusSuccess", { action }));
|
|
489
556
|
refreshTable();
|
|
490
557
|
return true;
|
|
491
558
|
} catch {
|
|
@@ -503,7 +570,7 @@ function handleDelete(selected?: number | string | Array<number | string> | Base
|
|
|
503
570
|
? [selected as BaseRole]
|
|
504
571
|
: [];
|
|
505
572
|
if (roleList.some(role => !canDeleteRole(role))) {
|
|
506
|
-
ElMessage.warning("
|
|
573
|
+
ElMessage.warning(t("system.role.message.protectedDelete"));
|
|
507
574
|
return;
|
|
508
575
|
}
|
|
509
576
|
|
|
@@ -511,29 +578,29 @@ function handleDelete(selected?: number | string | Array<number | string> | Base
|
|
|
511
578
|
roleList.length ? roleList.map(item => item.id) : normalizeSelectedIds(selected as number | string | Array<number | string>)
|
|
512
579
|
).join(",");
|
|
513
580
|
if (!roleIds) {
|
|
514
|
-
ElMessage.warning("
|
|
581
|
+
ElMessage.warning(t("system.common.message.selectDeleteItem"));
|
|
515
582
|
return;
|
|
516
583
|
}
|
|
517
584
|
|
|
518
585
|
const confirmMessage = roleList.length
|
|
519
586
|
? roleList.length === 1
|
|
520
|
-
?
|
|
521
|
-
:
|
|
522
|
-
: "
|
|
587
|
+
? t("system.role.message.confirmDeleteSingle", { name: roleList[0].name || roleList[0].code || `ID:${roleList[0].id}` })
|
|
588
|
+
: t("system.role.message.confirmDeleteBatch", { count: roleList.length })
|
|
589
|
+
: t("system.role.message.confirmDeleteSelected");
|
|
523
590
|
|
|
524
|
-
ElMessageBox.confirm(confirmMessage, "
|
|
525
|
-
confirmButtonText: "
|
|
526
|
-
cancelButtonText: "
|
|
591
|
+
ElMessageBox.confirm(confirmMessage, t("common.title.warning"), {
|
|
592
|
+
confirmButtonText: t("common.action.confirm"),
|
|
593
|
+
cancelButtonText: t("common.action.cancel"),
|
|
527
594
|
type: "warning"
|
|
528
595
|
}).then(
|
|
529
596
|
() => {
|
|
530
597
|
defBaseRoleService.DeleteBaseRole({ id: roleIds }).then(() => {
|
|
531
|
-
ElMessage.success("
|
|
598
|
+
ElMessage.success(t("system.role.message.deleteSuccess"));
|
|
532
599
|
refreshTable();
|
|
533
600
|
});
|
|
534
601
|
},
|
|
535
602
|
() => {
|
|
536
|
-
ElMessage.info("
|
|
603
|
+
ElMessage.info(t("system.role.message.deleteCanceled"));
|
|
537
604
|
}
|
|
538
605
|
);
|
|
539
606
|
}
|
|
@@ -544,7 +611,7 @@ function handleDelete(selected?: number | string | Array<number | string> | Base
|
|
|
544
611
|
async function handleOpenAssignPermDialog(row: BaseRole) {
|
|
545
612
|
if (!row.id) return;
|
|
546
613
|
if (!canManageRole(row)) {
|
|
547
|
-
ElMessage.warning("
|
|
614
|
+
ElMessage.warning(t("system.role.message.protectedPermission"));
|
|
548
615
|
return;
|
|
549
616
|
}
|
|
550
617
|
checkedBaseRole.value = { id: row.id, name: row.name };
|
|
@@ -565,15 +632,15 @@ function handleAssignPermSubmit() {
|
|
|
565
632
|
const checkedNodes = (permTreeRef.value?.getCheckedNodes(false, true) as Array<{ value: number }> | undefined) ?? [];
|
|
566
633
|
const checkedMenuIds = checkedNodes.map(node => Number(node.value));
|
|
567
634
|
if (!checkedMenuIds.length) {
|
|
568
|
-
ElMessage.warning("
|
|
635
|
+
ElMessage.warning(t("system.common.validation.requiredSelect", { field: t("system.role.field.menuPermission") }));
|
|
569
636
|
return;
|
|
570
637
|
}
|
|
571
638
|
if (new Set(checkedMenuIds).size !== checkedMenuIds.length) {
|
|
572
|
-
ElMessage.warning("
|
|
639
|
+
ElMessage.warning(t("system.role.validation.menuDuplicate"));
|
|
573
640
|
return;
|
|
574
641
|
}
|
|
575
642
|
defBaseRoleService.SetBaseRoleMenu({ id: roleId, menus: checkedMenuIds }).then(() => {
|
|
576
|
-
ElMessage.success("
|
|
643
|
+
ElMessage.success(t("system.role.message.assignSuccess"));
|
|
577
644
|
assignPermDialogVisible.value = false;
|
|
578
645
|
refreshTable();
|
|
579
646
|
});
|