From a1274d448fa9fd59da39d94f5d91e54780fc8de1 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期五, 24 四月 2026 11:01:10 +0800
Subject: [PATCH] fix: 出入库只有吨和公斤才能转换单位,其他单位不用转换。

---
 src/views/inventoryManagement/receiptManagement/Record.vue |  153 ++++++++++++++++++++++++++++++++------------------
 1 files changed, 98 insertions(+), 55 deletions(-)

diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
index 7f0641e..1390a51 100644
--- a/src/views/inventoryManagement/receiptManagement/Record.vue
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -47,81 +47,98 @@
                 :expand-row-keys="expandedRowKeys"
                 :row-key="row => row.id"
                 style="width: 100%"
-                height="calc(100vh - 18.5em)">
+                height="calc(100vh - 18.5em)"
+                :fit="true">
         <el-table-column align="center"
                          type="selection"
-                         width="55"/>
+                         min-width="55"
+                         fixed="left"/>
         <el-table-column align="center"
                          label="搴忓彿"
                          type="index"
-                         width="60"/>
+                         min-width="60"
+                         fixed="left"/>
         <el-table-column label="浜у搧绫诲瀷"
-                         prop="productType"
-                         width="100"
+                         prop="parentName"
+                         min-width="100"
                          show-overflow-tooltip/>
-        <el-table-column label="鍏ュ簱鎵规"
-                         prop="inboundBatches"
-                         width="280"
-                         show-overflow-tooltip/>
-        <el-table-column label="鍏ュ簱鏃堕棿"
-                         prop="createTime"
-                         show-overflow-tooltip/>
-        <el-table-column label="浜у搧澶х被"
-                         prop="productName"
-                         show-overflow-tooltip/>
-        <el-table-column label="瑙勬牸鍨嬪彿"
-                         prop="model"
-                         show-overflow-tooltip/>
-        <el-table-column label="鍗曚綅"
-                         prop="unit"
-                         show-overflow-tooltip/>
-        <!-- <el-table-column label="鍏ュ簱鏁伴噺"
-                         prop="stockInNum"
-                         show-overflow-tooltip/> -->
         <el-table-column label="杞︾墝鍙�"
                          prop="licensePlateNo"
                          v-if="type === '0'"
+                         min-width="120"
+                         show-overflow-tooltip/>
+        <el-table-column label="浜у搧鍚嶇О"
+                         prop="productName"
+                         min-width="120"
+                         show-overflow-tooltip/>
+        <el-table-column label="瑙勬牸鍨嬪彿"
+                         prop="model"
+                         min-width="150"
+                         show-overflow-tooltip/>
+        <el-table-column label="鍏ュ簱鏁伴噺"
+                         prop="stockInNum"
+                         min-width="100"
                          show-overflow-tooltip/>
         <el-table-column label="姣涢噸"
                          prop="grossWeight"
                          v-if="type === '0'"
+                         min-width="100"
                          show-overflow-tooltip/>
         <el-table-column label="鐨噸"
                          prop="tareWeight"
                          v-if="type === '0'"
+                         min-width="100"
                          show-overflow-tooltip/>
         <el-table-column label="鍑�閲�"
                          prop="netWeight"
                          v-if="type === '0'"
+                         min-width="100"
+                         show-overflow-tooltip/>
+        <el-table-column label="鍗曚綅"
+                         prop="unit"
+                         min-width="80"
+                         show-overflow-tooltip/>
+        <el-table-column label="杩囩鏃ユ湡"
+                         prop="weighingDate"
+                         v-if="type === '0'"
+                         min-width="160"
+                         show-overflow-tooltip/>
+        <el-table-column label="杩囩鍛�"
+                         prop="weighingOperator"
+                         v-if="type === '0'"
+                         min-width="100"
                          show-overflow-tooltip/>
         <el-table-column label="鍏ュ簱浜�"
                          prop="createBy"
+                         min-width="100"
+                         show-overflow-tooltip/>
+        <el-table-column label="鍏ュ簱鏃堕棿"
+                         prop="createTime"
+                         min-width="160"
+                         show-overflow-tooltip/>
+        <el-table-column label="鍏ュ簱鎵规"
+                         prop="inboundBatches"
+                         min-width="150"
                          show-overflow-tooltip/>
         <el-table-column label="鏉ユ簮"
                          prop="recordType"
+                         min-width="100"
                          show-overflow-tooltip>
           <template #default="scope">
             {{ getRecordType(scope.row.recordType) }}
           </template>
         </el-table-column>
