gaoluyang
6 天以前 e4994fccfb49ebfb108ba62cbd82aea4e004f6d8
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 { MdmItemApi } from '#/api/mdm/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';
@@ -19,11 +20,16 @@
import { Button } from 'ant-design-vue';
import { z } from '#/adapter/form';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { generateAutoCode } from '#/api/mes/md/autocode/record';
import { ErpSaleOrderSelect } from '#/views/erp/sale/order/components';
import { getRangePickerDefaultProps } from '#/utils';
import { MdClientSelect } from '#/views/mes/md/client/components';
import { MdItemSelect } from '#/views/mes/md/item/components';
import { MdmItemSelect } from '#/views/basicData/mdm/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  buildItemUnitSchema,
  useLineUnitHandlers,
} from '#/views/wls/utils/item-unit-convert';
import {
  WmSalesNoticeLineSelect,
  WmSalesNoticeSelect,
@@ -138,12 +144,38 @@
      },
    },
    {
      fieldName: 'saleOrderId',
      label: '销售订单编号',
      component: markRaw(ErpSaleOrderSelect),
      componentProps: {
        disabled: isHeaderReadonly(formType),
        placeholder: '请选择销售订单',
        onChange: (item: any) => {
          if (formApi) {
            formApi.setFieldValue('salesOrderCode', item?.no ?? '');
            if (item?.customerId) {
              formApi.setFieldValue('clientId', item.customerId);
            }
          }
        },
      },
      rules: 'selectRequired',
      dependencies: {
        triggerFields: ['salesOrderCode'],
        if: () => formType === 'create',
      },
    },
    {
      fieldName: 'salesOrderCode',
      label: '销售订单编号',
      component: 'Input',
      componentProps: {
        disabled: isHeaderReadonly(formType),
        placeholder: '请输入销售订单编号',
        disabled: true,
        placeholder: '销售订单编号',
      },
      dependencies: {
        triggerFields: [''],
        if: () => formType !== 'create',
      },
    },
    {
@@ -155,14 +187,14 @@
        disabled: isHeaderReadonly(formType),
        format: 'YYYY-MM-DD',
        placeholder: '请选择出库日期',
        valueFormat: 'x',
        valueFormat: 'YYYY-MM-DD',
      },
      rules: 'required',
    },
    {
      fieldName: 'clientId',
      label: '客户',
      component: markRaw(MdClientSelect),
      component: markRaw(CrmCustomerSelect),
      componentProps: {
        disabled: isHeaderReadonly(formType),
        placeholder: '请选择客户',
@@ -269,7 +301,7 @@
    {
      fieldName: 'clientId',
      label: '客户',
      component: markRaw(MdClientSelect),
      component: markRaw(CrmCustomerSelect),
      componentProps: {
        placeholder: '请选择客户',
      },
@@ -399,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',
@@ -445,6 +492,7 @@
  hasNotice: boolean,
  formApi?: VbenFormApi,
): VbenFormSchema[] {
  const unitHandlers = useLineUnitHandlers(formApi);
  return [
    {
      fieldName: 'noticeId',
@@ -461,6 +509,8 @@
      componentProps: {
        // 选择发货通知单行后,自动回填物料、数量、批次、是否检验
        onChange: async (line?: MesWmSalesNoticeLineApi.SalesNoticeLine) => {
          // 切换通知行等于切换产品,先重置型号与单位口径(会清空数量),再按通知行回填
          await unitHandlers.handleItemChange(line?.itemId);
          await formApi?.setValues({
            batchCode: line?.batchCode,
            itemId: line?.itemId,
@@ -480,9 +530,13 @@
    {
      fieldName: 'itemId',
      label: '产品',
      component: markRaw(MdItemSelect),
      component: markRaw(MdmItemSelect),
      componentProps: {
        placeholder: '请选择产品',
        // 切换产品后,重新记录物料主单位并清空型号、录入单位口径
        onChange: async (item?: MdmItemApi.Item) => {
          await unitHandlers.handleItemChange(item?.id);
        },
      },
      rules: 'selectRequired',
      dependencies: {
@@ -493,6 +547,8 @@
        }),
      },
    },
    // 物料型号 / 录入单位 / 录入数量 / 出库数量(物料主单位口径)
    ...buildItemUnitSchema(formApi),
    {
      fieldName: 'batchCode',
      label: '批次号',
@@ -500,18 +556,6 @@
      componentProps: {
        placeholder: '请输入批次号',
      },
    },
    {
      fieldName: 'quantity',
      label: '出库数量',
      component: 'InputNumber',
      componentProps: {
        class: '!w-full',
        min: 0,
        placeholder: '请输入出库数量',
        precision: 2,
      },
      rules: 'required',
    },
    {
      fieldName: 'oqcCheckFlag',
@@ -597,7 +641,7 @@
    {
      fieldName: 'itemId',
      label: '物料',
      component: markRaw(MdItemSelect),
      component: markRaw(MdmItemSelect),
      componentProps: {
        disabled: true,
      },