hsy
4 天以前 b3abd460d8f68b9f501b48aeecaa344ff18c033a
src/views/mes/pro/task/data.ts
@@ -1,7 +1,7 @@
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { z } from '#/adapter/form';
import { getSimpleUserListByRoleCode } from '#/api/system/user';
import { getUserListByWorkstationId } from '#/api/mes/md/workstation/worker';
import type { MesProTaskApi } from '#/api/mes/pro/task';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
@@ -393,7 +393,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: 'workstationId',
@@ -475,11 +475,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([]),
    },
@@ -500,6 +507,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);