src/views/wls/productsales/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 { MesWmProductSalesApi } from '#/api/mes/wm/productsales';
import type { MesWmProductSalesDetailApi } from '#/api/mes/wm/productsales/detail';
@@ -25,6 +26,10 @@
import { getRangePickerDefaultProps } from '#/utils';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  buildItemUnitSchema,
  useLineUnitHandlers,
} from '#/views/wls/utils/item-unit-convert';
import {
  WmSalesNoticeLineSelect,
  WmSalesNoticeSelect,
@@ -426,9 +431,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',
@@ -472,6 +492,7 @@
  hasNotice: boolean,
  formApi?: VbenFormApi,
): VbenFormSchema[] {
  const unitHandlers = useLineUnitHandlers(formApi);
  return [
    {
      fieldName: 'noticeId',
@@ -488,6 +509,8 @@
      componentProps: {
        // 选择发货通知单行后,自动回填物料、数量、批次、是否检验
        onChange: async (line?: MesWmSalesNoticeLineApi.SalesNoticeLine) => {
          // 切换通知行等于切换产品,先重置型号与单位口径(会清空数量),再按通知行回填
          await unitHandlers.handleItemChange(line?.itemId);
          await formApi?.setValues({
            batchCode: line?.batchCode,
            itemId: line?.itemId,
@@ -510,6 +533,10 @@
      component: markRaw(MdItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        // 切换产品后,重新记录物料主单位并清空型号、录入单位口径
        onChange: async (item?: MesMdItemApi.Item) => {
          await unitHandlers.handleItemChange(item?.id);
        },
      },
      rules: 'selectRequired',
      dependencies: {
@@ -520,6 +547,8 @@
        }),
      },
    },
    // 物料型号 / 录入单位 / 录入数量 / 出库数量(物料主单位口径)
    ...buildItemUnitSchema(formApi),
    {
      fieldName: 'batchCode',
      label: '批次号',
@@ -527,18 +556,6 @@
      componentProps: {
        placeholder: '请输入批次号',
      },
    },
    {
      fieldName: 'quantity',
      label: '出库数量',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        placeholder: '请输入出库数量',
        precision: 2,
      },
      rules: 'required',
    },
    {
      fieldName: 'oqcCheckFlag',