From 9038ce2b1156ba050d998cd64ff5d94883b74943 Mon Sep 17 00:00:00 2001 From: chenwenchang <479999519@qq.com> Date: Wed, 4 Sep 2024 14:47:59 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E8=B5=84=E6=BA=90=E6=B1=A0?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=BB=9F=E8=AE=A1=E8=A7=86=E5=9B=BE=E3=80=81?= =?UTF-8?q?=E4=B8=93=E7=94=A8=E4=B8=9A=E5=8A=A1=E4=B8=93=E7=94=A8db?= =?UTF-8?q?=E6=94=B9=E5=8D=95=E9=80=89=20#6519=20#=20Reviewed,=20transacti?= =?UTF-8?q?on=20id:=2017384?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/services/source/dbresourceResource.ts | 13 -------- .../components/com-factory/Index.vue | 4 +-- .../{Subzones.vue => SubzoneIds.vue} | 32 ++++++++++++------- .../search-box/components/field-config.ts | 10 +++--- .../components/field-input/Index.vue | 4 +-- .../search-box/components/Region.vue | 21 ++++++------ 6 files changed, 42 insertions(+), 42 deletions(-) rename dbm-ui/frontend/src/views/resource-manage/pool/host-list/components/search-box/components/com-factory/components/{Subzones.vue => SubzoneIds.vue} (72%) 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, }), });