From 7f12ce3148e7f2a1e2cf2e238c7b4800bf38e0eb Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 05 二月 2026 10:17:27 +0800
Subject: [PATCH] 进销存升级app: 1.编辑来票台账时,修改来票数1为3后,未来票数由9变为6,并且还有提示请输入数据 2.供应商往来数据跟web端展示数据不符
---
src/pages/procurementManagement/procurementInvoiceLedger/detail.vue | 108 +++++++++++++++++++++++++++++++++++++++++------------
1 files changed, 83 insertions(+), 25 deletions(-)
diff --git a/src/pages/procurementManagement/procurementInvoiceLedger/detail.vue b/src/pages/procurementManagement/procurementInvoiceLedger/detail.vue
index a5c74f6..179e7e1 100644
--- a/src/pages/procurementManagement/procurementInvoiceLedger/detail.vue
+++ b/src/pages/procurementManagement/procurementInvoiceLedger/detail.vue
@@ -55,7 +55,7 @@
placeholder="璇疯緭鍏�"
@blur="inputTicketsAmount" />
</up-form-item>
- <view class="tip-text">鏈潵绁ㄦ暟锛歿{ formatAmount(form.futureTickets) }} 鍏�</view>
+ <view class="tip-text">鏈潵绁ㄦ暟锛歿{ formatAmount(form.futureTickets) }} </view>
<!-- 浣跨敤鍏叡搴曢儴鎸夐挳缁勪欢 -->
<FooterButtons show
cancelText="鍙栨秷"
@@ -100,6 +100,7 @@
const fileList = ref([]);
const currentId = ref("");
const temFutureTickets = ref(0);
+ const originalTicketsNum = ref(0); // 淇濆瓨鍘熷鏉ョエ鏁�
// 琛ㄥ崟鏍¢獙瑙勫垯
const rules = {
@@ -114,6 +115,12 @@
uni.navigateBack();
};
const inputTicketsNum = () => {
+ // 澶勭悊绌哄�兼儏鍐�
+ if (!form.value.ticketsNum || form.value.ticketsNum === "") {
+ form.value.ticketsNum = 0;
+ return;
+ }
+
// 纭繚鍚◣鍗曚环瀛樺湪涓斾笉涓洪浂
if (
!form.value.taxInclusiveUnitPrice ||
@@ -125,23 +132,39 @@
});
return;
}
- if (Number(form.value.ticketsNum) > Number(temFutureTickets.value)) {
+
+ const newTicketsNum = Number(form.value.ticketsNum) || 0;
+ // 璁$畻鎬诲彲鐢ㄧエ鏁帮細鍘熷鏈潵绁ㄦ暟 + 鍘熷鏉ョエ鏁�
+ const totalAvailableTickets = Number(temFutureTickets.value) + Number(originalTicketsNum.value);
+
+ // 楠岃瘉鏉ョエ鏁颁笉鑳藉ぇ浜庢�诲彲鐢ㄧエ鏁�
+ if (newTicketsNum > totalAvailableTickets) {
uni.showToast({
- title: "鏉ョエ鏁颁笉寰楀ぇ浜庢湭鏉ョエ鏁�",
+ title: "鏉ョエ鏁颁笉寰楀ぇ浜庢�诲彲鐢ㄧエ鏁�",
icon: "none",
});
- form.value.ticketsNum = temFutureTickets.value;
+ form.value.ticketsNum = totalAvailableTickets;
+ // 閲嶆柊璁$畻鏈潵绁ㄦ暟
+ const futureTickets = totalAvailableTickets - totalAvailableTickets;
+ form.value.futureTickets = Number(futureTickets.toFixed(2));
+ form.value.ticketsAmount = Number((totalAvailableTickets * Number(form.value.taxInclusiveUnitPrice)).toFixed(2));
+ return;
}
// 纭繚鎵�鏈夋暟鍊奸兘杞崲涓烘暟瀛楃被鍨嬭繘琛岃绠�
const ticketsAmount =
- Number(form.value.ticketsNum) * Number(form.value.taxInclusiveUnitPrice);
- const futureTickets =
- Number(temFutureTickets.value) - Number(form.value.ticketsNum);
+ newTicketsNum * Number(form.value.taxInclusiveUnitPrice);
+ // 璁$畻鏈潵绁ㄦ暟锛氭�诲彲鐢ㄧエ鏁� - 鏂版潵绁ㄦ暟
+ const futureTickets = totalAvailableTickets - newTicketsNum;
form.value.futureTickets = Number(futureTickets.toFixed(2));
form.value.ticketsAmount = Number(ticketsAmount.toFixed(2));
};
const inputTicketsAmount = () => {
+ // 澶勭悊绌哄�兼儏鍐�
+ if (!form.value.ticketsAmount || form.value.ticketsAmount === "") {
+ form.value.ticketsAmount = 0;
+ }
+
// 纭繚鍚◣鍗曚环瀛樺湪涓斾笉涓洪浂
if (
!form.value.taxInclusiveUnitPrice ||
@@ -154,28 +177,34 @@
return;
}
- if (
- Number(form.value.ticketsAmount) >
- Number(form.value.futureTickets * form.value.taxInclusiveUnitPrice)
- ) {
+ const newTicketsAmount = Number(form.value.ticketsAmount) || 0;
+ // 璁$畻鎬诲彲鐢ㄩ噾棰濓細鍘熷鏈潵绁ㄦ暟 + 鍘熷鏉ョエ鏁�
+ const totalAvailableTickets = Number(temFutureTickets.value) + Number(originalTicketsNum.value);
+ const totalAvailableAmount = totalAvailableTickets * Number(form.value.taxInclusiveUnitPrice);
+
+ if (newTicketsAmount > totalAvailableAmount) {
uni.showToast({
title: "鏈鏉ョエ閲戦涓嶅緱澶т簬鎬婚噾棰�",
icon: "none",
});
- form.value.ticketsAmount = (
- form.value.futureTickets * form.value.taxInclusiveUnitPrice
- ).toFixed(2);
+ form.value.ticketsAmount = totalAvailableAmount.toFixed(2);
const ticketsNum =
Number(form.value.ticketsAmount) /
Number(form.value.taxInclusiveUnitPrice);
form.value.ticketsNum = Number(ticketsNum.toFixed(2));
+ // 鏇存柊鏈潵绁ㄦ暟
+ const futureTickets = totalAvailableTickets - form.value.ticketsNum;
+ form.value.futureTickets = Number(futureTickets.toFixed(2));
return;
}
// 纭繚鎵�鏈夋暟鍊奸兘杞崲涓烘暟瀛楃被鍨嬭繘琛岃绠�
const ticketsNum =
- Number(form.value.ticketsAmount) / Number(form.value.taxInclusiveUnitPrice);
+ newTicketsAmount / Number(form.value.taxInclusiveUnitPrice);
form.value.ticketsNum = Number(ticketsNum.toFixed(2));
+ // 鏇存柊鏈潵绁ㄦ暟
+ const futureTickets = totalAvailableTickets - form.value.ticketsNum;
+ form.value.futureTickets = Number(futureTickets.toFixed(2));
};
const formatAmount = val => {
if (val === undefined || val === null || val === "") return "0.00";
@@ -197,6 +226,7 @@
const data = res?.data || res;
form.value = { ...data };
temFutureTickets.value = data.futureTickets;
+ originalTicketsNum.value = Number(data.ticketsNum) || 0; // 淇濆瓨鍘熷鏉ョエ鏁�
fileList.value = data?.fileList || [];
if (!form.value.invoicePerson) {
form.value.invoicePerson = userStore.nickName;
@@ -234,17 +264,45 @@
};
// 琛ㄥ崟鎻愪氦
- const onSubmit = () => {
- formRef.value
- .validate()
- .then(() => {
- // 琛ㄥ崟楠岃瘉閫氳繃锛屾彁浜よ〃鍗�
+ const onSubmit = async () => {
+ if (!formRef.value) {
+ console.log("琛ㄥ崟寮曠敤涓嶅瓨鍦�");
+ return;
+ }
+
+ try {
+ // 鍏堣皟鐢� validate 鏂规硶
+ const validateResult = formRef.value.validate();
+
+ // 濡傛灉 validate 杩斿洖 undefined 鎴� null锛岀洿鎺ユ彁浜�
+ if (validateResult === undefined || validateResult === null) {
submitForm();
- })
- .catch(error => {
- // 琛ㄥ崟楠岃瘉澶辫触
- console.log("琛ㄥ崟楠岃瘉澶辫触", error);
- });
+ return;
+ }
+
+ // 濡傛灉杩斿洖 Promise锛屼娇鐢� await 鍜� catch
+ if (validateResult && typeof validateResult.then === 'function') {
+ const valid = await validateResult.catch(() => false);
+ if (valid) {
+ // 琛ㄥ崟楠岃瘉閫氳繃锛屾彁浜よ〃鍗�
+ submitForm();
+ } else {
+ // 琛ㄥ崟楠岃瘉澶辫触
+ console.log("琛ㄥ崟楠岃瘉澶辫触");
+ }
+ } else {
+ // 濡傛灉杩斿洖甯冨皵鍊硷紝鐩存帴鍒ゆ柇
+ if (validateResult) {
+ submitForm();
+ } else {
+ console.log("琛ㄥ崟楠岃瘉澶辫触");
+ }
+ }
+ } catch (error) {
+ // 濡傛灉 validate 鏂规硶涓嶅瓨鍦ㄦ垨鎶涘嚭閿欒锛岀洿鎺ユ彁浜�
+ console.log("琛ㄥ崟楠岃瘉澶辫触", error);
+ submitForm();
+ }
};
const purchaseLedgerId = ref("");
const productModelId = ref({});
--
Gitblit v1.9.3