From df1406d0f571972d033dffd6a93fb4b94febeb56 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期二, 24 六月 2025 16:46:44 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev' into dev

---
 src/views/production/components/ProductionDetailsTable.vue |  180 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 92 insertions(+), 88 deletions(-)

diff --git a/src/views/production/components/ProductionDetailsTable.vue b/src/views/production/components/ProductionDetailsTable.vue
index eb4091b..1db3794 100644
--- a/src/views/production/components/ProductionDetailsTable.vue
+++ b/src/views/production/components/ProductionDetailsTable.vue
@@ -1,20 +1,20 @@
 <template>
-  <el-table :data="tableData" :border="border" style="width: 100%">    
+  <el-table :data="tableData" :border="border" style="width: 100%">
     <el-table-column label="鐓ょ" min-width="120">
       <template #default="{ row, $index }">
-        <el-select 
-          clearable 
-          :model-value="getCoalNameById(row.coal) || row.coal"
-          placeholder="璇烽�夋嫨鐓ょ"
-          @change="(value) => handleCoalSelectChange(row, value)"
-          filterable
-          :key="`coal-select-${$index}-${weekList.length}`"
+        <el-select
+            clearable
+            :model-value="getCoalNameById(row.coalId) || row.coalId"
+            placeholder="璇烽�夋嫨鐓ょ"
+            @change="(value) => handleCoalSelectChange(row, value)"
+            filterable
+            :key="`coalId-select-${$index}-${weekList.length}`"
         >
           <el-option
-            v-for="(item, index) of weekList"
-            :key="`option-${index}-${item.key}`"
-            :label="item.value"
-            :value="item.value"
+              v-for="(item, index) of weekList"
+              :key="`option-${index}-${item.key}`"
+              :label="item.value"
+              :value="item.value"
           />
         </el-select>
       </template>
@@ -22,10 +22,10 @@
     <el-table-column label="鐢熶骇鏁伴噺" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          v-model="row.productionQuantity"
-          placeholder="璇疯緭鍏ョ敓浜ф暟閲�"
-          type="number"
-          @input="handleInput('productionQuantity', $index, $event)"
+            v-model="row.productionQuantity"
+            placeholder="璇疯緭鍏ョ敓浜ф暟閲�"
+            type="number"
+            @input="handleInput('productionQuantity', $index, $event)"
         />
       </template>
     </el-table-column>
@@ -33,10 +33,10 @@
     <el-table-column label="浜哄伐鎴愭湰" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          v-model="row.laborCost"
-          placeholder="璇疯緭鍏ヤ汉宸ユ垚鏈�"
-          type="number"
-          @input="handleInput('laborCost', $index, $event)"
+            v-model="row.laborCost"
+            placeholder="璇疯緭鍏ヤ汉宸ユ垚鏈�"
+            type="number"
+            @input="handleInput('laborCost', $index, $event)"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -48,10 +48,10 @@
     <el-table-column label="鑳借�楁垚鏈�" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          v-model="row.energyConsumptionCost"
-          placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�"
-          type="number"
-          @input="handleInput('energyConsumptionCost', $index, $event)"
+            v-model="row.energyConsumptionCost"
+            placeholder="璇疯緭鍏ヨ兘鑰楁垚鏈�"
+            type="number"
+            @input="handleInput('energyConsumptionCost', $index, $event)"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -63,10 +63,10 @@
     <el-table-column label="璁惧鎶樻棫" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          v-model="row.equipmentDepreciation"
-          placeholder="璇疯緭鍏ヨ澶囨姌鏃�"
-          type="number"
-          @input="handleInput('equipmentDepreciation', $index, $event)"
+            v-model="row.equipmentDepreciation"
+            placeholder="璇疯緭鍏ヨ澶囨姌鏃�"
+            type="number"
+            @input="handleInput('equipmentDepreciation', $index, $event)"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -78,10 +78,10 @@
     <el-table-column label="閲囪喘鍗曚环" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          v-model="row.purchasePrice"
-          placeholder="璇疯緭鍏ラ噰璐崟浠�"
-          type="number"
-          @input="handleInput('purchasePrice', $index, $event)"
+            v-model="row.purchasePrice"
+            placeholder="璇疯緭鍏ラ噰璐崟浠�"
+            type="number"
+            @input="handleInput('purchasePrice', $index, $event)"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -93,12 +93,12 @@
     <el-table-column label="鎬绘垚鏈�" min-width="120">
       <template #default="{ row, $index }">
         <el-input
