From 60977504246152d12e2b08640fb63545090d2054 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 12 二月 2026 13:28:55 +0800
Subject: [PATCH] 进销存升级 1.选择台账时,若未来票金额为0时,来票登记按钮置灰,来票结束的采购限制不能继续来票操作)还有台账存在多个产品,若其中一个产品不能继续来票操作,这种情况也需要让有关来票的输入框置灰
---
src/views/procurementManagement/invoiceEntry/index.vue | 16 ++++
src/views/procurementManagement/invoiceEntry/components/Modal.vue | 138 ++++++++++++++++++++++++++++++++++-----------
2 files changed, 118 insertions(+), 36 deletions(-)
diff --git a/src/views/procurementManagement/invoiceEntry/components/Modal.vue b/src/views/procurementManagement/invoiceEntry/components/Modal.vue
index b723175..33d5144 100644
--- a/src/views/procurementManagement/invoiceEntry/components/Modal.vue
+++ b/src/views/procurementManagement/invoiceEntry/components/Modal.vue
@@ -133,10 +133,15 @@
/>
<el-table-column label="鏈寮�绁ㄦ暟" prop="ticketsNum" width="180">
<template #default="scope">
- <el-input-number :step="0.1" :min="0" :max="scope.row.tempFutureTickets || 0" style="width: 100%"
- :precision="2"
- v-model="scope.row.ticketsNum"
- @change="invoiceNumBlur(scope.row)"
+ <el-input-number
+ :step="0.1"
+ :min="0"
+ :max="scope.row.tempFutureTickets || 0"
+ style="width: 100%"
+ :precision="2"
+ v-model="scope.row.ticketsNum"
+ :disabled="isProductDisabled(scope.row)"
+ @change="invoiceNumBlur(scope.row)"
/>
</template>
</el-table-column>
@@ -146,10 +151,14 @@
width="180"
>
<template #default="scope">
- <el-input-number :step="0.01" :min="0" style="width: 100%"
- :precision="2"
- v-model="scope.row.ticketsAmount"
- @change="invoiceAmountBlur(scope.row)"
+ <el-input-number
+ :step="0.01"
+ :min="0"
+ style="width: 100%"
+ :precision="2"
+ v-model="scope.row.ticketsAmount"
+ :disabled="isProductDisabled(scope.row)"
+ @change="invoiceAmountBlur(scope.row)"
/>
</template>
</el-table-column>
@@ -402,7 +411,7 @@
// 璁剧疆浜у搧鏁版嵁锛屽苟鍒濆鍖栧紑绁ㄦ暟閲忓拰閲戦
allProductData.forEach(item => {
- // 淇濆瓨鈥滃師濮嬫湭鏉ョエ鏁�/閲戦鈥濓紙鐢ㄤ簬鏍¢獙涓庤绠楋級
+ // 淇濆瓨"鍘熷鏈潵绁ㄦ暟/閲戦"锛堢敤浜庢牎楠屼笌璁$畻锛�
// 浼樺厛浣跨敤鍚庣杩斿洖鐨� futureTickets/futureTicketsAmount锛涙病鏈夊垯鍥為��鍒� quantity/taxInclusiveTotalPrice
item.tempFutureTickets = Number(
item.futureTickets !== undefined ? item.futureTickets : (item.quantity || 0)
@@ -411,15 +420,23 @@
item.futureTicketsAmount !== undefined ? item.futureTicketsAmount : (item.taxInclusiveTotalPrice || 0)
);
- // 鏂板鏃讹細鏈寮�绁ㄦ暟榛樿 = 鏈潵绁ㄦ暟锛堜笖涓嶈兘澶т簬鏈潵绁ㄦ暟锛�
- item.ticketsNum = Number(item.tempFutureTickets || 0);
- // 鑱斿姩璁$畻鏈寮�绁ㄩ噾棰濄�佹湭鏉ョエ鏁般�佹湭鏉ョエ閲戦
- const unitPrice = Number(item.taxInclusiveUnitPrice || 0);
- item.ticketsAmount = Number((item.ticketsNum * unitPrice).toFixed(2));
- item.futureTickets = Number((item.tempFutureTickets - item.ticketsNum).toFixed(2));
- item.futureTicketsAmount = Number(
- (item.tempFutureTicketsAmount - item.ticketsAmount).toFixed(2)
- );
+ // 濡傛灉鏈潵绁ㄩ噾棰濅负0锛屽垯鏈寮�绁ㄦ暟鍜岄噾棰濋兘璁剧疆涓�0
+ if (item.tempFutureTicketsAmount <= 0) {
+ item.ticketsNum = 0;
+ item.ticketsAmount = 0;
+ item.futureTickets = Number(item.tempFutureTickets || 0);
+ item.futureTicketsAmount = 0;
+ } else {
+ // 鏂板鏃讹細鏈寮�绁ㄦ暟榛樿 = 鏈潵绁ㄦ暟锛堜笖涓嶈兘澶т簬鏈潵绁ㄦ暟锛�
+ item.ticketsNum = Number(item.tempFutureTickets || 0);
+ // 鑱斿姩璁$畻鏈寮�绁ㄩ噾棰濄�佹湭鏉ョエ鏁般�佹湭鏉ョエ閲戦
+ const unitPrice = Number(item.taxInclusiveUnitPrice || 0);
+ item.ticketsAmount = Number((item.ticketsNum * unitPrice).toFixed(2));
+ item.futureTickets = Number((item.tempFutureTickets - item.ticketsNum).toFixed(2));
+ item.futureTicketsAmount = Number(
+ (item.tempFutureTicketsAmount - item.ticketsAmount).toFixed(2)
+ );
+ }
});
form.productData = allProductData;
@@ -435,15 +452,45 @@
});
} else if (type == "edit") {
const id = Array.isArray(selectedRows) ? selectedRows[0].id : selectedRows;
- const data = await getPurchaseById({ id, type: 2 });
- form.purchaseLedgerNo = data.purchaseContractNumber;
+ const response = await getPurchaseById({ id, type: 2 });
+ // 鍏煎涓嶅悓鐨勮繑鍥炴牸寮忥細鍙兘鏄� { code, data } 鎴栫洿鎺ヨ繑鍥炴暟鎹�
+ const data = response.data || response;
+
+ // 鍏煎涓嶅悓鐨勫瓧娈靛悕锛歱urchaseContractNumber 鎴� purchaseLedgerNo
+ form.purchaseLedgerNo = data.purchaseContractNumber || data.purchaseLedgerNo || "";
form.invoiceAmount = data.invoiceAmount;
form.invoiceNumber = data.invoiceNumber;
form.salesContractNo = data.salesContractNo;
form.projectName = data.projectName;
form.supplierName = data.supplierName;
form.entryDate = data.entryDate;
- form.productData = data.productData;
+ form.enterDate = data.enterDate || dayjs().format("YYYY-MM-DD");
+
+ // 缂栬緫鏃朵篃闇�瑕佸垵濮嬪寲浜у搧鏁版嵁鐨� tempFutureTickets 鍜� tempFutureTicketsAmount
+ // 鍚屾椂涓烘瘡涓骇鍝佹坊鍔犲悎鍚屽彿绛変俊鎭�
+ const contractNumber = data.purchaseContractNumber || data.purchaseLedgerNo || "";
+ if (data.productData && Array.isArray(data.productData)) {
+ data.productData.forEach(item => {
+ // 淇濆瓨"鍘熷鏈潵绁ㄦ暟/閲戦"锛堢敤浜庢牎楠屼笌璁$畻锛�
+ // 浼樺厛浣跨敤鍚庣杩斿洖鐨� futureTickets/futureTicketsAmount锛涙病鏈夊垯鍥為��鍒� quantity/taxInclusiveTotalPrice
+ item.tempFutureTickets = Number(
+ item.futureTickets !== undefined ? item.futureTickets : (item.quantity || 0)
+ );
+ item.tempFutureTicketsAmount = Number(
+ item.futureTicketsAmount !== undefined ? item.futureTicketsAmount : (item.taxInclusiveTotalPrice || 0)
+ );
+
+ // 纭繚姣忎釜浜у搧閮芥湁鍚堝悓鍙凤紝鐢ㄤ簬鏄剧ず鍦�"鎵�灞炲悎鍚�"鍒�
+ if (!item.purchaseLedgerNo) {
+ item.purchaseLedgerNo = contractNumber;
+ }
+ });
+ }
+
+ form.productData = data.productData || [];
+
+ // 缂栬緫妯″紡涓嬶紝鏍规嵁浜у搧鏁版嵁涓殑鏈寮�绁ㄩ噾棰濊嚜鍔ㄨ绠楀彂绁ㄩ噾棰�
+ calculateinvoiceAmount();
}
};
// 瀛愯〃鍚堣鏂规硶
@@ -515,22 +562,45 @@
form.invoiceAmount = Number(invoiceAmountTotal.toFixed(2));
};
-const open = async (type, selectedRows) => {
- visible.value = true;
+// 鍒ゆ柇浜у搧鏄惁鍙互缁х画鏉ョエ鎿嶄綔锛氬鏋滄湭鏉ョエ鏁板拰鏈潵绁ㄩ噾棰濋兘涓�0鎴栧皬浜庣瓑浜�0锛屽垯绂佺敤
+const isProductDisabled = (row) => {
+ // 浼樺厛浣跨敤 tempFutureTickets锛堝師濮嬫湭鏉ョエ鏁帮級锛屽鏋滄病鏈夊垯浣跨敤 futureTickets
+ const futureTickets = Number(row.tempFutureTickets !== undefined
+ ? row.tempFutureTickets
+ : (row.futureTickets !== undefined ? row.futureTickets : 0));
- // 濡傛灉鏄壒閲忔搷浣滐紝璁剧疆鏍囬
- if (Array.isArray(selectedRows) && selectedRows.length > 1) {
- modalOptions.value = {
- ...(modalOptions.value || {}),
- title: `鎵归噺鏂板 (${selectedRows.length}鏉�)`,
- };
- } else {
- modalOptions.value = {
- ...(modalOptions.value || {}),
- title: type === "add" ? "鏂板" : "缂栬緫",
- };
+ // 浼樺厛浣跨敤 tempFutureTicketsAmount锛堝師濮嬫湭鏉ョエ閲戦锛夛紝濡傛灉娌℃湁鍒欎娇鐢� futureTicketsAmount
+ const futureAmount = Number(row.tempFutureTicketsAmount !== undefined
+ ? row.tempFutureTicketsAmount
+ : (row.futureTicketsAmount !== undefined ? row.futureTicketsAmount : 0));
+
+ // 鍙湁褰撴湭鏉ョエ鏁板拰鏈潵绁ㄩ噾棰濋兘涓�0鎴栧皬浜庣瓑浜�0鏃讹紝鎵嶇鐢�
+ return futureTickets <= 0 && futureAmount <= 0;
+};
+
+const open = async (type, selectedRows) => {
+ // 纭繚 modalOptions.value 鏄璞�
+ if (!modalOptions.value || typeof modalOptions.value !== 'object') {
+ modalOptions.value = {};
}
+ // 鏍规嵁鎿嶄綔绫诲瀷鍜岄�変腑鏁版嵁璁剧疆鏍囬
+ if (Array.isArray(selectedRows) && selectedRows.length > 1) {
+ // 鎵归噺鎿嶄綔
+ modalOptions.value.title = type === "add" ? `鎵归噺鏂板 (${selectedRows.length}鏉�)` : `鎵归噺缂栬緫 (${selectedRows.length}鏉�)`;
+ } else {
+ // 鍗曚釜鎿嶄綔 - 鏄庣‘鍒ゆ柇 type 鐨勫��
+ if (type === "add" || type === "鏂板") {
+ modalOptions.value.title = "鏂板";
+ } else if (type === "edit" || type === "缂栬緫") {
+ modalOptions.value.title = "缂栬緫";
+ } else {
+ modalOptions.value.title = "鏉ョエ鐧昏"; // 榛樿鏍囬
+ }
+ }
+
+ visible.value = true;
+
// 濡傛灉鏄崟涓搷浣滐紝鑾峰彇id
if (!Array.isArray(selectedRows) || selectedRows.length === 1) {
const idValue = Array.isArray(selectedRows) ? selectedRows[0].id : selectedRows;
diff --git a/src/views/procurementManagement/invoiceEntry/index.vue b/src/views/procurementManagement/invoiceEntry/index.vue
index 00a6881..8c435e0 100644
--- a/src/views/procurementManagement/invoiceEntry/index.vue
+++ b/src/views/procurementManagement/invoiceEntry/index.vue
@@ -39,7 +39,7 @@
<div></div>
<div>
<el-button @click="handleExport" style="margin-right: 10px">瀵煎嚭</el-button>
- <el-button type="primary" @click="handleAdd('add')">
+ <el-button type="primary" @click="handleAdd('add')" :disabled="isInvoiceDisabled">
鏉ョエ鐧昏
</el-button>
<!-- <el-button type="danger" plain @click="handleDelete">鍒犻櫎</el-button>-->
@@ -84,7 +84,7 @@
<script setup>
import { usePaginationApi } from "@/hooks/usePaginationApi";
import {delRegistration, gePurchaseListPage} from "@/api/procurementManagement/invoiceEntry.js";
-import { nextTick, onMounted, getCurrentInstance, ref } from "vue";
+import { nextTick, onMounted, getCurrentInstance, ref, computed } from "vue";
import ExpandTable from "./components/ExpandTable.vue";
import Modal from "./components/Modal.vue";
import {ElMessageBox} from "element-plus";
@@ -186,6 +186,18 @@
);
};
+// 璁$畻鏄惁鍙互鏉ョエ鐧昏锛氬鏋滄墍鏈夐�変腑琛岀殑寰呮潵绁ㄩ噾棰濋兘涓�0锛屽垯绂佺敤鎸夐挳
+const isInvoiceDisabled = computed(() => {
+ if (selectedRows.value.length === 0) {
+ return true;
+ }
+ // 濡傛灉鎵�鏈夐�変腑琛岀殑寰呮潵绁ㄩ噾棰濋兘涓�0鎴栧皬浜庣瓑浜�0锛屽垯绂佺敤
+ return selectedRows.value.every(row => {
+ const amount = parseFloat(row.unReceiptPaymentAmount || 0);
+ return amount <= 0;
+ });
+});
+
const handleAdd = (type) => {
if (selectedRows.value.length < 1) {
proxy.$modal.msgWarning("璇疯嚦灏戦�変腑涓�鏉℃暟鎹�");
--
Gitblit v1.9.3