Skip to content

Commit db64638

Browse files
fix(frontend): 分区执行合并处理步骤 #10201
1 parent 18e3b94 commit db64638

File tree

7 files changed

+124
-796
lines changed

7 files changed

+124
-796
lines changed

dbm-ui/frontend/src/services/source/partitionManage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ interface IDryRunData {
8383
shard_name: string;
8484
}
8585
// 分区策略前置执行
86-
export const dryRun = function (params: { cluster_id: number; cluster_type: string; config_id: number }) {
86+
export const dryRun = function (params: { cluster_id: number; config_id: number }) {
8787
const { currentBizId } = useGlobalBizs();
8888
return http.post<Record<number, IDryRunData[]>>('/apis/partition/dry_run/', {
8989
bk_biz_id: currentBizId,

dbm-ui/frontend/src/views/db-manage/mysql/partition-manage/Index.vue

Lines changed: 50 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@
3838
@clear-search="handleClearSearch"
3939
@selection="handleTableSelection"
4040
@setting-change="handleSettingChange" />
41-
<DryRun
42-
v-model="isShowDryRun"
43-
:cluster-id="operationData?.cluster_id || operationDryRunDataClusterId"
44-
:operation-dry-run-data="operationDryRunData"
45-
:partition-data="operationData" />
4641
<PartitionOperation
4742
v-model:is-show="isShowOperation"
4843
:data="operationData"
@@ -60,36 +55,47 @@
6055
</div>
6156
</template>
6257
<script setup lang="tsx">
58+
import _ from 'lodash';
6359
import { ref, shallowRef } from 'vue';
6460
import { useI18n } from 'vue-i18n';
6561
6662
import type PartitionModel from '@services/model/partition/partition';
67-
import { batchRemove, disablePartition, dryRun, enablePartition, getList } from '@services/source/partitionManage';
63+
import {
64+
batchRemove,
65+
disablePartition,
66+
dryRun,
67+
enablePartition,
68+
execute,
69+
getList,
70+
} from '@services/source/partitionManage';
71+
72+
import { useTicketMessage } from '@hooks';
6873
6974
import { ClusterTypes } from '@common/const';
7075
import { batchSplitRegex } from '@common/regex';
7176
7277
import { getSearchSelectorParams, messageSuccess } from '@utils';
7378
74-
import DryRun from './components/DryRun.vue';
7579
import ExecuteLog from './components/ExecuteLog.vue';
7680
import PartitionOperation from './components/Operation.vue';
7781
import useTableSetting from './hooks/useTableSetting';
7882
79-
const { t } = useI18n();
83+
type DryRunData = ServiceReturnType<typeof dryRun>;
8084
85+
const { t } = useI18n();
86+
const ticketMessage = useTicketMessage();
8187
const { handleChange: handleSettingChange, setting: tableSetting } = useTableSetting();
8288
8389
const tableRef = ref();
8490
const searchValues = ref([]);
8591
const isShowOperation = ref(false);
8692
const isShowExecuteLog = ref(false);
87-
const isShowDryRun = ref(false);
8893
const executeLoadingMap = ref<Record<number, boolean>>({});
89-
const selectionList = shallowRef<number[]>([]);
90-
const operationData = shallowRef<PartitionModel>();
9194
const operationDryRunDataClusterId = ref(0);
92-
const operationDryRunData = shallowRef<ServiceReturnType<typeof dryRun>>();
95+
96+
const operationData = shallowRef<PartitionModel>();
97+
const operationDryRunData = shallowRef<DryRunData>();
98+
const selectionList = shallowRef<number[]>([]);
9399
94100
const serachData = [
95101
{
@@ -400,9 +406,29 @@
400406
};
401407
402408
// 执行
403-
const handleExecute = (payload: PartitionModel) => {
404-
isShowDryRun.value = true;
405-
operationData.value = payload;
409+
const handleExecute = async (data: PartitionModel) => {
410+
executeLoadingMap.value[data.id] = true;
411+
operationData.value = data;
412+
try {
413+
const dryRunResults = await dryRun({
414+
cluster_id: data.cluster_id,
415+
config_id: data.id,
416+
});
417+
const dryRunData = Object.keys(dryRunResults).reduce<DryRunData>(
418+
(result, configId) =>
419+
Object.assign(result, {
420+
[configId]: _.filter(dryRunResults[Number(configId)], (item) => !item.message),
421+
}),
422+
{},
423+
);
424+
const executeResult = await execute({
425+
cluster_id: data.cluster_id,
426+
partition_objects: dryRunData,
427+
});
428+
ticketMessage(executeResult.map((item) => item.id).join(','));
429+
} finally {
430+
executeLoadingMap.value[data.id] = false;
431+
}
406432
};
407433
// 编辑
408434
const handleEdit = (payload: PartitionModel) => {
@@ -421,12 +447,16 @@
421447
fetchData();
422448
};
423449
// 新建成功
424-
const handleOperationCreateSuccess = (payload: ServiceReturnType<typeof dryRun>, clusterId: number) => {
450+
const handleOperationCreateSuccess = async (payload: DryRunData, clusterId: number) => {
425451
fetchData();
426452
operationDryRunData.value = payload;
427453
operationDryRunDataClusterId.value = clusterId;
428454
operationData.value = undefined;
429-
isShowDryRun.value = true;
455+
const executeResult = await execute({
456+
cluster_id: clusterId,
457+
partition_objects: payload,
458+
});
459+
ticketMessage(executeResult.map((item) => item.id).join(','));
430460
};
431461
432462
const handleDisable = (payload: PartitionModel) => {
@@ -450,8 +480,9 @@
450480
};
451481
452482
const handleClone = (payload: PartitionModel) => {
453-
operationData.value = payload;
454-
operationData.value.id = 0;
483+
const rowDataClone = _.cloneDeep(payload);
484+
rowDataClone.id = 0;
485+
operationData.value = rowDataClone;
455486
isShowOperation.value = true;
456487
};
457488

0 commit comments

Comments
 (0)