-        <el-table-column label="杩囩鏃ユ湡"
-                         prop="weighingDate"
-                         v-if="type === '0'"
-                         show-overflow-tooltip/>
-        <el-table-column label="杩囩鍛�"
-                         prop="weighingOperator"
-                         v-if="type === '0'"
-                         show-overflow-tooltip/>
         <el-table-column label="鎿嶄綔"
-                         width="260"
-                         align="center">
+                         min-width="200"
+                         align="center"
+                         fixed="right">
           <template #default="scope">
             <el-button v-if="scope.row.recordType === '0' && hasReceiptEdit"
               type="primary"
               size="mini"
               @click="handleEdit(scope.row)"
             >缂栬緫</el-button>
-            <el-button v-if="scope.row.recordType === '0'"
+            <el-button v-if="scope.row.recordType === '0' && scope.row.parentName === '鍘熸潗鏂�'"
                        type="primary"
                        size="mini"
                        @click="handlePreview(scope.row)">瀵煎嚭杩囩鍗�</el-button>
@@ -135,24 +152,25 @@
         @close="closeEditModal"
       >
         <el-form label-width="140px" :model="editForm" label-position="top" ref="editFormRef">
-          <!-- <el-form-item
-            label="鍏ュ簱鏁伴噺"
-            prop="stockInNum"
-          >
-            <el-input-number
-              v-model="editForm.stockInNum"
-              :min="0"
-              :step="1"
-              :precision="0"
-              controls-position="right"
-              style="width: 100%"
-              disabled
-            />
-          </el-form-item> -->
+          <!-- 鍘熸潗鏂欐樉绀哄叆搴撴暟閲� -->
+          <template v-if="editForm.parentName !== '鍘熸潗鏂�'">
+            <el-form-item
+              label="鍏ュ簱鏁伴噺"
+              prop="stockInNum"
+            >
+              <el-input-number
+                v-model="editForm.stockInNum"
+                :min="0"
+                :step="1"
+                :precision="0"
+                controls-position="right"
+                style="width: 100%"
+              />
+            </el-form-item>
+          </template>
 
-          <template v-if="type === '0'">
-            
-
+          <!-- 闈炲師鏉愭枡鏄剧ず杩囩鐩稿叧瀛楁 -->
+          <template v-if="type === '0' && editForm.parentName === '鍘熸潗鏂�'">
             <el-form-item
               label="杞︾墝鍙�"
               prop="licensePlateNo"
@@ -169,9 +187,14 @@
                 placeholder="璇烽�夋嫨鍗曚綅"
                 style="width: 100%"
                 clearable
+                :disabled="!canEditUnit"
               >
-                <el-option label="鍚�" value="鍚�" />
-                <el-option label="鍏枻" value="鍏枻" />
+                <el-option
+                  v-for="item in editableUnitOptions"
+                  :key="item.value"
+                  :label="item.label"
+                  :value="item.value"
+                />
               </el-select>
             </el-form-item>
             <el-form-item
@@ -377,6 +400,21 @@
 const isShowEditModal = ref(false);
 const editFormRef = ref(null);
 const editForm = ref({});
+const unitEditableValues = ['鍚�', '鍏枻'];
+
+const canEditUnit = computed(() => unitEditableValues.includes(editForm.value?.unit));
+
+const editableUnitOptions = computed(() => {
+  const options = [
+    { label: '鍚�', value: '鍚�' },
+    { label: '鍏枻', value: '鍏枻' },
+  ];
+  const currentUnit = editForm.value?.unit;
+  if (currentUnit && !unitEditableValues.includes(currentUnit)) {
+    return [{ label: currentUnit, value: currentUnit }];
+  }
+  return options;
+});
 
 // 姣涢噸 - 鐨噸 璁$畻鍑�閲嶏紙淇濈暀涓や綅灏忔暟锛屼笖涓嶄负璐燂級
 const computeNetWeightEdit = () => {
@@ -409,7 +447,12 @@
 const handleEditSubmit = () => {
   editFormRef.value?.validate?.((valid) => {
     if (!valid) return;
-    editStockInStock(editForm.value).then(() => {
+    const submitData = {
+      ...editForm.value,
+      productType: editForm.value.parentName === '鍘熸潗鏂�' ? 0 : 1,
+      netWeight: editForm.value.parentName === '鍘熸潗鏂�' ? editForm.value.netWeight : editForm.value.stockInNum
+    };
+    editStockInStock(submitData).then(() => {
       closeEditModal();
       proxy.$modal.msgSuccess("缂栬緫鎴愬姛");
       getList();

--
Gitblit v1.9.3