云
18 小时以前 c2e8526f8f857be5e3a8c6f2b39c5efd424de33e
src/views/mes/pro/task/data.ts
@@ -3,6 +3,7 @@
import { z } from '#/adapter/form';
import { getSimpleUserListByRoleCode } from '#/api/system/user';
import { getTemplatePage } from '#/api/mes/pro/processdesign/template';
import { getUserListByWorkstationId } from '#/api/mes/md/workstation/worker';
import type { MesProTaskApi } from '#/api/mes/pro/task';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
@@ -85,6 +86,7 @@
/** 待排产订单列表的字段 */
export function useGridColumns(): VxeTableGridOptions<MesProWorkOrderApi.WorkOrder>['columns'] {
  return [
    { type: 'checkbox', width: 48, fixed: 'left' },
    {
      field: 'code',
      title: '订单编码',
@@ -142,15 +144,6 @@
      },
    },
    {
      field: 'productionStatus',
      title: '生产状态',
      width: 100,
      cellRender: {
        name: 'CellDict',
        props: { type: DICT_TYPE.ORDER_PRODUCTION_STATUS },
      },
    },
    {
      field: 'quantity',
      title: '订单数量',
      width: 100,
@@ -166,9 +159,10 @@
      width: 100,
    },
    {
      field: 'clientCode',
      title: '客户编码',
      width: 120,
      field: 'progressPercent',
      title: '完成进度',
      width: 150,
      slots: { default: 'progressPercent' },
    },
    {
      field: 'clientName',
@@ -184,7 +178,7 @@
    {
      title: '操作',
      width: 160,
      width: 240,
      fixed: 'right',
      slots: { default: 'actions' },
    },
@@ -348,6 +342,12 @@
      width: 120,
    },
    {
      field: 'paramTemplateId',
      title: '工艺参数模板',
      minWidth: 140,
      formatter: ({ cellValue }) => cellValue ? `模板 #${cellValue}` : '未配置',
    },
    {
      field: 'quantity',
      title: '排产数量',
      width: 100,
@@ -394,7 +394,7 @@
}
/** 生产任务新增/修改的表单 */
export function useTaskFormSchema(formApi?: VbenFormApi, workOrderQuantity?: Ref<number | undefined>, feedbackRole?: Ref<string | undefined>): VbenFormSchema[] {
export function useTaskFormSchema(formApi?: VbenFormApi, workOrderQuantity?: Ref<number | undefined>): VbenFormSchema[] {
  return [
    {
      fieldName: 'paramTemplateId',
@@ -489,11 +489,18 @@
      component: 'ApiSelect',
      componentProps: {
        placeholder: '请选择报工人',
        api: getSimpleUserListByRoleCode,
        params: { code: feedbackRole?.value || 'production_submit_work' },
        api: getUserListByWorkstationId,
        labelField: 'nickname',
        valueField: 'id',
        mode: 'multiple',
      },
      dependencies: {
        triggerFields: ['workstationId'],
        componentProps: (values) => ({
          params: { workstationId: values.workstationId },
          disabled: !values.workstationId,
          placeholder: values.workstationId ? '请选择报工人' : '请先选择工作站',
        }),
      },
      rules: z.array(z.number()).min(1, '请选择报工人').default([]),
    },
@@ -514,6 +521,18 @@
async function recalcDuration(formApi?: VbenFormApi) {
  if (!formApi) return;
  const values = await formApi.getValues();
  if (values.workstationId) {
    try {
      const users = await getUserListByWorkstationId({ workstationId: values.workstationId });
      if (!users || users.length === 0) {
        message.warning('当前工作站没有配置人力资源');
      }
    } catch {
      // ignore
    }
  }
  if (!values.workstationId || !values.quantity) return;
  try {
    const res = await calculateTaskDuration(values.workstationId, values.quantity);