|
79 | 79 | <template #main>
|
80 | 80 | <BkLoading :loading="inputState.isLoading">
|
81 | 81 | <Table
|
82 |
| - :checked="checkedMap" |
| 82 | + :active-panel-id="activePanelId" |
| 83 | + :last-values="lastValues" |
83 | 84 | :table-data="tableData"
|
84 | 85 | @change="handleChange" />
|
85 | 86 | </BkLoading>
|
86 | 87 | </template>
|
87 | 88 | </BkResizeLayout>
|
88 | 89 | </div>
|
89 | 90 | </template>
|
90 |
| -<script setup lang="ts" generic="T extends TendbhaModel"> |
| 91 | +<script setup lang="ts" generic="T extends ClusterInfo"> |
91 | 92 | import { useI18n } from 'vue-i18n';
|
92 | 93 |
|
93 |
| - import type TendbhaModel from '@services/model/mysql/tendbha'; |
94 |
| - import { checkDomains } from '@services/source/mysql'; |
| 94 | + import type { ClusterInfo } from '@services/source/dbbase'; |
| 95 | + import { checkDomains } from '@services/source/dbbase'; |
95 | 96 |
|
96 | 97 | import { domainRegex } from '@common/regex';
|
97 | 98 |
|
98 | 99 | import Table from './Table.vue';
|
99 | 100 |
|
100 | 101 | interface Props {
|
101 |
| - checked: Record<string, T>; |
102 |
| - checkKey?: string; |
| 102 | + lastValues: Record<string, T[]>; |
| 103 | + activePanelId: string; |
103 | 104 | }
|
104 | 105 |
|
105 | 106 | interface Emits {
|
106 |
| - (e: 'change', value: Props['checked']): void; |
| 107 | + (e: 'change', value: Props['lastValues']): void; |
107 | 108 | }
|
108 |
| - const props = withDefaults(defineProps<Props>(), { |
109 |
| - checkKey: 'master_domain', |
110 |
| - }); |
| 109 | + const props = defineProps<Props>(); |
111 | 110 | const emits = defineEmits<Emits>();
|
112 | 111 |
|
113 | 112 | const { t } = useI18n();
|
114 | 113 | const inputRef = ref();
|
115 |
| - const checkedMap = computed(() => props.checked); |
116 | 114 |
|
117 | 115 | const inputState = reactive({
|
118 | 116 | values: '',
|
|
135 | 133 | },
|
136 | 134 | });
|
137 | 135 |
|
138 |
| - const handleChange = (checked: Props['checked']) => { |
| 136 | + const handleChange = (checked: Props['lastValues']) => { |
139 | 137 | emits('change', checked);
|
140 | 138 | };
|
141 | 139 |
|
|
198 | 196 | const item = lines[i];
|
199 | 197 | const infos = results[i];
|
200 | 198 | const remove = lines.splice(i, 1);
|
201 |
| - const isExisted = results.find((existItem) => existItem[props.checkKey as keyof TendbhaModel] === item); |
| 199 | + const isExisted = results.find((existItem) => existItem.immute_domain === item); |
202 | 200 | if (!isExisted) {
|
203 | 201 | legalLines.push(...remove);
|
204 | 202 | } else {
|
|
212 | 210 | errorState.domain.selectionEnd = legalLines.join('\n').length;
|
213 | 211 |
|
214 | 212 | // 解析完成后选中
|
215 |
| - const checked = { ...props.checked }; |
| 213 | + const lastValues = { ...props.lastValues }; |
216 | 214 | for (const item of tableData.value) {
|
217 |
| - const domain = item.master_domain; |
218 |
| - checked[domain] = item as T; |
| 215 | + const clusterType = props.activePanelId; |
| 216 | + if (!lastValues[clusterType]) { |
| 217 | + lastValues[clusterType] = []; |
| 218 | + } |
| 219 | + const list = lastValues[clusterType]; |
| 220 | + const isExisted = |
| 221 | + list.length > 0 && |
| 222 | + list.find((i) => `${i.immute_domain}_${i.bk_cloud_id}` === `${item.immute_domain}_${item.bk_cloud_id}`); |
| 223 | + if (!isExisted) { |
| 224 | + lastValues[clusterType].push(item); |
| 225 | + } |
219 | 226 | }
|
220 |
| - emits('change', checked); |
| 227 | + emits('change', { |
| 228 | + ...props.lastValues, |
| 229 | + ...lastValues, |
| 230 | + }); |
221 | 231 | } catch (_) {
|
222 | 232 | console.error(_);
|
223 | 233 | }
|
|
0 commit comments