src/views/mes/pro/task/data.ts
@@ -3,6 +3,8 @@
import type { MesProTaskApi } from '#/api/mes/pro/task';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
import type { Ref } from 'vue';
import { markRaw } from 'vue';
import { DICT_TYPE } from '@vben/constants';
@@ -166,7 +168,7 @@
    },
    {
      title: '操作',
      width: 100,
      width: 160,
      fixed: 'right',
      slots: { default: 'actions' },
    },
@@ -347,8 +349,8 @@
    },
    {
      field: 'duration',
      title: '生产时长',
      width: 80,
      title: '生产时长(h)',
      width: 120,
    },
    {
      field: 'endTime',
@@ -376,7 +378,7 @@
}
/** 生产任务新增/修改的表单 */
export function useTaskFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
export function useTaskFormSchema(formApi?: VbenFormApi, workOrderQuantity?: Ref<number | undefined>): VbenFormSchema[] {
  return [
    {
      fieldName: 'workstationId',
@@ -391,6 +393,7 @@
      fieldName: 'quantity',
      label: '排产数量',
      component: 'InputNumber',
      description: () => workOrderQuantity?.value != null ? `订单数量:${workOrderQuantity.value}` : '',
      componentProps: {
        class: '!w-full',
        min: 0.01,
@@ -420,7 +423,7 @@
    },
    {
      fieldName: 'duration',
      label: '生产时长',
      label: '生产时长(h)',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
@@ -456,7 +459,7 @@
  ];
}
/** 计算结束时间:开始时间 + 生产时长 × 8 小时 */
/** 计算结束时间:开始时间 + 生产时长(小时) */
async function recalcEndTime(formApi?: VbenFormApi) {
  if (!formApi) {
    return;
@@ -466,7 +469,7 @@
    const start = Number(values.startTime);
    await formApi.setFieldValue(
      'endTime',
      start + values.duration * 8 * 3600 * 1000,
      start + values.duration * 3600 * 1000,
    );
  }
}
@@ -553,7 +556,7 @@
      width: 170,
      formatter: 'formatDateTime',
    },
    { field: 'duration', title: '生产时长', width: 100 },
    { field: 'duration', title: '生产时长(h)', width: 120 },
    {
      field: 'endTime',
      title: '预计完成时间',