Skip to content

Commit

Permalink
fix(frontend): redis主从多集群部署端口计算逻辑问题修复 #8801
Browse files Browse the repository at this point in the history
  • Loading branch information
jinquantianxia committed Dec 24, 2024
1 parent 1e50e9e commit 7fcdf42
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
21 changes: 21 additions & 0 deletions dbm-ui/frontend/src/views/db-manage/redis/apply-ha/Index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@
:is-append="isAppend"
:max-memory="maxMemory"
:port="formData.details.port"
:port-type="portType"
@host-change="handleHostChange" />
</BkFormItem>
<BkFormItem :label="t('备注')">
Expand Down Expand Up @@ -315,6 +316,26 @@

const isAppend = computed(() => formData.details.appendApply === 'append');
const machineCount = computed(() => formData.details.cluster_count / formData.details.group_count);
const portType = computed(() => {
if (formData.details.cluster_count % formData.details.group_count !== 0) {
return '';
}
if (formData.details.cluster_count === formData.details.group_count) {
return 'increment'; // 递增端口号
}
if (formData.details.group_count === 1) {
return 'same'; // 端口号相同
}
const ports = Array(formData.details.group_count)
.fill(0)
.map((_, index) => formData.details.port + index);
const groups = formData.details.cluster_count / formData.details.group_count;
return _.flatMap(
Array(groups)
.fill(0)
.map(() => ports),
);
});

watch(
() => formData.details.city_code,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
cityCode: string,
cityName: string
}
portType: string | number[];
}

interface Emits {
Expand Down Expand Up @@ -156,7 +157,7 @@
const columns = computed(() => {
const baseColums: Column[] = [
{
type: 'index',
type: 'seq',
label: t('序号'),
width: 60,
},
Expand Down Expand Up @@ -194,7 +195,12 @@
onChange={(value: string) => handleChangeCellValue(value, index, 'cluster_name')}
/>
</bk-form-item>
<div class="ml-4">.{ props.appAbbr }.db{props.isAppend ? '' : `#${props.port + index}`}</div>
{
typeof props.portType === 'string' ?
<div class="ml-4">.{ props.appAbbr }.db{props.isAppend ? '' : `#${props.portType === 'increment' ? props.port + index : props.port }`}</div>
:
<div class="ml-4">.{ props.appAbbr }.db{props.isAppend ? '' : `#${props.portType.length === tableData.value.length ? props.portType[index] : ''}`}</div>
}
</div>
),
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div class="ticket-details-info-title mt-20">{{ t('地域要求') }}</div>
<InfoList>
<InfoItem :label="t('数据库部署地域')">
{{ ticketDetails?.details.city_name || '--' }}
{{ ticketDetails?.details.city_code || '--' }}
</InfoItem>
</InfoList>
<div class="ticket-details-info-title mt-20">{{ t('数据库部署信息') }}</div>
Expand Down

0 comments on commit 7fcdf42

Please sign in to comment.