Skip to content

Commit

Permalink
fix: 1.服务管理-配置项批量删除问题;2.模板管理-配置模板跨页批量修改权限问题;3.模板管理部分数据不再使用仓库传输--bug=1…
Browse files Browse the repository at this point in the history
…28881823
  • Loading branch information
q15971095971 committed Aug 13, 2024
1 parent 2c35f97 commit 2827051
Show file tree
Hide file tree
Showing 11 changed files with 106 additions and 45 deletions.
11 changes: 4 additions & 7 deletions bcs-services/bcs-bscp/ui/src/api/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,7 @@ export const downloadConfigContent = (bizId: string, appId: number, signature: s
* @param signature 文件内容的SHA256值
* @returns
*/
export const getConfigUploadFileIsExist = (
bizId: string,
appId: number,
signature: string,
) =>
export const getConfigUploadFileIsExist = (bizId: string, appId: number, signature: string) =>
http
.get(`/biz/${bizId}/content/metadata`, {
headers: {
Expand Down Expand Up @@ -511,9 +507,10 @@ export const deleteKv = (bizId: string, appId: number, configId: number) =>
* @param bizId 业务ID
* @param appId 应用ID
* @param ids 配置项ID列表
* @param exclusion_operation 是否跨页
*/
export const batchDeleteKv = (bizId: string, appId: number, ids: number[]) =>
http.post(`config/biz/${bizId}/apps/${appId}/kvs/batch_delete`, { ids });
export const batchDeleteKv = (bizId: string, appId: number, ids: number[], exclusion_operation: boolean) =>
http.post(`config/biz/${bizId}/apps/${appId}/kvs/batch_delete`, { ids, exclusion_operation });

/**
* 获取已发布kv
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@
if (props.isFileType) {
await batchDeleteServiceConfigs(props.bkBizId, props.appId, props.selectedIds);
} else {
await batchDeleteKv(props.bkBizId, props.appId, props.selectedIds);
await batchDeleteKv(props.bkBizId, props.appId, props.selectedIds, props.isAcrossChecked);
}
Message({
theme: 'success',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,18 @@
@closed="close">
<template #header>
<div class="header-wrapper">
<div class="title">{{ isMultiple || isAcrossChecked ? t('批量添加至') : t('添加至套餐') }}</div>
<div class="title">{{ isMultiple || props.isAcrossChecked ? t('批量添加至') : t('添加至套餐') }}</div>
<div v-if="props.value.length === 1" class="config-name">{{ fileAP(props.value[0]) }}</div>
</div>
</template>
<div v-if="isMultiple || isAcrossChecked" class="selected-mark">
<div v-if="isMultiple || props.isAcrossChecked" class="selected-mark">
{{ t('已选') }}
<span class="num">{{ isAcrossChecked ? dataCount - props.value.length : props.value.length }}</span>
<span class="num">{{ props.isAcrossChecked ? props.dataCount - props.value.length : props.value.length }}</span>
{{ t('个配置文件') }}
</div>
<bk-form ref="formRef" form-type="vertical" :model="{ pkgs: selectedPkgs }">
<bk-form-item
:label="isMultiple || isAcrossChecked ? t('添加至模板套餐') : t('模板套餐')"
:label="isMultiple || props.isAcrossChecked ? t('添加至模板套餐') : t('模板套餐')"
property="pkgs"
required>
<bk-select v-model="selectedPkgs" multiple @change="handPkgsChange" @clear="handleClearPkgs">
Expand Down Expand Up @@ -72,13 +72,15 @@
import LinkToApp from '../../../components/link-to-app.vue';
const { spaceId } = storeToRefs(useGlobalStore());
const { packageList, currentTemplateSpace, currentPkg, isAcrossChecked, dataCount } = storeToRefs(useTemplateStore());
const { packageList, currentTemplateSpace, currentPkg } = storeToRefs(useTemplateStore());
const { t } = useI18n();
const props = defineProps<{
show: boolean;
value: ITemplateConfigItem[];
citeByPkgIds?: number[];
isAcrossChecked: boolean;
dataCount: number;
}>();
const emits = defineEmits(['update:show', 'added']);
Expand Down Expand Up @@ -179,7 +181,7 @@
currentTemplateSpace.value,
templateIds,
selectedPkgs.value,
isAcrossChecked.value,
props.isAcrossChecked,
typeof currentPkg.value === 'string' ? 0 : currentPkg.value,
currentPkg.value === 'no_specified',
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@after-show="isPopoverOpen = true"
@after-hidden="isPopoverOpen = false">
<bk-button
:disabled="props.configs.length === 0 && !isAcrossChecked"
:disabled="props.configs.length === 0 && !props.isAcrossChecked"
:class="['batch-set-btn', { 'popover-open': isPopoverOpen }]">
{{ t('批量操作') }}
<AngleDown class="angle-icon" />
Expand All @@ -29,18 +29,24 @@
</div>
</template>
</bk-popover>
<AddToDialog v-model:show="isAddToDialogShow" :value="props.configs" @added="emits('refresh')" />
<AddToDialog
v-model:show="isAddToDialogShow"
:value="props.configs"
:is-across-checked="props.isAcrossChecked"
:data-count="props.dataCount"
@added="emits('refresh')" />
<EditPermissionDialg
v-model:show="isEditPermissionShow"
:loading="editLoading"
:configs-length="isAcrossChecked ? dataCount - props.configs.length : props.configs.length"
:configs-length="props.isAcrossChecked ? props.dataCount - props.configs.length : props.configs.length"
:configs="props.configs"
@confirm="handleConfirmEditPermission($event)" />
<BatchMoveOutFromPkgDialog
v-model:show="isBatchMoveDialogShow"
:current-pkg="props.currentPkg as number"
:value="props.configs"
:value-length="isAcrossChecked ? dataCount - props.configs.length : props.configs.length"
:value-length="props.isAcrossChecked ? props.dataCount - props.configs.length : props.configs.length"
:is-across-checked="props.isAcrossChecked"
@moved-out="emits('movedOut')" />
<MoveOutFromPkgsDialog
v-model:show="isSingleMoveDialogShow"
Expand All @@ -52,17 +58,17 @@
v-model:show="isDeleteConfigDialogShow"
:is-batch-delete="true"
:configs="props.configs"
:is-across-checked="props.isAcrossChecked"
:data-count="props.dataCount"
@deleted="emits('deleted')" />
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { AngleDown } from 'bkui-vue/lib/icon';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { storeToRefs } from 'pinia';
import Message from 'bkui-vue/lib/message';
import { ITemplateConfigItem } from '../../../../../../../../types/template';
import useTemplateStore from '../../../../../../../store/template';
import { batchEditTemplatePermission } from '../../../../../../../api/template';
import AddToDialog from '../add-to-pkgs/add-to-dialog.vue';
import EditPermissionDialg from '../edit-permission/edit-permission-dialog.vue';
Expand All @@ -76,7 +82,6 @@
user_group: string;
}
const { isAcrossChecked, dataCount } = storeToRefs(useTemplateStore());
const { t } = useI18n();
const route = useRoute();
Expand All @@ -86,6 +91,8 @@
configs: ITemplateConfigItem[];
pkgType: string;
currentPkg?: number | string;
isAcrossChecked: boolean;
dataCount: number;
}>();
const emits = defineEmits(['refresh', 'movedOut', 'deleted']);
Expand Down Expand Up @@ -141,7 +148,7 @@
template_ids: props.configs.map((item) => item.id),
app_ids: appIds,
template_space_id: bkBizId.value,
current_check_type: isAcrossChecked,
exclusion_operation: props.isAcrossChecked,
template_set_id: props.currentPkg !== undefined ? props.currentPkg : 0,
no_set_specified: props.pkgType === 'without',
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
v-if="props.isBatchDelete"
:title="
t('确认删除所选的 {n} 个配置文件?', {
n: isAcrossChecked ? dataCount - props.configs.length : props.configs.length,
n: props.isAcrossChecked ? props.dataCount - props.configs.length : props.configs.length,
})
"
header-align="left"
:is-show="props.show"
ext-cls="delete-confirm-dialog">
<div class="tips">{{ t('一旦删除,该操作将无法撤销,请谨慎操作') }}</div>
<bk-table v-show="!isAcrossChecked" :data="props.configs" border="outer" max-height="200">
<bk-table v-show="!props.isAcrossChecked" :data="props.configs" border="outer" max-height="200">
<bk-table-column :label="t('配置文件绝对路径')">
<template #default="{ row }">
<span v-if="row.spec">{{ fileAP(row) }}</span>
Expand Down Expand Up @@ -54,13 +54,15 @@
import { deleteTemplate } from '../../../../../../../api/template';
import DeleteConfirmDialog from '../../../../../../../components/delete-confirm-dialog.vue';
const { spaceId } = storeToRefs(useGlobalStore());
const { currentTemplateSpace, isAcrossChecked, dataCount } = storeToRefs(useTemplateStore());
const { currentTemplateSpace } = storeToRefs(useTemplateStore());
const { t } = useI18n();
const props = defineProps<{
show: boolean;
configs: ITemplateConfigItem[];
isBatchDelete?: boolean;
isAcrossChecked: boolean;
dataCount: number;
}>();
const emits = defineEmits(['update:show', 'deleted']);
Expand All @@ -80,7 +82,7 @@
try {
pending.value = true;
const ids = props.configs.map((config) => config.id);
await deleteTemplate(spaceId.value, currentTemplateSpace.value, ids, isAcrossChecked.value);
await deleteTemplate(spaceId.value, currentTemplateSpace.value, ids, props.isAcrossChecked);
close();
setTimeout(() => {
emits('deleted');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,15 @@
import LinkToApp from '../../../components/link-to-app.vue';
const { spaceId } = storeToRefs(useGlobalStore());
const { packageList, currentTemplateSpace, isAcrossChecked } = storeToRefs(useTemplateStore());
const { packageList, currentTemplateSpace } = storeToRefs(useTemplateStore());
const { t } = useI18n();
const props = defineProps<{
show: boolean;
currentPkg: number;
value: ITemplateConfigItem[];
valueLength: number;
isAcrossChecked: boolean;
}>();
const emits = defineEmits(['update:show', 'movedOut']);
Expand Down Expand Up @@ -113,7 +114,7 @@
currentTemplateSpace.value,
ids,
[props.currentPkg as number],
isAcrossChecked.value,
props.isAcrossChecked,
pkg.id, // 全部配置文件/未指定套餐没有移出套餐选项
);
emits('movedOut');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
}
const { spaceId } = storeToRefs(useGlobalStore());
const { currentTemplateSpace, isAcrossChecked } = storeToRefs(useTemplateStore());
const { currentTemplateSpace } = storeToRefs(useTemplateStore());
const { t } = useI18n();
const props = defineProps<{
Expand Down Expand Up @@ -192,7 +192,7 @@
currentTemplateSpace.value,
[props.id],
selectedPkgs.value,
isAcrossChecked.value,
false,
typeof props.currentPkg === 'string' ? 0 : props.currentPkg,
);
emits('movedOut');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@
v-model:show="isAddToPkgsDialogShow"
:value="crtConfig"
:cite-by-pkg-ids="configCiteByPkgIds"
:is-across-checked="props.isAcrossChecked"
:data-count="props.dataCount"
@added="handleAdded" />
<MoveOutFromPkgsDialog
v-model:show="isMoveOutFromPkgsDialogShow"
Expand All @@ -147,7 +149,12 @@
:space-id="spaceId"
:current-template-space="currentTemplateSpace"
:config="appBoundByTemplateSliderData.data" />
<DeleteConfigDialog v-model:show="isDeleteConfigDialogShow" :configs="crtConfig" @deleted="handleConfigsDeleted" />
<DeleteConfigDialog
v-model:show="isDeleteConfigDialogShow"
:configs="crtConfig"
:is-across-checked="props.isAcrossChecked"
:data-count="props.dataCount"
@deleted="handleConfigsDeleted" />
<ViewConfig
v-model:show="isViewConfigShow"
:space-id="spaceId"
Expand Down Expand Up @@ -197,7 +204,7 @@
const { t, locale } = useI18n();
const { spaceId } = storeToRefs(useGlobalStore());
const templateStore = useTemplateStore();
const { currentTemplateSpace, topIds, isAcrossChecked } = storeToRefs(templateStore);
const { currentTemplateSpace, topIds } = storeToRefs(templateStore);
const { pagination, updatePagination } = useTablePagination('commonConfigTable');
const props = defineProps<{
Expand All @@ -207,9 +214,11 @@
showBoundByAppsCol?: boolean; // 是否显示模板被服务引用列
showDeleteAction?: boolean; // 是否显示删除操作
getConfigList: Function;
isAcrossChecked: boolean;
dataCount: number;
}>();
const emits = defineEmits(['update:selectedConfigs']);
const emits = defineEmits(['update:selectedConfigs', 'sendAcrossCheckedType']);
const listLoading = ref(false);
const list = ref<ITemplateConfigItem[]>([]);
Expand All @@ -236,6 +245,7 @@
const editConfigId = ref(0);
const selectConfigMemo = ref('');
const configCiteByPkgIds = ref<number[]>([]);
const isAcrossChecked = ref(false);
const crossPageSelect = computed(() => pagination.value.limit < pagination.value.count);
Expand All @@ -255,10 +265,9 @@
},
);
watch(selections, () => {
templateStore.$patch((state) => {
state.isAcrossChecked = [CheckType.HalfAcrossChecked, CheckType.AcrossChecked].includes(selectType.value);
});
isAcrossChecked.value = [CheckType.HalfAcrossChecked, CheckType.AcrossChecked].includes(selectType.value);
emits('update:selectedConfigs', selections.value);
emits('sendAcrossCheckedType', isAcrossChecked.value, pagination.value.count);
});
onMounted(() => {
Expand Down Expand Up @@ -296,9 +305,6 @@
const res = await props.getConfigList(params);
list.value = res.details;
pagination.value.count = res.count;
templateStore.$patch((state) => {
state.dataCount = res.count;
});
listLoading.value = false;
const ids = list.value.map((item) => item.id);
citeByPkgsList.value = [];
Expand Down Expand Up @@ -366,6 +372,7 @@
// 根据选择类型决定传递的状态
handleRowCheckChange(shouldBeChecked, row);
emits('update:selectedConfigs', selections.value);
emits('sendAcrossCheckedType', isAcrossChecked.value, pagination.value.count);
};
// 选中状态
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,25 @@
current-pkg="all"
:show-cited-by-pkgs-col="true"
:show-bound-by-apps-col="true"
:get-config-list="getConfigList">
:get-config-list="getConfigList"
:is-across-checked="acrossCheckedType.isAcrossChecked"
:data-count="acrossCheckedType.dataCount"
@send-across-checked-type="
(checked, dataCount) => {
acrossCheckedType.isAcrossChecked = checked;
acrossCheckedType.dataCount = dataCount;
}
">
<template #tableOperations>
<AddConfigs @refresh="refreshConfigList" />
<BatchOperationButton
:space-id="spaceId"
:configs="selectedConfigs"
:current-template-space="currentTemplateSpace"
pkg-type="all"
@refresh="refreshConfigList"/>
:is-across-checked="acrossCheckedType.isAcrossChecked"
:data-count="acrossCheckedType.dataCount"
@refresh="refreshConfigList" />
</template>
</CommonConfigTable>
</template>
Expand All @@ -35,6 +45,10 @@
const configTable = ref();
const selectedConfigs = ref<ITemplateConfigItem[]>([]);
const acrossCheckedType = ref<{ isAcrossChecked: boolean; dataCount: number }>({
isAcrossChecked: false,
dataCount: 0,
});
const getConfigList = (params: ICommonQuery) => {
console.log('All Config List Loading');
Expand Down
Loading

0 comments on commit 2827051

Please sign in to comment.