15 小时以前 bbce6db600e6bb0cf2a3bb78bdf5ccff70b737a8
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 { AutoGeneratePreview } from '#/api/mes/pro/task';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
 
import { ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { message, Tag } from 'ant-design-vue';
 
import { autoGenerateTasks } from '#/api/mes/pro/task';
 
defineOptions({ name: 'SchedulePreviewModal' });
 
interface Props {
  workOrder?: MesProWorkOrderApi.WorkOrder;
  preview?: AutoGeneratePreview;
}
 
const props = withDefaults(defineProps<Props>(), {});
 
interface Emits {
  (e: 'success'): void;
}
 
const emit = defineEmits<Emits>();
 
const [Modal, modalApi] = useVbenModal({
  onOpenChange: (open) => {
    if (!open) return;
  },
});
 
const executing = ref(false);
 
async function handleExecute() {
  if (!props.workOrder?.id) return;
  executing.value = true;
  try {
    const result = await autoGenerateTasks({
      workOrderId: props.workOrder.id,
      routeId: props.preview?.routeId,
    });
    message.success(`排产成功,生成 ${result.taskIds?.length || 0} 个任务`);
    modalApi.close();
    emit('success');
  } finally {
    executing.value = false;
  }
}
</script>
 
<template>
  <Modal title="一键排产预览" @ok="handleExecute">
    <a-descriptions :column="2" bordered size="small" class="mb-4">
      <a-descriptions-item label="工单编码">{{ props.workOrder?.code }}</a-descriptions-item>
      <a-descriptions-item label="生产数量">{{ props.workOrder?.quantity }}</a-descriptions-item>
      <a-descriptions-item label="工艺路线">{{ props.preview?.routeName }}</a-descriptions-item>
      <a-descriptions-item label="预生成任务数">{{ props.preview?.taskList?.length || 0 }}</a-descriptions-item>
    </a-descriptions>
 
    <vxe-grid
      :columns="[
        { field: 'sort', title: '序号', width: 60 },
        { field: 'processName', title: '工序名称', minWidth: 120 },
        {
          field: 'keyFlag',
          title: '关键工序',
          width: 80,
          slots: { default: 'keyFlag' },
        },
        { field: 'suggestWorkstationName', title: '建议工作站', width: 140 },
        { field: 'quantity', title: '排产数量', width: 100 },
      ]"
      :data="props.preview?.taskList || []"
      height="auto"
      size="small"
    >
      <template #keyFlag="{ row: taskRow }">
        <Tag :color="taskRow.keyFlag ? 'blue' : 'default'">
          {{ taskRow.keyFlag ? '是' : '否' }}
        </Tag>
      </template>
    </vxe-grid>
  </Modal>
</template>