From 477f9e61542753ea7338eadc59654200f3146f79 Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期二, 20 十月 2026 15:16:28 +0800
Subject: [PATCH] feat: 发货台账添加是否超发按钮
---
src/views/salesManagement/salesLedger/index.vue | 266 +++++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 259 insertions(+), 7 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index e18897b..6314348 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -990,12 +990,34 @@
<el-form-item label="宸查�夋嫨鍙戣揣鏁伴噺锛�">
<el-input :model-value="selectedDeliveryQuantity"
disabled />
+ <div class="delivery-quantity-tip"
+ :class="deliveryQuantityTipClass">
+ {{ deliveryQuantityTip }}
+ </div>
</el-form-item>
</el-col>
<el-col :span="24">
<el-form-item label="瓒呭彂鏁伴噺锛�">
- <el-input :model-value="excessDeliveryQuantity"
- disabled />
+ <div class="delivery-excess-row">
+ <el-input :model-value="excessDeliveryQuantity"
+ class="delivery-excess-input"
+ :class="{ 'is-over': excessDeliveryQuantity > 0 }"
+ disabled />
+ <div class="delivery-over-switch">
+ <el-switch v-model="deliveryForm.allowOverDelivery"
+ inline-prompt
+ active-text="鍏佽瓒呭彂"
+ inactive-text="绂佹瓒呭彂"
+ :width="88"
+ @change="handleAllowOverDeliveryChange" />
+ <el-tooltip placement="top"
+ content="鍏抽棴鏃讹紝鏈鍙戣揣鎬婚噺涓嶈兘瓒呰繃寰呭彂璐ф暟閲忥紱寮�鍚悗锛屽彲鎸夊簱瀛樻暟閲忚秴鍙�">
+ <el-icon class="delivery-over-switch__tip">
+ <QuestionFilled />
+ </el-icon>
+ </el-tooltip>
+ </div>
+ </div>
</el-form-item>
</el-col>
</el-row>
@@ -1044,6 +1066,28 @@
<el-col :span="24">
<el-form-item label="搴撳瓨锛�"
prop="batchNo">
+ <div class="delivery-batch-toolbar">
+ <span class="delivery-batch-toolbar__hint">
+ {{ deliveryForm.allowOverDelivery
+ ? "宸插紑鍚秴鍙戯紝鍚勬壒鍙峰彂璐ф暟閲忎笉鑳藉ぇ浜庡簱瀛樻暟閲�"
+ : `鏈紑鍚秴鍙戯紝鏈鍙戣揣鎬婚噺涓嶈兘瓒呰繃寰呭彂璐ф暟閲忥紙${getCurrentDeliveryRowQuantity()}锛塦 }}
+ </span>
+ <div class="delivery-batch-toolbar__actions">
+ <el-button size="small"
+ type="primary"
+ plain
+ :disabled="!canAutoAllocateDeliveryQuantity"
+ @click="autoAllocateDeliveryQuantity">
+ 涓�閿垎閰嶅緟鍙戣揣鏁伴噺
+ </el-button>
+ <el-button size="small"
+ text
+ :disabled="selectedDeliveryQuantity <= 0"
+ @click="clearDeliveryQuantity">
+ 娓呯┖
+ </el-button>
+ </div>
+ </div>
<el-table :data="deliveryForm.batchNoList"
border
size="small"
@@ -1141,6 +1185,7 @@
roundAmount,
} from "@/utils/numberFormat";
import ImageUpload from "@/components/AttachmentUpload/image/index.vue";
+ import { QuestionFilled } from "@element-plus/icons-vue";
import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
import { getCurrentDate } from "@/utils/index.js";
import { listCustomer } from "@/api/basicData/customer.js";
@@ -1327,18 +1372,149 @@
)
);
});
+ const remainingDeliveryQuantity = computed(() => {
+ return roundAmount(
+ getCurrentDeliveryRowQuantity() - selectedDeliveryQuantity.value
+ );
+ });
+ const allowOverDelivery = computed(
+ () => !!deliveryForm.value.allowOverDelivery
+ );
+ const deliveryQuantityTip = computed(() => {
+ const pendingQuantity = getCurrentDeliveryRowQuantity();
+ const remainQuantity = remainingDeliveryQuantity.value;
+ if (allowOverDelivery.value) {
+ return excessDeliveryQuantity.value > 0
+ ? `宸茶秴鍙� ${excessDeliveryQuantity.value}锛岃纭瓒呭彂鏁伴噺鏃犺`
+ : "宸插紑鍚秴鍙戯紝鏈鍙戣揣鏁伴噺浠呭彈搴撳瓨鏁伴噺闄愬埗";
+ }
+ if (remainQuantity < 0) {
+ return `宸茶秴鍑哄緟鍙戣揣鏁伴噺 ${Math.abs(remainQuantity)}锛岃鍑忓皯鍙戣揣鏁伴噺`;
+ }
+ if (remainQuantity === 0 && pendingQuantity > 0) {
+ return `宸茶揪鍒板緟鍙戣揣鏁伴噺 ${pendingQuantity}锛屽綋鍓嶄笉鍏佽瓒呭彂`;
+ }
+ return `鏈紑鍚秴鍙戯紝鏈鏈�澶氬彲鍙� ${pendingQuantity}锛岃繕宸� ${remainQuantity}`;
+ });
+ const deliveryQuantityTipClass = computed(() => ({
+ "is-over": excessDeliveryQuantity.value > 0,
+ "is-full":
+ !allowOverDelivery.value &&
+ remainingDeliveryQuantity.value === 0 &&
+ getCurrentDeliveryRowQuantity() > 0,
+ }));
+ const hasDeliveryStock = computed(() => {
+ return (deliveryForm.value.batchNoList || []).some(
+ item => Number(getDeliveryBatchQuantity(item) || 0) > 0
+ );
+ });
+ const canAutoAllocateDeliveryQuantity = computed(
+ () => getCurrentDeliveryRowQuantity() > 0 && hasDeliveryStock.value
+ );
const getDeliveryBatchDeliveryMax = row => {
- const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0);
- return Math.max(0, batchQuantity);
+ const batchQuantity = Math.max(
+ 0,
+ Number(getDeliveryBatchQuantity(row) || 0)
+ );
+ if (allowOverDelivery.value) {
+ return batchQuantity;
+ }
+ // 鏈紑鍚秴鍙戞椂锛屽崟涓壒鍙锋渶澶氳繕鑳藉~鈥滃緟鍙戣揣鏁伴噺 - 鍏朵粬鎵瑰彿宸查�夋暟閲忊��
+ const currentQuantity = Number(row?.deliveryQuantity || 0);
+ const otherSelectedQuantity = roundAmount(
+ selectedDeliveryQuantity.value - currentQuantity
+ );
+ const availableQuantity = Math.max(
+ 0,
+ roundAmount(getCurrentDeliveryRowQuantity() - otherSelectedQuantity)
+ );
+ return Math.min(batchQuantity, availableQuantity);
};
const handleDeliveryBatchQuantityChange = row => {
- const batchQuantity = Number(getDeliveryBatchQuantity(row) || 0);
+ const batchQuantity = Math.max(
+ 0,
+ Number(getDeliveryBatchQuantity(row) || 0)
+ );
const currentValue = Number(row?.deliveryQuantity || 0);
+ const maxQuantity = getDeliveryBatchDeliveryMax(row);
- if (currentValue > batchQuantity) {
- row.deliveryQuantity = batchQuantity;
+ if (currentValue <= maxQuantity) {
+ return;
+ }
+ row.deliveryQuantity = roundAmount(maxQuantity);
+ // 鏈紑鍚秴鍙戜笖鏄緟鍙戣揣鏁伴噺鍏堝埌涓婇檺鏃讹紝鎻愮ず寰呭彂璐ф暟閲忛檺鍒�
+ if (!allowOverDelivery.value && maxQuantity < batchQuantity) {
+ proxy.$modal.msgWarning(
+ `鏈紑鍚秴鍙戯紝鏈鍙戣揣鎬婚噺涓嶈兘瓒呰繃寰呭彂璐ф暟閲� ${getCurrentDeliveryRowQuantity()}`
+ );
+ } else {
proxy.$modal.msgWarning("鍙戣揣鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
}
+ };
+ // 鎸夋壒鍙烽�愭潯鎶婄洰鏍囨暟閲忓~鍏ュ悇鎵瑰彿
+ const fillDeliveryQuantity = targetQuantity => {
+ let remainingQuantity = roundAmount(Math.max(0, targetQuantity));
+ (deliveryForm.value.batchNoList || []).forEach(row => {
+ const batchQuantity = Math.max(
+ 0,
+ Number(getDeliveryBatchQuantity(row) || 0)
+ );
+ const quantity = Math.min(batchQuantity, remainingQuantity);
+ row.deliveryQuantity = roundAmount(quantity);
+ remainingQuantity = roundAmount(remainingQuantity - quantity);
+ });
+ return remainingQuantity;
+ };
+ const autoAllocateDeliveryQuantity = () => {
+ const pendingQuantity = getCurrentDeliveryRowQuantity();
+ if (pendingQuantity <= 0) {
+ proxy.$modal.msgWarning("寰呭彂璐ф暟閲忎负0锛屾棤闇�鍒嗛厤鍙戣揣鏁伴噺");
+ return;
+ }
+ if (!hasDeliveryStock.value) {
+ proxy.$modal.msgWarning("褰撳墠娌℃湁鍙敤搴撳瓨鎵瑰彿");
+ return;
+ }
+ const unallocatedQuantity = fillDeliveryQuantity(pendingQuantity);
+ if (unallocatedQuantity > 0) {
+ proxy.$modal.msgWarning(
+ `搴撳瓨涓嶈冻锛屽緟鍙戣揣鏁伴噺浠嶆湁 ${unallocatedQuantity} 鏈垎閰峘
+ );
+ } else {
+ proxy.$modal.msgSuccess(`宸叉寜鎵瑰彿閫愭潯鍒嗛厤寰呭彂璐ф暟閲� ${pendingQuantity}`);
+ }
+ };
+ const clearDeliveryQuantity = () => {
+ (deliveryForm.value.batchNoList || []).forEach(row => {
+ row.deliveryQuantity = 0;
+ });
+ };
+ const handleAllowOverDeliveryChange = allow => {
+ if (allow) return;
+ const pendingQuantity = getCurrentDeliveryRowQuantity();
+ // 寰呭彂璐ф暟閲忎负0鏃跺叧闂秴鍙戜細瀵艰嚧鏃犳硶鍙戣揣锛屽己鍒朵繚鎸佸厑璁�
+ if (pendingQuantity <= 0) {
+ deliveryForm.value.allowOverDelivery = true;
+ proxy.$modal.msgWarning("寰呭彂璐ф暟閲忎负0锛屾棤娉曞叧闂秴鍙�");
+ return;
+ }
+ if (selectedDeliveryQuantity.value <= pendingQuantity) return;
+ ElMessageBox.confirm(
+ `褰撳墠宸查�夊彂璐ф暟閲� ${selectedDeliveryQuantity.value} 瓒呰繃寰呭彂璐ф暟閲� ${pendingQuantity}锛屽叧闂秴鍙戝悗灏嗘寜鎵瑰彿閫愭潯鑷姩缂╁噺鑷� ${pendingQuantity}锛屾槸鍚︾户缁紵`,
+ "鍏抽棴瓒呭彂",
+ {
+ type: "warning",
+ confirmButtonText: "缁х画",
+ cancelButtonText: "鍙栨秷",
+ }
+ )
+ .then(() => {
+ fillDeliveryQuantity(pendingQuantity);
+ proxy.$modal.msgSuccess(`宸插皢鍙戣揣鎬婚噺璋冩暣涓� ${pendingQuantity}`);
+ })
+ .catch(() => {
+ deliveryForm.value.allowOverDelivery = true;
+ });
};
const getSelectedDeliveryBatchRows = () => {
return (deliveryForm.value.batchNoList || []).filter(
@@ -1383,6 +1559,7 @@
expressCompany: "",
expressNumber: "",
type: "璐ц溅", // 璐ц溅, 蹇��, 鑷��
+ allowOverDelivery: false, // 鏄惁鍏佽瓒呭彂锛岄粯璁ゅ叧闂�
},
deliveryRules: {
shippingCarNumber: [
@@ -2578,6 +2755,8 @@
expressCompany: "",
expressNumber: "",
type: "璐ц溅",
+ // 寰呭彂璐ф暟閲忎负0鏃讹紝鈥滅姝㈣秴鍙戔�濅細瀵艰嚧鏃犳硶鍙戣揣锛屾鏃堕粯璁ゅ厑璁歌秴鍙�
+ allowOverDelivery: !(Number(row?.noQuantity || 0) > 0),
batchNo: [],
batchNoList,
};
@@ -2592,6 +2771,16 @@
const selectedBatchRows = getSelectedDeliveryBatchRows();
if (selectedBatchRows.length === 0) {
proxy.$modal.msgWarning("璇疯嚦灏戝~鍐欎竴涓壒鍙风殑鍙戣揣鏁伴噺");
+ return;
+ }
+ // 鍏抽棴瓒呭彂鏃讹紝鍙戣揣鎬婚噺涓嶈兘瓒呰繃寰呭彂璐ф暟閲�
+ if (
+ !allowOverDelivery.value &&
+ selectedDeliveryQuantity.value > getCurrentDeliveryRowQuantity()
+ ) {
+ proxy.$modal.msgWarning(
+ `鏈紑鍚秴鍙戯紝鏈鍙戣揣鎬婚噺涓嶈兘瓒呰繃寰呭彂璐ф暟閲� ${getCurrentDeliveryRowQuantity()}`
+ );
return;
}
// 淇濆瓨褰撳墠灞曞紑鐨勮ID锛屼互渚垮彂璐у悗閲嶆柊鍔犺浇瀛愯〃鏍兼暟鎹�
@@ -2725,6 +2914,69 @@
margin-bottom: 10px;
}
+ .delivery-quantity-tip {
+ margin-top: 4px;
+ font-size: 12px;
+ line-height: 18px;
+ color: #909399;
+
+ &.is-full {
+ color: #67c23a;
+ }
+
+ &.is-over {
+ color: #f56c6c;
+ }
+ }
+
+ .delivery-excess-row {
+ display: flex;
+ align-items: center;
+ gap: 16px;
+ width: 100%;
+ }
+
+ .delivery-excess-input {
+ flex: 1;
+
+ &.is-over :deep(.el-input__inner) {
+ color: #f56c6c;
+ font-weight: 600;
+ }
+ }
+
+ .delivery-over-switch {
+ display: flex;
+ flex-shrink: 0;
+ align-items: center;
+ gap: 4px;
+ }
+
+ .delivery-over-switch__tip {
+ color: #909399;
+ cursor: help;
+ }
+
+ .delivery-batch-toolbar {
+ display: flex;
+ flex-wrap: wrap;
+ align-items: center;
+ justify-content: space-between;
+ gap: 8px;
+ width: 100%;
+ margin-bottom: 8px;
+ }
+
+ .delivery-batch-toolbar__hint {
+ font-size: 12px;
+ color: #909399;
+ }
+
+ .delivery-batch-toolbar__actions {
+ display: flex;
+ align-items: center;
+ }
+
.print-preview-dialog {
.el-dialog__body {
padding: 0;
--
Gitblit v1.9.3