From 8db0c69163959824c904cb5865b41124b1a04f2d Mon Sep 17 00:00:00 2001
From: zhang_12370 <z2864490065@outlook.com>
Date: 星期二, 24 六月 2025 16:04:39 +0800
Subject: [PATCH] 优化生产加工模块

---
 src/components/Table/EtableModify.vue                |   63 +++++++++++++------------------
 src/views/production/components/ProductionDialog.vue |   32 +++++++++++++---
 2 files changed, 52 insertions(+), 43 deletions(-)

diff --git a/src/components/Table/EtableModify.vue b/src/components/Table/EtableModify.vue
index 9afb58d..b42e487 100644
--- a/src/components/Table/EtableModify.vue
+++ b/src/components/Table/EtableModify.vue
@@ -28,33 +28,35 @@
       type="index"
       width="60"
       align="center"
-    />
-    <template v-for="col in columns" :key="col.prop">
+    />    <template v-for="col in columns" :key="col.prop">
       <el-table-column
         v-bind="col"
-        :show-overflow-tooltip="false"
         align="center"
       >
         <template #default="scope">
           <template v-if="col.slot">
-            <slot></slot>
-          </template>
-          <template v-else>
+            <slot
+              :name="col.prop"
+              :row="scope.row"
+              :column="scope.column"
+              :index="scope.$index"
+            ></slot>
+          </template>          <template v-else>
             <div
               class="cell-edit"
               @dblclick="handleCellEdit(scope.row, col.prop)"
               :class="{ editable: isColumnEditable(col.prop) }"
             >
+              <!-- 鏄剧ず鐘舵�侊細浣跨敤鏍煎紡鍖栫殑鍊� -->
               <span
                 v-if="!scope.row.editing || !scope.row.editing[col.prop]"
                 class="cell-text"
               >
                 {{
-                  scope.row[col.prop] == null || scope.row[col.prop] === ""
-                    ? "--"
-                    : scope.row[col.prop]
+                  formatCellValue(scope.row, scope.column, scope.row[col.prop], col)
                 }}
               </span>
+              <!-- 缂栬緫鐘舵�侊細浣跨敤鍘熷鍊硷紝涓嶇粡杩囨牸寮忓寲 -->
               <el-input
                 v-else
                 v-model="scope.row[col.prop]"
@@ -69,34 +71,6 @@
         </template>
       </el-table-column>
     </template>
-    <!-- 鎿嶄綔鍒� -->
-    <el-table-column
-      v-if="showOperations"
-      :label="operationsLabel"
-      :width="operationsWidth"
-      fixed="right"
-      align="center"
-    >
-      <template #default="scope">
-        <slot name="operations" :row="scope.row">
-          <el-button
-            v-if="operations.includes('edit')"
-            link
-            type="primary"
-            size="small"
-            @click="handleEdit(scope.row)"
-            >缂栬緫</el-button
-          >
-          <!--            <el-button-->
-          <!--              v-if="operations.includes('delete')"-->
-          <!--              link-->
-          <!--              type="danger"-->
-          <!--              size="small"-->
-          <!--              @click="handleDelete(scope.row)"-->
-          <!--            >鍒犻櫎</el-button>-->
-        </slot>
-      </template>
-    </el-table-column>
   </el-table>
 </template>
 
@@ -217,7 +191,22 @@
   // 妫�鏌ヨ鍒楀湪鎵�鏈夋暟鎹腑鏄惁鏈夐潪绌哄��
   return data.some((row) => row[col.prop] != null && row[col.prop] !== "");
 };
+// 榛樿鐨勬牸寮忓寲鍑芥暟
+const defaultFormatter = (row, column, cellValue) => {
+  return cellValue == null || cellValue === "" || cellValue === 0
+    ? "0"
+    : cellValue;
+};
 
+// 鏍煎紡鍖栧崟鍏冩牸鍊�
+const formatCellValue = (row, column, cellValue, col) => {
+  // 濡傛灉鍒楁湁鑷畾涔夋牸寮忓寲鍣紝浣跨敤鑷畾涔夋牸寮忓寲鍣�
+  if (col.formatter && typeof col.formatter === 'function') {
+    return col.formatter(row, column, cellValue);
+  }
+  // 鍚﹀垯浣跨敤榛樿鏍煎紡鍖栧櫒
+  return defaultFormatter(row, column, cellValue);
+};
 // 澶勭悊鍗曞厓鏍肩紪杈�
 const handleCellEdit = (row, prop) => {
   // 濡傛灉涓嶅厑璁哥紪杈戝崟鍏冩牸锛岀洿鎺ヨ繑鍥�
diff --git a/src/views/production/components/ProductionDialog.vue b/src/views/production/components/ProductionDialog.vue
index 124e32f..3b96834 100644
--- a/src/views/production/components/ProductionDialog.vue
+++ b/src/views/production/components/ProductionDialog.vue
@@ -157,6 +157,7 @@
 import {
   getOfficialAll,
   addOrEditPM,
+  getCoalInfoList,
   deleteProductionInventory,
 } from "@/api/production/index.js";
 import {validateFormData, validateNumber, deepClone, createDefaultProductionRow} from "@/utils/production";
@@ -192,9 +193,15 @@
 const selectedIds = ref([]);
 const currentRow = ref(null);
 const copyForm = ref(null);
+const coalList = ref([])
+const supplierList = ref({});
 // 琛ㄦ牸鍒楅厤缃�
 const columns = [
-  {label: "鐓ょ", prop: "coal", minwidth: 120},
+  {prop: "coalId", label: "鐓ょ", minwidth: 60,slot:false,
+    formatter: (row) => {
+      return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
+    }
+  },
   {label: "搴撳瓨鏁伴噺", prop: "inventoryQuantity", minwidth: 100},
   {
     label: "浣跨敤鏁伴噺",
@@ -206,8 +213,18 @@
 ];
 
 const formalDatabaseColumns = ref([
-  {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150},
-  {prop: "coal", label: "鐓ょ绫诲瀷", minwidth: 60},
+  {prop: "supplierName", label: "渚涘簲鍟嗗悕绉�", minwidth: 150
+  // ,formatter: (row) => {
+  //     console.log(row);
+  //     return supplierList.value[row.supplierId] || "--";
+  //   }
+  },
+  {prop: "coalId", label: "鐓ょ", minwidth: 60,
+    formatter: (row) => {
+      // return coalList.value[row.coalId].coal || "--";
+      return coalList.value.find(coal => coal.id === row.coalId)?.coal || "--";
+    }
+  },
   {prop: "inventoryQuantity", label: "搴撳瓨鏁伴噺", minwidth: 80},
   {prop: "unit", label: "鍗曚綅", minwidth: 20},
   {prop: "priceExcludingTax", label: "鍗曚环锛堜笉鍚◣锛�", minwidth: 80},
@@ -229,9 +246,12 @@
 // 鑾峰彇閰嶇疆鏁版嵁
 const handlData = async () => {
   innerVisible.value = true;
-  let res = await getOfficialAll();
-  if (res.code === 200) {
-    formalDatabaseData.value = res.data;
+  let getSupplier = await getOfficialAll();
+  let getCoalName = await getCoalInfoList();
+  coalList.value = getCoalName.data || [];
+  supplierList.value = getSupplier.data || [];
+  if (getSupplier.code === 200) {
+    formalDatabaseData.value = getSupplier.data;
     const existingOfficialIds = tableData.value
         .map((item) => item.officialId)
         .filter((id) => id);

--
Gitblit v1.9.3