gaoluyang
7 天以前 6ebcfebf58fe23ea401de1050b15ba85e41763a9
src/views/wls/productsales/data.ts
@@ -4,31 +4,21 @@
import type { MesWmProductSalesApi } from '#/api/mes/wm/productsales';
import type { MesWmProductSalesDetailApi } from '#/api/mes/wm/productsales/detail';
import type { MesWmProductSalesLineApi } from '#/api/mes/wm/productsales/line';
import type { MesWmSalesNoticeApi } from '#/api/mes/wm/salesnotice';
import type { MesWmSalesNoticeLineApi } from '#/api/mes/wm/salesnotice/line';
import { h, markRaw } from 'vue';
import {
  DICT_TYPE,
  MesAutoCodeRuleCode,
  MesWmSalesNoticeStatusEnum,
} from '@vben/constants';
import { DICT_TYPE, MesAutoCodeRuleCode } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
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 { MdItemSelect } from '#/views/mes/md/item/components';
import { WmMaterialStockSelect } from '#/views/wls/materialstock/components';
import {
  WmSalesNoticeLineSelect,
  WmSalesNoticeSelect,
} from '#/views/wls/salesnotice/components';
import { WmSalesNoticeLineSelect } from '#/views/wls/salesnotice/components';
import {
  WmWarehouseAreaSelect,
  WmWarehouseLocationSelect,
@@ -120,44 +110,12 @@
      rules: 'required',
    },
    {
      fieldName: 'noticeId',
      label: '发货通知单',
      component: markRaw(WmSalesNoticeSelect),
      fieldName: 'noticeCode',
      label: '发货通知单号',
      component: 'Input',
      componentProps: {
        disabled: isHeaderReadonly(formType),
        // 选择发货通知单后,自动回填销售订单号、客户、收货人信息
        onChange: async (notice?: MesWmSalesNoticeApi.SalesNotice) => {
          await formApi?.setValues({
            clientId: notice?.clientId,
            contactAddress: notice?.recipientAddress,
            contactName: notice?.recipientName,
            contactTelephone: notice?.recipientTelephone,
            salesOrderCode: notice?.salesOrderCode,
          });
        },
        status: MesWmSalesNoticeStatusEnum.APPROVED,
      },
    },
    {
      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',
        placeholder: '请输入发货通知单号',
      },
    },
    {
@@ -165,12 +123,8 @@
      label: '销售订单编号',
      component: 'Input',
      componentProps: {
        disabled: true,
        placeholder: '销售订单编号',
      },
      dependencies: {
        triggerFields: [''],
        if: () => formType !== 'create',
        disabled: isHeaderReadonly(formType),
        placeholder: '请输入销售订单编号',
      },
    },
    {
@@ -187,14 +141,14 @@
      rules: 'required',
    },
    {
      fieldName: 'clientId',
      fieldName: 'clientName',
      label: '客户',
      component: markRaw(CrmCustomerSelect),
      component: 'Input',
      componentProps: {
        disabled: isHeaderReadonly(formType),
        placeholder: '请选择客户',
        placeholder: '请输入客户名称',
      },
      rules: 'selectRequired',
      rules: 'required',
    },
    {
      fieldName: 'contactName',
@@ -294,11 +248,12 @@
      },
    },
    {
      fieldName: 'clientId',
      fieldName: 'clientName',
      label: '客户',
      component: markRaw(CrmCustomerSelect),
      component: 'Input',
      componentProps: {
        placeholder: '请选择客户',
        allowClear: true,
        placeholder: '请输入客户名称',
      },
    },
    {