@@ -45,20 +54,29 @@ import DrawerHeader from '@/components/drawer-header/index.vue';
import i18n from '@/lang';
const deleteVisible = ref(false);
-const deleteForm = reactive({
+const form = reactive({
+ id: '',
+ force: false,
tags: [] as Array,
deleteTags: [] as Array,
});
+const deleteAll = ref();
+const isIndeterminate = ref(true);
const opRef = ref();
interface DialogProps {
+ id: string;
+ isUsed: boolean;
tags: Array;
}
const acceptParams = (params: DialogProps) => {
+ deleteAll.value = false;
deleteVisible.value = true;
- deleteForm.deleteTags = [];
- deleteForm.tags = params.tags;
+ form.deleteTags = [];
+ form.id = params.id;
+ form.tags = params.tags;
+ form.force = !params.isUsed;
};
const handleClose = () => {
deleteVisible.value = false;
@@ -69,20 +87,39 @@ const onSearch = () => {
emit('search');
};
+const handleCheckAllChange = (val: boolean) => {
+ form.deleteTags = val ? form.tags : [];
+ isIndeterminate.value = false;
+};
+const handleCheckedCitiesChange = (value: string[]) => {
+ const checkedCount = value.length;
+ deleteAll.value = checkedCount === form.tags.length;
+ isIndeterminate.value = checkedCount > 0 && checkedCount < form.tags.length;
+};
+
const batchDelete = async () => {
let names = [];
- for (const item of deleteForm.deleteTags) {
- names.push(item);
+ let showNames = [];
+ if (deleteAll.value) {
+ names.push(form.id);
+ for (const item of form.deleteTags) {
+ showNames.push(item);
+ }
+ } else {
+ for (const item of form.deleteTags) {
+ names.push(item);
+ showNames.push(item);
+ }
}
opRef.value.acceptParams({
title: i18n.global.t('commons.button.delete'),
- names: names,
+ names: showNames,
msg: i18n.global.t('commons.msg.operatorHelper', [
i18n.global.t('container.image'),
i18n.global.t('commons.button.delete'),
]),
api: imageRemove,
- params: { names: names },
+ params: { names: names, force: form.force },
});
};
diff --git a/frontend/src/views/container/image/index.vue b/frontend/src/views/container/image/index.vue
index 26f524a28..451dd1788 100644
--- a/frontend/src/views/container/image/index.vue
+++ b/frontend/src/views/container/image/index.vue
@@ -279,6 +279,7 @@ const buttons = [
}
let params = {
id: row.id,
+ isUsed: row.isUsed,
tags: row.tags,
};
dialogDeleteRef.value!.acceptParams(params);