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 | 157 +++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 131 insertions(+), 26 deletions(-)
diff --git a/src/views/salesManagement/invoiceRegistration/index.vue b/src/views/salesManagement/invoiceRegistration/index.vue
index 0104fd1..e981c6f 100644
--- a/src/views/salesManagement/invoiceRegistration/index.vue
+++ b/src/views/salesManagement/invoiceRegistration/index.vue
@@ -2,7 +2,7 @@
<div class="app-container">
<div class="search_form">
<el-form :inline="true" :model="searchForm">
- <el-form-item label="寮�绁ㄧ櫥璁�">
+ <el-form-item label="瀹㈡埛鍚嶇О">
<el-input
v-model="searchForm.customerName"
style="width: 240px"
@@ -26,6 +26,12 @@
clearable
/>
</el-form-item>
+ <br>
+ <el-form-item label="浜у搧澶х被锛�">
+ <el-input v-model="searchForm.productCategory" placeholder="璇疯緭鍏�" clearable prefix-icon="Search"
+ @change="handleQuery" />
+ </el-form-item>
+
<el-form-item>
<el-checkbox
v-model="searchForm.status"
@@ -36,15 +42,18 @@
<el-form-item>
<el-button type="primary" @click="handleQuery"> 鎼滅储 </el-button>
<el-button @click="resetForm"> 閲嶇疆 </el-button>
+ <el-button @click="handleExport" style="margin-right: 10px">瀵煎嚭</el-button>
</el-form-item>
</el-form>
</div>
<div class="table_list">
<div class="flex justify-between">
<div></div>
+ <div>
<el-button type="primary" @click="openForm" style="margin-bottom: 8px">
鏂板鐧昏
</el-button>
+ </div>
</div>
<el-table
:data="tableData"
@@ -81,7 +90,7 @@
/>
<el-table-column label="鍗曚綅" prop="unit" width="70" />
<el-table-column label="鏁伴噺" prop="quantity" width="70" />
- <el-table-column label="绋庣巼(%)" prop="taxRate" width="70" />
+ <el-table-column label="绋庣巼(%)" prop="taxRate" width="80" />
<el-table-column
label="鍚◣鍗曚环(鍏�)"
prop="taxInclusiveUnitPrice"
@@ -139,7 +148,7 @@
show-overflow-tooltip
width="240"
/>
- <el-table-column label="涓氬姟鍛�" prop="salesman" show-overflow-tooltip />
+ <el-table-column label="涓氬姟鍛�" prop="salesman" show-overflow-tooltip width="90"/>
<el-table-column
label="椤圭洰鍚嶇О"
prop="projectName"
@@ -151,7 +160,7 @@
prop="contractAmount"
show-overflow-tooltip
:formatter="formattedNumber"
- width="120"
+ width="220"
/>
<el-table-column
@@ -297,16 +306,18 @@
/>
<el-table-column label="鍗曚綅" prop="unit" />
<el-table-column label="鏁伴噺" prop="quantity" width="70" />
- <el-table-column label="绋庣巼(%)" prop="taxRate" width="70" />
+ <el-table-column label="绋庣巼(%)" prop="taxRate" width="80" />
<el-table-column
label="鍚◣鍗曚环(鍏�)"
prop="taxInclusiveUnitPrice"
:formatter="formattedNumber"
+ width="200"
/>
<el-table-column
label="鍚◣鎬讳环(鍏�)"
prop="taxInclusiveTotalPrice"
:formatter="formattedNumber"
+ width="200"
/>
<el-table-column
label="涓嶅惈绋庢�讳环(鍏�)"
@@ -314,27 +325,29 @@
:formatter="formattedNumber"
width="150"
/>
- <el-table-column label="鏈寮�绁ㄦ暟" prop="currentInvoiceNum" width="150">
+ <el-table-column label="鏈寮�绁ㄦ暟" prop="currentInvoiceNum" width="180">
<template #default="scope">
<el-input-number :step="0.1" :min="0" style="width: 100%"
+ :precision="2"
v-model="scope.row.currentInvoiceNum"
- @blur="invoiceNumBlur(scope.row)"
+ @change="invoiceNumBlur(scope.row)"
></el-input-number>
</template>
</el-table-column>
<el-table-column
label="鏈寮�绁ㄩ噾棰�(鍏�)"
prop="currentInvoiceAmount"
- width="150"
+ width="180"
>
<template #default="scope">
<el-input-number :step="0.01" :min="0" style="width: 100%"
+ :precision="2"
v-model="scope.row.currentInvoiceAmount"
- @blur="invoiceAmountBlur(scope.row)"
+ @change="invoiceAmountBlur(scope.row)"
></el-input-number>
</template>
</el-table-column>
- <el-table-column label="鏈紑绁ㄦ暟" prop="noInvoiceNum" width="100">
+ <el-table-column label="鏈紑绁ㄦ暟" prop="noInvoiceNum" width="120">
<template #default="scope">
<el-input
type="number"
@@ -347,7 +360,7 @@
<el-table-column
label="鏈紑绁ㄩ噾棰�(鍏�)"
prop="noInvoiceAmount"
- width="150"
+ width="200"
>
<template #default="scope">
<el-input
@@ -435,6 +448,8 @@
createUer: undefined, // 鐧昏浜�
issueDate: undefined, // 寮�绁ㄦ棩鏈�
createTime: undefined, // 褰曞叆鏃ユ湡锛�
+ productCategory: "",
+ isInvoice: 1
},
form: {
salesLedgerId: "",
@@ -445,11 +460,13 @@
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" }],
createTime: [{ required: true, message: "璇烽�夋嫨", trigger: "change" }],
},
});
@@ -537,24 +554,60 @@
"currentInvoiceAmount",
"noInvoiceNum",
"noInvoiceAmount",
+ "currentInvoiceNum",
]);
};
// 鎵撳紑寮规
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 };
- form.value.createTime = dayjs().format("YYYY-MM-DD");
- form.value.createUer = userStore.nickName;
- productData.value = form.value.productData.map((item) => {
- return item;
+
+ // 鍔犺浇鎵�鏈夐�変腑鍚堝悓鐨勪骇鍝佹暟鎹�
+ 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;
+ form.value.selectedContractIds = selectedRows.value.map(row => row.id); // 瀛樺偍鎵�鏈夐�変腑鐨勫悎鍚孖D
+
+ productData.value = allProductData;
+
dialogFormVisible.value = true;
console.log("productData.value ", productData.value);
});
@@ -564,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();
+ });
+ }
}
});
};
@@ -586,6 +671,21 @@
})
.then(() => {
proxy.download("/invoiceRegistration/export", {}, "寮�绁ㄧ櫥璁颁俊鎭�.xlsx");
+ })
+ .catch(() => {
+ proxy.$modal.msg("宸插彇娑�");
+ });
+};
+
+// 瀵煎嚭閿�鍞彴璐�
+const handleExport = () => {
+ ElMessageBox.confirm("閫変腑鐨勫唴瀹瑰皢琚鍑猴紝鏄惁纭瀵煎嚭锛�", "瀵煎嚭", {
+ confirmButtonText: "纭",
+ cancelButtonText: "鍙栨秷",
+ type: "warning",
+ })
+ .then(() => {
+ proxy.download("/sales/ledger/exportOne", { ...searchForm, ...page }, "寮�绁ㄧ櫥璁�.xlsx");
})
.catch(() => {
proxy.$modal.msg("宸插彇娑�");
@@ -659,3 +759,8 @@
font-weight: bold;
}
</style>
+
+
+
+
+
--
Gitblit v1.9.3