5 天以前 91c82965b2d987452ca276e3a03b48c8dcda2ae9
src/views/erp/finance/payment/data.ts
@@ -6,7 +6,8 @@
import { erpPriceInputFormatter } from '@vben/utils';
import { getAccountSimpleList } from '#/api/erp/finance/account';
import { getSupplierSimpleList } from '#/api/erp/purchase/supplier';
import { getPurchaseInvoiceSimpleList } from '#/api/erp/purchase/invoice';
import { getSupplierSimpleList } from '#/api/srm/supplier';
import { getSimpleUserList } from '#/api/system/user';
import { getRangePickerDefaultProps } from '#/utils';
@@ -42,7 +43,7 @@
        placeholder: '选择付款时间',
        showTime: true,
        format: 'YYYY-MM-DD HH:mm:ss',
        valueFormat: 'x',
        valueFormat: 'YYYY-MM-DD HH:mm:ss',
      },
      rules: 'required',
    },
@@ -50,7 +51,7 @@
      fieldName: 'supplierId',
      label: '供应商',
      component: 'ApiSelect',
      componentProps: {
      componentProps: (_values, form) => ({
        disabled: formType === 'detail',
        placeholder: '请选择供应商',
        allowClear: true,
@@ -58,8 +59,54 @@
        api: getSupplierSimpleList,
        labelField: 'name',
        valueField: 'id',
      },
        onChange: () => {
          // 供应商变化后,清空已选的关联来票
          form.setFieldValue('invoiceId', undefined);
        },
      }),
      rules: 'required',
    },
    {
      fieldName: 'invoiceId',
      label: '关联来票',
      component: formType === 'detail' ? 'Input' : 'Select',
      componentProps:
        formType === 'detail'
          ? {
              disabled: true,
              placeholder: '--',
            }
          : undefined,
      rules: 'required',
      dependencies: {
        // 依赖 invoiceId 自身,确保编辑回显时重新加载选项以匹配已选来票
        triggerFields: ['supplierId', 'invoiceId'],
        disabled: (values) => formType === 'detail' || !values.supplierId,
        async componentProps(values) {
          if (formType === 'detail') {
            return {};
          }
          if (!values.supplierId) {
            return {
              options: [],
              placeholder: '请先选择供应商',
            };
          }
          const invoices = await getPurchaseInvoiceSimpleList(
            values.supplierId,
          );
          return {
            options: invoices.map((item) => {
              const remain = item.remainingInvoicePrice ?? item.price ?? 0;
              return {
                label: `${item.no} / ${item.invoiceNo ?? '-'} / ¥${item.price ?? 0} / 剩余可付 ¥${remain.toFixed(2)}`,
                value: item.id,
              };
            }),
            placeholder: '请选择关联来票',
          } as any;
        },
      },
    },
    {
      fieldName: 'financeUserId',
@@ -86,10 +133,13 @@
      formItemClass: 'col-span-2',
    },
    {
      fieldName: 'fileUrl',
      fieldName: 'blobIds',
      label: '附件',
      component: 'FileUpload',
      componentProps: {
        valueKey: 'id',
        maxNumber: 10,
        multiple: true,
        showDescription: formType !== 'detail',
        disabled: formType === 'detail',
      },
@@ -113,6 +163,7 @@
        labelField: 'name',
        valueField: 'id',
      },
      help: '付款账户数据来自【财务管理 → 结算账户】菜单维护的开启状态账户,无选项时请先在结算账户页面新增。',
    },
    {
      fieldName: 'totalPrice',
@@ -130,6 +181,7 @@
      fieldName: 'discountPrice',
      label: '优惠金额',
      component: 'InputNumber',
      defaultValue: 0,
      componentProps: {
        class: '!w-full',
        disabled: formType === 'detail',
@@ -162,15 +214,13 @@
  ];
}
/** 表单的明细表格列 */
export function useFormItemColumns(
  disabled: boolean,
): VxeTableGridOptions['columns'] {
/** 表单的明细表格列(付款基于来票,明细由来票自动生成,不可删除) */
export function useFormItemColumns(): VxeTableGridOptions['columns'] {
  return [
    { type: 'seq', title: '序号', minWidth: 50, fixed: 'left' },
    {
      field: 'bizNo',
      title: '采购单据编号',
      title: '来票编号',
      minWidth: 200,
    },
    {
@@ -197,13 +247,6 @@
      title: '备注',
      minWidth: 150,
      slots: { default: 'remark' },
    },
    {
      title: '操作',
      width: 50,
      fixed: 'right',
      slots: { default: 'actions' },
      visible: !disabled,
    },
  ];
}
@@ -332,6 +375,12 @@
      minWidth: 120,
    },
    {
      field: 'invoice',
      title: '关联来票',
      minWidth: 200,
      slots: { default: 'invoice' },
    },
    {
      field: 'paymentTime',
      title: '付款时间',
      width: 160,