-          disabled
-          v-model="row.totalCost"
-          placeholder="鎬绘垚鏈�"
-          type="number"
-          :readonly="autoCalculate"
-          @input="handleInput('totalCost', $index, $event)"
+            disabled
+            v-model="row.totalCost"
+            placeholder="鎬绘垚鏈�"
+            type="number"
+            :readonly="autoCalculate"
+            @input="handleInput('totalCost', $index, $event)"
         >
           <template #suffix>
             <i style="font-style: normal">鍏�</i>
@@ -109,34 +109,34 @@
     <el-table-column label="鐢熶骇浜�" min-width="120">
       <template #default="{ row, $index }">
         <el-select
-          clearable
-          :model-value="getUserNameById(row.producer) || row.producer"
-          placeholder="璇烽�夋嫨鐢熶骇浜�"
-          @change="(value) => handleUserSelectChange(row, value)"
-          filterable
-          :key="`producer-select-${$index}-${userList.length}`"
+            clearable
+            :model-value="getUserNameById(row.producer) || row.producer"
+            placeholder="璇烽�夋嫨鐢熶骇浜�"
+            @change="(value) => handleUserSelectChange(row, value)"
+            filterable
+            :key="`producer-select-${$index}-${userList.length}`"
         >
           <el-option
-            v-for="(item, index) of userList"
-            :key="`option-${index}-${item.key}`"
-            :label="item.value"
-            :value="item.value"
+              v-for="(item, index) of userList"
+              :key="`option-${index}-${item.key}`"
+              :label="item.value"
+              :value="item.value"
           />
         </el-select>
       </template>
     </el-table-column>
     <el-table-column
-      v-if="showOperations"
-      label="鎿嶄綔"
-      width="120"
-      fixed="right"
+        v-if="showOperations"
+        label="鎿嶄綔"
+        width="120"
+        fixed="right"
     >
       <template #default="{ $index }">
         <el-button
-          type="danger"
-          size="small"
-          @click="handleDelete($index)"
-          :icon="Delete"
+            type="danger"
+            size="small"
+            @click="handleDelete($index)"
+            :icon="Delete"
         >
           鍒犻櫎
         </el-button>
@@ -146,10 +146,12 @@
 </template>
 
 <script setup name="ProductionDetailsTable">
-import { ref, computed, watch, onMounted, nextTick } from "vue";
-import { Delete } from "@element-plus/icons-vue";
-import { getCoalFieldList } from "@/api/basicInformation/coalQualityMaintenance";
-import { userListAll } from "@/api/publicApi";
+import {ref, computed, watch, onMounted, nextTick} from "vue";
+import {Delete} from "@element-plus/icons-vue";
+import {getCoalFieldList} from "@/api/basicInformation/coalQualityMaintenance";
+import {getCoalInfoList} from "@/api/production";
+import {userListAll} from "@/api/publicApi";
+
 const props = defineProps({
   modelValue: {
     type: Array,
@@ -188,19 +190,19 @@
 
   // 濡傛灉寮�鍚嚜鍔ㄨ绠楁�绘垚鏈�
   if (
-    props.autoCalculate &&
-    [
-      "laborCost",
-      "energyCost",
-      "equipmentDepreciation",
-      "purchasePrice",
-    ].includes(field)
+      props.autoCalculate &&
+      [
+        "laborCost",
+        "energyCost",
+        "equipmentDepreciation",
+        "purchasePrice",
+      ].includes(field)
   ) {
     calculateTotalCost(newData[index]);
   }
 
   tableData.value = newData;
-  emit("input-change", { field, index, value, row: newData[index] });
+  emit("input-change", {field, index, value, row: newData[index]});
 };
 
 // 璁$畻鎬绘垚鏈�
@@ -211,10 +213,10 @@
   const purchasePrice = parseFloat(row.purchasePrice) || 0;
 
   row.totalCost = (
-    laborCost +
-    energyCost +
-    equipmentDepreciation +
-    purchasePrice
+      laborCost +
+      energyCost +
+      equipmentDepreciation +
+      purchasePrice
   ).toFixed(2);
 };
 
@@ -233,16 +235,16 @@
   // 鏍规嵁閫夋嫨鐨勫悕绉版壘鍒板搴旂殑ID
   const coalItem = weekList.value.find(item => item.value === selectedName);
   if (coalItem) {
-    row.coal = coalItem.key; // 璁剧疆涓篒D
+    row.coalId = coalItem.key; // 璁剧疆涓篒D
   } else {
-    row.coal = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
+    row.coalId = ''; // 濡傛灉娌℃壘鍒帮紝娓呯┖
   }
 };
 
 // 鏍规嵁ID鑾峰彇鐓ょ鍚嶇О锛堢敤浜庢樉绀猴級
 const getCoalNameById = (id) => {
-  const coal = weekList.value.find(item => item.key == id);
-  return coal ? coal.value : id;
+  const coalId = weekList.value.find(item => item.key == id);
+  return coalId ? coalId.value : id;
 };
 
 const weekList = ref([]);
