@liujitcn/kratos-admin-core 0.0.71 → 0.0.73
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/dist/package/declarations/src/locales/generated.d.ts +0 -4
- package/dist/package/declarations/src/tenant.d.ts +1 -9
- package/dist/package/src/locales/en-US.json +0 -1
- package/dist/package/src/locales/ja-JP.json +0 -1
- package/dist/package/src/locales/zh-CN.json +0 -1
- package/dist/package/src/locales/zh-TW.json +0 -1
- package/dist/package/src/tenant.ts +6 -41
- package/package.json +1 -1
|
@@ -362,7 +362,6 @@ export declare const LOCALE_MESSAGES: {
|
|
|
362
362
|
"common.field.sort": string;
|
|
363
363
|
"common.field.status": string;
|
|
364
364
|
"common.field.tenant": string;
|
|
365
|
-
"common.field.tenant_global": string;
|
|
366
365
|
"common.field.project": string;
|
|
367
366
|
"common.field.updated_at": string;
|
|
368
367
|
"common.field.user": string;
|
|
@@ -850,7 +849,6 @@ export declare const LOCALE_MESSAGES: {
|
|
|
850
849
|
"common.field.sort": string;
|
|
851
850
|
"common.field.status": string;
|
|
852
851
|
"common.field.tenant": string;
|
|
853
|
-
"common.field.tenant_global": string;
|
|
854
852
|
"common.field.project": string;
|
|
855
853
|
"common.field.updated_at": string;
|
|
856
854
|
"common.field.user": string;
|
|
@@ -1338,7 +1336,6 @@ export declare const LOCALE_MESSAGES: {
|
|
|
1338
1336
|
"common.field.sort": string;
|
|
1339
1337
|
"common.field.status": string;
|
|
1340
1338
|
"common.field.tenant": string;
|
|
1341
|
-
"common.field.tenant_global": string;
|
|
1342
1339
|
"common.field.project": string;
|
|
1343
1340
|
"common.field.updated_at": string;
|
|
1344
1341
|
"common.field.user": string;
|
|
@@ -1826,7 +1823,6 @@ export declare const LOCALE_MESSAGES: {
|
|
|
1826
1823
|
"common.field.sort": string;
|
|
1827
1824
|
"common.field.status": string;
|
|
1828
1825
|
"common.field.tenant": string;
|
|
1829
|
-
"common.field.tenant_global": string;
|
|
1830
1826
|
"common.field.project": string;
|
|
1831
1827
|
"common.field.updated_at": string;
|
|
1832
1828
|
"common.field.user": string;
|
|
@@ -7,10 +7,6 @@ export * from "./utils/tenant";
|
|
|
7
7
|
export declare function requestTenantCodeOptions(): Promise<{
|
|
8
8
|
data: EnumProps[];
|
|
9
9
|
}>;
|
|
10
|
-
/** 查询包含全局选项的租户选项,值为零表示全局。 */
|
|
11
|
-
export declare function requestGlobalTenantOptions(): Promise<{
|
|
12
|
-
data: SelectOptionResponse_Option[];
|
|
13
|
-
}>;
|
|
14
10
|
/** 租户上下文状态。 */
|
|
15
11
|
export interface TenantScope {
|
|
16
12
|
/** 当前账号是否为默认租户。 */
|
|
@@ -22,7 +18,7 @@ export interface TenantScope {
|
|
|
22
18
|
/** 加载默认租户可选择的租户。 */
|
|
23
19
|
loadTenantOptions: (includeCurrentTenant?: boolean) => Promise<void>;
|
|
24
20
|
/** 将页面租户筛选值转换成后端请求值。 */
|
|
25
|
-
toRequestTenantId: (value: unknown
|
|
21
|
+
toRequestTenantId: (value: unknown) => number | undefined;
|
|
26
22
|
/** 创建默认租户可见的表单字段。 */
|
|
27
23
|
tenantFormField: (options: TenantFormFieldOptions) => ProFormField;
|
|
28
24
|
/** 创建默认租户可见的表格租户列。 */
|
|
@@ -40,8 +36,6 @@ export interface TenantFormFieldOptions {
|
|
|
40
36
|
props?: Record<string, any>;
|
|
41
37
|
/** 是否允许编辑态修改租户。 */
|
|
42
38
|
disabledOnEdit?: boolean;
|
|
43
|
-
/** 是否在选项最前面追加全局选项(值为零)。 */
|
|
44
|
-
includeGlobal?: boolean;
|
|
45
39
|
}
|
|
46
40
|
/** 租户表格列配置。 */
|
|
47
41
|
export interface TenantColumnOptions {
|
|
@@ -67,8 +61,6 @@ export interface TenantColumnOptions {
|
|
|
67
61
|
searchEl?: SearchType;
|
|
68
62
|
/** 自定义单元格展示。 */
|
|
69
63
|
render?: (scope: RenderScope) => ReturnType<NonNullable<ColumnProps["render"]>>;
|
|
70
|
-
/** 是否在选项最前面追加全局选项(值为零)。 */
|
|
71
|
-
includeGlobal?: boolean;
|
|
72
64
|
}
|
|
73
65
|
/** 创建租户范围能力,统一默认租户和普通租户的前端行为。 */
|
|
74
66
|
export declare function useTenantScope(): TenantScope;
|
|
@@ -357,7 +357,6 @@
|
|
|
357
357
|
"common.field.sort": "Sort order",
|
|
358
358
|
"common.field.status": "Status",
|
|
359
359
|
"common.field.tenant": "Tenant",
|
|
360
|
-
"common.field.tenant_global": "Global",
|
|
361
360
|
"common.field.project": "Project",
|
|
362
361
|
"common.field.updated_at": "Updated at",
|
|
363
362
|
"common.field.user": "User",
|
|
@@ -357,7 +357,6 @@
|
|
|
357
357
|
"common.field.sort": "並べ替え",
|
|
358
358
|
"common.field.status": "ステータス",
|
|
359
359
|
"common.field.tenant": "テナント",
|
|
360
|
-
"common.field.tenant_global": "グローバル",
|
|
361
360
|
"common.field.project": "プロジェクト",
|
|
362
361
|
"common.field.updated_at": "更新時間",
|
|
363
362
|
"common.field.user": "ユーザー",
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { computed, ref, type ComputedRef, type Ref } from "vue";
|
|
2
2
|
import type { ProFormField } from "./components/ProForm/interface";
|
|
3
3
|
import type { ColumnProps, EnumProps, RenderScope, SearchType } from "./components/ProTable/interface";
|
|
4
|
-
import { t } from "./locales";
|
|
5
4
|
import { defBaseTenantService } from "./api/system/admin/v1/base_tenant";
|
|
6
5
|
import type { SelectOptionResponse_Option } from "./rpc/common/v1/common";
|
|
7
6
|
import { useUserStore } from "./stores/runtime";
|
|
@@ -26,22 +25,6 @@ export async function requestTenantCodeOptions() {
|
|
|
26
25
|
return { data: options };
|
|
27
26
|
}
|
|
28
27
|
|
|
29
|
-
/** 查询包含全局选项的租户选项,值为零表示全局。 */
|
|
30
|
-
export async function requestGlobalTenantOptions() {
|
|
31
|
-
const { data } = await requestTenantOptionData();
|
|
32
|
-
return { data: [globalTenantOption(), ...data] };
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/** 构造全局租户选项。 */
|
|
36
|
-
function globalTenantOption(): SelectOptionResponse_Option {
|
|
37
|
-
return { label: t("common.field.tenant_global"), value: 0, disabled: false };
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/** 在租户选项前插入全局选项。 */
|
|
41
|
-
function prependGlobalTenantOption(options: SelectOptionResponse_Option[]) {
|
|
42
|
-
return [globalTenantOption(), ...options];
|
|
43
|
-
}
|
|
44
|
-
|
|
45
28
|
/** 租户上下文状态。 */
|
|
46
29
|
export interface TenantScope {
|
|
47
30
|
/** 当前账号是否为默认租户。 */
|
|
@@ -53,7 +36,7 @@ export interface TenantScope {
|
|
|
53
36
|
/** 加载默认租户可选择的租户。 */
|
|
54
37
|
loadTenantOptions: (includeCurrentTenant?: boolean) => Promise<void>;
|
|
55
38
|
/** 将页面租户筛选值转换成后端请求值。 */
|
|
56
|
-
toRequestTenantId: (value: unknown
|
|
39
|
+
toRequestTenantId: (value: unknown) => number | undefined;
|
|
57
40
|
/** 创建默认租户可见的表单字段。 */
|
|
58
41
|
tenantFormField: (options: TenantFormFieldOptions) => ProFormField;
|
|
59
42
|
/** 创建默认租户可见的表格租户列。 */
|
|
@@ -72,8 +55,6 @@ export interface TenantFormFieldOptions {
|
|
|
72
55
|
props?: Record<string, any>;
|
|
73
56
|
/** 是否允许编辑态修改租户。 */
|
|
74
57
|
disabledOnEdit?: boolean;
|
|
75
|
-
/** 是否在选项最前面追加全局选项(值为零)。 */
|
|
76
|
-
includeGlobal?: boolean;
|
|
77
58
|
}
|
|
78
59
|
|
|
79
60
|
/** 租户表格列配置。 */
|
|
@@ -100,8 +81,6 @@ export interface TenantColumnOptions {
|
|
|
100
81
|
searchEl?: SearchType;
|
|
101
82
|
/** 自定义单元格展示。 */
|
|
102
83
|
render?: (scope: RenderScope) => ReturnType<NonNullable<ColumnProps["render"]>>;
|
|
103
|
-
/** 是否在选项最前面追加全局选项(值为零)。 */
|
|
104
|
-
includeGlobal?: boolean;
|
|
105
84
|
}
|
|
106
85
|
|
|
107
86
|
/** 创建租户范围能力,统一默认租户和普通租户的前端行为。 */
|
|
@@ -117,13 +96,10 @@ export function useTenantScope(): TenantScope {
|
|
|
117
96
|
tenantOptions.value = await loadSharedTenantOptions();
|
|
118
97
|
}
|
|
119
98
|
|
|
120
|
-
function toRequestTenantId(value: unknown
|
|
99
|
+
function toRequestTenantId(value: unknown) {
|
|
121
100
|
if (!isDefaultTenant.value || value === undefined || value === null || value === "") return undefined;
|
|
122
101
|
const tenantId = Number(value);
|
|
123
|
-
|
|
124
|
-
// 允许全局时零值原样透传,由后端筛选全局策略。
|
|
125
|
-
if (tenantId === 0) return allowGlobal ? 0 : undefined;
|
|
126
|
-
return tenantId;
|
|
102
|
+
return Number.isFinite(tenantId) && tenantId > 0 ? tenantId : undefined;
|
|
127
103
|
}
|
|
128
104
|
|
|
129
105
|
function tenantFormField(options: TenantFormFieldOptions): ProFormField {
|
|
@@ -134,7 +110,6 @@ export function useTenantScope(): TenantScope {
|
|
|
134
110
|
component: "tenant-select",
|
|
135
111
|
props: (model: Record<string, any>) => ({
|
|
136
112
|
filterable: true,
|
|
137
|
-
...(options.includeGlobal ? { options: prependGlobalTenantOption(tenantOptions.value) } : {}),
|
|
138
113
|
...(options.disabledOnEdit ? { disabled: Boolean(model.id) } : {}),
|
|
139
114
|
...options.props
|
|
140
115
|
}),
|
|
@@ -145,7 +120,6 @@ export function useTenantScope(): TenantScope {
|
|
|
145
120
|
function tenantColumns(options: TenantColumnOptions): ColumnProps[] {
|
|
146
121
|
if (!isDefaultTenant.value) return [];
|
|
147
122
|
const prop = options.prop ?? "tenant_id";
|
|
148
|
-
const includeGlobal = options.includeGlobal === true;
|
|
149
123
|
return [
|
|
150
124
|
{
|
|
151
125
|
prop,
|
|
@@ -161,18 +135,11 @@ export function useTenantScope(): TenantScope {
|
|
|
161
135
|
: {
|
|
162
136
|
el: options.searchEl ?? "tenant-select",
|
|
163
137
|
key: options.searchKey ?? prop,
|
|
164
|
-
props: {
|
|
165
|
-
filterable: true,
|
|
166
|
-
...(includeGlobal ? { options: prependGlobalTenantOption(tenantOptions.value) } : {})
|
|
167
|
-
},
|
|
138
|
+
props: { filterable: true },
|
|
168
139
|
order: options.order ?? 1
|
|
169
140
|
},
|
|
170
|
-
enum: options.enum ??
|
|
171
|
-
render:
|
|
172
|
-
options.render ??
|
|
173
|
-
(scope =>
|
|
174
|
-
// 租户编号为零表示全局数据。
|
|
175
|
-
includeGlobal && Number(scope.row[prop]) === 0 ? t("common.field.tenant_global") : resolveTenantLabel(scope.row, prop))
|
|
141
|
+
enum: options.enum ?? requestTenantOptionData,
|
|
142
|
+
render: options.render ?? (scope => resolveTenantLabel(scope.row, prop))
|
|
176
143
|
}
|
|
177
144
|
];
|
|
178
145
|
}
|
|
@@ -182,8 +149,6 @@ export function useTenantScope(): TenantScope {
|
|
|
182
149
|
if (directLabel) return String(directLabel);
|
|
183
150
|
const value = row[field];
|
|
184
151
|
if (value === undefined || value === null || value === "") return "";
|
|
185
|
-
// 租户编号为零表示全局数据。
|
|
186
|
-
if (Number(value) === 0) return t("common.field.tenant_global");
|
|
187
152
|
const nameMap = new Map(options.map(item => [String(item.value), item.label] as const));
|
|
188
153
|
return nameMap.get(String(value)) ?? String(value);
|
|
189
154
|
}
|