From c4c30f9b0028a84e9ffc43298c285aa000a8522f Mon Sep 17 00:00:00 2001 From: 3octaves <873551943@qq.com> Date: Fri, 6 Dec 2024 18:34:28 +0800 Subject: [PATCH] =?UTF-8?q?feat(frontend):=20=E6=A8=A1=E5=9D=97=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E6=97=B6=E5=A2=9E=E5=8A=A0=E6=A8=A1=E5=9D=97=E7=9A=84?= =?UTF-8?q?=E5=9F=BA=E6=9C=AC=E4=BF=A1=E6=81=AF=20#8424?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/common/const/clusterTypeInfos.ts | 33 +- .../generateCloneData/mysql/singleApply.ts | 2 +- .../common/apply-items/ModuleItem.vue | 442 ++++++++++++++++++ .../db-manage/mysql/apply/ApplyMySQL.vue | 207 ++------ .../mysql/apply/hooks/useMysqlData.ts | 157 +++---- .../src/views/db-manage/riak/apply/Index.vue | 73 +-- .../db-manage/sqlserver/apply/SqlServer.vue | 276 +---------- .../db-manage/tendb-cluster/apply/Index.vue | 10 +- 8 files changed, 601 insertions(+), 599 deletions(-) create mode 100644 dbm-ui/frontend/src/views/db-manage/common/apply-items/ModuleItem.vue diff --git a/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts b/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts index 2e34f23728..406b809d1b 100644 --- a/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts +++ b/dbm-ui/frontend/src/common/const/clusterTypeInfos.ts @@ -275,26 +275,19 @@ const bigdata: InfoType = { name: t('冷_热节点规格'), }, ], - [ClusterTypes.DORIS]: { - id: ClusterTypes.DORIS, - name: 'Doris', - dbType: DBTypes.DORIS, - moduleId: 'bigdata', - machineList: [ - { - id: MachineTypes.DORIS_FOLLOWER, - name: t('Follower节点规格'), - }, - { - id: MachineTypes.DORIS_OBSERVER, - name: t('Observer节点规格'), - }, - { - id: MachineTypes.DORIS_BACKEND, - name: t('冷_热节点规格'), - }, - ], - }, + }, + [ClusterTypes.RIAK]: { + id: ClusterTypes.RIAK, + name: 'Riak', + specClusterName: 'Riak', + dbType: DBTypes.RIAK, + moduleId: 'bigdata', + machineList: [ + { + id: MachineTypes.RIAK, + name: t('后端存储'), + }, + ], }, }; diff --git a/dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/mysql/singleApply.ts b/dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/mysql/singleApply.ts index e88b79fc7f..a993b02451 100644 --- a/dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/mysql/singleApply.ts +++ b/dbm-ui/frontend/src/hooks/useTicketCloneInfo/generateCloneData/mysql/singleApply.ts @@ -28,7 +28,7 @@ export function generateMysqlSingleApplyCloneData(ticketData: TicketModel + + + +
+ + {{ item.alias_name }} + + + {{ getBaseInfo(item) }} + +
+
+ +
+ + + +
+ +
+
+ {{ item.label }}: + {{ item.value }} +
+
+ +
+
+
+ + + + + + diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/apply/ApplyMySQL.vue b/dbm-ui/frontend/src/views/db-manage/mysql/apply/ApplyMySQL.vue index 23ec7ee51e..b0e2ae5f53 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/apply/ApplyMySQL.vue +++ b/dbm-ui/frontend/src/views/db-manage/mysql/apply/ApplyMySQL.vue @@ -26,91 +26,13 @@ v-model:biz-id="formdata.bk_biz_id" perrmision-action-id="mysql_apply" @change-biz="handleChangeBiz" /> - - - - - - - - -
- -
-
- {{ item.description || item.conf_name }}: - {{ item.conf_value }} -
-
-
- {{ t('该模块暂未绑定数据库相关配置') }} - - {{ isBindModule ? t('已完成') : t('去绑定') }} - -
-
- {{ t('需要绑定数据库相关配置') }} -
-
-
-
+ @@ -399,6 +321,7 @@ import AffinityItem from '@views/db-manage/common/apply-items/AffinityItem.vue'; import BusinessItems from '@views/db-manage/common/apply-items/BusinessItems.vue'; import CloudItem from '@views/db-manage/common/apply-items/CloudItem.vue'; + import ModuleItem from '@views/db-manage/common/apply-items/ModuleItem.vue'; import RegionItem from '@views/db-manage/common/apply-items/RegionItem.vue'; import SpecSelector from '@views/db-manage/common/apply-items/SpecSelector.vue'; @@ -504,14 +427,20 @@ const isSingleType = route.name === 'SelfServiceApplySingle'; const dbType: string = isSingleType ? TicketTypes.MYSQL_SINGLE_APPLY : TicketTypes.MYSQL_HA_APPLY; + const moduleItemRef = ref>(); const specProxyRef = ref(); const specBackendRef = ref(); const specSingleRef = ref(); const backendRef = ref(); const proxyRef = ref(); const moduleRef = ref(); - const isBindModule = ref(false); const regionItemRef = ref(); + const moduleAliasName = ref(''); + const moduleLevelConfig = ref({ + charset: '', + dbVersion: '', + systemVersionList: [] as string[], + }); const cloudInfo = reactive({ id: '' as number | string, @@ -525,18 +454,6 @@ validator: (val: string) => nameRegx.test(val), }, ], - 'details.db_module_id': [ - { - message: t('请先选择所属业务'), - trigger: 'blur', - validator: () => !!formdata.bk_biz_id, - }, - { - message: t('DB模块名不能为空'), - trigger: 'blur', - validator: (val: number) => !!val, - }, - ], 'details.nodes.proxy': [ { message: t('请添加服务器'), @@ -573,10 +490,6 @@ }); const hostSpecInfo = computed(() => fetchState.hostSpecs.find((info) => info.spec === formdata.details.spec)); const typeInfo = computed(() => mysqlType[dbType as MysqlTypeString]); - const moduleAliasName = computed(() => { - const item = fetchState.moduleList.find((item) => item.db_module_id === formdata.details.db_module_id); - return item?.alias_name ?? ''; - }); const tableData = computed(() => { if (moduleAliasName.value && formdata.details.db_app_abbr) { return formdata.details.domains; @@ -596,8 +509,7 @@ // const isDefaultCity = computed(() => formdata.details.city_code === 'default'); // 获取基础数据信息 - const { formdata, fetchState, loading, leveConfig, handleResetFormdata, fetchModules, fetchLevelConfig } = - useMysqlData(dbType); + const { formdata, fetchState, handleResetFormdata } = useMysqlData(dbType); function handleChangeClusterCount(value: number) { if (value && formdata.details.inst_num > value) { @@ -714,20 +626,20 @@ } /** 获取版本、字符集信息 */ - watch( - () => fetchState.levelConfigList, - (value) => { - value.forEach((item) => { - Object.keys(leveConfig).forEach((key) => { - if (key === item.conf_name) { - if (item.conf_value !== undefined) { - leveConfig[key as keyof typeof leveConfig] = item.conf_value; - } - } - }); - }); - }, - ); + // watch( + // () => fetchState.levelConfigList, + // (value) => { + // value.forEach((item) => { + // Object.keys(leveConfig).forEach((key) => { + // if (key === item.conf_name) { + // if (item.conf_value !== undefined) { + // leveConfig[key as keyof typeof leveConfig] = item.conf_value; + // } + // } + // }); + // }); + // }, + // ); /** * 预览功能 @@ -736,17 +648,18 @@ proxy: formatNodes(formdata.details.nodes.proxy), backend: formatNodes(formdata.details.nodes.backend), })); - const previewData = computed(() => - tableData.value.map(({ key }: { key: string }) => ({ + const previewData = computed(() => { + const { dbVersion, charset } = moduleLevelConfig.value; + return tableData.value.map(({ key }: { key: string }) => ({ domain: `${moduleAliasName.value}db.${key}.${formdata.details.db_app_abbr}.db`, slaveDomain: `${moduleAliasName.value}db.${key}.${formdata.details.db_app_abbr}.db`, disasterDefence: t('同城跨园区'), deployStructure: typeInfo.value.name, - version: leveConfig.db_version, - charset: leveConfig.charset, + version: dbVersion, + charset, spec: hostSpecInfo.value ? `${hostSpecInfo.value.cpu}/${hostSpecInfo.value.mem}` : '', - })), - ); + })); + }); const isShowPreview = ref(false); const handleShowPreview = () => { isShowPreview.value = true; @@ -773,7 +686,7 @@ ?.validate() .then(() => true) .catch(() => false); - if (validate && fetchState.levelConfigList.length) { + if (validate) { baseState.isSubmitting = true; const getDetails = () => { @@ -850,50 +763,6 @@ } }; - /** - * 新建模块 - */ - const handleCreateModule = () => { - const url = router.resolve({ - name: 'SelfServiceCreateDbModule', - params: { - type: dbType, - bk_biz_id: formdata.bk_biz_id, - }, - query: { - from: route.name as string, - }, - }); - window.open(url.href, '_blank'); - }; - - const handleBindConfig = () => { - if (isBindModule.value) { - fetchLevelConfig(formdata.details.db_module_id as number); - return; - } - const moduleInfo = fetchState.moduleList.find((item) => item.db_module_id === formdata.details.db_module_id); - const moduleAliasName = moduleInfo?.alias_name ?? ''; - const moduleAliasNameQuery = moduleAliasName - ? { - alias_name: moduleAliasName, - } - : {}; - isBindModule.value = true; - const url = router.resolve({ - name: 'SelfServiceBindDbModule', - params: { - type: dbType, - bk_biz_id: formdata.bk_biz_id, - db_module_id: formdata.details.db_module_id, - }, - query: { - ...moduleAliasNameQuery, - }, - }); - window.open(url.href, '_blank'); - }; - defineExpose({ routerBack() { if (!route.query.from) { diff --git a/dbm-ui/frontend/src/views/db-manage/mysql/apply/hooks/useMysqlData.ts b/dbm-ui/frontend/src/views/db-manage/mysql/apply/hooks/useMysqlData.ts index 12b1811103..632de40cc7 100644 --- a/dbm-ui/frontend/src/views/db-manage/mysql/apply/hooks/useMysqlData.ts +++ b/dbm-ui/frontend/src/views/db-manage/mysql/apply/hooks/useMysqlData.ts @@ -15,18 +15,13 @@ import InfoBox from 'bkui-vue/lib/info-box'; import _ from 'lodash'; import { useI18n } from 'vue-i18n'; -import { getModules } from '@services/source/cmdb'; -import { getLevelConfig } from '@services/source/configs'; import { getInfrasHostSpecs } from '@services/source/infras'; -import { createTicket } from '@services/source/ticket'; import type { HostInfo } from '@services/types'; -import { mysqlType, type MysqlTypeString } from '@common/const'; +import { type MysqlTypeString } from '@common/const'; type FetchState = { hostSpecs: ServiceReturnType; - moduleList: ServiceReturnType; - levelConfigList: ServiceReturnType['conf_items']; }; const getFormData = (type: string) => ({ @@ -86,17 +81,6 @@ export const useMysqlData = (type: string) => { // 接口数据 const fetchState = reactive({ hostSpecs: [], - moduleList: [], - levelConfigList: [], - }); - const loading = reactive({ - hostSpecs: false, - modules: false, - levelConfigs: false, - }); - const leveConfig = reactive({ - charset: '', - db_version: '', }); /** @@ -120,39 +104,39 @@ export const useMysqlData = (type: string) => { }, ); - /** - * 获取配置详情下拉展示 - */ - const fetchLevelConfig = (moduleId: number) => { - const params = { - bk_biz_id: formdata.bk_biz_id as number, - conf_type: 'deploy', - level_name: 'module', - level_value: moduleId, - meta_cluster_type: mysqlType[ticketType].type, - version: 'deploy_info', - }; - loading.levelConfigs = true; - getLevelConfig(params) - .then((res) => { - fetchState.levelConfigList = res.conf_items; - }) - .finally(() => { - loading.levelConfigs = false; - }); - }; + // /** + // * 获取配置详情下拉展示 + // */ + // const fetchLevelConfig = (moduleId: number) => { + // const params = { + // bk_biz_id: formdata.bk_biz_id as number, + // conf_type: 'deploy', + // level_name: 'module', + // level_value: moduleId, + // meta_cluster_type: mysqlType[ticketType].type, + // version: 'deploy_info', + // }; + // loading.levelConfigs = true; + // getLevelConfig(params) + // .then((res) => { + // fetchState.levelConfigList = res.conf_items; + // }) + // .finally(() => { + // loading.levelConfigs = false; + // }); + // }; /** * 查询层级(业务、模块、集群)配置详情 */ - watch( - () => formdata.details.db_module_id, - (value) => { - if (value) { - fetchLevelConfig(value); - } - }, - ); + // watch( + // () => formdata.details.db_module_id, + // (value) => { + // if (value) { + // fetchLevelConfig(value); + // } + // }, + // ); /** * 获取服务器规格列表 @@ -167,45 +151,40 @@ export const useMysqlData = (type: string) => { }, ); const fetchInfrasHostSpecs = () => { - loading.hostSpecs = true; - getInfrasHostSpecs() - .then((res) => { - fetchState.hostSpecs = res || []; - }) - .finally(() => { - loading.hostSpecs = false; - }); + getInfrasHostSpecs().then((res) => { + fetchState.hostSpecs = res || []; + }); }; - /** - * 获取模块列表 - */ - watch( - () => formdata.bk_biz_id, - (value) => { - if (value) { - fetchModules(value); - } - }, - ); - const fetchModules = (bizId: number | null) => { - if (!bizId) { - return; - } - - loading.modules = true; - const params = { - bk_biz_id: bizId, - cluster_type: mysqlType[ticketType].type, - }; - getModules(params) - .then((res) => { - fetchState.moduleList = res || []; - }) - .finally(() => { - loading.modules = false; - }); - }; + // /** + // * 获取模块列表 + // */ + // watch( + // () => formdata.bk_biz_id, + // (value) => { + // if (value) { + // fetchModules(value); + // } + // }, + // ); + // const fetchModules = (bizId: number | null) => { + // if (!bizId) { + // return; + // } + + // loading.modules = true; + // const params = { + // bk_biz_id: bizId, + // cluster_type: mysqlType[ticketType].type, + // }; + // getModules(params) + // .then((res) => { + // fetchState.moduleList = res || []; + // }) + // .finally(() => { + // loading.modules = false; + // }); + // }; /** * reset formdata @@ -228,16 +207,16 @@ export const useMysqlData = (type: string) => { /** * 创建单据 */ - const submitTicket = () => createTicket(formdata); + // const submitTicket = () => createTicket(formdata); return { formdata, fetchState, - loading, - leveConfig, - submitTicket, + // loading, + // leveConfig, + // submitTicket, handleResetFormdata, - fetchModules, - fetchLevelConfig, + // fetchModules, + // fetchLevelConfig, }; }; diff --git a/dbm-ui/frontend/src/views/db-manage/riak/apply/Index.vue b/dbm-ui/frontend/src/views/db-manage/riak/apply/Index.vue index 30351b3141..fdfec69016 100644 --- a/dbm-ui/frontend/src/views/db-manage/riak/apply/Index.vue +++ b/dbm-ui/frontend/src/views/db-manage/riak/apply/Index.vue @@ -27,33 +27,11 @@ v-model:biz-id="formData.bk_biz_id" perrmision-action-id="riak_cluster_apply" @change-biz="handleChangeBiz" /> - - - - - + import InfoBox from 'bkui-vue/lib/info-box'; import { useI18n } from 'vue-i18n'; - import { useRequest } from 'vue-request'; - import { getModules } from '@services/source/cmdb'; import type { BizItem, HostInfo } from '@services/types'; import { useApplyBase } from '@hooks'; @@ -226,6 +202,7 @@ import CloudItem from '@views/db-manage/common/apply-items/CloudItem.vue'; import ClusterAlias from '@views/db-manage/common/apply-items/ClusterAlias.vue'; import ClusterName from '@views/db-manage/common/apply-items/ClusterName.vue'; + import ModuleItem from '@views/db-manage/common/apply-items/ModuleItem.vue'; import RegionItem from '@views/db-manage/common/apply-items/RegionItem.vue'; import SpecSelector from '@views/db-manage/common/apply-items/SpecSelector.vue'; @@ -242,7 +219,7 @@ bk_cloud_id: 0, db_app_abbr: '', ip_source: 'resource_pool', - db_module_id: '' as number | '', + db_module_id: null as number | null, cluster_name: '', cluster_alias: '', city_code: '', @@ -264,26 +241,9 @@ id: '' as number | string, name: '', }); + const moduleAliasName = ref(''); const formData = reactive(genDefaultFormData()); - const { - data: moduleList, - run: getModulesRun, - loading: getModulesLoading, - } = useRequest(getModules, { - manual: true, - }); - - watch( - () => formData.bk_biz_id, - (value) => { - if (value) { - formData.details.db_module_id = ''; - fetchModules(value); - } - }, - ); - const formRules = { nodes_num: [ { @@ -309,17 +269,6 @@ bizState.hasEnglishName = !!info.english_name; }; - const fetchModules = (bizId: number | null) => { - if (!bizId) { - return; - } - - getModulesRun({ - bk_biz_id: bizId, - cluster_type: ClusterTypes.RIAK, - }); - }; - const handleChangeCloud = (info: { id: number | string; name: string }) => { cloudInfo.value = info; @@ -340,15 +289,11 @@ formRef.value.validate().then(() => { baseState.isSubmitting = true; - const { db_module_id: moduleId } = formData.details; - const moduleListValue = moduleList.value || []; - const moduleIndex = moduleListValue.findIndex((moduleItem) => Number(moduleItem.db_module_id) === moduleId); - const params = { ...formData, details: { ...formData.details, - db_module_name: moduleListValue[moduleIndex].alias_name, + db_module_name: moduleAliasName.value, }, }; diff --git a/dbm-ui/frontend/src/views/db-manage/sqlserver/apply/SqlServer.vue b/dbm-ui/frontend/src/views/db-manage/sqlserver/apply/SqlServer.vue index 245434f96b..15f9552743 100644 --- a/dbm-ui/frontend/src/views/db-manage/sqlserver/apply/SqlServer.vue +++ b/dbm-ui/frontend/src/views/db-manage/sqlserver/apply/SqlServer.vue @@ -13,85 +13,13 @@ v-model:biz-id="formData.bk_biz_id" perrmision-action-id="sqlserver_apply" @change-biz="handleChangeBiz" /> - - - - - - -
- -
-
-
{{ item.label }} :
-
{{ item.value }}
-
-
-
- {{ t('该模块暂未绑定数据库相关配置') }} - - {{ isBindModule ? t('已完成') : t('去绑定') }} - -
-
- {{ t('需要绑定数据库相关配置') }} -
-
-
-
+ @@ -292,24 +220,22 @@