gaoluyang
4 天以前 7b307741022678632e06bbed3c996a8ddd013759
fix: MOM
1.采购来票登记时选好采购订单后提示可来票金额
已修改6个文件
79 ■■■■ 文件已修改
src/api/erp/purchase/order/index.ts 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/finance/payment/data.ts 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/finance/payment/modules/form.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/invoice/data.ts 48 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/invoice/modules/form.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/erp/purchase/invoice/modules/purchase-order-select.vue 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/erp/purchase/order/index.ts
@@ -13,6 +13,7 @@
    totalCount?: number; // 合计数量
    totalPrice?: number; // 合计金额,单位:元
    totalProductPrice?: number; // 产品金额,单位:元
    totalTaxPrice?: number; // 合计税额,单位:元
    discountPercent?: number; // 优惠率,百分比
    discountPrice?: number; // 优惠金额,单位:元
    depositPrice?: number; // 定金金额,单位:元
src/views/erp/finance/payment/data.ts
@@ -152,18 +152,14 @@
      formItemClass: 'col-span-3',
    },
    {
      fieldName: 'accountId',
      fieldName: 'accountName',
      label: '付款账户',
      component: 'ApiSelect',
      component: 'Input',
      rules: 'required',
      componentProps: {
        placeholder: '请选择付款账户',
        placeholder: '请输入付款账户',
        allowClear: true,
        showSearch: true,
        api: getAccountSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
      help: '付款账户数据来自【财务管理 → 结算账户】菜单维护的开启状态账户,无选项时请先在结算账户页面新增。',
    },
    {
      fieldName: 'totalPrice',
src/views/erp/finance/payment/modules/form.vue
@@ -29,7 +29,7 @@
  id: undefined,
  no: '',
  supplierId: undefined,
  accountId: undefined,
  accountName: undefined,
  financeUserId: undefined,
  paymentTime: undefined,
  remark: '',
@@ -176,11 +176,11 @@
    formApi.setDisabled(formType.value === 'detail');
    formApi.updateSchema(useFormSchema(formType.value));
    if (!data || !data.id) {
      // 新增时,默认选中账户
      // 新增时,默认填入默认结算账户名称
      const accountList = await getAccountSimpleList();
      const defaultAccount = accountList.find((item) => item.defaultStatus);
      if (defaultAccount) {
        await formApi.setValues({ accountId: defaultAccount.id });
        await formApi.setValues({ accountName: defaultAccount.name });
      }
      return;
    }
src/views/erp/purchase/invoice/data.ts
@@ -1,7 +1,10 @@
import type { Ref } from 'vue';
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import { getSupplierSimpleList } from '#/api/srm/supplier';
import { z } from '#/adapter/form';
import { markRaw } from 'vue';
@@ -11,7 +14,9 @@
export type FormType = 'create' | 'detail' | 'edit';
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
export function useFormSchema(
  orderTotalTaxPrice?: Ref<number | undefined>,
): VbenFormSchema[] {
  return [
    {
      fieldName: 'id',
@@ -41,8 +46,15 @@
      },
      componentProps: (_values, form) => ({
        placeholder: '请选择采购订单',
        onChange: (order: { supplierName?: string } | undefined) => {
        onChange: (
          order:
            | { supplierName?: string; totalTaxPrice?: number }
            | undefined,
        ) => {
          form.setFieldValue('supplierName', order?.supplierName);
          if (orderTotalTaxPrice) {
            orderTotalTaxPrice.value = order?.totalTaxPrice;
          }
        },
      }),
    },
@@ -78,11 +90,37 @@
      label: '来票金额(元)',
      component: 'InputNumber',
      rules: 'required',
      description: () =>
        orderTotalTaxPrice?.value != null
          ? `采购订单未开票金额:${Number(orderTotalTaxPrice.value).toFixed(2)} 元`
          : '',
      componentProps: {
        class: '!w-full',
        placeholder: '请输入来票金额',
        min: 0,
        precision: 2,
      },
      dependencies: {
        triggerFields: ['purchaseOrderId'],
        componentProps: () => ({
          class: '!w-full',
          placeholder: '请输入来票金额',
          min: 0,
          max: orderTotalTaxPrice?.value ?? undefined,
          precision: 2,
        }),
        rules: () => {
          const max = orderTotalTaxPrice?.value;
          if (max != null) {
            return z
              .number({ message: '请输入来票金额' })
              .min(0, '来票金额不能小于 0')
              .max(max, `来票金额不能大于未开票金额 ${Number(max).toFixed(2)}`);
          }
          return z
            .number({ message: '请输入来票金额' })
            .min(0, '来票金额不能小于 0');
        },
      },
    },
    {
@@ -180,12 +218,6 @@
    {
      title: '来票金额(元)',
      field: 'price',
      minWidth: 150,
      formatter: 'formatAmount2',
    },
    {
      title: '剩余可付金额',
      field: 'remainingInvoicePrice',
      minWidth: 150,
      formatter: 'formatAmount2',
    },
src/views/erp/purchase/invoice/modules/form.vue
@@ -22,6 +22,7 @@
const emit = defineEmits(['success']);
const formData = ref<ErpPurchaseInvoiceApi.PurchaseInvoice>();
const formType = ref<FormType>('create');
const orderTotalTaxPrice = ref<number>(); // 所选采购订单合计税额(未开票金额,用于提示与校验)
const getTitle = computed(() => {
  if (formType.value === 'create') {
@@ -42,7 +43,7 @@
  },
  wrapperClass: 'grid-cols-2',
  layout: 'horizontal',
  schema: useFormSchema(),
  schema: useFormSchema(orderTotalTaxPrice),
  showDefaultActions: false,
});
@@ -71,12 +72,13 @@
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      formData.value = undefined;
      orderTotalTaxPrice.value = undefined;
      return;
    }
    const data = modalApi.getData<{ formType: FormType; id?: number }>();
    formType.value = data.formType;
    formApi.setDisabled(formType.value === 'detail');
    formApi.updateSchema(useFormSchema());
    formApi.updateSchema(useFormSchema(orderTotalTaxPrice));
    await formApi.resetForm();
    if (!data || !data.id) {
      return;
src/views/erp/purchase/invoice/modules/purchase-order-select.vue
@@ -92,6 +92,12 @@
        minWidth: 120,
      },
      {
        field: 'totalTaxPrice',
        title: '未开票金额',
        formatter: 'formatAmount2',
        minWidth: 120,
      },
      {
        field: 'status',
        title: '状态',
        minWidth: 100,