Skip to content

Commit

Permalink
fix: 调整业务列表组件
Browse files Browse the repository at this point in the history
  • Loading branch information
goodGai committed Jan 17, 2025
1 parent e942e64 commit ec840d6
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 39 deletions.
44 changes: 24 additions & 20 deletions bkmonitor/webpack/src/monitor-pc/components/biz-select/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@
import { Component, Emit, Prop, Mixins } from 'vue-property-decorator';
import { Component as tsc } from 'vue-tsx-support';

import store from '../../store/store';

import { SPACE_TYPE_MAP } from '../../common/constant';
import UserConfigMixin from '../../mixins/userStoreConfig';
import store from '../../store/store';

import type { ThemeType } from './biz-select';

Expand All @@ -39,6 +38,7 @@ interface IProps {
list: IListItem[];
checked?: number;
theme?: ThemeType;
canSetDefaultSpace?: boolean;
}
interface IEvents {
onSelected: number;
Expand Down Expand Up @@ -72,6 +72,8 @@ const DEFAULT_BIZ_ID = 'DEFAULT_BIZ_ID';
export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>) {
/** 选中的id */
@Prop({ type: Number }) checked: number;
/** 可设置默认空间 */
@Prop({ default: true, type: Boolean }) canSetDefaultSpace: boolean;
/** 列表数据 */
@Prop({ default: () => [], type: Array }) list: IListItem[];
/** 主题 */
Expand Down Expand Up @@ -171,7 +173,7 @@ export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>)
>
({child.space_type_id === ETagsType.BKCC ? `#${child.id}` : child.space_id || child.space_code})
</span>
{this.defaultBizId && Number(this.defaultBizId) === child.id && (
{this.canSetDefaultSpace && this.defaultBizId && Number(this.defaultBizId) === child.id && (
<span class='item-default-icon'>
<span class='item-default-text'>{this.$tc('默认')}</span>
</span>
Expand All @@ -190,23 +192,25 @@ export default class List extends Mixins(UserConfigMixin, tsc<IProps, IEvents>)
))}
</span>
)}
<div class='set-default-button'>
{this.defaultBizId && Number(this.defaultBizId) === child.id ? (
<div
class={`btn-style-${this.theme} remove`}
onClick={e => this.handleDefaultBizIdDialog(e, child, false)}
>
{this.$tc('取消默认')}
</div>
) : (
<div
class={`btn-style-${this.theme}`}
onClick={e => this.handleDefaultBizIdDialog(e, child, true)}
>
{this.$tc('设为默认')}
</div>
)}
</div>
{this.canSetDefaultSpace && (
<div class='set-default-button'>
{this.defaultBizId && Number(this.defaultBizId) === child.id ? (
<div
class={`btn-style-${this.theme} remove`}
onClick={e => this.handleDefaultBizIdDialog(e, child, false)}
>
{this.$tc('取消默认')}
</div>
) : (
<div
class={`btn-style-${this.theme}`}
onClick={e => this.handleDefaultBizIdDialog(e, child, true)}
>
{this.$tc('设为默认')}
</div>
)}
</div>
)}
</div>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,6 @@ import './home-biz-list.scss';

/** 业务组件常用的业务缓存key */
const BIZ_SELECTOR_COMMON_IDS = 'BIZ_SELECTOR_COMMON_IDS';
/** 业务组件常用业务缓存最大个数 */
const BIZ_SELECTOR_COMMON_MAX = 5;
const BIZ_COLOR_LIST = [
'#7250A9',
'#3563BE',
'#3799BA',
'#4FB17F',
'#86AF4A',
'#E9AE1D',
'#EB9258',
'#D36C68',
'#BC4FB3',
];

interface IProps {
zIndex?: number;
Expand Down Expand Up @@ -106,11 +93,11 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
limit: number;
data: IListItem[];
} = {
current: 1,
count: 0,
limit: 20,
data: [],
};
current: 1,
count: 0,
limit: 20,
data: [],
};

typeWrapInfo = {
showBtn: false,
Expand Down Expand Up @@ -379,7 +366,6 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
}

render() {
console.log('= = = >', this.bizListFilter);
return (
<div class={['new-biz-select-wrap', this.theme]}>
<bk-popover
Expand Down Expand Up @@ -467,6 +453,7 @@ export default class HomeBizSelect extends tsc<IProps, IEvents> {
onScroll={this.handleScroll}
>
<List
canSetDefaultSpace={false}
list={this.bizListFilter}
theme={this.theme}
onSelected={this.handleBizChange}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import 'monitor-pc/theme/mixin.scss';

.recent-content {
display: flex;
flex-wrap: wrap;
Expand Down Expand Up @@ -138,6 +140,7 @@
color: #979BA5;
text-align: right;
letter-spacing: 0;
@include ellipsis;
}

&:last-child {
Expand Down

0 comments on commit ec840d6

Please sign in to comment.