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 {