src/views/wls/returnvendor/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 { MesWmMaterialStockApi } from '#/api/mes/wm/materialstock';
import type { MesWmReturnVendorApi } from '#/api/mes/wm/returnvendor';
import type { MesWmReturnVendorDetailApi } from '#/api/mes/wm/returnvendor/detail';
@@ -17,6 +18,10 @@
import { ErpPurchaseOrderSelect } from '#/views/erp/purchase/order/components';
import { WmBatchSelect } from '#/views/wls/batch/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  buildItemUnitSchema,
  useLineUnitHandlers,
} from '#/views/wls/utils/item-unit-convert';
import {
  WmWarehouseAreaSelect,
  WmWarehouseLocationSelect,
@@ -301,9 +306,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',
@@ -333,6 +353,7 @@
  vendorId?: number,
  formApi?: VbenFormApi,
): VbenFormSchema[] {
  const unitHandlers = useLineUnitHandlers(formApi);
  return [
    {
      fieldName: 'itemId',
@@ -340,21 +361,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: 'batchId',
      label: '批次号',