src/views/wls/outsourceissue/data.ts
@@ -1,5 +1,6 @@
import type { VbenFormApi, VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MesMdItemApi } from '#/api/mes/md/item';
import type { MesProWorkOrderApi } from '#/api/mes/pro/workorder';
import type { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
import type { MesWmOutsourceIssueApi } from '#/api/mes/wm/outsourceissue';
@@ -22,6 +23,10 @@
import { MdItemSelect } from '#/views/mes/md/item/components';
import { MdVendorSelect } from '#/views/mes/md/vendor/components';
import { ProWorkOrderSelect } from '#/views/mes/pro/workorder/components';
import {
  buildItemUnitSchema,
  useLineUnitHandlers,
} from '#/views/wls/utils/item-unit-convert';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  WmWarehouseAreaSelect,
@@ -254,13 +259,28 @@
      minWidth: 120,
    },
    {
      field: 'itemModel',
      title: '物料型号',
      minWidth: 120,
    },
    {
      field: 'unitMeasureName',
      title: '单位',
      width: 80,
      title: '主计量单位',
      width: 100,
    },
    {
      field: 'enterUnitMeasureName',
      title: '录入单位',
      width: 90,
    },
    {
      field: 'enterQuantity',
      title: '录入数量',
      width: 100,
    },
    {
      field: 'quantity',
      title: '领料数量',
      title: '发料数量',
      width: 100,
    },
    {
@@ -287,7 +307,8 @@
}
/** 发料单行新增/修改的表单 */
export function useLineFormSchema(): VbenFormSchema[] {
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
  const unitHandlers = useLineUnitHandlers(formApi);
  return [
    {
      fieldName: 'itemId',
@@ -295,21 +316,15 @@
      component: markRaw(MdItemSelect),
      componentProps: {
        placeholder: '请选择物料',
        // 切换物料后,重新记录物料主单位并清空型号、录入单位口径
        onChange: async (item?: MesMdItemApi.Item) => {
          await unitHandlers.handleItemChange(item?.id);
        },
      },
      rules: 'selectRequired',
    },
    {
      fieldName: 'quantity',
      label: '发料数量',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        placeholder: '请输入发料数量',
        precision: 2,
      },
      rules: 'required',
    },
    // 物料型号 / 录入单位 / 录入数量 / 发料数量(物料主单位口径)
    ...buildItemUnitSchema(formApi, { quantityLabel: '发料数量' }),
    {
      fieldName: 'batchCode',
      label: '批次号',