gaoluyang
2026-11-03 3913f39ba957d8738487be4d252af8d9e1d2aa4f
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script lang="ts" setup>
import type { WorkOrderProgress } from '#/api/mes/pro/workorder';
 
import { ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
import { DICT_TYPE } from '@vben/constants';
 
import { DictTag } from '#/components/dict-tag';
import { Progress, Table, Tag } from 'ant-design-vue';
 
import { getWorkOrderProgress } from '#/api/mes/pro/workorder';
 
const loading = ref(false);
const progress = ref<WorkOrderProgress>({});
 
const taskColumns = [
  { title: '任务编码', dataIndex: 'taskCode', width: 170 },
  { title: '工作站', dataIndex: 'workstationName', width: 140 },
  { title: '计划数量', dataIndex: 'quantity', width: 100 },
  { title: '已生产数量', dataIndex: 'producedQuantity', width: 110 },
  { title: '进度', dataIndex: 'progressPercent', width: 160 },
  { title: '任务状态', dataIndex: 'status', width: 110 },
];
 
async function load(workOrderId: number) {
  loading.value = true;
  try {
    progress.value = (await getWorkOrderProgress(workOrderId)) || {};
  } finally {
    loading.value = false;
  }
}
 
const [Modal, modalApi] = useVbenModal({
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      progress.value = {};
      return;
    }
    modalApi.setState({ showCancelButton: false, showConfirmButton: false });
    const data = modalApi.getData<{ workOrderId?: number }>();
    if (data?.workOrderId) {
      await load(data.workOrderId);
    }
  },
});
</script>
 
<template>
  <Modal
    title="工单执行情况"
    class="w-3/4"
    content-class="!max-h-[75vh] overflow-y-auto"
  >
    <div class="mx-4 flex flex-col gap-3">
      <div class="grid grid-cols-4 gap-3">
        <div class="rounded border border-gray-200 p-2 text-center">
          <div class="text-xs text-gray-500">工单数量</div>
          <div class="text-lg font-semibold">{{ progress.quantity ?? '-' }}</div>
        </div>
        <div class="rounded border border-gray-200 p-2 text-center">
          <div class="text-xs text-gray-500">已排产数量</div>
          <div class="text-lg font-semibold">
            {{ progress.quantityScheduled ?? '-' }}
          </div>
        </div>
        <div class="rounded border border-gray-200 p-2 text-center">
          <div class="text-xs text-gray-500">已生产数量</div>
          <div class="text-lg font-semibold">
            {{ progress.quantityProduced ?? '-' }}
          </div>
        </div>
        <div class="rounded border border-gray-200 p-2 text-center">
          <div class="text-xs text-gray-500">完成进度</div>
          <div class="text-lg font-semibold">
            {{ progress.progressPercent ?? 0 }}%
          </div>
        </div>
      </div>
 
      <div v-if="progress.processList?.length" class="flex flex-col gap-3">
        <div
          v-for="process in progress.processList"
          :key="process.processId"
          class="rounded border border-gray-200 p-3"
        >
          <div class="mb-2 flex items-center gap-2">
            <span class="font-medium">
              {{ process.processCode || '' }} {{ process.processName || '' }}
            </span>
            <Tag v-if="process.keyFlag" color="red">关键工序</Tag>
            <span class="text-xs text-gray-500">
              计划 {{ process.plannedQuantity ?? '-' }} / 已生产
              {{ process.producedQuantity ?? '-' }}
            </span>
            <div class="ml-auto flex w-1/3 items-center gap-2">
              <Progress
                :percent="process.progressPercent || 0"
                :show-info="false"
                size="small"
                style="flex: 1; margin: 0"
              />
              <span class="text-xs">{{ process.progressPercent || 0 }}%</span>
            </div>
          </div>
          <Table
            :columns="taskColumns"
            :data-source="process.taskList || []"
            :loading="loading"
            :pagination="false"
            bordered
            row-key="taskId"
            size="small"
          >
            <template #bodyCell="{ column, record }">
              <template v-if="column.dataIndex === 'progressPercent'">
                <Progress
                  :percent="record.progressPercent || 0"
                  size="small"
                />
              </template>
              <template v-else-if="column.dataIndex === 'status'">
                <DictTag
                  :type="DICT_TYPE.MES_PRO_TASK_STATUS"
                  :value="record.status"
                />
              </template>
            </template>
          </Table>
        </div>
      </div>
      <div v-else class="py-8 text-center text-gray-400">
        该工单暂无工序/任务执行数据
      </div>
    </div>
  </Modal>
</template>