From 50717b73051aab8a85c10b8ee8d2944458b1fa6f Mon Sep 17 00:00:00 2001 From: yinq Date: Wed, 15 Apr 2026 18:27:06 +0800 Subject: [PATCH] =?UTF-8?q?1.1.19=20=E5=90=88=E5=90=8C=E8=AE=A2=E5=8D=95?= =?UTF-8?q?=E5=8F=B0=E8=B4=A6=E5=BC=80=E7=A5=A8=E4=BF=A1=E6=81=AF=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E6=96=B0=E5=A2=9E=E5=BC=80=E7=A5=A8=E6=8C=89=E9=92=AE?= =?UTF-8?q?=EF=BC=8C=E5=88=B7=E6=96=B0=E6=8C=89=E9=92=AE=E3=80=82=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=BC=80=E7=A5=A8=E6=8C=89=E5=90=88=E5=90=8CID?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E5=B8=A6=E5=87=BA=E9=A1=B9=E7=9B=AE=E4=B8=8E?= =?UTF-8?q?=E5=90=88=E5=90=8C=E7=9B=B8=E5=85=B3=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/oa/erp/finInvoiceInfo/edit.vue | 31 ++++++++++++++++++++++++ src/views/oa/erp/orderLedger/index.vue | 28 ++++++++++++++++----- 2 files changed, 53 insertions(+), 6 deletions(-) diff --git a/src/views/oa/erp/finInvoiceInfo/edit.vue b/src/views/oa/erp/finInvoiceInfo/edit.vue index b94f687..2c0aa24 100644 --- a/src/views/oa/erp/finInvoiceInfo/edit.vue +++ b/src/views/oa/erp/finInvoiceInfo/edit.vue @@ -321,6 +321,8 @@ import { UserVO } from '@/api/system/user/types'; import ContractSelectDialog from '@/views/oa/components/ContractSelectDialog.vue'; import FileUpload from '@/components/FileUpload/index.vue'; import { checkPermi } from '@/utils/permission'; +import { getContractInfo } from '@/api/oa/erp/contractInfo'; +import { listProjectInfoByContractId } from '@/api/oa/erp/projectInfo'; const userOptions = ref([]); const deptOptions = ref([]); @@ -549,6 +551,34 @@ const calculateReturnedRate = () => { } }; +// 新增开票页:从台账带入 contractId 时自动回填项目与合同信息 +const initByContractId = async () => { + const contractId = routeParams.value.contractId as string | number | undefined; + if (!contractId) return; + + const [contractRes, projectRes] = await Promise.all([getContractInfo(contractId), listProjectInfoByContractId(contractId)]); + const contract = contractRes?.data; + const projectList = (projectRes?.data || []) as any[]; + const routeProjectId = routeParams.value.projectId as string | number | undefined; + const matchedProject = + projectList.find((item) => routeProjectId && String(item.projectId) === String(routeProjectId)) || projectList[0]; + + Object.assign(form.value, { + contractId, + contractCode: contract?.contractCode, + contractName: contract?.contractName, + customerId: contract?.oneCustomerId, + customerName: contract?.oneCustomerName, + totalPrice: contract?.totalPrice, + projectId: matchedProject?.projectId, + projectCode: matchedProject?.projectCode, + projectName: matchedProject?.projectName, + contractFlag: matchedProject?.contractFlag + }); + + await getContractPaymentMethods(contractId); +}; + const isInitialized = ref(false); onMounted(async () => { @@ -568,6 +598,7 @@ onMounted(async () => { } else { const res = await getBaseInfo(); Object.assign(form.value, res.data); + await initByContractId(); handleAddItem(); } // 数据加载完成后,设置初始化标志为 true diff --git a/src/views/oa/erp/orderLedger/index.vue b/src/views/oa/erp/orderLedger/index.vue index 0898a33..1732ba6 100644 --- a/src/views/oa/erp/orderLedger/index.vue +++ b/src/views/oa/erp/orderLedger/index.vue @@ -319,6 +319,10 @@ 开票信息 {{ invoiceTotal }} 条 +
+ 新增开票 + 刷新 +
@@ -474,7 +478,7 @@ const purchaseQuery = reactive({ spareFlag: undefined as string | undefined }); const invoiceTotal = ref(0); -const invoiceQuery = reactive({ pageNum: 1, pageSize: 10, projectId: undefined as string | number | undefined, contractId: undefined as string | number | undefined }); +const invoiceQuery = reactive({ pageNum: 1, pageSize: 10, contractId: undefined as string | number | undefined }); /** 格式化数字 */ const formatNumber = (num: number) => { @@ -589,6 +593,20 @@ const viewInvoice = (row: FinInvoiceInfoVO) => { }); }; +/** 从台账新增开票,并携带合同信息 */ +const addInvoiceFromLedger = () => { + const contractId = orderInfo.value?.contractId ?? contractInfo.value?.contractId; + if (!contractId) { + proxy?.$modal.msgWarning('合同信息未加载完成,请稍后重试'); + return; + } + proxy?.$tab.openPage('/fin/finInvoiceInfo/edit', '开票信息', { + type: 'add', + source: 'orderLedger', + contractId + }); +}; + /** 加载订单基本信息和合同信息 */ const loadOrderAndContract = async () => { if (!projectId.value) return; @@ -647,16 +665,14 @@ const getPurchaseMaterialRowClass = ({ row }: { row: { unpurchasedAmount?: numbe /** 加载开票信息 */ const loadInvoiceList = async () => { - if (!projectId.value) { + const contractId = orderInfo.value?.contractId ?? contractInfo.value?.contractId; + if (!contractId) { invoiceList.value = []; invoiceTotal.value = 0; return; } - // 优先按合同ID查询(开票VO里也有contractId),否则按项目ID查询 - const contractId = orderInfo.value?.contractId ?? contractInfo.value?.contractId; - invoiceQuery.projectId = contractId ? undefined : projectId.value; - invoiceQuery.contractId = contractId ? contractId : undefined; + invoiceQuery.contractId = contractId; loadingInvoice.value = true; try {