From 49e10d634c159f9788a3c0a635a937fa9dc14a64 Mon Sep 17 00:00:00 2001 From: chenwenchang <479999519@qq.com> Date: Mon, 6 Jan 2025 18:03:10 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E5=B7=A5=E5=85=B7=E7=AE=B1?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E8=B5=84=E6=BA=90=E6=B1=A0=E5=8D=8F=E8=AE=AE?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=5F=E9=AA=8C=E6=94=B6=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E5=A4=84=E7=90=86=20#8076=20#=20Reviewed,=20transaction=20id:?= =?UTF-8?q?=2028579?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/editable-table/Index.vue | 3 +- .../components/editable-table/edit/Block.vue | 21 +-- .../components/editable-table/edit/Text.vue | 143 ----------------- .../editable-table/edit/Textarea.vue | 1 - .../resource-host-selector/Index.vue | 55 +++---- dbm-ui/frontend/src/locales/zh-cn.json | 4 +- .../column/hybrid-host-column/Index.vue | 3 + .../column/multiple-host-column/Index.vue | 5 + .../column/single-host-column/Index.vue | 5 +- .../components/ClusterColumn.vue | 7 +- .../components/ClusterMigrateTable.vue | 9 +- .../components/HostColumnGroup.vue | 48 +++--- .../components/HostMigrateTable.vue | 9 +- .../components/HostColumnGroup.vue | 48 +++--- .../components/HostTable.vue | 6 +- .../components/InstanceColumnGroup.vue | 33 ++-- .../components/InstanceTable.vue | 6 +- .../local-restore/SlaveInstanceColumn.vue | 12 +- .../restore/SlaveHostColumnGroup.vue | 9 +- .../WithRelatedClustersColumn.vue | 18 ++- .../components/HostColumn.vue | 12 +- .../redis/REDIS_PROXY_SCALE_DOWN/Create.vue | 1 + .../components/ClusterColumn.vue | 9 +- .../components/ClusterColumn.vue | 18 ++- .../components/ClusterColumn.vue | 3 +- .../local-restore/SlaveInstanceColumn.vue | 12 +- .../restore/SlaveHostColumnGroup.vue | 9 +- .../common/edit-table-column/HaCluster.vue | 147 ------------------ .../components/MasterHostColumnGroup.vue | 11 +- .../local-restore/SlaveInstanceColumn.vue | 12 +- .../restore/SlaveHostColumnGroup.vue | 14 +- .../TENDBCLUSTER_SPIDER_MNT_APPLY/Create.vue | 16 +- .../components/ClusterColumn.vue | 10 +- .../Create.vue | 1 + .../components/ClusterColumn.vue | 12 +- 35 files changed, 299 insertions(+), 433 deletions(-) delete mode 100644 dbm-ui/frontend/src/components/editable-table/edit/Text.vue delete mode 100644 dbm-ui/frontend/src/views/db-manage/sqlserver/common/edit-table-column/HaCluster.vue diff --git a/dbm-ui/frontend/src/components/editable-table/Index.vue b/dbm-ui/frontend/src/components/editable-table/Index.vue index da5d0f354e..f443a99719 100644 --- a/dbm-ui/frontend/src/components/editable-table/Index.vue +++ b/dbm-ui/frontend/src/components/editable-table/Index.vue @@ -67,7 +67,6 @@ import Input from './edit/Input.vue'; import Select from './edit/Select.vue'; import TagInput from './edit/TagInput.vue'; - import Text from './edit/Text.vue'; import Textarea from './edit/Textarea.vue'; import TimePicker from './edit/TimePicker.vue'; import useResize from './hooks/use-resize'; @@ -113,7 +112,7 @@ } & Expose > = Symbol.for('bk-editable-table'); - export { Block, Column, DatePicker, Input, Row, Select, TagInput, Text, Textarea, TimePicker, useColumn, useTable }; + export { Block, Column, DatePicker, Input, Row, Select, TagInput, Textarea, TimePicker, useColumn, useTable }; </script> <script setup lang="ts"> const props = defineProps<Props>(); diff --git a/dbm-ui/frontend/src/components/editable-table/edit/Block.vue b/dbm-ui/frontend/src/components/editable-table/edit/Block.vue index dde5e4d4fd..691f77d305 100644 --- a/dbm-ui/frontend/src/components/editable-table/edit/Block.vue +++ b/dbm-ui/frontend/src/components/editable-table/edit/Block.vue @@ -14,13 +14,9 @@ 'is-show-prepend': Boolean(slots.prepend), 'is-show-append': Boolean(slots.append), }"> - <span ref="content"> - <slot> - {{ modelValue }} - </slot> - </span> + <span v-if="modelValue">{{ modelValue }}</span> <div - v-if="isShowPlacehoder" + v-else class="bk-editable-text-content-placeholder"> {{ placeholder }} </div> @@ -33,7 +29,7 @@ </div> </template> <script setup lang="ts"> - import { nextTick, onUpdated, ref, useTemplateRef, type VNode, watch } from 'vue'; + import { type VNode, watch } from 'vue'; import useColumn from '../useColumn'; @@ -47,7 +43,6 @@ const slots = defineSlots<{ prepend?: () => VNode; - default?: () => VNode; append?: () => VNode; }>(); @@ -55,10 +50,6 @@ const modelValue = defineModel<string>(); - const contentRef = useTemplateRef('content'); - - const isShowPlacehoder = ref(true); - watch(modelValue, () => { columnContext?.validate('change'); }); @@ -71,12 +62,6 @@ const handleFocus = () => { columnContext?.focus(); }; - - onUpdated(() => { - nextTick(() => { - isShowPlacehoder.value = !contentRef.value?.innerText; - }); - }); </script> <style lang="less"> .bk-editable-text { diff --git a/dbm-ui/frontend/src/components/editable-table/edit/Text.vue b/dbm-ui/frontend/src/components/editable-table/edit/Text.vue deleted file mode 100644 index 709817a38e..0000000000 --- a/dbm-ui/frontend/src/components/editable-table/edit/Text.vue +++ /dev/null @@ -1,143 +0,0 @@ -<template> - <div - class="bk-editable-text" - @blur="handleBlur" - @focus="handleFocus"> - <div - v-if="slots.prepend" - class="text-prepend-wrapper"> - <slot name="prepend" /> - </div> - <div - class="text-content-wrapper" - :class="{ - 'is-show-prepend': Boolean(slots.prepend), - 'is-show-append': Boolean(slots.append), - }"> - <span ref="content"> - <slot> - {{ modelValue }} - </slot> - </span> - <div - v-if="isShowPlacehoder" - class="text-content-placeholder"> - {{ placeholder }} - </div> - </div> - <div - v-if="slots.append" - class="text-append-wrapper"> - <slot name="append" /> - </div> - </div> -</template> -<script setup lang="ts"> - import { ref, useTemplateRef, type VNode, watch } from 'vue'; - - import useColumn from '../useColumn'; - - interface Props { - placeholder?: string; - } - - withDefaults(defineProps<Props>(), { - placeholder: '请设置值', - }); - - const slots = defineSlots<{ - prepend?: () => VNode; - default?: () => VNode; - append?: () => VNode; - }>(); - - const columnContext = useColumn(); - - const modelValue = defineModel<string>(); - - const contentRef = useTemplateRef('content'); - - const isShowPlacehoder = ref(true); - - watch(modelValue, () => { - columnContext?.validate(); - }); - - const handleBlur = () => { - columnContext?.blur(); - }; - - const handleFocus = () => { - columnContext?.focus(); - }; - - onUpdated(() => { - nextTick(() => { - isShowPlacehoder.value = !contentRef.value?.innerText; - }); - }); -</script> -<style lang="less"> - .bk-editable-text { - position: relative; - display: flex; - width: 100%; - min-height: 40px; - align-items: center; - overflow: hidden; - - .text-prepend-wrapper, - .text-append-wrapper { - display: flex; - align-items: center; - justify-content: center; - height: 100%; - padding: 0 8px; - user-select: none; - } - - .text-prepend-wrapper { - padding-left: 10px; - } - - .text-append-wrapper { - padding-right: 10px; - margin-left: auto; - } - - .text-content-wrapper { - position: relative; - width: 100%; - min-height: 40px; - padding: 10px 0; - margin: 0 10px; - overflow: hidden; - line-height: 20px; - text-overflow: ellipsis; - white-space: nowrap; - flex: 1; - - &.is-show-prepend { - margin-left: 0; - } - - &.is-show-append { - margin-right: 0; - } - } - - .text-content-placeholder { - position: absolute; - display: flex; - height: 40px; - overflow: hidden; - font-size: 12px; - color: #c4c6cc; - text-overflow: ellipsis; - white-space: nowrap; - user-select: none; - align-items: center; - inset: 0; - } - } -</style> diff --git a/dbm-ui/frontend/src/components/editable-table/edit/Textarea.vue b/dbm-ui/frontend/src/components/editable-table/edit/Textarea.vue index 46b457ad9f..ee0e9d1978 100644 --- a/dbm-ui/frontend/src/components/editable-table/edit/Textarea.vue +++ b/dbm-ui/frontend/src/components/editable-table/edit/Textarea.vue @@ -44,7 +44,6 @@ const slots = defineSlots<{ prepend?: () => VNode; - default?: () => VNode; append?: () => VNode; }>(); diff --git a/dbm-ui/frontend/src/components/resource-host-selector/Index.vue b/dbm-ui/frontend/src/components/resource-host-selector/Index.vue index 59c252e70c..675462d636 100644 --- a/dbm-ui/frontend/src/components/resource-host-selector/Index.vue +++ b/dbm-ui/frontend/src/components/resource-host-selector/Index.vue @@ -23,12 +23,11 @@ :width="60"> <template #default="{ data }"> <BkCheckbox - v-if="multiple" - label - :model-value="Boolean(rowSelectMemo[data.bk_host_id])" - @change="() => handleSelectChange(data)" /> - <BkRadio - v-else + v-bk-tooltips="{ + content: t('已选够n台', { n: needNum }), + disabled: selectedNum < needNum, + }" + :disabled="selectedNum === needNum && !Boolean(rowSelectMemo[data.bk_host_id])" label :model-value="Boolean(rowSelectMemo[data.bk_host_id])" @change="() => handleSelectChange(data)" /> @@ -51,16 +50,14 @@ <HostAgentStatus :data="data.agent_status" /> </template> </BkTableColumn> - <!-- <BkTableColumn + <BkTableColumn field="bk_cpu" :label="t('资源归属')" :min-width="300"> <template #default="{ data }"> - <ResourceHostOwner - v-if="false" - :data="data" /> + <ResourceHostOwner :data="data" /> </template> - </BkTableColumn> --> + </BkTableColumn> <BkTableColumn field="rack_id" :label="t('机架')" @@ -137,7 +134,20 @@ </div> </div> <template #footer> + <I18nT + class="mr-20" + keypath="需n台_已选n台" + style="font-size: 14px; color: #63656e" + tag="span"> + <span style="font-weight: bold; color: #2dcb56"> {{ needNum }} </span> + <span style="font-weight: bold; color: #3a84ff"> {{ selectedNum }} </span> + </I18nT> <BkButton + v-bk-tooltips="{ + content: t('还差n台_请先勾选足够的IP', { n: needNum - selectedNum }), + disabled: selectedNum === needNum, + }" + :disabled="selectedNum !== needNum" theme="primary" @click="handleSubmit"> {{ t('确定') }} @@ -159,8 +169,8 @@ import DiskPopInfo from '@components/disk-pop-info/DiskPopInfo.vue'; import HostAgentStatus from '@components/host-agent-status/Index.vue'; + import ResourceHostOwner from '@components/resource-host-owner/Index.vue'; - // import ResourceHostOwner from '@components/resource-host-owner/Index.vue'; import PanelTab from './components/PanelTab.vue'; import useSearchSelectData from './hooks/use-search-select-data'; @@ -172,7 +182,7 @@ } interface Props { - multiple?: boolean; + needNum: number; params?: { for_biz?: number; bk_cloud_ids?: string; @@ -186,7 +196,6 @@ } const props = withDefaults(defineProps<Props>(), { - multiple: true, params: () => ({}), }); @@ -209,6 +218,8 @@ const currentPanelTab = ref('host'); const rowSelectMemo = shallowRef<Record<number, DbResourceModel>>({}); + const selectedNum = computed(() => Object.keys(rowSelectMemo.value).length); + const dataSource = (params: ServiceParameters<typeof fetchList>) => fetchList({ ...params, @@ -234,18 +245,12 @@ const handleSelectChange = (data: DbResourceModel) => { const latestSelectMemo = { ...rowSelectMemo.value }; - if (props.multiple) { - if (latestSelectMemo[data.bk_host_id]) { - delete latestSelectMemo[data.bk_host_id]; - } else { - latestSelectMemo[data.bk_host_id] = data; - } - rowSelectMemo.value = latestSelectMemo; + if (latestSelectMemo[data.bk_host_id]) { + delete latestSelectMemo[data.bk_host_id]; } else { - rowSelectMemo.value = { - [data.bk_host_id]: data, - }; + latestSelectMemo[data.bk_host_id] = data; } + rowSelectMemo.value = latestSelectMemo; }; const handleSubmit = () => { @@ -256,9 +261,7 @@ bk_host_id: item.bk_host_id, ip: item.ip, })); - modelValue.value = latestValue; - emits('change', latestValue); }; diff --git a/dbm-ui/frontend/src/locales/zh-cn.json b/dbm-ui/frontend/src/locales/zh-cn.json index dd307a1bd2..2356007dad 100644 --- a/dbm-ui/frontend/src/locales/zh-cn.json +++ b/dbm-ui/frontend/src/locales/zh-cn.json @@ -4020,6 +4020,8 @@ "目标Master主机": "目标 Master 主机", "请输入集群域名_多个集群用分隔符输入": "请输入集群域名,多个集群用分隔符输入", "单据创建成功": "单据创建成功", + "从资源池选择": "从资源池选择", + "还差n台_请先勾选足够的IP": "还差 {n} 台,请先勾选足够的 IP", + "已选够n台": "已选够 {n} 台", "这行勿动!新增翻译请在上一行添加!": "" - } diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/hybrid-host-column/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/hybrid-host-column/Index.vue index 4da4f6c886..1ddf2e8215 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/hybrid-host-column/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/hybrid-host-column/Index.vue @@ -38,6 +38,7 @@ </template> <template #append> <DbIcon + v-bk-tooltips="t('从资源池选择')" class="select-icon" type="host-select" @click.stop="handleShowSelector" /> @@ -59,6 +60,7 @@ <ResourceHostSelector v-model:is-show="showSelector" v-mode="hostList" + :need-num="needNum" :params="params" @change="handleSelectorChange" /> </template> @@ -83,6 +85,7 @@ interface Props { field: string; // 绑选项值的vmodel,不绑主机列表 label: string; + needNum: number; minWidth?: number; placeholder?: string; bkCloudId?: number; diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/multiple-host-column/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/multiple-host-column/Index.vue index 4453fe25e4..bd44e890f1 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/multiple-host-column/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/multiple-host-column/Index.vue @@ -29,6 +29,7 @@ </template> <template #append> <DbIcon + v-bk-tooltips="t('从资源池选择')" class="select-icon" type="host-select" @click="handleShowSelector" /> @@ -43,6 +44,7 @@ </template> <template #append> <DbIcon + v-bk-tooltips="t('从资源池选择')" class="select-icon" type="host-select" @click="handleShowSelector" /> @@ -52,6 +54,7 @@ <ResourceHostSelector v-model:is-show="showSelector" v-mode="modelValue" + :need-num="needNum" :params="params" @change="handleSelectorChange" /> <div style="display: none"> @@ -83,6 +86,7 @@ */ field: string; label: string; + needNum: number; editable?: boolean; params?: { for_biz?: number; @@ -201,6 +205,7 @@ const handleInputChange = (value: string) => { if (value) { queryHost({ + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, search_content: value, limit: -1, offset: 0, diff --git a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/single-host-column/Index.vue b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/single-host-column/Index.vue index 99b6cd6b66..9df6d2b017 100644 --- a/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/single-host-column/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/common/toolbox-field/column/single-host-column/Index.vue @@ -26,6 +26,7 @@ @change="handleInputChange"> <template #append> <DbIcon + v-bk-tooltips="t('从资源池选择')" class="select-icon" type="host-select" @click="handleShowSelector" /> @@ -37,6 +38,7 @@ :placeholder="t('请选择主机')"> <template #append> <DbIcon + v-bk-tooltips="t('从资源池选择')" class="select-icon" type="host-select" @click="handleShowSelector" /> @@ -46,7 +48,7 @@ <ResourceHostSelector v-model="selected" v-model:is-show="showSelector" - :multiple="false" + :need-num="1" :params="params" @change="handleSelectorChange" /> </template> @@ -124,6 +126,7 @@ const handleInputChange = (value: string) => { if (value) { queryHost({ + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, search_content: value, limit: -1, offset: 0, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterColumn.vue index 3d4e5704ca..da869947d1 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterColumn.vue @@ -71,7 +71,10 @@ cluster_ids: number[]; cluster_domains: string; }>({ - default: () => [], + default: () => ({ + cluster_ids: [], + cluster_domains: '', + }), }); const { t } = useI18n(); @@ -111,7 +114,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters, { manual: true, onSuccess: (data) => { - modelValue.value.cluster_ids = []; if (data.length) { Object.assign(domainIdMap, Object.fromEntries(data.map((cur) => [cur.master_domain, cur.id]))); modelValue.value.cluster_ids = data.map((item) => item.id); @@ -124,6 +126,7 @@ }; const handleInputChange = (value: string) => { + modelValue.value.cluster_ids = []; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterMigrateTable.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterMigrateTable.vue index d476fc0741..8f07d1e895 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterMigrateTable.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/ClusterMigrateTable.vue @@ -26,13 +26,11 @@ <SingleHostColumn v-model="item.newMaster" field="newMaster.ip" - :label="t('新Master主机')" - :params="{ for_biz: currentBizId }" /> + :label="t('新Master主机')" /> <SingleHostColumn v-model="item.newSlave" field="newSlave.ip" - :label="t('新Slave主机')" - :params="{ for_biz: currentBizId }" /> + :label="t('新Slave主机')" /> <OperationColumn v-model:table-data="tableData" :create-row-method="createTableRow" /> @@ -45,8 +43,6 @@ import TendbhaModel from '@services/model/mysql/tendbha'; - import { useGlobalBizs } from '@stores'; - import EditableTable, { Row as EditableTableRow } from '@components/editable-table/Index.vue'; import OperationColumn from '@views/db-manage/common/toolbox-field/column/operation-column/Index.vue'; @@ -114,7 +110,6 @@ const { t } = useI18n(); const tableRef = useTemplateRef('table'); - const { currentBizId } = useGlobalBizs(); const createTableRow = (data = {} as Partial<RowData>) => ({ cluster: data.cluster || { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostColumnGroup.vue index c5d15619af..4de60a4511 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostColumnGroup.vue @@ -119,6 +119,7 @@ }>({ default: () => ({ bk_cloud_id: 0, + bk_host_id: undefined, ip: '', port: 0, cluster_ids: [], @@ -181,24 +182,26 @@ const { run: queryInstance, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - const [hostInfo] = data; - const clusterIds: number[] = []; - const relatedInstances: string[] = []; - const relatedClusters: string[] = []; - data.forEach((item) => { - clusterIds.push(item.cluster_id); - relatedInstances.push(item.instance_address); - relatedClusters.push(item.master_domain); - }); - modelValue.value = { - bk_cloud_id: hostInfo.bk_cloud_id, - bk_host_id: hostInfo.bk_host_id, - ip: hostInfo.ip, - port: hostInfo.port, - cluster_ids: clusterIds, - related_instances: relatedInstances, - related_clusters: relatedClusters, - }; + if (data.length) { + const [hostInfo] = data; + const clusterIds: number[] = []; + const relatedInstances: string[] = []; + const relatedClusters: string[] = []; + data.forEach((item) => { + clusterIds.push(item.cluster_id); + relatedInstances.push(item.instance_address); + relatedClusters.push(item.master_domain); + }); + modelValue.value = { + bk_cloud_id: hostInfo.bk_cloud_id, + bk_host_id: hostInfo.bk_host_id, + ip: hostInfo.ip, + port: hostInfo.port, + cluster_ids: clusterIds, + related_instances: relatedInstances, + related_clusters: relatedClusters, + }; + } }, }); @@ -207,6 +210,15 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_host_id: undefined, + bk_cloud_id: 0, + ip: value, + port: 0, + cluster_ids: [], + related_instances: [], + related_clusters: [], + }; if (value) { queryInstance({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostMigrateTable.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostMigrateTable.vue index ccf62f8c27..c14b4ed29b 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostMigrateTable.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_MIGRATE_CLUSTER/components/HostMigrateTable.vue @@ -27,14 +27,12 @@ v-model="item.newMaster" field="newMaster.ip" :label="t('新Master主机')" - :min-width="150" - :params="{ for_biz: currentBizId }" /> + :min-width="150" /> <SingleHostColumn v-model="item.newSlave" field="newSlave.ip" :label="t('新Slave主机')" - :min-width="150" - :params="{ for_biz: currentBizId }" /> + :min-width="150" /> <OperationColumn v-model:table-data="tableData" :create-row-method="createTableRow" /> @@ -45,8 +43,6 @@ import { useTemplateRef } from 'vue'; import { useI18n } from 'vue-i18n'; - import { useGlobalBizs } from '@stores'; - import EditableTable, { Row as EditableTableRow } from '@components/editable-table/Index.vue'; import OperationColumn from '@views/db-manage/common/toolbox-field/column/operation-column/Index.vue'; @@ -119,7 +115,6 @@ const { t } = useI18n(); const tableRef = useTemplateRef('table'); - const { currentBizId } = useGlobalBizs(); const createTableRow = (data = {} as Partial<RowData>) => ({ master: data.master || { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostColumnGroup.vue index 031274c59b..1db99b70e2 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostColumnGroup.vue @@ -119,6 +119,7 @@ }>({ default: () => ({ bk_cloud_id: 0, + bk_host_id: undefined, ip: '', port: 0, cluster_ids: [], @@ -186,24 +187,26 @@ const { run: queryInstance, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - const [hostInfo] = data; - const clusterIds: number[] = []; - const relatedInstances: string[] = []; - const relatedClusters: string[] = []; - data.forEach((item) => { - clusterIds.push(item.cluster_id); - relatedInstances.push(item.instance_address); - relatedClusters.push(item.master_domain); - }); - modelValue.value = { - bk_cloud_id: hostInfo.bk_cloud_id, - bk_host_id: hostInfo.bk_host_id, - ip: hostInfo.ip, - port: hostInfo.port, - cluster_ids: clusterIds, - related_instances: relatedInstances, - related_clusters: relatedClusters, - }; + if (data.length) { + const [hostInfo] = data; + const clusterIds: number[] = []; + const relatedInstances: string[] = []; + const relatedClusters: string[] = []; + data.forEach((item) => { + clusterIds.push(item.cluster_id); + relatedInstances.push(item.instance_address); + relatedClusters.push(item.master_domain); + }); + modelValue.value = { + bk_cloud_id: hostInfo.bk_cloud_id, + bk_host_id: hostInfo.bk_host_id, + ip: hostInfo.ip, + port: hostInfo.port, + cluster_ids: clusterIds, + related_instances: relatedInstances, + related_clusters: relatedClusters, + }; + } }, }); @@ -212,6 +215,15 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_host_id: undefined, + bk_cloud_id: 0, + ip: value, + port: 0, + cluster_ids: [], + related_instances: [], + related_clusters: [], + }; if (value) { queryInstance({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostTable.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostTable.vue index 710fc529e5..d39d90b690 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostTable.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/HostTable.vue @@ -26,8 +26,7 @@ <SingleHostColumn v-model="item.targetProxy" field="targetProxy.ip" - :label="t('新Proxy主机')" - :params="{ for_biz: currentBizId }" /> + :label="t('新Proxy主机')" /> <OperationColumn v-model:table-data="tableData" :create-row-method="createTableRow" /> @@ -38,8 +37,6 @@ import { useTemplateRef } from 'vue'; import { useI18n } from 'vue-i18n'; - import { useGlobalBizs } from '@stores'; - import EditableTable, { Row as EditableTableRow } from '@components/editable-table/Index.vue'; import OperationColumn from '@views/db-manage/common/toolbox-field/column/operation-column/Index.vue'; @@ -101,7 +98,6 @@ const { t } = useI18n(); const tableRef = useTemplateRef('table'); - const { currentBizId } = useGlobalBizs(); const createTableRow = (data = {} as Partial<RowData>) => ({ originProxy: data.originProxy || { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceColumnGroup.vue index af9104ea8e..54c1c2f4cb 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceColumnGroup.vue @@ -91,7 +91,7 @@ }>({ default: () => ({ bk_cloud_id: 0, - bk_host_id: 0, + bk_host_id: undefined, ip: '', port: 0, cluster_id: 0, @@ -158,16 +158,18 @@ const { run: queryInstance, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - const [hostInfo] = data; - modelValue.value = { - bk_cloud_id: hostInfo.bk_cloud_id, - bk_host_id: hostInfo.bk_host_id, - ip: hostInfo.ip, - port: hostInfo.port, - cluster_id: hostInfo.cluster_id, - instance_address: hostInfo.instance_address, - master_domain: hostInfo.master_domain, - }; + if (data.length) { + const [hostInfo] = data; + modelValue.value = { + bk_cloud_id: hostInfo.bk_cloud_id, + bk_host_id: hostInfo.bk_host_id, + ip: hostInfo.ip, + port: hostInfo.port, + cluster_id: hostInfo.cluster_id, + instance_address: hostInfo.instance_address, + master_domain: hostInfo.master_domain, + }; + } }, }); @@ -176,6 +178,15 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_cloud_id: 0, + bk_host_id: undefined, + ip: '', + port: 0, + cluster_id: 0, + instance_address: value, + master_domain: '', + }; if (value) { queryInstance({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceTable.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceTable.vue index 624a84d399..d70a3482dc 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceTable.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_PROXY_SWITCH/components/InstanceTable.vue @@ -26,8 +26,7 @@ <SingleHostColumn v-model="item.targetProxy" field="targetProxy.ip" - :label="t('新Proxy主机')" - :params="{ for_biz: currentBizId }" /> + :label="t('新Proxy主机')" /> <OperationColumn v-model:table-data="tableData" :create-row-method="createTableRow" /> @@ -38,8 +37,6 @@ import { useTemplateRef } from 'vue'; import { useI18n } from 'vue-i18n'; - import { useGlobalBizs } from '@stores'; - import EditableTable, { Row as EditableTableRow } from '@components/editable-table/Index.vue'; import OperationColumn from '@views/db-manage/common/toolbox-field/column/operation-column/Index.vue'; @@ -101,7 +98,6 @@ const { t } = useI18n(); const tableRef = useTemplateRef('table'); - const { currentBizId } = useGlobalBizs(); const createTableRow = (data = {} as Partial<RowData>) => ({ originProxy: data.originProxy || { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue index 2328b3e564..d0553f733b 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue @@ -85,6 +85,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', port: 0, instance_address: '', @@ -141,7 +142,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; modelValue.value = { @@ -163,6 +163,16 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: '', + port: 0, + instance_address: value, + cluster_id: 0, + master_domain: '', + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue index 3b2c3ebb58..6fb8c25b15 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/MYSQL_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue @@ -102,6 +102,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', related_clusters: [], }), @@ -155,7 +156,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; modelValue.value = { @@ -177,6 +177,13 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: value, + related_clusters: [], + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-table-column/WithRelatedClustersColumn.vue b/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-table-column/WithRelatedClustersColumn.vue index 25ff487fee..6a6a2271af 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-table-column/WithRelatedClustersColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/common/edit-table-column/WithRelatedClustersColumn.vue @@ -91,7 +91,7 @@ }[]; }>({ default: () => ({ - id: 0, + id: undefined, master_domain: '', related_clusters: [], }), @@ -111,6 +111,15 @@ })); const rules = [ + { + // 监听输入项变化时关联集群重置 + validator: () => { + modelValue.value.related_clusters = []; + return true; + }, + message: '', + trigger: 'change', + }, { validator: (value: string) => domainRegex.test(value), message: t('集群域名格式不正确'), @@ -136,7 +145,6 @@ const { run: queryRelatedClusters, loading: relatedClusterLoading } = useRequest(findRelatedClustersByClusterIds, { manual: true, onSuccess: (data) => { - modelValue.value.related_clusters = []; if (data.length) { modelValue.value.related_clusters = data[0].related_clusters.map((item) => ({ id: item.id, @@ -149,7 +157,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { modelValue.value.id = data[0].id; } @@ -173,6 +180,11 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + id: undefined, + master_domain: value, + related_clusters: [], + }; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_CLUSTER_CUTOFF/components/HostColumn.vue b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_CLUSTER_CUTOFF/components/HostColumn.vue index 8d63de5d4c..b5289522a0 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_CLUSTER_CUTOFF/components/HostColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_CLUSTER_CUTOFF/components/HostColumn.vue @@ -85,6 +85,7 @@ }>({ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_host_id: undefined, bk_cloud_id: 0, ip: '', role: '', @@ -127,7 +128,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const currentHost = data[0]; const roleMap = { @@ -158,6 +158,16 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_host_id: undefined, + bk_cloud_id: 0, + ip: value, + role: '', + cluster_domain: '', + cluster_ids: [], + spec_config: {} as SpecInfo, + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/Create.vue b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/Create.vue index 368b4793cf..15dfe5b1c6 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/Create.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/Create.vue @@ -54,6 +54,7 @@ field="host.type" :label="t('主机选择方式')" :min-width="150" + :need-num="1" :spec-ids="item.cluster.proxy_spec_ids" @change="(list) => handleSelectHost(list, item)" /> <Column diff --git a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/components/ClusterColumn.vue index 8fec514b43..aa748aa45a 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_PROXY_SCALE_DOWN/components/ClusterColumn.vue @@ -78,6 +78,7 @@ proxy_spec_ids: number[]; }>({ default: () => ({ + id: undefined, master_domain: '', cluster_type_name: '', role: '', @@ -145,7 +146,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters<RedisModel>, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { const [currentCluster] = data; modelValue.value = { @@ -164,6 +164,13 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + id: undefined, + master_domain: '', + cluster_type_name: '', + role: '', + proxy_spec_ids: [], + }; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_SCALE_UPDOWN/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_SCALE_UPDOWN/components/ClusterColumn.vue index 0c0f66fe23..5ce3201145 100644 --- a/dbm-ui/frontend/src/views/db-manage/redis/REDIS_SCALE_UPDOWN/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/redis/REDIS_SCALE_UPDOWN/components/ClusterColumn.vue @@ -98,6 +98,9 @@ bk_cloud_id: 0, cluster_capacity: 0, disaster_tolerance_level: 'CROS_SUBZONE', + id: undefined, + cluster_stats: {}, + cluster_spec: {}, }), }); @@ -155,7 +158,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters<RedisModel>, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { const [currentCluster] = data; modelValue.value = { @@ -181,6 +183,20 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + master_domain: value, + cluster_type: '', + cluster_type_name: '', + major_version: '', + shard_num: 0, + group_num: 0, + bk_cloud_id: 0, + cluster_capacity: 0, + disaster_tolerance_level: 'CROS_SUBZONE', + id: undefined, + cluster_stats: {} as RedisModel['cluster_stats'], + cluster_spec: {} as RedisModel['cluster_spec'], + }; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_ADD_SLAVE/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_ADD_SLAVE/components/ClusterColumn.vue index 52deda5729..65eb7ac6db 100644 --- a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_ADD_SLAVE/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_ADD_SLAVE/components/ClusterColumn.vue @@ -74,6 +74,7 @@ master_domain: string; }>({ default: () => ({ + id: undefined, master_domain: '', }), }); @@ -129,7 +130,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { modelValue.value.id = data[0].id; } @@ -141,6 +141,7 @@ }; const handleInputChange = (value: string) => { + modelValue.value.id = undefined; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue index 34d1c93ee8..0d12b8df1e 100644 --- a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue @@ -86,6 +86,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', port: 0, instance_address: '', @@ -142,7 +143,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; modelValue.value = { @@ -164,6 +164,16 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: '', + port: 0, + instance_address: value, + cluster_id: 0, + master_domain: '', + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue index 560eaded25..3f8ed8123d 100644 --- a/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/sqlserver/SQLSERVER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue @@ -103,6 +103,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', related_clusters: [], }), @@ -156,7 +157,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; modelValue.value = { @@ -178,6 +178,13 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: value, + related_clusters: [], + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/sqlserver/common/edit-table-column/HaCluster.vue b/dbm-ui/frontend/src/views/db-manage/sqlserver/common/edit-table-column/HaCluster.vue deleted file mode 100644 index ffce22a1ca..0000000000 --- a/dbm-ui/frontend/src/views/db-manage/sqlserver/common/edit-table-column/HaCluster.vue +++ /dev/null @@ -1,147 +0,0 @@ -<!-- - * 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 athttps://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. ---> - -<template> - <Column - :append-rules="rules" - field="cluster.domain" - fixed="left" - :label="t('目标集群')" - :loading="loading" - :min-width="300" - required> - <template #headAppend> - <span - v-bk-tooltips="t('批量选择')" - class="batch-host-select" - @click="handleShowSelector"> - <DbIcon type="batch-host-select" /> - </span> - </template> - <div style="flex: 1"> - <Input - v-model="modelValue.domain" - :placeholder="t('请输入集群域名')" - @change="handleInputChange" /> - </div> - </Column> - <ClusterSelector - v-model:is-show="showSelector" - :cluster-types="[ClusterTypes.SQLSERVER_HA]" - :selected="selectedClusters" - @change="handleSelectorChange" /> -</template> -<script lang="ts" setup> - import { useI18n } from 'vue-i18n'; - import { useRequest } from 'vue-request'; - - import SqlserverHaModel from '@services/model/sqlserver/sqlserver-ha'; - import { filterClusters } from '@services/source/dbbase'; - - import { ClusterTypes } from '@common/const'; - import { domainRegex } from '@common/regex'; - - import ClusterSelector from '@components/cluster-selector/Index.vue'; - import { Column, Input } from '@components/editable-table/Index.vue'; - - interface Props { - selected: { - id: number; - domain: string; - }[]; - } - - interface Emits { - (e: 'batch-edit', list: SqlserverHaModel[]): void; - (e: 'change', data: ServiceReturnType<typeof filterClusters>[number]): void; - } - - const props = defineProps<Props>(); - - const emits = defineEmits<Emits>(); - - const modelValue = defineModel<{ - id?: number; - domain: string; - }>({ - default: () => ({ - domain: '', - }), - }); - - const { t } = useI18n(); - - const showSelector = ref(false); - const selectedClusters = computed<Record<string, SqlserverHaModel[]>>(() => ({ - [ClusterTypes.SQLSERVER_HA]: props.selected.map( - (item) => - ({ - id: item.id, - master_domain: item.domain, - }) as SqlserverHaModel, - ), - })); - - const rules = [ - { - validator: (value: string) => domainRegex.test(value), - message: t('集群域名格式不正确'), - trigger: 'change', - }, - { - validator: () => { - if (!modelValue.value.domain) { - return true; - } - return Boolean(modelValue.value.id); - }, - message: t('目标集群不存在'), - trigger: 'blur', - }, - ]; - - const { run: queryCluster, loading } = useRequest(filterClusters, { - manual: true, - onSuccess: (data) => { - modelValue.value.id = undefined; - if (data.length) { - modelValue.value.id = data[0].id; - emits('change', data[0]); - } - }, - }); - - const handleShowSelector = () => { - showSelector.value = true; - }; - - const handleInputChange = (value: string) => { - if (value) { - queryCluster({ - bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, - exact_domain: value, - }); - } - }; - - const handleSelectorChange = (selected: Record<string, SqlserverHaModel[]>) => { - emits('batch-edit', selected[ClusterTypes.SQLSERVER_HA]); - }; -</script> -<style lang="less" scoped> - .batch-host-select { - font-size: 14px; - color: #3a84ff; - cursor: pointer; - } -</style> diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_MIGRATE_CLUSTER/components/MasterHostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_MIGRATE_CLUSTER/components/MasterHostColumnGroup.vue index 73792a3079..8ebfa02fe4 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_MIGRATE_CLUSTER/components/MasterHostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_MIGRATE_CLUSTER/components/MasterHostColumnGroup.vue @@ -98,6 +98,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', related_instances: [], cluster_id: 0, @@ -138,7 +139,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const currentHost = data[0]; const relatedInstances: string[] = []; @@ -163,6 +163,15 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: value, + related_instances: [], + cluster_id: 0, + master_domain: '', + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue index 78ddf73bc4..95c4212663 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/local-restore/SlaveInstanceColumn.vue @@ -85,6 +85,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', port: 0, instance_address: '', @@ -141,7 +142,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; modelValue.value = { @@ -163,6 +163,16 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: '', + port: 0, + instance_address: value, + cluster_id: 0, + master_domain: '', + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue index d69c7a9564..22bd944543 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_RESTORE_SLAVE/components/restore/SlaveHostColumnGroup.vue @@ -104,6 +104,7 @@ default: () => ({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, bk_cloud_id: 0, + bk_host_id: undefined, ip: '', related_instances: [], cluster_id: 0, @@ -171,7 +172,6 @@ const { run: queryHost, loading } = useRequest(checkInstance, { manual: true, onSuccess: (data) => { - modelValue.value.bk_host_id = undefined; if (data.length) { const [currentHost] = data; const relatedInstances: string[] = []; @@ -199,6 +199,18 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: undefined, + ip: value, + related_instances: [], + cluster_id: 0, + master_domain: '', + spec_id: 0, + spec_name: '', + count: 0, + }; if (value) { queryHost({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/Create.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/Create.vue index a12c7fabfe..cb9f10b2c3 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/Create.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/Create.vue @@ -40,7 +40,7 @@ v-model="item.cluster.bk_cloud_name" :placeholder="t('自动生成')" /> </Column> - <MultipleHostColumn + <SingleHostColumn v-model="item.host" field="host" :label="t('运维节点 IP')" /> @@ -84,8 +84,8 @@ import EditableTable, { Block, Column, Row as EditableTableRow } from '@components/editable-table/Index.vue'; - import MultipleHostColumn from '@views/db-manage/common/toolbox-field/column/multiple-host-column/Index.vue'; import OperationColumn from '@views/db-manage/common/toolbox-field/column/operation-column/Index.vue'; + import SingleHostColumn from '@views/db-manage/common/toolbox-field/column/single-host-column/Index.vue'; import TicketRemark from '@views/db-manage/common/toolbox-field/form-item/ticket-remark/Index.vue'; import ClusterColumn from './components/ClusterColumn.vue'; @@ -98,10 +98,11 @@ bk_cloud_name: string; }; host: { + bk_biz_id: number; bk_cloud_id: number; bk_host_id: number; ip: string; - }[]; + }; } const { t } = useI18n(); @@ -114,7 +115,12 @@ bk_cloud_id: 0, bk_cloud_name: '', }, - host: data.host || [], + host: data.host || { + bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, + bk_cloud_id: 0, + bk_host_id: 0, + ip: '', + }, }); const defaultData = () => ({ @@ -157,7 +163,7 @@ resource_spec: { spider_ip_list: { spec_id: 0, - hosts: item.host, + hosts: [item.host], }, }, })), diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/components/ClusterColumn.vue index 509a47ab46..ca0af5a32b 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_MNT_APPLY/components/ClusterColumn.vue @@ -74,7 +74,10 @@ bk_cloud_name: string; }>({ default: () => ({ + id: undefined, master_domain: '', + bk_cloud_id: 0, + bk_cloud_name: '', }), }); @@ -117,7 +120,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters<TendbClusterModel>, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { const [currentCluster] = data; modelValue.value = { @@ -135,6 +137,12 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + id: undefined, + master_domain: value, + bk_cloud_id: 0, + bk_cloud_name: '', + }; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID, diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/Create.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/Create.vue index 7f8f82431c..0df8044f3b 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/Create.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/Create.vue @@ -47,6 +47,7 @@ field="host.type" :label="t('主机选择方式')" :min-width="200" + :need-num="1" :spec-ids="getSpecIds(item)" @change="(list) => handleSelectHost(list, item)" /> <Column diff --git a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/components/ClusterColumn.vue b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/components/ClusterColumn.vue index 6d8f3a67d0..1309dd55e9 100644 --- a/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/components/ClusterColumn.vue +++ b/dbm-ui/frontend/src/views/db-manage/tendb-cluster/TENDBCLUSTER_SPIDER_REDUCE_NODES/components/ClusterColumn.vue @@ -78,7 +78,11 @@ slave_spec_ids: number[]; }>({ default: () => ({ + id: undefined, master_domain: '', + role: '', + master_spec_ids: [], + slave_spec_ids: [], }), }); @@ -132,7 +136,6 @@ const { run: queryCluster, loading } = useRequest(filterClusters<TendbClusterModel>, { manual: true, onSuccess: (data) => { - modelValue.value.id = undefined; if (data.length) { const [currentCluster] = data; modelValue.value = { @@ -151,6 +154,13 @@ }; const handleInputChange = (value: string) => { + modelValue.value = { + id: undefined, + master_domain: value, + role: '', + master_spec_ids: [], + slave_spec_ids: [], + }; if (value) { queryCluster({ bk_biz_id: window.PROJECT_CONFIG.BIZ_ID,