云
2026-10-25 b7ffa7395cddfeb10f88d70a81567371f62021c3
src/views/mes/pro/route/data.ts
@@ -18,6 +18,9 @@
import { z } from '#/adapter/form';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getWarehouseSimpleList } from '#/api/mes/wm/warehouse';
import { getWarehouseAreaSimpleList } from '#/api/mes/wm/warehouse/area';
import { getWarehouseLocationSimpleList } from '#/api/mes/wm/warehouse/location';
import {
  MdItemSelect,
  MdProductBomSelect,
@@ -180,6 +183,7 @@
/** 工艺路线工序明细表单 */
export function useRouteProcessFormSchema(
  processOptions: Array<{ label: string; value: number }>,
  productIds: number[] = [],
): VbenFormSchema[] {
  return [
    {
@@ -250,6 +254,17 @@
        unCheckedChildren: '否',
      },
      rules: z.boolean().default(false),
    },
    {
      fieldName: 'outputItemIds',
      label: '产出产品',
      component: markRaw(MdItemSelect),
      componentProps: {
        multiple: true,
        productIds,
        placeholder: '中间工序选半成品,末道工序选全部成品',
      },
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'prepareTime',
@@ -323,6 +338,7 @@
    },
    { field: 'prepareTime', title: '准备时间(分)', width: 110 },
    { field: 'waitTime', title: '等待时间(分)', width: 110 },
    { field: 'outputItemNames', title: '产出产品', minWidth: 180 },
    {
      field: 'colorCode',
      title: '甘特图颜色',
@@ -347,6 +363,9 @@
    { field: 'specification', title: '规格型号', width: 150 },
    { field: 'unitName', title: '单位', width: 80 },
    { field: 'quantity', title: '生产数量', width: 100 },
    { field: 'warehouseName', title: '报工仓库', width: 130 },
    { field: 'locationName', title: '库区', width: 120 },
    { field: 'areaName', title: '库位', width: 120 },
    {
      field: 'productionTime',
      title: '生产用时',
@@ -384,6 +403,7 @@
/** 工艺路线产品表单 */
export function useRouteProductFormSchema(
  onItemChange?: (item: any) => void,
  getFormApi?: () => VbenFormApi,
): VbenFormSchema[] {
  return [
    {
@@ -419,6 +439,63 @@
      rules: z.number().default(1),
    },
    {
      fieldName: 'warehouseId',
      label: '报工仓库',
      component: 'ApiSelect',
      componentProps: {
        api: getWarehouseSimpleList,
        labelField: 'name',
        valueField: 'id',
        placeholder: '请选择报工产出仓库',
        onChange: async () => {
          await getFormApi?.().setFieldValue('locationId', undefined);
          await getFormApi?.().setFieldValue('areaId', undefined);
        },
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'locationId',
      label: '报工库区',
      component: 'Select',
      dependencies: {
        triggerFields: ['warehouseId'],
        disabled: (values) => !values.warehouseId,
        async componentProps(values) {
          const options = values.warehouseId
            ? await getWarehouseLocationSimpleList(values.warehouseId)
            : [];
          return {
            fieldNames: { label: 'name', value: 'id' },
            options,
            placeholder: '请选择报工产出库区',
            onChange: async () => getFormApi?.().setFieldValue('areaId', undefined),
          };
        },
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'areaId',
      label: '报工库位',
      component: 'Select',
      dependencies: {
        triggerFields: ['locationId'],
        disabled: (values) => !values.locationId,
        async componentProps(values) {
          const options = values.locationId
            ? await getWarehouseAreaSimpleList(values.locationId)
            : [];
          return {
            fieldNames: { label: 'name', value: 'id' },
            options,
            placeholder: '请选择报工产出库位',
          };
        },
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'productionTime',
      label: '生产用时',
      component: 'InputNumber',