liu
3 天以前 641941ac5c0d3f72f5b706da9a131dd5348ea8fb
feat(crm): 开票金额仅提示可开票金额,不再限制

- 开票金额输入框展示合同可开票金额(仅供参考)
- 保留提示但不限制实际开票金额
已修改1个文件
37 ■■■■■ 文件已修改
src/views/crm/invoice/data.ts 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/crm/invoice/data.ts
@@ -9,7 +9,14 @@
import { getSimpleUserList } from '#/api/system/user';
import CrmCustomerSelect from '#/components/crm-customer-select.vue';
import { markRaw } from 'vue';
import { markRaw, ref } from 'vue';
/**
 * 当前所选合同的可开票金额(合同金额 - 已开票金额)
 *
 * 仅用于输入框提示,不限制实际开票金额
 */
const invoiceableAmount = ref<null | number>(null);
/** 新增/修改的表单 */
export function useFormSchema(): VbenFormSchema[] {
@@ -60,6 +67,7 @@
        onChange: () => {
          form.setFieldValue('contractId', undefined);
          form.setFieldValue('price', undefined);
          invoiceableAmount.value = null;
        },
      }),
      dependencies: {
@@ -86,6 +94,16 @@
          const approvedContracts = contracts.filter(
            (item) => item.auditStatus === 20,
          );
          const findRemain = (contractId?: number) => {
            const contract = approvedContracts.find(
              (item) => item.id === contractId,
            );
            return contract
              ? (contract.totalPrice ?? 0) - (contract.totalInvoicePrice ?? 0)
              : null;
          };
          // 回填当前已选合同的可开票金额(编辑场景)
          invoiceableAmount.value = findRemain(values.contractId);
          return {
            options: approvedContracts.map((item) => {
              const remain =
@@ -96,8 +114,9 @@
              };
            }),
            placeholder: '请选择合同',
            onChange: () => {
            onChange: (value: number) => {
              form.setFieldValue('price', undefined);
              invoiceableAmount.value = findRemain(value);
            },
          } as any;
        },
@@ -136,12 +155,20 @@
      label: '开票金额(元)',
      component: 'InputNumber',
      rules: 'required',
      componentProps: {
      // 仅做提示,不限制实际开票金额
      help: () =>
        invoiceableAmount.value === null
          ? '可开票金额 = 合同金额 - 已开票金额,仅供参考,不限制开票金额'
          : `该合同可开票金额:¥${invoiceableAmount.value.toFixed(2)}(仅供参考,不限制开票金额)`,
      componentProps: () => ({
        class: '!w-full',
        placeholder: '请输入开票金额',
        placeholder:
          invoiceableAmount.value === null
            ? '请输入开票金额'
            : `可开票 ¥${invoiceableAmount.value.toFixed(2)}(不限)`,
        min: 0,
        precision: 2,
      },
      }),
    },
    {
      fieldName: 'invoiceTime',