Skip to content

Commit

Permalink
fix(frontend): 资源池主机列表交互优化 TencentBlueKing#8149
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 24766
  • Loading branch information
jinquantianxia committed Nov 25, 2024
1 parent 7d51cce commit 5d865bd
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
const isShowBatchSetting = ref(false);
const isShowImportHost = ref(false);
let searchParams = {};
let searchParams: Record<string, any> = {};
let selectionListWholeDataMemo: DbResourceModel[] = [];
const tableColumn = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@

<template>
<div class="resource-pool-search-box">
<KeepAlive>
<Component
:is="renderCom"
:key="renderKey"
v-model="searchParams"
@submit="handleSubmit" />
</KeepAlive>
<Component
:is="renderCom"
:key="renderKey"
v-model="searchParams"
@submit="handleSubmit" />
<div
class="toggle-btn"
@click="handleToggle">
Expand All @@ -28,6 +26,7 @@
</div>
</template>
<script setup lang="ts">
import _ from 'lodash';
import { computed, onMounted, ref } from 'vue';
import fieldConfig from './components/field-config';
Expand Down Expand Up @@ -57,6 +56,8 @@
const renderCom = computed(() => comMap[renderStatus.value]);
let localSearchParams: Record<string, any> = {};
// 切换搜索展示样式
const handleToggle = () => {
renderStatus.value = renderStatus.value === 'input' ? 'tag' : 'input';
Expand Down Expand Up @@ -107,7 +108,14 @@
return acc;
}, {});
if (
localSearchParams.resource_type &&
searchParams.value?.resource_type &&
localSearchParams.resource_type !== searchParams.value.resource_type
) {
delete params.spec_id;
}
localSearchParams = _.cloneDeep(params);
emits('change', params);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,21 @@

<template>
<BkSelect
display-key="display_name"
enable-virtual-render
filterable
id-key="bk_biz_id"
:input-search="false"
:list="bizList"
:model-value="defaultValue"
:placeholder="t('请选择所属业务')"
show-selected-icon
@change="handleChange">
<BkOption
<!-- <BkOption
v-for="bizItem in bizList"
:key="bizItem.bk_biz_id"
:label="bizItem.display_name"
:value="bizItem.bk_biz_id" />
:value="bizItem.bk_biz_id" /> -->
<template
v-if="simple"
#extension>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
<BkSelect
v-model="currentDbType"
:clearable="false"
:disabled="isDbTypeDisabled"
filterable
:input-search="false"
style="width: 150px"
Expand Down Expand Up @@ -102,8 +101,6 @@
const currentMachine = ref('');
const clusterMachineList = shallowRef<InfoItem['machineList']>([]);
const isDbTypeDisabled = computed(() => props.model.resource_type && props.model.resource_type !== 'PUBLIC');
const { loading: isResourceSpecLoading, run: fetchResourceSpecDetail } = useRequest(getResourceSpec, {
manual: true,
onSuccess(data) {
Expand Down Expand Up @@ -157,14 +154,13 @@
() => props.model,
() => {
const dbType = props.model.resource_type;
if (dbType && currentDbType.value && dbType !== currentDbType.value && dbType !== 'PUBLIC') {
if (dbType && dbType !== currentDbType.value) {
currentDbType.value = dbType;
clusterMachineList.value = DBTypeInfos[dbType as DBTypes]?.machineList || [];
currentMachine.value = '';
defaultValue.value = '';
return;
}
defaultValue.value = props.model.spec_id;
},
{
immediate: true,
Expand All @@ -182,6 +178,10 @@
emits('change', value);
};
onMounted(() => {
defaultValue.value = props.model.spec_id || '';
});
defineExpose<Expose>({
reset() {
rerenderKey.value = Date.now();
Expand Down

0 comments on commit 5d865bd

Please sign in to comment.