gaoluyang
9 天以前 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,50 +115,58 @@
  <Modal :title="getTitle" class="w-4/5">
    <Form class="mx-4" />
    <!-- 工序步骤导航 + 当前工序任务列表 -->
    <template v-if="routeProcessList.length > 0 && workOrder?.id">
      <Steps
        v-model:current="activeProcessStep"
        class="my-4 px-4"
        size="small"
        type="navigation"
      >
        <Steps.Step
          v-for="rp in routeProcessList"
          :key="rp.processId"
          :title="rp.processName"
          :description="rp.paramTemplateId ? `参数模板 #${rp.paramTemplateId}` : '未配置参数模板'"
        />
      </Steps>
      <template v-for="(rp, index) in routeProcessList" :key="rp.processId">
        <Card
          v-if="activeProcessStep === index"
          class="mx-4"
    <template v-if="workOrder?.id">
      <template v-if="routeProcessList.length > 0">
        <Steps
          v-model:current="activeProcessStep"
          class="my-4 px-4"
          size="small"
          type="navigation"
        >
          <TaskList
            :color-code="rp.colorCode"
            :disabled="isReadonly"
            :item-id="rp.outputItemId || workOrder.productId"
            :process-id="rp.processId!"
            :route-id="currentRouteId"
            :work-order-id="workOrder.id!"
            :work-order-quantity="workOrder.quantity"
          <Steps.Step
            v-for="rp in routeProcessList"
            :key="rp.processId"
            :title="rp.processName"
            :description="rp.paramTemplateId ? `参数模板 #${rp.paramTemplateId}` : '未配置参数模板'"
          />
        </Card>
        </Steps>
        <template v-for="(rp, index) in routeProcessList" :key="rp.processId">
          <Card
            v-if="activeProcessStep === index"
            class="mx-4"
          >
            <TaskList
              :color-code="rp.colorCode"
              :disabled="isReadonly"
              :item-id="rp.outputItemId || workOrder.productId"
              :process-id="rp.processId!"
              :route-id="currentRouteId"
              :work-order-id="workOrder.id!"
              :work-order-quantity="workOrder.quantity"
            />
          </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>