Skip to content

Commit 1551b60

Browse files
fix: 多租户体验提单汇总修复 (#2781)
1 parent f88e575 commit 1551b60

25 files changed

Lines changed: 247 additions & 170 deletions

File tree

webfe/package_vue/src/components/deploy/deploy-log-sideslider.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<div style="float: left">
1414
<template v-if="isMultiTenantDisplayMode">
1515
<span>{{ historySideslider.titlePrefix }}</span>
16-
<bk-user-display-name :user-id="historySideslider.operator"></bk-user-display-name>
16+
<UserDisplay :value="historySideslider.operator" />
1717
<span>{{ historySideslider.titleSuffix }}</span>
1818
</template>
1919
<span v-else>{{ historySideslider.title }}</span>
@@ -85,11 +85,13 @@
8585

8686
<script>
8787
import deployTimeline from './deploy-timeline';
88+
import UserDisplay from '@/components/user/user-display.vue';
8889
import { mapGetters } from 'vuex';
8990
9091
export default {
9192
components: {
9293
deployTimeline,
94+
UserDisplay,
9395
},
9496
props: {
9597
appCode: {

webfe/package_vue/src/components/paas-header.vue

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,7 @@
139139
>
140140
<div class="header-user is-left ps-head-last">
141141
<!-- 多租户展示 -->
142-
<span v-if="isMultiTenantDisplayMode">
143-
<bk-user-display-name :user-id="user.username"></bk-user-display-name>
144-
</span>
145-
<template v-else>{{ user.chineseName || user.username }}</template>
142+
<UserDisplay :value="user.username" :fallback="user.chineseName || user.username" />
146143
<i class="bk-icon icon-down-shape" />
147144
</div>
148145
<template #content>
@@ -175,12 +172,14 @@ import logVersion from './log-version.vue';
175172
import { ajaxRequest, uuid } from '@/common/utils';
176173
import logoSvg from '@static/images/logo.svg';
177174
import globalInput from './global-search/search-input.vue';
175+
import UserDisplay from '@/components/user/user-display.vue';
178176
import { mapState, mapGetters } from 'vuex';
179177
180178
export default {
181179
components: {
182180
logVersion,
183181
globalInput,
182+
UserDisplay,
184183
},
185184
mixins: [psHeaderInfo, selectEventMixin],
186185
props: [],

webfe/package_vue/src/components/user/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
apiBaseUrl() {
108108
// 多租户模式
109109
if (this.isMultiTenantDisplayMode) {
110-
return window.BK_API_URL_TMPL?.replace('{api_name}', 'bk-user-web');
110+
return window.BK_API_URL_TMPL?.replace('{api_name}', 'bk-user-web/prod');
111111
}
112112
// 上云版
113113
const baseUrl = window.BK_API_URL_TMPL;
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
<template>
2+
<span class="user-display-wrapper">
3+
<!-- 多租户模式:使用 bk-user-display-name 渲染 -->
4+
<template v-if="isMultiTenantDisplayMode && hasUserIds">
5+
<!-- 单个用户 -->
6+
<bk-user-display-name v-if="isSingle" :user-id="value" />
7+
<!-- 多个用户 -->
8+
<template v-else-if="isArray">
9+
<span v-for="(item, index) in value" :key="item" class="user-display-item">
10+
<bk-user-display-name :user-id="item" />
11+
<span v-if="index < value.length - 1" class="user-display-sep">{{ separator }}</span>
12+
</span>
13+
</template>
14+
<!-- 对象 -->
15+
<bk-user-display-name v-else-if="isObject" :user-id="displayId" />
16+
</template>
17+
18+
<!-- 非多租户模式 / 无有效数据:显示纯文本 -->
19+
<template v-else>{{ plainText }}</template>
20+
</span>
21+
</template>
22+
23+
<script>
24+
import { mapGetters } from 'vuex';
25+
26+
export default {
27+
name: 'UserDisplay',
28+
props: {
29+
/**
30+
* 用户数据,支持三种类型:
31+
* - String: 单个用户 ID,如 'admin'
32+
* - Array: 用户 ID 数组,如 ['admin', 'test']
33+
* - Object: 用户对象,如 { username: 'admin', display_name: '管理员' }
34+
*/
35+
value: {
36+
type: [String, Array, Object],
37+
default: '',
38+
},
39+
/**
40+
* 非多租户模式下的自定义回退文本,优先级高于 value
41+
* 适用场景:如 paas-header 中 user.chineseName || user.username
42+
*/
43+
fallback: {
44+
type: String,
45+
default: undefined,
46+
},
47+
/** 空值时的占位文本 */
48+
emptyText: {
49+
type: String,
50+
default: '--',
51+
},
52+
/** 数组分隔符 */
53+
separator: {
54+
type: String,
55+
default: '\uff0c',
56+
},
57+
/** 对象类型时取哪个字段作为显示文本(非多租户模式) */
58+
displayField: {
59+
type: String,
60+
default: 'username',
61+
},
62+
/** 对象类型时取哪个字段作为 user-id(多租户模式) */
63+
idField: {
64+
type: String,
65+
default: 'username',
66+
},
67+
},
68+
computed: {
69+
...mapGetters(['isMultiTenantDisplayMode']),
70+
71+
/** 值类型判断 */
72+
isSingle() {
73+
return typeof this.value === 'string';
74+
},
75+
isArray() {
76+
return Array.isArray(this.value);
77+
},
78+
isObject() {
79+
return this.value !== null && typeof this.value === 'object' && !Array.isArray(this.value);
80+
},
81+
82+
/** 是否存在有效的用户 ID(用于决定是否走多租户渲染) */
83+
hasUserIds() {
84+
if (this.isSingle) return !!this.value;
85+
if (this.isArray) return this.value.length > 0;
86+
if (this.isObject) return !!this.displayId;
87+
return false;
88+
},
89+
90+
/** 对象类型:多租户模式使用的 user-id */
91+
displayId() {
92+
return this.isObject ? (this.value[this.idField] || '') : '';
93+
},
94+
95+
/**
96+
* 非多租户模式下的纯文本
97+
* 优先级: fallback > 类型对应的文本 > emptyText
98+
*/
99+
plainText() {
100+
if (this.fallback !== undefined) return this.fallback;
101+
if (this.isSingle) return this.value || this.emptyText;
102+
if (this.isArray) {
103+
const joined = this.value.filter(Boolean).join(this.separator);
104+
return joined || this.emptyText;
105+
}
106+
if (this.isObject) {
107+
return this.value[this.displayField] || this.emptyText;
108+
}
109+
return this.emptyText;
110+
},
111+
},
112+
};
113+
</script>
114+
115+
<style scoped>
116+
.user-display-wrapper {
117+
display: inline;
118+
}
119+
.user-display-item {
120+
display: inline;
121+
}
122+
</style>

webfe/package_vue/src/language/lang/en.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,11 +292,8 @@ export default {
292292
批量删除成功: 'Batch delete successfully',
293293
'批量删除失败:': 'Batch delete failed: ',
294294
结果: 'Result',
295-
'申请人IP:': 'Applicant IP: ',
296-
'审批人:': 'Approver: ',
297-
'业务接口人:': 'Business interface person: ',
298-
'添加原因:': 'Reason for adding: ',
299-
'有效时间:': 'Effective time: ',
295+
申请人IP: 'Applicant IP',
296+
业务接口人: 'Business interface person',
300297
申请人: 'Applicant',
301298
公司: 'Company',
302299
业务: 'Business',

webfe/package_vue/src/language/lang/zh.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -281,11 +281,8 @@ export default {
281281
批量删除成功: '批量删除成功',
282282
'批量删除失败:': '批量删除失败:',
283283
结果: '结果',
284-
'申请人IP:': '申请人IP:',
285-
'审批人:': '审批人:',
286-
'业务接口人:': '业务接口人:',
287-
'添加原因:': '添加原因:',
288-
'有效时间:': '有效时间:',
284+
申请人IP: '申请人IP',
285+
业务接口人: '业务接口人',
289286
申请人: '申请人',
290287
公司: '公司',
291288
业务: '业务',

webfe/package_vue/src/views/dev-center/app/access-ctl/done-order.vue

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,23 @@
4747
class="detail-box"
4848
>
4949
<li>
50-
<span class="key"> {{ $t('申请人IP:') }} </span>
50+
<span class="key"> {{ `${$t('申请人IP')}:` }} </span>
5151
<pre class="value">{{ subProps.ip || '--' }}</pre>
5252
</li>
5353
<li>
54-
<span class="key"> {{ $t('审批人:') }} </span>
55-
<pre class="value">{{ subProps.auditor.username || '--' }}</pre>
54+
<span class="key"> {{ `${$t('审批人')}:` }} </span>
55+
<pre class="value"><UserDisplay :value="subProps.auditor.username"></UserDisplay></pre>
5656
</li>
5757
<li>
58-
<span class="key"> {{ $t('业务接口人:') }} </span>
58+
<span class="key"> {{ `${$t('业务接口人')}:` }} </span>
5959
<pre class="value">{{ subProps.business_interface_user || '--' }}</pre>
6060
</li>
6161
<li>
62-
<span class="key"> {{ $t('添加原因:') }} </span>
62+
<span class="key"> {{ `${$t('添加原因')}:` }} </span>
6363
<pre class="value">{{ subProps.reason || '--' }}</pre>
6464
</li>
6565
<li>
66-
<span class="key"> {{ $t('有效时间:') }} </span>
66+
<span class="key">{{ `${$t('有效时间')}:` }}</span>
6767
<pre class="value">{{ subProps.expires || '--' }}</pre>
6868
</li>
6969
</ul>
@@ -126,7 +126,9 @@
126126
<script>
127127
import appBaseInfoMixin from '@/mixins/app-base-mixin';
128128
import { bus } from '@/common/bus';
129+
import UserDisplay from '@/components/user/user-display.vue';
129130
export default {
131+
components: { UserDisplay },
130132
mixins: [appBaseInfoMixin],
131133
data () {
132134
return {

webfe/package_vue/src/views/dev-center/app/access-ctl/processing-order.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,19 @@
4747
class="detail-box"
4848
>
4949
<li>
50-
<span class="key"> {{ $t('申请人IP:') }} </span>
50+
<span class="key"> {{ `${$t('申请人IP')}:` }} </span>
5151
<pre class="value">{{ subProps.ip || '--' }}</pre>
5252
</li>
5353
<li>
54-
<span class="key"> {{ $t('业务接口人') }} </span>
54+
<span class="key"> {{ $t('业务接口人') }} </span>
5555
<pre class="value">{{ subProps.business_interface_user || '--' }}</pre>
5656
</li>
5757
<li>
58-
<span class="key"> {{ $t('添加原因:') }} </span>
58+
<span class="key"> {{ `${$t('添加原因')}:` }} </span>
5959
<pre class="value">{{ subProps.reason || '--' }}</pre>
6060
</li>
6161
<li>
62-
<span class="key"> {{ $t('有效时间:') }} </span>
62+
<span class="key">{{ `${$t('有效时间')}:` }}</span>
6363
<pre class="value">{{ subProps.expires || '--' }}</pre>
6464
</li>
6565
</ul>

webfe/package_vue/src/views/dev-center/app/basic-config/cloud-api/comps/apply-record.vue

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@
8585
:render-header="$renderHeader"
8686
>
8787
<template slot-scope="{ row }">
88-
<bk-user-display-name
89-
v-if="isMultiTenantDisplayMode"
90-
:user-id="row.applied_by"
91-
></bk-user-display-name>
92-
<span v-else>{{ row.applied_by }}</span>
88+
<UserDisplay :value="row.applied_by"></UserDisplay>
9389
</template>
9490
</bk-table-column>
9591
<bk-table-column
@@ -136,16 +132,7 @@
136132
:show-overflow-tooltip="true"
137133
>
138134
<template slot-scope="{ row }">
139-
<template v-if="isMultiTenantDisplayMode">
140-
<span
141-
v-for="userId in row.handled_by"
142-
:key="userId"
143-
>
144-
<bk-user-display-name :user-id="userId"></bk-user-display-name>
145-
<span>,</span>
146-
</span>
147-
</template>
148-
<template v-else>{{ getHandleBy(row.handled_by) }}</template>
135+
<UserDisplay :value="row.handled_by"></UserDisplay>
149136
</template>
150137
</bk-table-column>
151138
<bk-table-column
@@ -230,7 +217,11 @@
230217
class="value"
231218
:style="field.isTextarea ? 'line-height: 22px; padding-top: 10px' : ''"
232219
>
233-
{{ field.value || '--' }}
220+
<UserDisplay
221+
v-if="field.isUserDisplay"
222+
:value="field.value"
223+
></UserDisplay>
224+
<template v-else>{{ field.value || '--' }}</template>
234225
<bk-button
235226
v-if="
236227
field.isApplyStatus && isMcpService && curRecord.apply_status === 'pending' && curRecord?.approval_url
@@ -316,8 +307,10 @@
316307
import moment from 'moment';
317308
import { mapState, mapGetters } from 'vuex';
318309
import { copy } from '@/common/tools';
310+
import UserDisplay from '@/components/user/user-display.vue';
319311
320312
export default {
313+
components: { UserDisplay },
321314
props: {
322315
typeList: {
323316
type: Array,
@@ -525,6 +518,7 @@ export default {
525518
label: this.$t('申请人'),
526519
value: this.curRecord.applied_by,
527520
show: true,
521+
isUserDisplay: true,
528522
},
529523
];
530524
// 授权维度(非组件API才显示)
@@ -560,8 +554,9 @@ export default {
560554
},
561555
{
562556
label: this.$t('审批人'),
563-
value: this.getHandleBy(this.curRecord.handled_by),
557+
value: this.curRecord.handled_by,
564558
show: true,
559+
isUserDisplay: true,
565560
},
566561
{
567562
label: this.$t('审批时间'),

webfe/package_vue/src/views/dev-center/app/basic-config/members.vue

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,7 @@
9292
@error="handleAvatarError($event, row)"
9393
/>
9494
</span>
95-
<bk-user-display-name
96-
:user-id="row.user.username"
97-
v-if="isMultiTenantDisplayMode"
98-
></bk-user-display-name>
99-
<span v-else>{{ row.user.username }}</span>
95+
<UserDisplay :value="row.user.username" />
10096
</div>
10197
</template>
10298
</bk-table-column>
@@ -197,19 +193,11 @@
197193
>
198194
<span>{{ $t('删除成员') }}</span>
199195
&nbsp;
200-
<bk-user-display-name
201-
:user-id="selectedMember.name"
202-
v-if="isMultiTenantDisplayMode"
203-
></bk-user-display-name>
204-
<span v-else>{{ selectedMember.name }}</span>
196+
<UserDisplay :value="selectedMember.name" />
205197
</div>
206198
<div>
207199
{{ $t('用户') }}
208-
<bk-user-display-name
209-
:user-id="selectedMember.name"
210-
v-if="isMultiTenantDisplayMode"
211-
></bk-user-display-name>
212-
<span v-else>{{ selectedMember.name }}</span>
200+
<UserDisplay :value="selectedMember.name" />
213201
{{ $t('将失去此应用的对应权限,是否确定删除?') }}
214202
</div>
215203
</bk-dialog>
@@ -237,6 +225,7 @@ import auth from '@/auth';
237225
import appBaseMixin from '@/mixins/app-base-mixin';
238226
import user from '@/components/user';
239227
import CustomRadioCapsule from '@/components/custom-radio-capsule';
228+
import UserDisplay from '@/components/user/user-display.vue';
240229
import { mapState, mapGetters } from 'vuex';
241230
import { paginationFun } from '@/common/utils';
242231
import MembersSideslider from './members-sideslider.vue';
@@ -258,6 +247,7 @@ export default {
258247
user,
259248
CustomRadioCapsule,
260249
MembersSideslider,
250+
UserDisplay,
261251
},
262252
mixins: [appBaseMixin],
263253
data() {

0 commit comments

Comments
 (0)