From 641941ac5c0d3f72f5b706da9a131dd5348ea8fb Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期四, 05 十一月 2026 20:16:26 +0800
Subject: [PATCH] feat(crm): 开票金额仅提示可开票金额,不再限制
---
src/views/crm/invoice/data.ts | 37 ++++++++++++++++++++++++++++++++-----
1 files changed, 32 insertions(+), 5 deletions(-)
diff --git a/src/views/crm/invoice/data.ts b/src/views/crm/invoice/data.ts
index b2578d9..a90bd58 100644
--- a/src/views/crm/invoice/data.ts
+++ b/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',
--
Gitblit v1.9.3