From 357242b782a2e9a28bfc7f77257e544bacd7f868 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 27 十一月 2025 15:52:32 +0800
Subject: [PATCH] 1.湟水峡-销售管理的开票登记可以多个合同开一个发票
---
src/views/salesManagement/invoiceRegistration/index.vue | 100 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 86 insertions(+), 14 deletions(-)
diff --git a/src/views/salesManagement/invoiceRegistration/index.vue b/src/views/salesManagement/invoiceRegistration/index.vue
index 47b0e98..e981c6f 100644
--- a/src/views/salesManagement/invoiceRegistration/index.vue
+++ b/src/views/salesManagement/invoiceRegistration/index.vue
@@ -460,9 +460,10 @@
invoiceNo: "",
createUer: userStore.nickName,
issueDate: dayjs().format("YYYY-MM-DD"),
+ selectedContractIds: [], // 鏂板锛氬瓨鍌ㄦ墍鏈夐�変腑鐨勫悎鍚孖D
+ isBatch: false // 鏂板锛氭爣璇嗘槸鍚︿负鎵归噺鎿嶄綔
},
rules: {
- salesLedgerId: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
createUer: [{ required: true, message: "璇烽�夋嫨", trigger: "blur" }],
issueDate: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
invoiceNo: [{ required: true, message: "璇疯緭鍏�", trigger: "change" }],
@@ -558,21 +559,55 @@
};
// 鎵撳紑寮规
const openForm = () => {
- // 鍒ゆ柇鏄惁澶氶��
- if (selectedRows.value.length != 1) {
- proxy.$modal.msgError("璇烽�夋嫨涓�鏉″悎鍚�");
+ // 鍒ゆ柇鏄惁閫夋嫨浜嗗悎鍚�
+ if (selectedRows.value.length === 0) {
+ proxy.$modal.msgError("璇疯嚦灏戦�夋嫨涓�鏉″悎鍚�");
return;
}
+
+ // 妫�鏌ユ墍鏈夐�夋嫨鐨勫悎鍚屾槸鍚﹀叿鏈夌浉鍚岀殑瀹㈡埛鍚嶇О
+ const firstRow = selectedRows.value[0];
+ const isSameCustomer = selectedRows.value.every(row =>
+ row.customerName === firstRow.customerName
+ );
+
+ if (!isSameCustomer) {
+ proxy.$modal.msgError("璇烽�夋嫨鐩稿悓瀹㈡埛鍚嶇О鐨勫悎鍚�");
+ return;
+ }
+
form.value = {};
productData.value = [];
- getSalesLedgerWithProducts({ id: selectedRows.value[0].id }).then((res) => {
- form.value = { ...res };
+
+ // 鍔犺浇鎵�鏈夐�変腑鍚堝悓鐨勪骇鍝佹暟鎹�
+ const promises = selectedRows.value.map(row =>
+ getSalesLedgerWithProducts({ id: row.id })
+ );
+
+ Promise.all(promises).then(results => {
+ // 鍚堝苟鎵�鏈夊悎鍚岀殑浜у搧鏁版嵁锛屽苟涓烘瘡涓骇鍝佹坊鍔犲搴旂殑鍚堝悓ID
+ const allProductData = [];
+ results.forEach((result, index) => {
+ const contractId = selectedRows.value[index].id;
+ if (result.productData) {
+ result.productData.forEach(item => {
+ allProductData.push({
+ ...item,
+ salesLedgerId: contractId // 鏄庣‘璁剧疆鍚堝悓ID
+ });
+ });
+ }
+ });
+
+ // 璁剧疆琛ㄥ崟鏁版嵁锛堜娇鐢ㄧ涓�涓悎鍚岀殑鍩烘湰淇℃伅锛�
+ form.value = { ...results[0] };
form.value.createTime = dayjs().format("YYYY-MM-DD");
form.value.issueDate = dayjs().format("YYYY-MM-DD");
form.value.createUer = userStore.nickName;
- productData.value = form.value.productData.map((item) => {
- return item;
- });
+ form.value.selectedContractIds = selectedRows.value.map(row => row.id); // 瀛樺偍鎵�鏈夐�変腑鐨勫悎鍚孖D
+
+ productData.value = allProductData;
+
dialogFormVisible.value = true;
console.log("productData.value ", productData.value);
});
@@ -582,11 +617,43 @@
proxy.$refs["formRef"].validate((valid) => {
if (valid) {
form.value.productData = proxy.HaveJson(productData.value);
- invoiceRegistrationSave(form.value).then((res) => {
- proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
- closeDia();
- getList();
- });
+ form.value.isBatch = selectedRows.value.length > 1; // 璁剧疆鎵归噺鏍囪瘑
+
+ // 濡傛灉鏄壒閲忔搷浣滐紝闇�瑕佷负姣忎釜鍚堝悓鍒涘缓鍗曠嫭鐨勫紑绁ㄧ櫥璁拌褰�
+ if (selectedRows.value.length > 1) {
+ // 鎵归噺鎻愪氦閫昏緫
+ const promises = selectedRows.value.map(contract => {
+ // 绛涢�夊嚭灞炰簬褰撳墠鍚堝悓鐨勪骇鍝佹暟鎹�
+ const contractProductData = productData.value.filter(item =>
+ item.salesLedgerId === contract.id
+ );
+
+ const batchForm = {
+ ...form.value,
+ salesLedgerId: contract.id,
+ productData: contractProductData,
+ selectedContractIds: undefined, // 涓嶄紶閫掓壒閲廔D
+ isBatch: true
+ };
+ return invoiceRegistrationSave(batchForm);
+ });
+
+ Promise.all(promises).then(results => {
+ proxy.$modal.msgSuccess(`鎴愬姛鎻愪氦${results.length}鏉″紑绁ㄧ櫥璁拌褰昤);
+ closeDia();
+ getList();
+ }).catch(error => {
+ proxy.$modal.msgError("閮ㄥ垎鎻愪氦澶辫触锛岃妫�鏌ユ暟鎹�");
+ console.error("鎵归噺鎻愪氦閿欒:", error);
+ });
+ } else {
+ // 鍗曚釜鍚堝悓鎻愪氦閫昏緫
+ invoiceRegistrationSave(form.value).then((res) => {
+ proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
+ closeDia();
+ getList();
+ });
+ }
}
});
};
@@ -692,3 +759,8 @@
font-weight: bold;
}
</style>
+
+
+
+
+
--
Gitblit v1.9.3