shuishen
11 hours ago 385be2eca72eb3833efa4be0a0088b34e764788a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<script setup lang="ts">
import { computed, ref } from "vue";
import { DeleteOutlined } from "@ant-design/icons-vue";
import { deleteRun, loadRunDeletionPlan, type RunDeletionPlan } from "@/api/artifacts";
 
const props = defineProps<{ capability: string; runId: string; label: string }>();
const emit = defineEmits<{ removed: [] }>();
const visible = ref(false);
const loadingPlan = ref(false);
const deleting = ref(false);
const error = ref<string | null>(null);
const plan = ref<RunDeletionPlan | null>(null);
const directoryCount = computed(() => {
  const value = plan.value;
  return value ? value.outputDirectories.length + value.rawDirectories.length + value.processedDirectories.length + value.dependentDirectories.length : 0;
});
 
async function open() {
  loadingPlan.value = true;
  error.value = null;
  plan.value = null;
  visible.value = true;
  try { plan.value = await loadRunDeletionPlan(props.capability, props.runId); }
  catch (reason) { error.value = reason instanceof Error ? reason.message : "无法读取删除范围。"; }
  finally { loadingPlan.value = false; }
}
async function confirm() {
  if (!plan.value?.removable) return;
  deleting.value = true;
  error.value = null;
  try { await deleteRun(props.capability, props.runId); visible.value = false; emit("removed"); }
  catch (reason) { error.value = reason instanceof Error ? reason.message : "删除失败。"; }
  finally { deleting.value = false; }
}
</script>
 
<template>
  <a-tooltip title="删除该结果及其控制台关联副本">
    <a-button type="text" danger size="small" aria-label="删除完整结果" @click.stop="open"><DeleteOutlined /></a-button>
  </a-tooltip>
  <a-modal v-model:open="visible" :title="`移除完整结果:${label}`" :confirm-loading="deleting" :ok-button-props="{ danger: true, disabled: loadingPlan || !plan?.removable }" :ok-text="plan?.removable ? '移除全部关联数据' : '不可删除'" cancel-text="取消" @ok="confirm">
    <a-spin :spinning="loadingPlan">
      <a-alert v-if="error" type="error" show-icon :message="error" />
      <a-alert v-else-if="plan && !plan.removable" type="info" show-icon message="该结果不能通过控制台删除" :description="plan.reason" />
      <template v-else-if="plan">
        <a-alert type="warning" show-icon message="此操作不可恢复" description="仅删除本地控制台生成的结果和上传副本;baseData 与外部原始输入不会删除。" />
        <a-descriptions size="small" :column="1" class="deletion-summary">
          <a-descriptions-item label="结果目录">{{ plan.outputDirectories.length }}</a-descriptions-item>
          <a-descriptions-item label="原始上传副本">{{ plan.rawDirectories.length }}</a-descriptions-item>
          <a-descriptions-item label="处理副本">{{ plan.processedDirectories.length }}</a-descriptions-item>
          <a-descriptions-item label="关联结果">{{ plan.dependentDirectories.length }}</a-descriptions-item>
          <a-descriptions-item label="目录总数">{{ directoryCount }}</a-descriptions-item>
        </a-descriptions>
      </template>
    </a-spin>
  </a-modal>
</template>
 
<style scoped>
.deletion-summary { margin-top: 16px; }
</style>