Skip to content

Commit

Permalink
feat(frontend): 资源池增加统计视图、专用业务专用db改单选 TencentBlueKing#6519
Browse files Browse the repository at this point in the history
# Reviewed, transaction id: 17384
  • Loading branch information
JustaCattt committed Sep 4, 2024
1 parent b08a34c commit 9038ce2
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
13 changes: 0 additions & 13 deletions dbm-ui/frontend/src/services/source/dbresourceResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,6 @@ export function fetchMountPoints() {
return http.get<string[]>(`${path}/get_mountpoints/`);
}

/**
* 根据逻辑城市查询园区
*/
export function fetchSubzones(params: { citys: string[] }) {
return http.get<
ListBase<
{
citys: string[];
}[]
>
>(`${path}/get_subzones/`, params);
}

/**
* 资源池导入
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -93,7 +93,7 @@
mem: Mem,
disk: Disk,
disk_type: DiskType,
subzones: Subzones,
subzone_ids: SubzoneIds,
bk_cloud_ids: BkCloudIds,
spec_id: SpecId,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,25 @@

<template>
<BkSelect
:model-value="defaultValue"
collapse-tags
:model-value="localValue"
multiple
multiple-mode="tag"
show-select-all
@change="handleChange">
<BkOption
v-for="item in data"
:key="item">
{{ item }}
</BkOption>
:key="item.bk_sub_zone_id"
:label="item.bk_sub_zone"
:value="`${item.bk_sub_zone_id}`" />
</BkSelect>
</template>

<script setup lang="ts">
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<string, any>;
Expand All @@ -38,23 +42,28 @@
}

const props = defineProps<Props>();

const emits = defineEmits<Emits>();

defineOptions({
inheritAttrs: false,
});
const { data, run: fetchData } = useRequest(fetchSubzones, {

const localValue = ref<string[]>(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,
});
},
{
Expand All @@ -63,6 +72,7 @@
);

const handleChange = (value: Props['defaultValue']) => {
localValue.value = value as string[];
emits('change', value);
};
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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('机型'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@
name="disk_type"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'subzones')"
:ref="(el: any) => initInputRefCallback(el, 'subzone_ids')"
:model="localValueMemo"
name="subzones"
name="subzone_ids"
@change="handleChange" />
<ComFactory
:ref="(el: any) => initInputRefCallback(el, 'os_type')"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:value="item.city_code" />
</BkSelect>
<BkSelect
v-model="subzones"
v-model="subzoneIds"
collapse-tags
:disabled="!cityCode"
filterable
Expand All @@ -23,7 +23,7 @@
v-for="item in subzoneList"
:key="item.bk_sub_zone_id"
:label="item.bk_sub_zone"
:value="item.bk_sub_zone" />
:value="`${item.bk_sub_zone_id}`" />
</BkSelect>
</BkComposeFormItem>
</template>
Expand All @@ -43,7 +43,7 @@
interface Exposes {
getValue: () => {
city: string;
sub_zones: string[];
subzone_ids: string[];
};
}
Expand All @@ -53,7 +53,7 @@
default: '',
});
const subzones = defineModel<string[]>('subzones', {
const subzoneIds = defineModel<string[]>('subzoneIds', {
default: [],
});
Expand All @@ -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,
});
}
},
Expand All @@ -92,8 +95,8 @@
defineExpose<Exposes>({
getValue: () => ({
city: cityCode.value,
sub_zones: subzones.value,
city: cityCode.value === 'default' ? '' : cityCode.value,
subzone_ids: subzoneIds.value,
}),
});
</script>
Expand Down

0 comments on commit 9038ce2

Please sign in to comment.