gaoluyang
2026-11-02 fa95ef8dd4c23d05bf7bee16927f207cc0793412
src/views/mes/pro/task/modules/schedule-form.vue
@@ -43,24 +43,18 @@
  wrapperClass: 'grid-cols-3',
});
/** 加载工单工序列表(仅使用工单工序,不回退到工艺路线模板) */
/** 加载工单工序列表;未配置工序时按单工序生产处理 */
async function loadRouteProcesses(workOrderId: number, productId: number) {
  const woProcesses = await getWorkOrderProcessListByWorkOrderId(workOrderId);
  if (!woProcesses || woProcesses.length === 0) {
    message.warning('当前订单未配置工序,请先在工单中维护工序信息');
    return;
  }
  // 确定工艺路线ID:工单路线 → 产品路线
  // 确定工艺路线ID:有工序时按产品路线带出;未配置工序时按单工序生产
  let tempRouteId = 0;
  if (workOrder.value?.routeId) {
    tempRouteId = workOrder.value.routeId;
  } else {
  if (woProcesses && woProcesses.length > 0) {
    const processes = await getRouteProcessListByProduct(productId);
    tempRouteId = processes?.[0]?.routeId ?? 0;
  }
  currentRouteId.value = tempRouteId;
  routeProcessList.value = [...woProcesses].toSorted(
  routeProcessList.value = [...(woProcesses ?? [])].toSorted(
    (a, b) => (a.sort ?? 0) - (b.sort ?? 0),
  );
}
@@ -121,7 +115,8 @@
  <Modal :title="getTitle" class="w-4/5">
    <Form class="mx-4" />
    <!-- 工序步骤导航 + 当前工序任务列表 -->
    <template v-if="routeProcessList.length > 0 && workOrder?.id">
    <template v-if="workOrder?.id">
      <template v-if="routeProcessList.length > 0">
      <Steps
        v-model:current="activeProcessStep"
        class="my-4 px-4"
@@ -152,19 +147,26 @@
        </Card>
      </template>
    </template>
      <!-- 未配置工序/工艺路线:整张工单按单工序排产 -->
      <Card v-else class="mx-4">
        <TaskList
          :disabled="isReadonly"
          :item-id="workOrder.productId"
          :route-id="currentRouteId || undefined"
          :work-order-id="workOrder.id!"
          :work-order-quantity="workOrder.quantity"
        />
      </Card>
    </template>
    <template #prepend-footer>
      <div class="flex flex-auto items-center gap-2">
        <template v-if="formType === 'schedule'">
          <Popconfirm
            v-if="routeProcessList.length > 0"
            title="确认要完成该订单吗?完成后订单下所有任务将标记为已完成。"
            @confirm="handleFinish"
          >
            <Button type="primary">完成</Button>
          </Popconfirm>
          <span v-else class="text-gray-400 text-sm">
            当前订单未配置工序,请先在工单中维护工序信息后再完成
          </span>
        </template>
      </div>
    </template>