From 4c3dee416ab4940d10e43af0e0ec79433ddd012a Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期六, 20 六月 2026 14:55:36 +0800
Subject: [PATCH] feat: 新增销售产品展示库存数量
---
src/views/salesManagement/salesLedger/index.vue | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/src/views/salesManagement/salesLedger/index.vue b/src/views/salesManagement/salesLedger/index.vue
index 1b1c2e9..ff5d53f 100644
--- a/src/views/salesManagement/salesLedger/index.vue
+++ b/src/views/salesManagement/salesLedger/index.vue
@@ -727,12 +727,33 @@
<el-col :span="12">
<el-form-item label="鏄惁鐢熶骇锛�"
prop="isProduction">
- <el-radio-group v-model="productForm.isProduction">
- <el-radio label="鏄�"
- :value="true" />
- <el-radio label="鍚�"
- :value="false" />
- </el-radio-group>
+ <div style="display: flex; align-items: center; width: 100%;">
+ <el-radio-group v-model="productForm.isProduction">
+ <el-radio label="鏄�"
+ :value="true" />
+ <el-radio label="鍚�"
+ :value="false" />
+ </el-radio-group>
+ <div
+ v-if="currentStock !== null"
+ :style="{
+ marginLeft: '20px',
+ padding: '0 12px',
+ height: '28px',
+ lineHeight: '28px',
+ borderRadius: '4px',
+ fontSize: '13px',
+ fontWeight: '500',
+ display: 'inline-block',
+ whiteSpace: 'nowrap',
+ backgroundColor: (productForm.quantity || 0) > currentStock ? '#fff0f0' : '#f0f9eb',
+ border: (productForm.quantity || 0) > currentStock ? '1px solid #ffcccc' : '1px solid #e1f3d8',
+ color: (productForm.quantity || 0) > currentStock ? '#f56c6c' : '#67c23a'
+ }"
+ >
+ <span>褰撳墠搴撳瓨锛歿{ currentStock }} {{ productForm.unit || '' }}</span>
+ </div>
+ </div>
</el-form-item>
</el-col>
</el-row>
@@ -1198,6 +1219,27 @@
item?.stockQuantity;
return quantity ?? 0;
};
+ const currentStock = ref(null);
+ const fetchCurrentStock = async (productModelId) => {
+ if (!productModelId) {
+ currentStock.value = null;
+ return;
+ }
+ try {
+ const res = await getStockInventoryByModelId(productModelId);
+ const rawList = Array.isArray(res?.data)
+ ? res.data
+ : res?.data?.records || res?.data?.rows || [];
+ let total = 0;
+ rawList.forEach(item => {
+ total += Number(getDeliveryBatchQuantity(item) || 0);
+ });
+ currentStock.value = total;
+ } catch (e) {
+ console.error(e);
+ currentStock.value = 0;
+ }
+ };
const getCurrentDeliveryRowQuantity = () => {
return Number(currentDeliveryRow.value?.noQuantity || 0);
};
@@ -1463,6 +1505,7 @@
// 鑾峰彇tree瀛愭暟鎹�
const getModels = value => {
productForm.value.productCategory = findNodeById(productOptions.value, value);
+ currentStock.value = null;
modelList({ id: value }).then(res => {
modelOptions.value = res;
});
@@ -1472,9 +1515,11 @@
if (index !== -1) {
productForm.value.specificationModel = modelOptions.value[index].model;
productForm.value.unit = modelOptions.value[index].unit;
+ fetchCurrentStock(value);
} else {
productForm.value.specificationModel = null;
productForm.value.unit = null;
+ currentStock.value = null;
}
};
const findNodeById = (nodes, productId) => {
@@ -1798,6 +1843,7 @@
productOperationType.value = type;
productForm.value = {};
+ currentStock.value = null;
if (type === "add") {
productForm.value.isProduction = false;
}
@@ -1824,6 +1870,7 @@
);
if (currentModel) {
productForm.value.productModelId = currentModel.id;
+ fetchCurrentStock(currentModel.id);
}
}
} catch (e) {
--
Gitblit v1.9.3