@liujitcn/kratos-admin-system 0.0.48 → 0.0.50

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.
Files changed (95) hide show
  1. package/README.md +44 -8
  2. package/dist/package/declarations/src/api/system/admin/v1/base_i18n_custom.d.ts +18 -0
  3. package/dist/package/declarations/src/api/system/admin/v1/base_tenant.d.ts +2 -2
  4. package/dist/package/declarations/src/api/system/admin/v1/base_tenant_project.d.ts +23 -0
  5. package/dist/package/declarations/src/api/system/admin/v1/base_tenant_project_grant.d.ts +16 -0
  6. package/dist/package/declarations/src/components/{LogTable.vue.d.ts → log/LogTable.vue.d.ts} +2 -0
  7. package/dist/package/declarations/src/components/tenant-project/ProjectGrantDialog.vue.d.ts +8 -0
  8. package/dist/package/declarations/src/components/tenant-project/TenantProjectManager.vue.d.ts +29 -0
  9. package/dist/package/declarations/src/components/tenant-project/TenantProjectSelect.vue.d.ts +31 -0
  10. package/dist/package/declarations/src/components/tenant-project/TenantProjectText.vue.d.ts +19 -0
  11. package/dist/package/declarations/src/components/tenant-project/tenant-project-manager-data.d.ts +14 -0
  12. package/dist/package/declarations/src/components/tenant-project/tenant-project-manager.d.ts +40 -0
  13. package/dist/package/declarations/src/index.d.ts +2 -0
  14. package/dist/package/declarations/src/locales/generated.d.ts +172 -0
  15. package/dist/package/declarations/src/rpc/base/v1/config.d.ts +11 -0
  16. package/dist/package/declarations/src/rpc/system/admin/v1/base_i18n_custom.d.ts +105 -0
  17. package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant.d.ts +10 -1
  18. package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant_project.d.ts +141 -0
  19. package/dist/package/declarations/src/rpc/system/admin/v1/base_tenant_project_grant.d.ts +105 -0
  20. package/dist/package/declarations/src/views/ai/chat/components/SessionPanel.vue.d.ts +2 -2
  21. package/dist/package/declarations/src/views/base/i18n-custom/index.vue.d.ts +3 -0
  22. package/dist/package/declarations/src/views/base/project-grant/index.vue.d.ts +3 -0
  23. package/dist/package/declarations/src/views/base/tenant-project/index.vue.d.ts +3 -0
  24. package/dist/package/src/api/system/admin/v1/base_i18n_custom.ts +72 -0
  25. package/dist/package/src/api/system/admin/v1/base_tenant.ts +3 -2
  26. package/dist/package/src/api/system/admin/v1/base_tenant_project.ts +94 -0
  27. package/dist/package/src/api/system/admin/v1/base_tenant_project_grant.ts +63 -0
  28. package/dist/package/src/components/{LogTable.vue → log/LogTable.vue} +9 -1
  29. package/dist/package/src/components/tenant-project/ProjectGrantDialog.vue +108 -0
  30. package/dist/package/src/components/tenant-project/TenantProjectManager.vue +452 -0
  31. package/dist/package/src/components/tenant-project/TenantProjectSelect.vue +83 -0
  32. package/dist/package/src/components/tenant-project/TenantProjectText.vue +37 -0
  33. package/dist/package/src/components/tenant-project/tenant-project-manager-data.ts +26 -0
  34. package/dist/package/src/components/tenant-project/tenant-project-manager.ts +48 -0
  35. package/dist/package/src/index.ts +12 -0
  36. package/dist/package/src/locales/README.md +1 -1
  37. package/dist/package/src/locales/en-US.json +45 -2
  38. package/dist/package/src/locales/ja-JP.json +45 -2
  39. package/dist/package/src/locales/zh-CN.json +45 -2
  40. package/dist/package/src/locales/zh-TW.json +45 -2
  41. package/dist/package/src/module.ts +3 -3
  42. package/dist/package/src/rpc/base/v1/config.ts +12 -0
  43. package/dist/package/src/rpc/system/admin/v1/base_i18n_custom.ts +126 -0
  44. package/dist/package/src/rpc/system/admin/v1/base_tenant.ts +11 -1
  45. package/dist/package/src/rpc/system/admin/v1/base_tenant_project.ts +166 -0
  46. package/dist/package/src/rpc/system/admin/v1/base_tenant_project_grant.ts +128 -0
  47. package/dist/package/src/views/ai/chat/components/XSender.vue +4 -3
  48. package/dist/package/src/views/base/api-log/index.vue +3 -3
  49. package/dist/package/src/views/base/config/index.vue +3 -3
  50. package/dist/package/src/views/base/data-access-log/index.vue +4 -4
  51. package/dist/package/src/views/base/dept/index.vue +10 -44
  52. package/dist/package/src/views/base/dict/index.vue +3 -3
  53. package/dist/package/src/views/base/dict/item.vue +3 -3
  54. package/dist/package/src/views/base/file/index.vue +12 -3
  55. package/dist/package/src/views/base/i18n-custom/index.vue +321 -0
  56. package/dist/package/src/views/base/job/index.vue +3 -3
  57. package/dist/package/src/views/base/job/log.vue +1 -0
  58. package/dist/package/src/views/base/login-log/index.vue +13 -4
  59. package/dist/package/src/views/base/login-policy/index.vue +97 -34
  60. package/dist/package/src/views/base/menu/index.vue +3 -3
  61. package/dist/package/src/views/base/message/index.vue +9 -31
  62. package/dist/package/src/views/base/message-category/index.vue +2 -4
  63. package/dist/package/src/views/base/oauth-client/index.vue +8 -41
  64. package/dist/package/src/views/base/online-session/index.vue +8 -26
  65. package/dist/package/src/views/base/operation-log/index.vue +5 -5
  66. package/dist/package/src/views/base/permission-log/index.vue +3 -3
  67. package/dist/package/src/views/base/policy-evaluation-log/index.vue +3 -3
  68. package/dist/package/src/views/base/post/index.vue +9 -41
  69. package/dist/package/src/views/base/project-grant/index.vue +336 -0
  70. package/dist/package/src/views/base/role/index.vue +13 -46
  71. package/dist/package/src/views/base/tenant/index.vue +163 -19
  72. package/dist/package/src/views/base/tenant-project/index.vue +12 -0
  73. package/dist/package/src/views/base/user/index.vue +30 -50
  74. package/dist/package/src/views/profile/components/login-log.vue +15 -2
  75. package/dist/package/src/views/profile/components/password.vue +1 -1
  76. package/dist/package/src/views/profile/components/security.vue +2 -2
  77. package/dist/package/src/views/tool/code-gen/components/CodeGenLocaleEditor.vue +2 -2
  78. package/dist/package/src/views/tool/code-gen/config.ts +2 -1
  79. package/package.json +2 -2
  80. /package/dist/package/declarations/src/components/{ChangePasswordForm.vue.d.ts → account/ChangePasswordForm.vue.d.ts} +0 -0
  81. /package/dist/package/declarations/src/components/{ForcedPasswordDialog.vue.d.ts → account/ForcedPasswordDialog.vue.d.ts} +0 -0
  82. /package/dist/package/declarations/src/components/{Ai.vue.d.ts → ai/Ai.vue.d.ts} +0 -0
  83. /package/dist/package/declarations/src/components/{DynamicI18nCell.vue.d.ts → i18n/DynamicI18nCell.vue.d.ts} +0 -0
  84. /package/dist/package/declarations/src/components/{DynamicI18nEditor.vue.d.ts → i18n/DynamicI18nEditor.vue.d.ts} +0 -0
  85. /package/dist/package/declarations/src/components/{dynamicI18n.d.ts → i18n/dynamicI18n.d.ts} +0 -0
  86. /package/dist/package/declarations/src/components/{log.d.ts → log/log.d.ts} +0 -0
  87. /package/dist/package/declarations/src/components/{Notification.vue.d.ts → notification/Notification.vue.d.ts} +0 -0
  88. /package/dist/package/src/components/{ChangePasswordForm.vue → account/ChangePasswordForm.vue} +0 -0
  89. /package/dist/package/src/components/{ForcedPasswordDialog.vue → account/ForcedPasswordDialog.vue} +0 -0
  90. /package/dist/package/src/components/{Ai.vue → ai/Ai.vue} +0 -0
  91. /package/dist/package/src/components/{DynamicI18nCell.vue → i18n/DynamicI18nCell.vue} +0 -0
  92. /package/dist/package/src/components/{DynamicI18nEditor.vue → i18n/DynamicI18nEditor.vue} +0 -0
  93. /package/dist/package/src/components/{dynamicI18n.ts → i18n/dynamicI18n.ts} +0 -0
  94. /package/dist/package/src/components/{log.ts → log/log.ts} +0 -0
  95. /package/dist/package/src/components/{Notification.vue → notification/Notification.vue} +0 -0
