gaoluyang
2026-08-03 75242bbba28ae8902ddf86d33febb497d79e5fc3
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<script lang="ts" setup>
import type { MesProAiApi } from '#/api/mes/pro/ai';
 
import { ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
import { IconifyIcon } from '@vben/icons';
 
import { Alert, Button, message, Progress, Tag } from 'ant-design-vue';
 
import { predictDelivery } from '#/api/mes/pro/ai';
 
defineOptions({ name: 'MesProAiPredictDelivery' });
 
const props = defineProps<{ workOrderId: number }>();
 
const loading = ref(false);
const result = ref<MesProAiApi.PredictDeliveryRespVO>();
 
async function handlePredict() {
  loading.value = true;
  result.value = undefined;
  try {
    result.value = await predictDelivery(props.workOrderId);
    modalApi.open();
  } catch {
    message.error('AI 分析暂时不可用,请稍后重试');
  } finally {
    loading.value = false;
  }
}
 
const [ResultModal, modalApi] = useVbenModal({ footer: false });
</script>
 
<template>
  <Button :loading="loading" @click="handlePredict">
    <template #icon><IconifyIcon icon="ant-design:check-circle-outlined" /></template>
    AI 交付评估
  </Button>
 
  <ResultModal title="AI 按时交付预测" class="w-1/2">
    <template v-if="result">
      <div class="mb-4 flex items-center gap-4">
        <div class="flex items-center gap-2">
          <span class="text-base font-medium">能否按时交付:</span>
          <Tag :color="result.onTime ? 'green' : 'red'">
            {{ result.onTime ? '可按时交付' : '无法按时交付' }}
          </Tag>
        </div>
        <div class="flex items-center gap-2">
          <span class="text-base">置信度:</span>
          <span class="font-medium">{{ result.confidence }}%</span>
        </div>
      </div>
 
      <div class="mb-4 flex items-center gap-4">
        <div class="flex-1">
          <div class="mb-1 text-sm text-gray-500">
            生产进度 {{ result.progressPercent }}%
          </div>
          <Progress :percent="result.progressPercent" :stroke-color="{ '0%': '#108ee9', '100%': '#87d068' }" />
        </div>
        <div class="text-sm text-gray-500">
          剩余 {{ result.remainingDays }} 天
        </div>
      </div>
 
      <div class="mb-4 rounded bg-gray-50 p-3 text-sm leading-relaxed">
        {{ result.reasoning }}
      </div>
 
      <div v-if="!result.onTime && result.delayFactors?.length">
        <div class="mb-2 text-base font-medium">延期因素:</div>
        <Alert
          v-for="(factor, index) in result.delayFactors"
          :key="index"
          type="error"
          show-icon
          class="mb-2"
          :message="factor"
        />
      </div>
    </template>
  </ResultModal>
</template>