|
38 | 38 | @clear-search="handleClearSearch"
|
39 | 39 | @selection="handleTableSelection"
|
40 | 40 | @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" /> |
46 | 41 | <PartitionOperation
|
47 | 42 | v-model:is-show="isShowOperation"
|
48 | 43 | :data="operationData"
|
|
60 | 55 | </div>
|
61 | 56 | </template>
|
62 | 57 | <script setup lang="tsx">
|
| 58 | + import _ from 'lodash'; |
63 | 59 | import { ref, shallowRef } from 'vue';
|
64 | 60 | import { useI18n } from 'vue-i18n';
|
65 | 61 |
|
66 | 62 | 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'; |
68 | 73 |
|
69 | 74 | import { ClusterTypes } from '@common/const';
|
70 | 75 | import { batchSplitRegex } from '@common/regex';
|
71 | 76 |
|
72 | 77 | import { getSearchSelectorParams, messageSuccess } from '@utils';
|
73 | 78 |
|
74 |
| - import DryRun from './components/DryRun.vue'; |
75 | 79 | import ExecuteLog from './components/ExecuteLog.vue';
|
76 | 80 | import PartitionOperation from './components/Operation.vue';
|
77 | 81 | import useTableSetting from './hooks/useTableSetting';
|
78 | 82 |
|
79 |
| - const { t } = useI18n(); |
| 83 | + type DryRunData = ServiceReturnType<typeof dryRun>; |
80 | 84 |
|
| 85 | + const { t } = useI18n(); |
| 86 | + const ticketMessage = useTicketMessage(); |
81 | 87 | const { handleChange: handleSettingChange, setting: tableSetting } = useTableSetting();
|
82 | 88 |
|
83 | 89 | const tableRef = ref();
|
84 | 90 | const searchValues = ref([]);
|
85 | 91 | const isShowOperation = ref(false);
|
86 | 92 | const isShowExecuteLog = ref(false);
|
87 |
| - const isShowDryRun = ref(false); |
88 | 93 | const executeLoadingMap = ref<Record<number, boolean>>({});
|
89 |
| - const selectionList = shallowRef<number[]>([]); |
90 |
| - const operationData = shallowRef<PartitionModel>(); |
91 | 94 | 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[]>([]); |
93 | 99 |
|
94 | 100 | const serachData = [
|
95 | 101 | {
|
|
400 | 406 | };
|
401 | 407 |
|
402 | 408 | // 执行
|
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 | + } |
406 | 432 | };
|
407 | 433 | // 编辑
|
408 | 434 | const handleEdit = (payload: PartitionModel) => {
|
|
421 | 447 | fetchData();
|
422 | 448 | };
|
423 | 449 | // 新建成功
|
424 |
| - const handleOperationCreateSuccess = (payload: ServiceReturnType<typeof dryRun>, clusterId: number) => { |
| 450 | + const handleOperationCreateSuccess = async (payload: DryRunData, clusterId: number) => { |
425 | 451 | fetchData();
|
426 | 452 | operationDryRunData.value = payload;
|
427 | 453 | operationDryRunDataClusterId.value = clusterId;
|
428 | 454 | 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(',')); |
430 | 460 | };
|
431 | 461 |
|
432 | 462 | const handleDisable = (payload: PartitionModel) => {
|
|
450 | 480 | };
|
451 | 481 |
|
452 | 482 | 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; |
455 | 486 | isShowOperation.value = true;
|
456 | 487 | };
|
457 | 488 |
|
|
0 commit comments