@@ -150,12 +150,10 @@ import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn
150
150
  import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
151
151
  import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
152
152
  import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
153
- import { DEFAULT_TENANT_CODE, requestTenantOptions } from "@liujitcn/kratos-admin-core/tenant";
154
- import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
153
+ import { useTenantScope } from "@liujitcn/kratos-admin-core/tenant";
155
154
  import { t } from "@liujitcn/kratos-admin-core";
156
155
  import { defBaseMessageService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_message";
157
156
  import { defBaseMessageCategoryService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_message_category";
158
- import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_tenant";
159
157
  import type {
160
158
  BaseMessage,
161
159
  BaseMessageDetail,
@@ -189,12 +187,10 @@ type MessageFormState = Omit<BaseMessageForm, "tenant_id" | "category_id"> & {
189
187
  };
190
188
 
191
189
  const { BUTTONS } = useAuthButtons();
192
- const userStore = useUserStore();
193
- const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
190
+ const { isDefaultTenant, tenantColumns, tenantFormField, loadTenantOptions } = useTenantScope();
194
191
  const proTable = ref<ProTableInstance>();
195
192
  const formDialogRef = ref<InstanceType<typeof FormDialog>>();
196
193
  const categoryOptions = ref<ProFormOption[]>([]);
197
- const tenantOptions = ref<ProFormOption[]>([]);
198
194
  const dialog = reactive({ visible: false, titleKey: "common.action.create" });
199
195
  const content = reactive<{ visible: boolean; loading: boolean; data?: BaseMessageDetail }>({ visible: false, loading: false });
200
196
  const detail = reactive<{ visible: boolean; data?: BaseMessageDetail }>({ visible: false });
@@ -270,13 +266,12 @@ const rules = computed(() => ({
270
266
 
271
267
  const formFields = computed<ProFormField[]>(() => [
272
268
  {
273
- prop: "tenant_id",
274
- label: t("common.field.tenant"),
275
- labelTooltip: t("system.base.message.tooltip.tenant"),
276
- component: "select",
277
- visible: () => isDefaultTenant.value,
278
- options: tenantOptions.value,
279
- props: { filterable: true, disabled: Boolean(formState.id), placeholder: t("system.base.message.placeholder.tenant") }
269
+ ...tenantFormField({
270
+ label: t("common.field.tenant"),
271
+ disabledOnEdit: true,
272
+ props: { placeholder: t("system.base.message.placeholder.tenant") }
273
+ }),
274
+ labelTooltip: t("system.base.message.tooltip.tenant")
280
275
  },
281
276
  {
282
277
  prop: "category_id",
@@ -358,17 +353,7 @@ const formFields = computed<ProFormField[]>(() => [
358
353
 
359
354
  const columns = computed<ColumnProps[]>(() => [
360
355
  { type: "selection", width: 55 },
361
- ...(isDefaultTenant.value
362
- ? ([
363
- {
364
- prop: "tenant_id",
365
- label: t("common.field.tenant"),
366
- minWidth: 120,
367
- search: { el: "select" },
368
- enum: requestTenantOptions
369
- }
370
- ] satisfies ColumnProps[])
371
- : []),
356
+ ...tenantColumns({ label: t("common.field.tenant"), minWidth: 120 }),
372
357
  {
373
358
  prop: "title",
374
359
  label: t("system.base.message.field.title"),
@@ -552,13 +537,6 @@ async function requestTable(params: Record<string, unknown>) {
552
537
  return { data: { list: data.base_messages ?? [], total: data.total } };
553
538
  }
554
539
 
555
- /** 加载租户选项。 */
556
- async function loadTenantOptions() {
557
- if (!isDefaultTenant.value) return;
558
- const result = await defBaseTenantService.OptionBaseTenant({ keyword: "" });
559
- tenantOptions.value = result.list.map(item => ({ label: item.label, value: item.value }));
560
- }
561
-
562
540
  /** 加载消息分类选项。 */
563
541
  async function loadCategoryOptions() {
564
542
  const result = await defBaseMessageCategoryService.OptionBaseMessageCategory({});
@@ -23,8 +23,7 @@ import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn
23
23
  import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/components/ProForm/interface";
24
24
  import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
25
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";
26
+ import { useTenantScope } from "@liujitcn/kratos-admin-core/tenant";
28
27
  import { t } from "@liujitcn/kratos-admin-core";
29
28
  import { defBaseMessageCategoryService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_message_category";
30
29
  import type {
@@ -39,8 +38,7 @@ defineOptions({ name: "BaseMessageCategory", inheritAttrs: false });
39
38
 
40
39
  /** 消息分类页面表单状态。 */
41
40
  const { BUTTONS } = useAuthButtons();
42
- const userStore = useUserStore();
43
- const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
41
+ const { isDefaultTenant } = useTenantScope();
44
42
  const proTable = ref<ProTableInstance>();
45
43
  const formDialogRef = ref<InstanceType<typeof FormDialog>>();
46
44
  const dialog = reactive({ visible: false, titleKey: "common.action.create" });
@@ -34,7 +34,6 @@ import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-c
34
34
  import { t } from "@liujitcn/kratos-admin-core";
35
35
  import { copyText } from "@liujitcn/kratos-admin-core/security";
36
36
  import { defOauthClientService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/oauth_client";
37
- import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_tenant";
38
37
  import type { BaseApi } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_api";
39
38
  import {
40
39
  OauthClientCryptoType,
@@ -42,10 +41,8 @@ import {
42
41
  type OauthClientForm,
43
42
  type PageOauthClientRequest
44
43
  } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/oauth_client";
45
- import type { SelectOptionResponse_Option } from "@liujitcn/kratos-admin-system/rpc/common/v1/common";
46
44
  import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
47
- import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
48
- import { DEFAULT_TENANT_CODE, requestTenantOptions } from "@liujitcn/kratos-admin-core/tenant";
45
+ import { useTenantScope } from "@liujitcn/kratos-admin-core/tenant";
49
46
 
50
47
  /** 开放授权客户端表单状态,新增时租户保持未选择。 */
51
48
  type OauthClientFormState = Omit<OauthClientForm, "tenant_id"> & {
@@ -59,12 +56,10 @@ defineOptions({
59
56
  });
60
57
 
61
58
  const { BUTTONS } = useAuthButtons();
62
- const userStore = useUserStore();
63
- const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
59
+ const { isDefaultTenant, tenantColumns, tenantFormField, loadTenantOptions } = useTenantScope();
64
60
  const proTable = ref<ProTableInstance>();
65
61
  const formDialogRef = ref<InstanceType<typeof FormDialog>>();
66
62
  const apiOptions = ref<BaseApi[]>([]);
67
- const tenantOptions = ref<SelectOptionResponse_Option[]>([]);
68
63
 
69
64
  const dialog = reactive({
70
65
  titleKey: "common.action.create",
@@ -102,8 +97,6 @@ const transferOptions = computed<ProFormOption[]>(() =>
102
97
  }))
103
98
  );
104
99
 
105
- const tenantNameMap = computed(() => new Map(tenantOptions.value.map(item => [item.value, item.label])));
106
-
107
100
  const rules = computed(() => ({
108
101
  tenant_id: [
109
102
  {
@@ -137,18 +130,7 @@ const rules = computed(() => ({
137
130
  }));
138
131
 
139
132
  const formFields = computed<ProFormField[]>(() => [
140
- {
141
- prop: "tenant_id",
142
- label: t("common.field.tenant"),
143
- component: "select",
144
- props: {
145
- filterable: true,
146
- disabled: Boolean(formData.id),
147
- placeholder: t("common.placeholder.select")
148
- },
149
- options: tenantOptions.value,
150
- visible: () => isDefaultTenant.value
151
- },
133
+ tenantFormField({ label: t("common.field.tenant"), disabledOnEdit: true, props: { placeholder: t("common.placeholder.select") } }),
152
134
  {
153
135
  prop: "client_name",
154
136
  label: t("system.base.oauth_client.field.client_name"),
@@ -184,19 +166,7 @@ const formFields = computed<ProFormField[]>(() => [
184
166
 
185
167
  const columns = computed<ColumnProps[]>(() => [
186
168
  { type: "selection", width: 55 },
187
- ...(isDefaultTenant.value
188
- ? ([
189
- {
190
- prop: "tenant_id",
191
- label: t("common.field.tenant"),
192
- minWidth: 130,
193
- search: { el: "select", key: "tenant_id", props: { filterable: true }, order: 1 },
194
- enum: requestTenantOptions,
195
- render: scope =>
196
- tenantNameMap.value.get((scope.row as OauthClient).tenant_id) ?? String((scope.row as OauthClient).tenant_id)
197
- }
198
- ] satisfies ColumnProps[])
199
- : []),
169
+ ...tenantColumns({ label: t("common.field.tenant"), minWidth: 130, order: 1 }),
200
170
  { prop: "client_id", label: t("system.base.oauth_client.field.client_id"), minWidth: 220 },
201
171
  { prop: "client_name", label: t("system.base.oauth_client.field.client_name"), minWidth: 160, search: { el: "input" } },
202
172
  {
@@ -283,7 +253,10 @@ const headerActions = computed<HeaderActionProps[]>(() => [
283
253
  ]);
284
254
 
285
255
  async function requestOauthClientTable(params: PageOauthClientRequest) {
286
- const data = await defOauthClientService.PageOauthClient(buildPageRequest(params));
256
+ const data = await defOauthClientService.PageOauthClient({
257
+ ...buildPageRequest(params),
258
+ tenant_id: isDefaultTenant.value ? params.tenant_id : undefined
259
+ });
287
260
  return { data: { list: data.oauth_clients ?? [], total: data.total } };
288
261
  }
289
262
 
@@ -292,12 +265,6 @@ async function loadApiOptions() {
292
265
  apiOptions.value = data.base_apis ?? [];
293
266
  }
294
267
 
295
- async function loadTenantOptions() {
296
- if (userStore.userInfo.tenant_code !== DEFAULT_TENANT_CODE || tenantOptions.value.length) return;
297
- const data = await defBaseTenantService.OptionBaseTenant({ keyword: "" });
298
- tenantOptions.value = data.list ?? [];
299
- }
300
-
301
268
  async function handleOpenDialog(id?: number) {
302
269
  await loadTenantOptions();
303
270
  await loadApiOptions();
@@ -15,14 +15,12 @@
15
15
  <script setup lang="ts">
16
16
  import { computed, ref } from "vue";
17
17
  import ProTable from "@liujitcn/kratos-admin-core/components/ProTable";
18
- import type { ColumnProps, EnumProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
19
- import { DEFAULT_TENANT_CODE } from "@liujitcn/kratos-admin-core/tenant";
20
- import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
18
+ import type { ColumnProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
19
+ import { requestTenantCodeOptions, useTenantScope } from "@liujitcn/kratos-admin-core/tenant";
21
20
  import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
22
21
  import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
23
22
  import { formatDateTime } from "@liujitcn/kratos-admin-core/format";
24
23
  import { t } from "@liujitcn/kratos-admin-core";
25
- import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_tenant";
26
24
  import { defBaseSessionService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_session";
27
25
  import type { BaseSession, PageOnlineBaseSessionsRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_session";
28
26
 
@@ -30,17 +28,17 @@ defineOptions({ name: "BaseOnlineSession", inheritAttrs: false });
30
28
 
31
29
  const { BUTTONS } = useAuthButtons();
32
30
  const proTable = ref<ProTableInstance>();
33
- const userStore = useUserStore();
34
- const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
31
+ const { isDefaultTenant, tenantColumns } = useTenantScope();
35
32
 
36
33
  const columns = computed<ColumnProps[]>(() => [
37
- {
34
+ ...tenantColumns({
38
35
  prop: "tenant_code",
39
36
  label: t("common.field.tenant"),
40
37
  minWidth: 130,
41
- search: isDefaultTenant.value ? { el: "select", props: { filterable: true }, order: 1 } : undefined,
42
- enum: requestSessionTenantOptions
43
- },
38
+ enum: requestTenantCodeOptions,
39
+ searchEl: "select",
40
+ render: scope => String((scope.row as BaseSession).tenant_code ?? "")
41
+ }),
44
42
  {
45
43
  prop: "user_name",
46
44
  label: t("system.base.online_session.field.user_name"),
@@ -74,22 +72,6 @@ const columns = computed<ColumnProps[]>(() => [
74
72
  }
75
73
  ]);
76
74
 
77
- /** 将租户名称映射到会话使用的租户编码,供下拉筛选与表格展示复用。 */
78
- async function requestSessionTenantOptions() {
79
- if (!isDefaultTenant.value) {
80
- return { data: [{ value: userStore.userInfo.tenant_code, label: userStore.userInfo.tenant_name }] };
81
- }
82
- const options: EnumProps[] = [];
83
- const pageSize = 100;
84
- for (let pageNum = 1; ; pageNum++) {
85
- const response = await defBaseTenantService.PageBaseTenant({ code: "", name: "", page_num: pageNum, page_size: pageSize });
86
- const tenants = response.base_tenants ?? [];
87
- options.push(...tenants.map(tenant => ({ value: tenant.code, label: tenant.name })));
88
- if (options.length >= response.total || tenants.length === 0) break;
89
- }
90
- return { data: options };
91
- }
92
-
93
75
  /** 查询在线用户会话列表。 */
94
76
  async function requestTable(params: Record<string, unknown>) {
95
77
  const response = await defBaseSessionService.PageOnlineBaseSessions(
@@ -6,10 +6,10 @@
6
6
  import { computed, ref } from "vue";
7
7
  import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
8
8
  import { t } from "@liujitcn/kratos-admin-core";
9
- import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log";
9
+ import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log/log";
10
10
  import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
11
- import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/LogTable.vue";
12
- import { logDateSearch, logDetailColumn, logEnumLabel, createLogEnumOptions, requestLogTrace } from "@liujitcn/kratos-admin-system/components/log";
11
+ import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/log/LogTable.vue";
12
+ import { logDateSearch, logDetailColumn, logEnumLabel, createLogEnumOptions, requestLogTrace } from "@liujitcn/kratos-admin-system/components/log/log";
13
13
  import { defBaseOperationLogService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_operation_log";
14
14
  import { BaseLogResult } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_log";
15
15
  import { BaseOperationAction } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_operation_log";
@@ -37,7 +37,7 @@ const actionOptions = computed(() => createLogEnumOptions([
37
37
  ]));
38
38
  const columns = computed<ColumnProps[]>(() => [
39
39
  { prop: "resource_type", label: t("system.base.log.field.resource_type"), minWidth: 150, search: { el: "input" } },
40
- { prop: "resource_id", label: t("system.base.log.field.resource_id"), minWidth: 120, align: "right" },
40
+ { prop: "resource_id", label: t("system.base.log.field.resource_id"), minWidth: 120, align: "left" },
41
41
  { prop: "resource_name", label: t("system.base.log.field.resource_name"), minWidth: 160 },
42
42
  { prop: "action", label: t("system.base.log.field.action"), minWidth: 110, search: { el: "select", enum: actionOptions.value }, render: scope => logEnumLabel(actionOptions.value, (scope.row as BaseOperationLog).action) },
43
43
  { prop: "result", label: t("system.base.log.field.result"), minWidth: 110, search: { el: "select", enum: resultOptions.value }, render: scope => logEnumLabel(resultOptions.value, (scope.row as BaseOperationLog).result) },
@@ -58,7 +58,7 @@ const config = computed<LogTableConfig>(() => ({
58
58
  { key: "user_id", label: t("system.base.log.field.user_id") },
59
59
  { key: "user_name", label: t("system.base.log.field.user_name") },
60
60
  { key: "resource_type", label: t("system.base.log.field.resource_type") },
61
- { key: "resource_id", label: t("system.base.log.field.resource_id") },
61
+ { key: "resource_id", label: t("system.base.log.field.resource_id"), align: "left" },
62
62
  { key: "resource_name", label: t("system.base.log.field.resource_name") },
63
63
  { key: "action", label: t("system.base.log.field.action"), enum: actionOptions.value },
64
64
  { key: "result", label: t("system.base.log.field.result"), enum: resultOptions.value },
@@ -6,10 +6,10 @@
6
6
  import { computed, ref } from "vue";
7
7
  import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
8
8
  import { t } from "@liujitcn/kratos-admin-core";
9
- import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log";
9
+ import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log/log";
10
10
  import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
11
- import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/LogTable.vue";
12
- import { logDateSearch, logDetailColumn, logEnumLabel, createLogEnumOptions, requestLogTrace } from "@liujitcn/kratos-admin-system/components/log";
11
+ import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/log/LogTable.vue";
12
+ import { logDateSearch, logDetailColumn, logEnumLabel, createLogEnumOptions, requestLogTrace } from "@liujitcn/kratos-admin-system/components/log/log";
13
13
  import { defBasePermissionLogService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_permission_log";
14
14
  import { BaseLogResult } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_log";
15
15
  import { BasePermissionAction, BasePermissionTargetType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_permission_log";
@@ -6,9 +6,9 @@
6
6
  import { computed, ref } from "vue";
7
7
  import type { ColumnProps } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
8
8
  import { t } from "@liujitcn/kratos-admin-core";
9
- import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log";
9
+ import { formatLogDateTime } from "@liujitcn/kratos-admin-system/components/log/log";
10
10
  import { buildPageRequest } from "@liujitcn/kratos-admin-core/table";
11
- import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/LogTable.vue";
11
+ import LogTable, { type LogTableConfig } from "@liujitcn/kratos-admin-system/components/log/LogTable.vue";
12
12
  import {
13
13
  createLogEnumOptions,
14
14
  formatLogCount,
@@ -17,7 +17,7 @@ import {
17
17
  logDetailColumn,
18
18
  logEnumLabel,
19
19
  requestLogTrace
20
- } from "@liujitcn/kratos-admin-system/components/log";
20
+ } from "@liujitcn/kratos-admin-system/components/log/log";
21
21
  import { defBasePolicyEvaluationLogService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_policy_evaluation_log";
22
22
  import { BasePolicyDecision, BasePolicyEvaluationType } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_policy_evaluation_log";
23
23
  import type { BasePolicyEvaluationLog, PageBasePolicyEvaluationLogRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_policy_evaluation_log";
@@ -24,7 +24,7 @@
24
24
  </template>
25
25
 
26
26
  <script setup lang="ts">
27
- import { computed, reactive, ref } from "vue";
27
+ import { computed, onMounted, reactive, ref } from "vue";
28
28
  import { ElMessage, ElMessageBox } from "element-plus";
29
29
  import { CirclePlus, Delete, EditPen } from "@element-plus/icons-vue";
30
30
  import type { ColumnProps, HeaderActionProps, ProTableInstance } from "@liujitcn/kratos-admin-core/components/ProTable/interface";
@@ -34,12 +34,9 @@ import type { ProFormField, ProFormOption } from "@liujitcn/kratos-admin-core/co
34
34
  import { useAuthButtons } from "@liujitcn/kratos-admin-core/auth";
35
35
  import { defBasePostService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_post";
36
36
  import type { BasePost, BasePostForm, PageBasePostRequest } from "@liujitcn/kratos-admin-system/rpc/system/admin/v1/base_post";
37
- import { defBaseTenantService } from "@liujitcn/kratos-admin-system/api/system/admin/v1/base_tenant";
38
- import type { SelectOptionResponse_Option } from "@liujitcn/kratos-admin-system/rpc/common/v1/common";
39
37
  import { Status } from "@liujitcn/kratos-admin-system/rpc/common/v1/enum";
40
38
  import { buildPageRequest, normalizeSelectedIds } from "@liujitcn/kratos-admin-core/table";
41
- import { DEFAULT_TENANT_CODE, requestTenantOptions } from "@liujitcn/kratos-admin-core/tenant";
42
- import { useUserStore } from "@liujitcn/kratos-admin-core/stores/runtime";
39
+ import { useTenantScope } from "@liujitcn/kratos-admin-core/tenant";
43
40
  import { t } from "@liujitcn/kratos-admin-core";
44
41
 
45
42
  defineOptions({
@@ -54,7 +51,6 @@ type BasePostFormState = Omit<BasePostForm, "tenant_id"> & {
54
51
  };
55
52
 
56
53
  const { BUTTONS } = useAuthButtons();
57
- const userStore = useUserStore();
58
54
  const proTable = ref<ProTableInstance>();
59
55
  const formDialogRef = ref<InstanceType<typeof FormDialog>>();
60
56
 
@@ -62,7 +58,6 @@ const dialog = reactive({
62
58
  titleKey: "common.action.create_resource",
63
59
  visible: false
64
60
  });
65
- const tenantOptions = ref<SelectOptionResponse_Option[]>([]);
66
61
  const statusOptions = computed<ProFormOption[]>(() => [
67
62
  { label: t("common.status.enabled"), value: Status.STATUS_ENABLE },
68
63
  { label: t("common.status.disabled"), value: Status.STATUS_DISABLE }
@@ -132,23 +127,14 @@ const rules = computed(() => ({
132
127
  ]
133
128
  }));
134
129
 
135
- /** 当前登录账号是否默认租户。 */
136
- const isDefaultTenant = computed(() => userStore.userInfo.tenant_code === DEFAULT_TENANT_CODE);
130
+ const { isDefaultTenant, tenantColumns, tenantFormField, toRequestTenantId, loadTenantOptions } = useTenantScope();
131
+ onMounted(() => {
132
+ if (isDefaultTenant.value) void loadTenantOptions();
133
+ });
137
134
 
138
135
  /** 岗位表单字段配置。 */
139
136
  const formFields = computed<ProFormField[]>(() => [
140
- {
141
- prop: "tenant_id",
142
- label: t("common.field.tenant"),
143
- component: "select",
144
- props: {
145
- placeholder: t("common.placeholder.select"),
146
- filterable: true,
147
- disabled: Boolean(formData.id)
148
- },
149
- visible: () => isDefaultTenant.value,
150
- options: tenantOptions.value
151
- },
137
+ tenantFormField({ label: t("common.field.tenant"), disabledOnEdit: true }),
152
138
  {
153
139
  prop: "name",
154
140
  label: t("system.base.post.field.name"),
@@ -179,18 +165,7 @@ const formFields = computed<ProFormField[]>(() => [
179
165
  /** 岗位表格列配置。 */
180
166
  const columns = computed<ColumnProps[]>(() => [
181
167
  { type: "selection", width: 55 },
182
- ...(isDefaultTenant.value
183
- ? ([
184
- {
185
- prop: "tenant_id",
186
- label: t("common.field.tenant"),
187
- minWidth: 140,
188
- showOverflowTooltip: true,
189
- search: { el: "select", key: "tenant_id", props: { filterable: true }, order: 1 },
190
- enum: requestTenantOptions
191
- }
192
- ] satisfies ColumnProps[])
193
- : []),
168
+ ...tenantColumns({ label: t("common.field.tenant"), order: 1 }),
194
169
  { prop: "name", label: t("system.base.post.field.name"), minWidth: 140, search: { el: "input" } },
195
170
  { prop: "code", label: t("system.base.post.field.code"), minWidth: 140, search: { el: "input" } },
196
171
  { prop: "sort", label: t("common.field.sort"), minWidth: 90, align: "right" },
@@ -261,7 +236,7 @@ const headerActions = computed<HeaderActionProps[]>(() => [
261
236
  async function requestBasePostTable(params: PageBasePostRequest) {
262
237
  const data = await defBasePostService.PageBasePost({
263
238
  ...buildPageRequest(params),
264
- tenant_id: isDefaultTenant.value ? params.tenant_id : undefined
239
+ tenant_id: toRequestTenantId(params.tenant_id)
265
240
  });
266
241
  return { data: { list: data.base_posts ?? [], total: data.total } };
267
242
  }
@@ -271,13 +246,6 @@ function refreshTable() {
271
246
  proTable.value?.getTableList();
272
247
  }
273
248
 
274
- /** 加载租户选项。 */
275
- async function loadTenantOptions() {
276
- if (!isDefaultTenant.value || tenantOptions.value.length) return;
277
- const response = await defBaseTenantService.OptionBaseTenant({ keyword: "" });
278
- tenantOptions.value = response.list ?? [];
279
- }
280
-
281
249
  /** 打开岗位编辑弹窗。 */
282
250
  async function handleOpenDialog(id?: number) {
283
251
  resetForm();