Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: 操作中的按钮需禁用 --bug=126386957 #3309

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
@closed="handleClose">
<slot></slot>
<template #footer>
<bk-button theme="primary" @click="emits('confirm')" :loading="pending" style="margin-right: 8px">
<bk-button
theme="primary"
@click="emits('confirm')"
:disabled="pending"
:loading="pending"
style="margin-right: 8px">
{{ confirmText || t('删除') }}
</bk-button>
<bk-button @click="handleClose">{{ t('取消') }}</bk-button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
baseGroupList.value.some((baseGroupItem) => {
if (baseGroupItem.template_space_id === currentGroupItem.template_space_id) {
return baseGroupItem.configs.some((config) => {
if (config.id === crtItem.id) {
if (config.id === crtItem.id || config.name === crtItem.name) {
baseItem = config;
return true;
}
Expand Down Expand Up @@ -443,7 +443,7 @@
currentGroupList.value.some((baseGroupItem) => {
if (baseGroupItem.template_space_id === baseGroupItem.template_space_id) {
return baseGroupItem.configs.some((config) => {
if (config.id === baseItem.id) {
if (config.id === baseItem.id || config.name === baseItem.name) {
currentItem = config;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@
theme: 'success',
message: props.isFileType ? t('批量删除配置文件成功') : t('批量删除配置项成功'),
});
batchDeletePending.value = false;
isBatchDeleteDialogShow.value = false;
emits('deleted');
setTimeout(() => {
emits('deleted');
batchDeletePending.value = false;
}, 300);
};

const handleOpenBantchEditPerm = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,12 +109,12 @@
<bk-button
theme="primary"
style="margin-right: 8px"
:disabled="!confirmBtnDisabled"
:disabled="!confirmBtnDisabled || loading"
:loading="loading"
@click="handleConfirm">
{{ t('导入') }}
</bk-button>
<bk-button @click="emits('update:show', false)">{{ t('取消') }}</bk-button>
<bk-button :loading="closeLoading" :disabled="closeLoading" @click="handleClose">{{ t('取消') }}</bk-button>
</template>
</bk-dialog>
</template>
Expand Down Expand Up @@ -167,6 +167,7 @@
const isClearDraft = ref(false);
const uploadFileLoading = ref(false);
const decompressing = ref(false);
const closeLoading = ref(false);

const confirmBtnDisabled = computed(() => {
if (importType.value === 'configTemplate' && importFromTemplateRef.value) {
Expand Down Expand Up @@ -197,6 +198,8 @@
handleClearTable();
selectVerisonId.value = undefined;
getVersionList();
decompressing.value = false;
closeLoading.value = false;
}
},
);
Expand Down Expand Up @@ -375,6 +378,11 @@
existTemplateConfigList.value = [];
nonExistTemplateConfigList.value = [];
};

const handleClose = () => {
closeLoading.value = true;
emits('update:show', false);
};
</script>

<style scoped lang="scss">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
</div>
<div v-show="expand">
<bk-table class="template-table" :border="['outer', 'row', 'col']" :data="data" :row-draggable="false">
<bk-table-column :label="t('配置模板空间')" prop="template_set_name" :width="432"></bk-table-column>
<bk-table-column :label="t('模板套餐')" prop="template_space_name"></bk-table-column>
<bk-table-column :label="t('配置模板空间')" prop="template_space_name" :width="432"></bk-table-column>
<bk-table-column :label="t('模板套餐')" prop="template_set_name"></bk-table-column>
<bk-table-column label="" align="center" :width="50">
<template #default="{ index }">
<i class="bk-bscp-icon icon-reduce delete-icon" @click="handleDeleteConfig(index)"></i>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<bk-button
theme="primary"
style="margin-right: 8px"
:disabled="confirmBtnDisabled"
:disabled="confirmBtnDisabled || loading"
:loading="loading"
@click="handleConfirm">
{{ t('导入') }}
Expand Down Expand Up @@ -198,17 +198,19 @@
} else {
await importKvFormText(props.bkBizId, props.appId, importConfigList.value, isClearDraft.value);
}
Message({
theme: 'success',
message: t('配置项导入成功'),
});
emits('update:show', false);
setTimeout(() => {
emits('confirm');
Message({
theme: 'success',
message: t('配置项导入成功'),
});
}, 300);
} catch (error) {
console.error(error);
} finally {
loading.value = false;
}
emits('update:show', false);
emits('confirm');
};

const handleTableChange = (data: IConfigKvItem[], isNonExistData: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,12 @@
:opacity="0.7">
<div v-if="importConfigList.length" class="content">
<div class="head">
<bk-checkbox style="margin-left: 24px" v-model="isClearDraft"> {{ $t('导入前清空草稿区') }} </bk-checkbox>
<div v-if="!isClearDraft" class="tips">
<div class="tips">
{{ t('共将导入') }} <span style="color: #3a84ff">{{ importConfigList.length }}</span>
{{ t('个配置项,其中') }} <span style="color: #ffa519">{{ existConfigList.length }}</span>
{{ t('个已存在,导入后将') }}
<span style="color: #ffa519">{{ t('覆盖原配置') }}</span>
</div>
<div v-else class="tips">
{{ t('将') }} <span style="color: #ffa519">{{ t('清空') }}</span> {{ t('现有草稿区,并导入') }}
<span style="color: #3a84ff">{{ importConfigList.length }}</span>
{{ t('个配置项') }}
</div>
</div>
<ConfigTable
v-if="nonExistConfigList.length"
Expand Down Expand Up @@ -110,13 +104,13 @@
const expandExistTable = ref(true);
const isSelectPkgDialogShow = ref(false);
const importType = ref('localFile');
const isClearDraft = ref(false);
const uploadFileLoading = ref(false);
const decompressing = ref(false);

watch(
() => props.show,
(val) => {
clearData();
isShow.value = val;
isTableChange.value = false;
},
Expand Down Expand Up @@ -230,11 +224,6 @@
margin-left: 0 !important;
font-size: 12px;
}
.tips {
padding-left: 16px;
border-left: 1px solid #dcdee5;
margin-left: 16px;
}
}
}
.config-table-loading {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
:esc-close="false"
:quick-close="false"
:is-loading="props.pending"
:is-disabled="props.pending"
@confirm="handleConfirm"
@closed="close">
<bk-form ref="formRef" form-type="vertical" :model="{ pkgs: selectedPkgs }">
Expand Down Expand Up @@ -43,6 +44,17 @@
</bk-table>
</bk-loading>
</div>
<template #footer>
<bk-button
theme="primary"
style="margin-right: 8px"
:disabled="props.pending"
:loading="props.pending"
@click="handleConfirm">
{{ t('确认') }}
</bk-button>
<bk-button @click="close">{{ t('取消') }}</bk-button>
</template>
</bk-dialog>
</template>
<script lang="ts" setup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@
:name="props.configs.length > 0 ? props.configs[0].spec.name : ''"
:current-pkg="props.currentPkg as number"
@moved-out="emits('movedOut')" />
<DeleteConfigDialog v-model:show="isDeleteConfigDialogShow" :configs="props.configs" @deleted="emits('deleted')" />
<DeleteConfigDialog
v-model:show="isDeleteConfigDialogShow"
:is-batch-delete="true"
:configs="props.configs"
@deleted="emits('deleted')" />
</template>
<script lang="ts" setup>
import { ref } from 'vue';
Expand Down Expand Up @@ -122,7 +126,6 @@
appIds: number[];
}) => {
try {
console.log(appIds);
editLoading.value = true;
const { privilege, user, user_group } = permission;
const query = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
:title="t('确认删除以下配置文件?')"
header-align="center"
:is-show="props.show"
ext-cls="delete-confirm-dialog"
@confirm="handleConfirm"
@closed="close">
ext-cls="delete-confirm-dialog">
<div class="tips">{{ t('一旦删除,该操作将无法撤销,请谨慎操作') }}</div>
<bk-table :data="props.configs" border="outer" max-height="200">
<bk-table-column :label="t('配置文件名称')">
Expand All @@ -20,11 +18,23 @@
</template>
</bk-table-column>
</bk-table>
<template #footer>
<bk-button
theme="primary"
style="margin-right: 8px"
:disabled="pending"
:loading="pending"
@click="handleConfirm">
{{ t('删除') }}
</bk-button>
<bk-button @click="close">{{ t('取消') }}</bk-button>
</template>
</bk-dialog>
<DeleteConfirmDialog
v-else
:title="t('确认删除该配置文件?')"
:is-show="props.show"
:pending="pending"
@confirm="handleConfirm"
@close="close">
<div style="margin-bottom: 8px">
Expand Down Expand Up @@ -64,11 +74,13 @@
const ids = props.configs.map((config) => config.id);
await deleteTemplate(spaceId.value, currentTemplateSpace.value, ids);
close();
emits('deleted');
Message({
theme: 'success',
message: t('删除配置文件成功'),
});
setTimeout(() => {
emits('deleted');
Message({
theme: 'success',
message: t('删除配置文件成功'),
});
}, 300);
} catch (e) {
console.log(e);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
theme="primary"
style="margin-right: 8px"
:loading="loading"
:disabled="loading"
@click="emits('confirm', { permission: localVal, appIds: citeByAppIds })">
{{ t('保存') }}
</bk-button>
Expand Down
Loading