diff --git a/dbm-ui/frontend/src/services/source/dbresourceResource.ts b/dbm-ui/frontend/src/services/source/dbresourceResource.ts index 4ff09bd8b1..972093939d 100644 --- a/dbm-ui/frontend/src/services/source/dbresourceResource.ts +++ b/dbm-ui/frontend/src/services/source/dbresourceResource.ts @@ -51,19 +51,6 @@ export function fetchMountPoints() { return http.get(`${path}/get_mountpoints/`); } -/** - * 根据逻辑城市查询园区 - */ -export function fetchSubzones(params: { citys: string[] }) { - return http.get< - ListBase< - { - citys: string[]; - }[] - > - >(`${path}/get_subzones/`, params); -} - /** * 资源池导入 */ diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/Index.vue index 974ec9228b..5b36245baa 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/Index.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/Index.vue @@ -57,7 +57,7 @@ import OSType from './components/OSType.vue'; import ResourceType from './components/ResourceType.vue'; import SpecId from './components/SpecId.vue'; - import Subzones from './components/Subzones.vue'; + import SubzoneIds from './components/SubzoneIds.vue'; interface Props { name: string; @@ -93,7 +93,7 @@ mem: Mem, disk: Disk, disk_type: DiskType, - subzones: Subzones, + subzone_ids: SubzoneIds, bk_cloud_ids: BkCloudIds, spec_id: SpecId, }; diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/Subzones.vue b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/SubzoneIds.vue similarity index 72% rename from dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/Subzones.vue rename to dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/SubzoneIds.vue index 70fd2819e0..7f2ef9c8d8 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/Subzones.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/SubzoneIds.vue @@ -13,13 +13,17 @@ @@ -27,7 +31,7 @@ import { watch } from 'vue'; import { useRequest } from 'vue-request'; - import { fetchSubzones } from '@services/source/dbresourceResource'; + import { getInfrasSubzonesByCity } from '@services/source/infras'; interface Props { model: Record; @@ -38,23 +42,28 @@ } const props = defineProps(); + const emits = defineEmits(); + defineOptions({ inheritAttrs: false, }); - const { data, run: fetchData } = useRequest(fetchSubzones, { + + const localValue = ref(props.defaultValue || []); + + const { data, run: fetchData } = useRequest(getInfrasSubzonesByCity, { initialData: [], manual: true, + onSuccess() { + localValue.value = []; + }, }); watch( - () => props.model, + () => props.model.city, () => { - if (!props.model.city) { - return; - } fetchData({ - citys: props.model.city, + city_code: props.model.city, }); }, { @@ -63,6 +72,7 @@ ); const handleChange = (value: Props['defaultValue']) => { + localValue.value = value as string[]; emits('change', value); }; diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-config.ts b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-config.ts index 269f6e1c54..5ad7fd0151 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-config.ts +++ b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-config.ts @@ -14,9 +14,9 @@ import _ from 'lodash'; import { getBizs } from '@services/source/cmdb'; -import { fetchMountPoints, fetchSubzones } from '@services/source/dbresourceResource'; +import { fetchMountPoints } from '@services/source/dbresourceResource'; import { getResourceSpec } from '@services/source/dbresourceSpec'; -import { fetchDbTypeList, getInfrasCities } from '@services/source/infras'; +import { fetchDbTypeList, getInfrasCities, getInfrasSubzonesByCity } from '@services/source/infras'; import { getCloudList } from '@services/source/ipchooser'; import { ipv4 } from '@common/regex'; @@ -90,10 +90,10 @@ export default { return undefined; }, }, - subzones: { + subzone_ids: { label: t('园区'), - component: 'subzones', - service: fetchSubzones, + component: 'subzone_ids', + service: getInfrasSubzonesByCity, }, device_class: { label: t('机型'), diff --git a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-input/Index.vue b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-input/Index.vue index 68189f9e4d..c98eabdbdb 100644 --- a/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-input/Index.vue +++ b/dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/field-input/Index.vue @@ -83,9 +83,9 @@ name="disk_type" @change="handleChange" /> + :value="`${item.bk_sub_zone_id}`" /> @@ -43,7 +43,7 @@ interface Exposes { getValue: () => { city: string; - sub_zones: string[]; + subzone_ids: string[]; }; } @@ -53,7 +53,7 @@ default: '', }); - const subzones = defineModel('subzones', { + const subzoneIds = defineModel('subzoneIds', { default: [], }); @@ -67,17 +67,20 @@ citiyList.value = cloneData; }, }); - const { data: subzoneList, run: fetchSubzones } = useRequest(getInfrasSubzonesByCity, { + const { data: subzoneList, run: fetchData } = useRequest(getInfrasSubzonesByCity, { initialData: [], manual: true, + onSuccess() { + subzoneIds.value = []; + }, }); watch( cityCode, () => { if (cityCode.value) { - fetchSubzones({ - city_code: cityCode.value, + fetchData({ + city_code: cityCode.value === 'default' ? '' : cityCode.value, }); } }, @@ -92,8 +95,8 @@ defineExpose({ getValue: () => ({ - city: cityCode.value, - sub_zones: subzones.value, + city: cityCode.value === 'default' ? '' : cityCode.value, + subzone_ids: subzoneIds.value, }), });