@@ -253,7 +255,7 @@
   if (newValue && weekList.value.length > 0) {
     // 褰撴暟鎹姞杞藉畬鎴愪笖weekList宸茶幏鍙栨椂锛岀‘淇濇樉绀烘纭�
   }
-}, { deep: true });
+}, {deep: true});
 
 // 鐩戝惉weekList鍙樺寲锛屽綋涓嬫媺鏁版嵁鍔犺浇瀹屾垚鍚庡鐞嗘樉绀�
 watch(weekList, (newList) => {
@@ -265,22 +267,23 @@
       tableData.value = tempData;
     });
   }
-}, { deep: true });
+}, {deep: true});
 
-onMounted(async()=>{
-  let res = await getCoalFieldList()
+onMounted(async () => {
+  let res = await getCoalInfoList()
+  console.log(res);
   res.data.forEach(item => {
     let obj = {};
-    obj.value = item.fieldName;
+    obj.value = item.coal;
     obj.key = item.id;
-    weekList.value.push(obj); 
+    weekList.value.push(obj);
   });
   let ress = await userListAll();
   ress.data.forEach(item => {
     let obj = {};
     obj.value = item.nickName;
     obj.key = item.userId;
-    userList.value.push(obj); 
+    userList.value.push(obj);
   });
   // 閫氱煡鐖剁粍浠秝eekList宸插姞杞藉畬鎴�
   nextTick(() => {
@@ -292,7 +295,7 @@
   let res = await getCoalFieldList();
   if (res.code === 200) {
     dropdownList.value = res.data.map((item) => ({
-      value: item.fieldName,
+      value: item.coal,
       key: item.id,
     }));
   } else {
@@ -300,7 +303,7 @@
   }
 };
 const userList = ref([]);
-const getUserList = (async()=>{
+const getUserList = (async () => {
   let res = await userListAll();
   if (res.code === 200) {
     userList.value = res.data.map((item) => ({
@@ -316,7 +319,7 @@
   if (newValue && userList.value.length > 0) {
     // 褰撴暟鎹姞杞藉畬鎴愪笖weekList宸茶幏鍙栨椂锛岀‘淇濇樉绀烘纭�
   }
-}, { deep: true });
+}, {deep: true});
 
 // 鐩戝惉userList鍙樺寲锛屽綋涓嬫媺鏁版嵁鍔犺浇瀹屾垚鍚庡鐞嗘樉绀�
 watch(userList, (newList) => {
@@ -328,7 +331,7 @@
       tableData.value = tempData;
     });
   }
-}, { deep: true });
+}, {deep: true});
 
 const getUserNameById = (id) => {
   const producer = userList.value.find(item => item.key == id);
@@ -348,11 +351,12 @@
 defineExpose({
   calculateTotalCost,
   getDropdownData,
+  getUserList,
   getCoalNameById, // 鏆撮湶鑾峰彇鐓ょ鍚嶇О鐨勬柟娉�
   weekList, // 鏆撮湶weekList璁╃埗缁勪欢鍙互璁块棶
   addRow: (rowData = {}) => {
     const defaultRow = {
-      coal: "",
+      coalId: "",
       calorificValue: "",
       productionQuantity: "",
       laborCost: "",

--
Gitblit v1.9.3