From c4ed1b10350af1d696b3e031c99d7709c2ca973c Mon Sep 17 00:00:00 2001 From: austinqli <1344583166@qq.com> Date: Thu, 11 Jan 2024 16:39:14 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E9=9B=86=E7=BE=A4=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=99=A8=E6=96=B0=E5=A2=9E=E5=B7=B2=E7=A6=81=E7=94=A8?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=E4=B8=8Emongodb=E7=B1=BB=E5=9E=8B=20#3004=20?= =?UTF-8?q?#=20Reviewed,=20transaction=20id:=201848?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/cluster-selector-new/Index.vue | 38 +- .../common/result-preview/CollapseMini.vue | 4 +- .../components/mongo/Index.vue | 353 ++++++++++++++++++ .../components/mongo/useClusterData.ts | 106 ++++++ .../components/redis/Index.vue | 63 ++-- .../components/tendb-cluster/Index.vue | 58 ++- .../components/tendbha/Index.vue | 58 ++- .../dropdown-export-excel/index.vue | 2 +- dbm-ui/frontend/src/locales/zh-cn.json | 15 +- .../services/model/mongodb/mongodb-detail.ts | 200 ++++++++++ .../model/mongodb/mongodb-instance-detail.ts | 4 +- .../model/mongodb/mongodb-instance.ts | 10 +- .../src/services/model/mongodb/mongodb.ts | 109 ++++++ .../frontend/src/services/source/mongodb.ts | 129 +++++++ .../src/services/source/mongodbInstance.ts | 64 ---- .../detail/components/BaseInfo.vue | 4 +- .../mongodb-instance/detail/index.vue | 4 +- .../mongodb-instance/list/index.vue | 14 +- 18 files changed, 1082 insertions(+), 153 deletions(-) create mode 100644 dbm-ui/frontend/src/components/cluster-selector-new/components/mongo/Index.vue create mode 100644 dbm-ui/frontend/src/components/cluster-selector-new/components/mongo/useClusterData.ts create mode 100644 dbm-ui/frontend/src/services/model/mongodb/mongodb-detail.ts create mode 100644 dbm-ui/frontend/src/services/model/mongodb/mongodb.ts create mode 100644 dbm-ui/frontend/src/services/source/mongodb.ts delete mode 100644 dbm-ui/frontend/src/services/source/mongodbInstance.ts diff --git a/dbm-ui/frontend/src/components/cluster-selector-new/Index.vue b/dbm-ui/frontend/src/components/cluster-selector-new/Index.vue index 8f5d25296a..d679447ab9 100644 --- a/dbm-ui/frontend/src/components/cluster-selector-new/Index.vue +++ b/dbm-ui/frontend/src/components/cluster-selector-new/Index.vue @@ -120,16 +120,14 @@ - + diff --git a/dbm-ui/frontend/src/components/cluster-selector-new/components/mongo/useClusterData.ts b/dbm-ui/frontend/src/components/cluster-selector-new/components/mongo/useClusterData.ts new file mode 100644 index 0000000000..7c435bb92b --- /dev/null +++ b/dbm-ui/frontend/src/components/cluster-selector-new/components/mongo/useClusterData.ts @@ -0,0 +1,106 @@ +/* + * TencentBlueKing is pleased to support the open source community by making 蓝鲸智云-DB管理系统(BlueKing-BK-DBM) available. + * + * Copyright (C) 2017-2023 THL A29 Limited, a Tencent company. All rights reserved. + * + * Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. + * You may obtain a copy of the License at https://opensource.org/licenses/MIT + * + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed + * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for + * the specific language governing permissions and limitations under the License. +*/ + +import type { ISearchValue } from 'bkui-vue/lib/search-select/utils'; +import { + type ComponentInternalInstance, + getCurrentInstance, + reactive, + ref, + shallowRef, +} from 'vue'; + +import { useGlobalBizs } from '@stores'; + +import { getSearchSelectorParams } from '@utils'; + +/** + * 处理集群列表数据 + */ +export function useClusterData() { + const globalBizsStore = useGlobalBizs(); + const currentInstance = getCurrentInstance() as ComponentInternalInstance & { + proxy: { + activeTab: string, + getResourceList: (params: any) => Promise + } + }; + + const isLoading = ref(false); + const tableData = shallowRef([]); + const isAnomalies = ref(false); + const pagination = reactive({ + current: 1, + count: 0, + limit: 10, + small: true, + }); + const searchSelectValue = ref([]); + + watch(searchSelectValue, () => { + setTimeout(() => { + handleChangePage(1); + }); + }, { + immediate: true, + deep: true, + }); + + /** + * 获取列表 + */ + const fetchResources = async () => { + isLoading.value = true; + return currentInstance.proxy.getResourceList({ + bk_biz_id: globalBizsStore.currentBizId, + cluster_type: currentInstance.proxy.activeTab, + limit: pagination.limit, + offset: pagination.limit * (pagination.current - 1), + ...getSearchSelectorParams(searchSelectValue.value), + }) + .then((res) => { + pagination.count = res.count; + tableData.value = res.results; + isAnomalies.value = false; + }) + .catch(() => { + tableData.value = []; + pagination.count = 0; + isAnomalies.value = true; + }) + .finally(() => { + isLoading.value = false; + }); + }; + + const handleChangePage = (value: number) => { + pagination.current = value; + return fetchResources(); + }; + + const handeChangeLimit = (value: number) => { + pagination.limit = value; + return handleChangePage(1); + }; + + return { + isLoading, + data: tableData, + pagination, + isAnomalies, + searchSelectValue, + fetchResources, + handleChangePage, + handeChangeLimit, + }; +} diff --git a/dbm-ui/frontend/src/components/cluster-selector-new/components/redis/Index.vue b/dbm-ui/frontend/src/components/cluster-selector-new/components/redis/Index.vue index f58860534b..317fb7cf20 100644 --- a/dbm-ui/frontend/src/components/cluster-selector-new/components/redis/Index.vue +++ b/dbm-ui/frontend/src/components/cluster-selector-new/components/redis/Index.vue @@ -90,9 +90,25 @@ /> ), render: ({ data }: { data: ResourceItem }) => { + if (data.phase === 'offline') { + return ( + + {{ + default: () => , + content: () => {t('集群已禁用')}, + }} + + ); + } if (props.disabledRowConfig && props.disabledRowConfig.handler(data)) { return ( - + {{ default: () => , content: () => {props.disabledRowConfig?.tip}, @@ -117,14 +133,23 @@ render: ({ data }: { data: ResourceItem }) => (
{data.master_domain}
- {data.operations && data.operations.length > 0 && - {{ - default: () => {data.operations.length}, - content: () => , - }} - } + {data.phase === 'offline' && ( + + )} + {data.operations && data.operations.length > 0 && ( + + {{ + default: () => {data.operations.length}, + content: () => , + }} + + )}
), }, { @@ -142,11 +167,6 @@ field: 'cluster_name', showOverflowTooltip: true, }, - // { - // label: t('所属模块'), - // field: 'db_module_name', - // showOverflowTooltip: true, - // }, { label: t('管控区域'), field: 'bk_cloud_name', @@ -214,7 +234,6 @@ watch(() => activeTab.value, (tab) => { if (tab) { searchSelectValue.value = []; - handleTablePageChange(1); } }); @@ -232,7 +251,9 @@ return; } for (const data of tableData.value) { - handleSelecteRow(data, value); + if (data.phase !== 'offline') { + handleSelecteRow(data, value); + } } }; @@ -276,7 +297,7 @@ }; const handleRowClick = (row:any, data: ResourceItem) => { - if (props.disabledRowConfig && props.disabledRowConfig.handler(data)) { + if ((props.disabledRowConfig && props.disabledRowConfig.handler(data)) || data.phase === 'offline') { return; } const currentSelected = selectedMap.value[activeTab.value]; @@ -285,19 +306,19 @@ }; - function handleTablePageChange(value: number) { + const handleTablePageChange = (value: number) => { handleChangePage(value) .then(() => { checkSelectedAll(); }); - } + }; - function handleTableLimitChange(value: number) { + const handleTableLimitChange = (value: number) => { handeChangeLimit(value) .then(() => { checkSelectedAll(); }); - } + };