From 3bd642ad4d805032ae43e1fd23e0c4e6b7dfa9f2 Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期六, 12 七月 2025 11:58:41 +0800
Subject: [PATCH] 1、修改采购管理的匹配逻辑 2、修改生产加工新增生产明细的总数居匹配问题 3、修改配煤计算器 4、修改设备管理领用记录的提交问题

---
 src/views/production/components/ProductionDetailsTable.vue |   36 +++++++++++++++++++++++++++++-------
 1 files changed, 29 insertions(+), 7 deletions(-)

diff --git a/src/views/production/components/ProductionDetailsTable.vue b/src/views/production/components/ProductionDetailsTable.vue
index 1db3794..48308f4 100644
--- a/src/views/production/components/ProductionDetailsTable.vue
+++ b/src/views/production/components/ProductionDetailsTable.vue
@@ -9,6 +9,7 @@
             @change="(value) => handleCoalSelectChange(row, value)"
             filterable
             :key="`coalId-select-${$index}-${weekList.length}`"
+            :disabled="isViewMode"
         >
           <el-option
               v-for="(item, index) of weekList"
@@ -26,6 +27,7 @@
             placeholder="璇疯緭鍏ョ敓浜ф暟閲�"
             type="number"
             @input="handleInput('productionQuantity', $index, $event)"
+            :disabled="isViewMode"
         />
       </template>
     </el-table-column>
@@ -37,6 +39,7 @@
             placeholder="璇疯緭鍏ヤ汉宸ユ垚鏈�"
             type="number"
             @input="handleInput('laborCost', $index, $event)"
+            :disabled="isViewMode"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -47,11 +50,15 @@
 
     <el-table-column label="鑳借�楁垚鏈�" min-width="120">
       <template #default="{ row, $index }">
+        <!-- 涓嶈兘涓鸿礋鏁� -->
         <el-input
             v-model="row.energyConsumptionCost"
             placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�"
             type="number"
+            min="0"
+            step="0.01"
             @input="handleInput('energyConsumptionCost', $index, $event)"
+            :disabled="isViewMode"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -67,6 +74,7 @@
             placeholder="璇疯緭鍏ヨ澶囨姌鏃�"
             type="number"
             @input="handleInput('equipmentDepreciation', $index, $event)"
+            :disabled="isViewMode"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -82,6 +90,7 @@
             placeholder="璇疯緭鍏ラ噰璐崟浠�"
             type="number"
             @input="handleInput('purchasePrice', $index, $event)"
+            :disabled="isViewMode"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -99,6 +108,7 @@
             type="number"
             :readonly="autoCalculate"
             @input="handleInput('totalCost', $index, $event)"
+            
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -110,11 +120,12 @@
       <template #default="{ row, $index }">
         <el-select
             clearable
-            :model-value="getUserNameById(row.producer) || row.producer"
+            :model-value="getUserNameById(row.producerId) || row.producerId"
             placeholder="璇烽�夋嫨鐢熶骇浜�"
             @change="(value) => handleUserSelectChange(row, value)"
             filterable
             :key="`producer-select-${$index}-${userList.length}`"
+            :disabled="isViewMode"
         >
           <el-option
               v-for="(item, index) of userList"
@@ -126,10 +137,10 @@
       </template>
     </el-table-column>
     <el-table-column
-        v-if="showOperations"
         label="鎿嶄綔"
         width="120"
         fixed="right"
+        v-if="dialogType !== 'viewRow'"
     >
       <template #default="{ $index }">
         <el-button
@@ -148,6 +159,7 @@
 <script setup name="ProductionDetailsTable">
 import {ref, computed, watch, onMounted, nextTick} from "vue";
 import {Delete} from "@element-plus/icons-vue";
+import {ElMessage} from "element-plus";
 import {getCoalFieldList} from "@/api/basicInformation/coalQualityMaintenance";
 import {getCoalInfoList} from "@/api/production";
 import {userListAll} from "@/api/publicApi";
@@ -169,8 +181,12 @@
     type: Boolean,
     default: true,
   },
+  dialogType:{
+    type: String,
+    default:'add'
+  }
 });
-
+const isViewMode = computed(() => props.dialogType === "viewRow");
 const emit = defineEmits(["update:modelValue", "input-change", "delete-row"]);
 
 // 浣跨敤 v-model 杩涜鍙屽悜缁戝畾
@@ -185,6 +201,11 @@
 
 // 澶勭悊杈撳叆鍙樺寲
 const handleInput = (field, index, value) => {
+  // 纭繚杈撳叆鍊兼槸鏁板瓧鎴栫┖瀛楃涓茶�屼笖闈炶礋鏁�
+  if (!/^\d*\.?\d*$/.test(value) && value !== "") {
+    ElMessage.error("璇疯緭鍏ユ湁鏁堢殑鏁板瓧");
+    return;
+  }
   const newData = [...tableData.value];
   newData[index][field] = value;
 
@@ -208,7 +229,7 @@
 // 璁$畻鎬绘垚鏈�
 const calculateTotalCost = (row) => {
   const laborCost = parseFloat(row.laborCost) || 0;
-  const energyCost = parseFloat(row.energyCost) || 0;
+  const energyCost = parseFloat(row.energyConsumptionCost) || 0;
   const equipmentDepreciation = parseFloat(row.equipmentDepreciation) || 0;
   const purchasePrice = parseFloat(row.purchasePrice) || 0;
 
@@ -339,12 +360,13 @@
 };
 // 澶勭悊鐢ㄦ埛閫夋嫨鍙樺寲锛堟柊鏂规硶锛氬悕绉伴�夋嫨杞琁D锛�
 const handleUserSelectChange = (row, selectedName) => {
+  console.log("handleUserSelectChange", row, selectedName);
   // 鏍规嵁閫夋嫨鐨勫悕绉版壘鍒板搴旂殑ID
   const userItem = userList.value.find(item => item.value === selectedName);
   if (userItem) {
-    row.producer = userItem.key; // 璁剧疆涓篒D
+    row.producerId = userItem.key; // 璁剧疆涓篒D
   } else {
-    row.producer = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
+    row.producerId = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
   }
 };
 // 鏆撮湶鏂规硶缁欑埗缁勪欢浣跨敤
@@ -364,7 +386,7 @@
       equipmentDepreciation: "",
       purchasePrice: "",
       totalCost: "",
-      producer: "",
+      producerId: "",
       ...rowData,
     };
     tableData.value = [...tableData.value, defaultRow];

--
Gitblit v1.9.3