From 195770f92f7d739ffba6447fdbf3a3d5b9e009fa Mon Sep 17 00:00:00 2001
From: 张诺 <zhang_12370@163.com>
Date: 星期五, 24 四月 2026 16:32:57 +0800
Subject: [PATCH] fix(生产订单): 修复绑定工艺路线时的材料规格验证和显示问题
---
src/views/salesManagement/invoiceRegistration/index.vue | 108 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 82 insertions(+), 26 deletions(-)
diff --git a/src/views/salesManagement/invoiceRegistration/index.vue b/src/views/salesManagement/invoiceRegistration/index.vue
index 2cf92a8..b61d123 100644
--- a/src/views/salesManagement/invoiceRegistration/index.vue
+++ b/src/views/salesManagement/invoiceRegistration/index.vue
@@ -30,7 +30,12 @@
<div class="flex justify-between">
<div></div>
<div>
- <el-button type="primary" @click="openForm" style="margin-bottom: 8px">
+ <el-button
+ type="primary"
+ @click="openForm"
+ style="margin-bottom: 8px"
+ :disabled="!canInvoice"
+ >
寮�绁ㄧ櫥璁�
</el-button>
</div>
@@ -111,7 +116,7 @@
</el-table-column>
<el-table-column align="center" label="搴忓彿" type="index" width="60" />
<el-table-column
- label="閿�鍞悎鍚屽彿"
+ label="璁㈠崟缂栧彿"
prop="salesContractNo"
show-overflow-tooltip
/>
@@ -179,7 +184,7 @@
>
<el-row :gutter="30">
<el-col :span="12">
- <el-form-item label="閿�鍞悎鍚屽彿锛�" prop="salesContractNo">
+ <el-form-item label="璁㈠崟缂栧彿锛�" prop="salesContractNo">
<el-input v-model="form.salesContractNo" disabled placeholder="澶氬悎鍚屾壒閲忓鐞嗭紙鍏蜂綋鍚堝悓鍙疯浜у搧鍒楄〃锛�"></el-input>
</el-form-item>
</el-col>
@@ -296,10 +301,14 @@
/>
<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"
- @change="invoiceNumBlur(scope.row)"
+ <el-input-number
+ :step="0.1"
+ :min="0"
+ style="width: 100%"
+ :precision="2"
+ v-model="scope.row.currentInvoiceNum"
+ @change="invoiceNumBlur(scope.row)"
+ :disabled="isProductInvoiceDisabled(scope.row)"
></el-input-number>
</template>
</el-table-column>
@@ -309,10 +318,14 @@
width="180"
>
<template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%"
- :precision="2"
- v-model="scope.row.currentInvoiceAmount"
- @change="invoiceAmountBlur(scope.row)"
+ <el-input-number
+ :step="0.01"
+ :min="0"
+ style="width: 100%"
+ :precision="2"
+ v-model="scope.row.currentInvoiceAmount"
+ @change="invoiceAmountBlur(scope.row)"
+ :disabled="isProductInvoiceDisabled(scope.row)"
></el-input-number>
</template>
</el-table-column>
@@ -375,7 +388,7 @@
<script setup>
import pagination from "@/components/PIMTable/Pagination.vue";
import FormDialog from '@/components/Dialog/FormDialog.vue';
-import { onMounted, ref } from "vue";
+import { onMounted, ref, computed } from "vue";
import { Search } from "@element-plus/icons-vue";
import { ElMessageBox } from "element-plus";
// import {userListNoPage} from "@/api/system/user.js";
@@ -439,17 +452,38 @@
const formattedNumber = (row, column, cellValue) => {
if (cellValue == 0) {
- return parseFloat(cellValue).toFixed(2);
+ return parseFloat(cellValue).toFixed(3);
}
if (cellValue) {
- return parseFloat(cellValue).toFixed(2);
+ return parseFloat(cellValue).toFixed(3);
} else {
return cellValue;
}
};
const formattedInputNumber = (value) => {
- return value ? parseFloat(value).toFixed(2) : 0;
+ return value ? parseFloat(value).toFixed(3) : 0;
+};
+
+// 鍒ゆ柇鏄惁鍙互寮�绁紙鍩轰簬閫変腑鐨勫彴璐︽暟鎹級
+const canInvoice = computed(() => {
+ if (selectedRows.value.length === 0) {
+ return false;
+ }
+ // 妫�鏌ユ墍鏈夐�変腑鐨勫彴璐︼紝鍙鏈変竴涓湭寮�绁ㄩ噾棰濆ぇ浜�0锛屽氨鍙互寮�绁�
+ return selectedRows.value.some(row => {
+ const noInvoiceAmount = parseFloat(row.noInvoiceAmountTotal || 0);
+ return noInvoiceAmount > 0;
+ });
+});
+
+// 鍒ゆ柇鍗曚釜浜у搧鏄惁鍙互寮�绁�
+const isProductInvoiceDisabled = (row) => {
+ // 妫�鏌ユ湭寮�绁ㄩ噾棰濆拰鏈紑绁ㄦ暟锛屽鏋滈兘涓�0鎴栧皬浜庣瓑浜�0锛屽垯绂佺敤
+ // 浼樺厛浣跨敤 tempnoInvoiceAmount 鍜� tempNoInvoiceNum锛堝垵濮嬪�硷級锛屽鏋滄病鏈夊垯浣跨敤 noInvoiceAmount 鍜� originalNoInvoiceNum
+ const noInvoiceAmount = parseFloat(row.tempnoInvoiceAmount || row.noInvoiceAmount || 0);
+ const noInvoiceNum = parseFloat(row.tempNoInvoiceNum || row.originalNoInvoiceNum || row.noInvoiceNum || 0);
+ return noInvoiceAmount <= 0 || noInvoiceNum <= 0;
};
// 鏌ヨ鍒楄〃
@@ -505,7 +539,11 @@
"contractAmount",
"invoiceTotal",
"noInvoiceAmountTotal",
- ]);
+ ], {
+ contractAmount: { decimalPlaces: 3 },
+ invoiceTotal: { decimalPlaces: 3 },
+ noInvoiceAmountTotal: { decimalPlaces: 3 },
+ });
};
// 瀛愯〃鍚堣鏂规硶
const summarizeChildrenTable = (param) => {
@@ -519,7 +557,17 @@
"noInvoiceNum",
"noInvoiceAmount",
"currentInvoiceNum",
- ]);
+ ], {
+ taxInclusiveUnitPrice: { decimalPlaces: 3 },
+ taxInclusiveTotalPrice: { decimalPlaces: 3 },
+ taxExclusiveTotalPrice: { decimalPlaces: 3 },
+ invoiceNum: { decimalPlaces: 3 },
+ invoiceAmount: { decimalPlaces: 3 },
+ currentInvoiceAmount: { decimalPlaces: 3 },
+ noInvoiceNum: { decimalPlaces: 3 },
+ noInvoiceAmount: { decimalPlaces: 3 },
+ currentInvoiceNum: { decimalPlaces: 3 },
+ });
};
// 鎵撳紑寮规
const openForm = () => {
@@ -555,13 +603,13 @@
const allProductData = [];
results.forEach((result, index) => {
const contract = selectedRows.value[index];
- const contractId = contract.id;
+ // const contractId = contract.id;
if (result.productData) {
result.productData.forEach(item => {
allProductData.push({
...item,
- id: contractId, // 鏄庣‘璁剧疆鍚堝悓ID
- salesContractNo: contract.salesContractNo, // 娣诲姞閿�鍞悎鍚屽彿
+ // id: contractId, // 鏄庣‘璁剧疆鍚堝悓ID
+ salesContractNo: contract.salesContractNo, // 娣诲姞璁㈠崟缂栧彿
customerName: contract.customerName, // 娣诲姞瀹㈡埛鍚嶇О
customerContractNo: contract.customerContractNo // 娣诲姞瀹㈡埛鍚堝悓鍙�
});
@@ -569,15 +617,23 @@
}
});
- // 璁剧疆琛ㄥ崟鏁版嵁锛堜娇鐢ㄧ涓�涓悎鍚岀殑鍩烘湰淇℃伅锛岄攢鍞悎鍚屽彿鐣欑┖锛�
+ // 璁剧疆琛ㄥ崟鏁版嵁锛堜娇鐢ㄧ涓�涓悎鍚岀殑鍩烘湰淇℃伅锛岃鍗曠紪鍙风暀绌猴級
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
- form.value.salesContractNo = ""; // 閿�鍞悎鍚屽彿鐣欑┖锛屽洜涓轰細鍦ㄤ骇鍝佽〃鏍间腑鍒嗗埆鏄剧ず
+ form.value.salesContractNo = ""; // 璁㈠崟缂栧彿鐣欑┖锛屽洜涓轰細鍦ㄤ骇鍝佽〃鏍间腑鍒嗗埆鏄剧ず
productData.value = allProductData;
+
+ // 瀵逛簬涓嶈兘寮�绁ㄧ殑浜у搧锛屽皢寮�绁ㄦ暟鍜屽紑绁ㄩ噾棰濊缃负0
+ productData.value.forEach(item => {
+ if (isProductInvoiceDisabled(item)) {
+ item.currentInvoiceNum = 0;
+ item.currentInvoiceAmount = 0;
+ }
+ });
dialogFormVisible.value = true;
console.log("productData.value ", productData.value);
@@ -710,7 +766,7 @@
// 璁$畻鏈寮�绁ㄩ噾棰�
row.currentInvoiceAmount = (
row.currentInvoiceNum * row.taxInclusiveUnitPrice
- ).toFixed(2);
+ ).toFixed(3);
// 璁$畻鏈紑绁ㄦ暟
row.noInvoiceNum = (row.originalNoInvoiceNum - row.currentInvoiceNum).toFixed(
2
@@ -718,7 +774,7 @@
// 璁$畻鏈紑绁ㄩ噾棰�
row.noInvoiceAmount = (
row.tempnoInvoiceAmount - row.currentInvoiceAmount
- ).toFixed(2);
+ ).toFixed(3);
};
// 鏈寮�绁ㄩ噾棰濆け鐒︽搷浣�
const invoiceAmountBlur = (row) => {
@@ -733,7 +789,7 @@
// 璁$畻鏈寮�绁ㄦ暟
row.currentInvoiceNum = (
row.currentInvoiceAmount / row.taxInclusiveUnitPrice
- ).toFixed(2);
+ ).toFixed(3);
console.log("row.currentInvoiceNum ", row.currentInvoiceNum);
console.log(" row.originalNoInvoiceNum ", row.originalNoInvoiceNum);
// 璁$畻鏈紑绁ㄦ暟
@@ -743,7 +799,7 @@
// 璁$畻鏈紑绁ㄩ噾棰�
row.noInvoiceAmount = (
row.tempnoInvoiceAmount - row.currentInvoiceAmount
- ).toFixed(2);
+ ).toFixed(3);
};
onMounted(() => {
--
Gitblit v1.9.3