src/views/mes/workbench/components/tabs/FeedbackTab.vue
@@ -18,7 +18,7 @@
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import {
  approveFeedback,
  createFeedback,
  createFeedback, getBatchRequirements,
  getFeedback,
  getFeedbackPage,
  rejectFeedback,
@@ -29,7 +29,10 @@
import { $t } from '#/locales';
import { useFormSchema } from '../../../pro/feedback/data';
import BatchInputDialog from '../../../pro/feedback/modules/batch-input-dialog.vue';
const batchDialogRef = ref<InstanceType<typeof BatchInputDialog>>();
const batchActionType = ref<'submit' | 'approve'>('');
const pendingSubmitMode = ref<'saveAndSubmit' | 'submit'>('submit');
defineOptions({ name: 'WorkbenchFeedbackTab' });
const props = defineProps<{
@@ -131,9 +134,9 @@
    itemSpecification: task.itemSpecification,
    unitMeasureName: task.unitMeasureName,
    scheduledQuantity: task.quantity,
    feedbackApprove: task.feedbackApprove,
    checkFlag,
  });
  originalSnapshot.value = JSON.stringify(await getAlignedData());
}
@@ -168,6 +171,7 @@
  if (props.task) {
    await resetForTask(props.task);
  }
  emit('reported');
}
@@ -203,8 +207,12 @@
    return;
  }
  pendingSubmitMode.value = 'saveAndSubmit';
  // 4. 调用提交接口
  await submitFeedback(record.id!);
  const isDone = await handleOnSubmit(feedbackId.value!,props.task.feedbackApprove);
  if (!isDone) return;
  feedbackId.value = record.id;
  feedbackStatus.value = record.status;
@@ -232,13 +240,60 @@
    await updateFeedback(data);
    originalSnapshot.value = JSON.stringify(data);
  }
  await submitFeedback(feedbackId.value!);
  message.success('报订单已提交');
  pendingSubmitMode.value = 'submit';
  const isDone = await handleOnSubmit(feedbackId.value!,props.task.feedbackApprove);
  if (!isDone) return;
  message.success('报工单已提交');
  // 重置表单为新建模式
  if (props.task) {
    await resetForTask(props.task);
  }
  emit('reported');
}
/** 提交方法 */
async function handleOnSubmit(id:any,feedbackRate:any): Promise<boolean> {
  if (feedbackRate&&feedbackRate==true){
    await submitFeedback({ id: feedbackId.value! });
    return true;
  }
  const checkResult = await getBatchRequirements(id);
  if (checkResult?.needBatchInput) {
    batchActionType.value = 'submit';
    batchDialogRef.value?.open({ checkResult });
    return false;
  } else {
    await submitFeedback({ id: feedbackId.value! });
    return true;
  }
}
/** 批次确认回调 */
async function handleBatchConfirm(batchData: Record<string, unknown>) {
  if (batchActionType.value === 'submit') {
    await submitFeedback({ id: feedbackId.value!, ...batchData });
    if (pendingSubmitMode.value === 'saveAndSubmit') {
      const data = await getAlignedData();
      const code = data.code as string;
      Modal.success({
        title: '保存并提交成功',
        content: `报工单 ${code} 已提交`,
        centered: true,
      });
    } else {
      message.success('报工单已提交');
    }
    if (props.task) {
      await resetForTask(props.task);
    }
    emit('reported');
  }
}
/** 审批通过 */
@@ -294,6 +349,7 @@
<template>
  <div class="feedback-tab">
    <BatchInputDialog ref="batchDialogRef" @confirm="handleBatchConfirm" />
    <div v-if="!task" class="feedback-tab__empty">
      请从左侧工单列表选择一条任务
    </div>