From 4a23db908d36b20deab22a211da5f25c4f683cca Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期五, 29 五月 2026 09:10:22 +0800
Subject: [PATCH] 采购含水量
---
src/views/procurementManagement/procurementLedger/index.vue | 196 +++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 196 insertions(+), 0 deletions(-)
diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 7eb6ba7..3994855 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -215,6 +215,11 @@
</el-button>
<el-button link
type="primary"
+ @click="handleStockIn(scope.row)"
+ :disabled="scope.row.approvalStatus !== 3 || scope.row.stockInStatus === '瀹屽叏鍏ュ簱'">鍏ュ簱
+ </el-button>
+ <el-button link
+ type="primary"
@click="openFileDialog(scope.row)">闄勪欢</el-button>
</template>
</el-table-column>
@@ -679,6 +684,86 @@
</el-row>
</el-form>
</FormDialog>
+ <!-- 鍏ュ簱寮圭獥 -->
+ <FormDialog v-model="stockInDialogVisible"
+ title="鍏ュ簱纭"
+ :width="'90%'"
+ @close="stockInDialogVisible = false"
+ @confirm="submitStockIn"
+ @cancel="stockInDialogVisible = false">
+ <el-form :model="stockInForm"
+ label-width="120px"
+ label-position="top">
+ <el-row :gutter="20">
+ <el-col :span="12">
+ <el-form-item label="閲囪喘鍚堝悓鍙�">
+ <el-input v-model="stockInForm.purchaseContractNumber"
+ disabled />
+ </el-form-item>
+ </el-col>
+ </el-row>
+ <el-table :data="stockInForm.details"
+ border>
+ <el-table-column align="center"
+ label="搴忓彿"
+ type="index"
+ width="60" />
+ <el-table-column label="浜у搧澶х被"
+ prop="productCategory"
+ show-overflow-tooltip />
+ <el-table-column label="瑙勬牸鍨嬪彿"
+ prop="specificationModel"
+ show-overflow-tooltip />
+ <el-table-column label="鍗曚綅"
+ prop="unit"
+ width="70" />
+ <el-table-column label="寰呭叆搴撴暟閲�"
+ prop="availableQuality"
+ width="100" />
+ <el-table-column label="鏈鍏ュ簱鏁伴噺"
+ width="130">
+ <template #default="scope">
+ <el-input-number v-model="scope.row.inboundQuantity"
+ :step="0.01"
+ :min="0"
+ :max="scope.row.availableQuality"
+ @change="handleInboundChange(scope.row)"
+ controls-position="right"
+ style="width: 100%" />
+ </template>
+ </el-table-column>
+ <el-table-column label="鏄惁鍚按"
+ width="100"
+ align="center">
+ <template #default="scope">
+ <el-switch v-model="scope.row.isContainsWater"
+ @change="handleInboundChange(scope.row)" />
+ </template>
+ </el-table-column>
+ <el-table-column label="鍚按閲�(%)"
+ width="130">
+ <template #default="scope">
+ <el-input-number v-if="scope.row.isContainsWater"
+ v-model="scope.row.waterContent"
+ :precision="2"
+ :step="0.1"
+ :min="0"
+ :max="100"
+ @change="handleInboundChange(scope.row)"
+ controls-position="right"
+ style="width: 100%" />
+ <span v-else>--</span>
+ </template>
+ </el-table-column>
+ <el-table-column label="瀹為檯鍏ュ簱鏁伴噺"
+ width="130">
+ <template #default="scope">
+ <span style="font-weight: bold; color: #409EFF;">{{ scope.row.actualInboundQuantity }}</span>
+ </template>
+ </el-table-column>
+ </el-table>
+ </el-form>
+ </FormDialog>
<FileList v-if="fileListDialogVisible"
v-model:visible="fileListDialogVisible"
record-type="purchase_ledger"
@@ -722,6 +807,7 @@
getPurchaseTemplateList,
delPurchaseTemplate,
} from "@/api/procurementManagement/procurementLedger.js";
+ import { addSutockIn } from "@/api/inventoryManagement/stockIn.js";
import useFormData from "@/hooks/useFormData.js";
const FileList = defineAsyncComponent(() =>
import("@/components/Dialog/FileList.vue")
@@ -741,6 +827,14 @@
const tableLoading = ref(false);
const recordId = ref();
const fileListDialogVisible = ref(false);
+ // 鍏ュ簱寮圭獥鐩稿叧
+ const stockInDialogVisible = ref(false);
+ const stockInLoading = ref(false);
+ const stockInForm = reactive({
+ purchaseLedgerId: null,
+ purchaseContractNumber: "",
+ details: [],
+ });
const page = reactive({
current: 1,
size: 100,
@@ -1234,6 +1328,108 @@
productSelectedRows.value = selectedRows;
};
const expandedRowKeys = ref([]);
+
+ // 鍏ュ簱澶勭悊
+ const handleStockIn = async row => {
+ stockInForm.purchaseLedgerId = row.id;
+ stockInForm.purchaseContractNumber = row.purchaseContractNumber;
+ stockInForm.details = [];
+
+ try {
+ proxy.$modal.loading("姝e湪鍔犺浇浜у搧淇℃伅...");
+ const res = await productList({ salesLedgerId: row.id, type: 2 });
+ if (res.code === 200) {
+ // 杩囨护鎺夊凡缁忓畬鍏ㄥ叆搴撶殑浜у搧锛堝鏋滄湁杩欎釜鐘舵�佺殑璇濓紝鎴栬�呯洿鎺ユ樉绀烘墍鏈夊彲鐢ㄦ暟閲忓ぇ浜�0鐨勪骇鍝侊級
+ stockInForm.details = (res.data || [])
+ .filter(item => (item.availableQuality || 0) > 0)
+ .map(item => ({
+ ...item,
+ inboundQuantity: item.availableQuality || 0, // 榛樿鍏ュ簱鍏ㄩ儴鍙敤鏁伴噺
+ isContainsWater: false,
+ waterContent: 0,
+ actualInboundQuantity: item.availableQuality || 0,
+ }));
+
+ if (stockInForm.details.length === 0) {
+ proxy.$modal.msgWarning("璇ュ悎鍚屼笅娌℃湁鍙叆搴撶殑浜у搧璁板綍");
+ return;
+ }
+ stockInDialogVisible.value = true;
+ }
+ } catch (error) {
+ console.error("鍔犺浇浜у搧鍒楄〃澶辫触:", error);
+ proxy.$modal.msgError("鍔犺浇浜у搧鍒楄〃澶辫触");
+ } finally {
+ proxy.$modal.closeLoading();
+ }
+ };
+
+ // 璁$畻瀹為檯鍏ュ簱鏁伴噺
+ const handleInboundChange = row => {
+ if (row.isContainsWater) {
+ // 瀹為檯鍏ュ簱 = 鏈鍏ュ簱鏁伴噺 * (1 - 鍚按閲�/100)
+ row.actualInboundQuantity = Number(
+ (row.inboundQuantity * (1 - (row.waterContent || 0) / 100)).toFixed(2)
+ );
+ } else {
+ row.actualInboundQuantity = row.inboundQuantity;
+ }
+ };
+
+ const submitStockIn = async () => {
+ if (stockInForm.details.length === 0) {
+ proxy.$modal.msgWarning("璇烽�夋嫨鍏ュ簱浜у搧");
+ return;
+ }
+
+ // 楠岃瘉鍏ュ簱鏁伴噺
+ const invalid = stockInForm.details.some(
+ item => !item.inboundQuantity || item.inboundQuantity <= 0
+ );
+ if (invalid) {
+ proxy.$modal.msgWarning("璇疯緭鍏ユ湁鏁堢殑鍏ュ簱鏁伴噺");
+ return;
+ }
+
+ const overLimit = stockInForm.details.some(
+ item => item.inboundQuantity > item.availableQuality
+ );
+ if (overLimit) {
+ proxy.$modal.msgWarning("鍏ュ簱鏁伴噺涓嶈兘瓒呰繃鍙敤鏁伴噺");
+ return;
+ }
+
+ try {
+ stockInLoading.value = true;
+ const params = {
+ purchaseLedgerId: stockInForm.purchaseLedgerId,
+ purchaseContractNumber: stockInForm.purchaseContractNumber,
+ nickName: userStore.nickName,
+ details: stockInForm.details.map(item => ({
+ id: item.id,
+ inboundQuantity: item.inboundQuantity,
+ isContainsWater: item.isContainsWater,
+ waterContent: item.isContainsWater ? item.waterContent : 0,
+ actualInboundQuantity: item.actualInboundQuantity,
+ })),
+ };
+
+ const res = await addSutockIn(params);
+ if (res.code === 200) {
+ proxy.$modal.msgSuccess("鍏ュ簱鎴愬姛");
+ stockInDialogVisible.value = false;
+ getList(); // 鍒锋柊鍒楄〃
+ } else {
+ proxy.$modal.msgError(res.msg || "鍏ュ簱澶辫触");
+ }
+ } catch (error) {
+ console.error("鍏ュ簱鎻愪氦澶辫触:", error);
+ proxy.$modal.msgError("鍏ュ簱鎻愪氦澶辫触");
+ } finally {
+ stockInLoading.value = false;
+ }
+ };
+
// 灞曞紑琛�
const expandChange = async (row, expandedRows) => {
if (expandedRows.length > 0) {
--
Gitblit v1.9.3