src/views/wls/miscissue/data.ts
@@ -13,6 +13,10 @@
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { getRangePickerDefaultProps } from '#/utils';
import {
  useLineUnitHandlers,
  buildItemUnitSchema,
} from '#/views/wls/utils/item-unit-convert';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  WmWarehouseAreaSelect,
@@ -283,9 +287,24 @@
      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',
@@ -327,6 +346,7 @@
/** 出库单行新增/修改的表单 */
export function useLineFormSchema(formApi?: VbenFormApi): VbenFormSchema[] {
  const unitHandlers = useLineUnitHandlers(formApi);
  return [
    {
      fieldName: 'itemId',
@@ -351,10 +371,11 @@
      componentProps: {
        // 选择库存物资后,自动回填物料、批次号、仓库位置和最大可出库数量
        onChange: async (stock?: MesWmMaterialStockApi.MaterialStock) => {
          // 切换库存物资等于切换物料,先清掉上一份型号与录入单位口径
          await unitHandlers.handleItemChange(stock?.itemId);
          await formApi?.setValues({
            areaId: stock?.areaId,
            batchCode: stock?.batchCode,
            itemId: stock?.itemId,
            locationId: stock?.locationId,
            quantityMax: stock?.quantity,
            warehouseId: stock?.warehouseId,
@@ -369,28 +390,8 @@
        }),
      },
    },
    {
      fieldName: 'quantity',
      label: '出库数量',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0.01,
        placeholder: '请输入出库数量',
        precision: 2,
      },
      rules: 'required',
      dependencies: {
        triggerFields: ['quantityMax'],
        componentProps: (values) => ({
          class: '!w-full',
          max: values.quantityMax,
          min: 0.01,
          placeholder: '请输入出库数量',
          precision: 2,
        }),
      },
    },
    // 物料型号 / 录入单位 / 录入数量 / 出库数量(主单位口径)
    ...buildItemUnitSchema(formApi),
    {
      fieldName: 'batchCode',
      label: '批次号',