From da57fbd8e7fa021614fb32502fb1520ea4e34e1e Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期一, 18 五月 2026 11:35:16 +0800
Subject: [PATCH] 浪潮 1.样式修改

---
 src/views/inventoryManagement/receiptManagement/Record.vue |  515 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 472 insertions(+), 43 deletions(-)

diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
index cd103ea..b7d2253 100644
--- a/src/views/inventoryManagement/receiptManagement/Record.vue
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -1,6 +1,6 @@
 <template>
-  <div class="app-container">
-    <div class="search_form">
+  <div>
+    <div class="search_form" style="margin-bottom: 10px;">
       <div>
         <span class="search_title ml10">鍏ュ簱鏃ユ湡锛�</span>
         <el-date-picker v-model="searchForm.timeStr"
@@ -31,6 +31,8 @@
         </el-button>
       </div>
       <div>
+        <el-button type="primary" @click="handleAdd">鏂板</el-button>
+        <el-button type="primary" @click="handleBatchApprove">瀹℃壒</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger"
                    plain
@@ -49,6 +51,7 @@
                 height="calc(100vh - 18.5em)">
         <el-table-column align="center"
                          type="selection"
+                         :selectable="isRowSelectableForApprove"
                          width="55"/>
         <el-table-column align="center"
                          label="搴忓彿"
@@ -67,6 +70,12 @@
         <el-table-column label="瑙勬牸鍨嬪彿"
                          prop="model"
                          show-overflow-tooltip/>
+        <el-table-column label="搴撲綅"
+                         prop="warehouseName"
+                         show-overflow-tooltip/>
+        <el-table-column label="鎵瑰彿"
+                         prop="batchNo"
+                         show-overflow-tooltip/>
         <el-table-column label="鍗曚綅"
                          prop="unit"
                          show-overflow-tooltip/>
@@ -83,6 +92,26 @@
             {{ getRecordType(scope.row.recordType) }}
           </template>
         </el-table-column>
+        <el-table-column label="瀹℃壒鐘舵��"
+                         prop="approvalStatus"
+                         show-overflow-tooltip>
+          <template #default="scope">
+            <el-tag :type="getApprovalStatusTagType(scope.row.approvalStatus)" size="small">
+              {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
+            </el-tag>
+          </template>
+        </el-table-column>
+        <el-table-column label="鎿嶄綔" width="120" align="center" fixed="right">
+          <template #default="scope">
+            <el-button
+              v-if="scope.row.approvalStatus !== 1 && scope.row.approvalStatus !== '1' && scope.row.approvalStatus !== 'approved' && scope.row.approvalStatus !== 'APPROVED'"
+              link
+              type="primary"
+              size="small"
+              @click="handleEdit(scope.row)">缂栬緫</el-button>
+            <span v-else style="color: #999; font-size: 12px;">宸查�氳繃</span>
+          </template>
+        </el-table-column>
       </el-table>
       <pagination v-show="total > 0"
                   :total="total"
@@ -91,34 +120,167 @@
                   :limit="page.size"
                   @pagination="pageProductChange"/>
     </div>
+
+    <!-- 鏂板/缂栬緫瀵硅瘽妗� -->
+    <el-dialog v-model="dialogVisible"
+               :title="dialogTitle"
+               width="800"
+               @close="closeDialog">
+      <el-form ref="formRef"
+               :model="formState"
+               label-width="140px"
+               label-position="top">
+        <el-form-item label="浜у搧鍚嶇О"
+                      prop="productModelId"
+                      :rules="[
+                        {
+                          required: true,
+                          message: '璇烽�夋嫨浜у搧',
+                          trigger: 'change',
+                        }
+                      ]">
+          <el-button type="primary"
+                     @click="showProductSelect = true">
+            {{ formState.productName ? formState.productName : '閫夋嫨浜у搧' }}
+          </el-button>
+        </el-form-item>
+        <el-form-item label="瑙勬牸"
+                      prop="productModelName">
+          <el-input v-model="formState.productModelName" disabled />
+        </el-form-item>
+        <el-form-item label="鍗曚綅"
+                      prop="unit">
+          <el-input v-model="formState.unit" disabled />
+        </el-form-item>
+        <el-form-item label="搴撲綅"
+                      prop="warehouseInfoId"
+                      :rules="[
+                        {
+                          required: true,
+                          message: '璇烽�夋嫨搴撲綅',
+                          trigger: 'change',
+                        }
+                      ]">
+          <el-select v-model="formState.warehouseInfoId"
+                     placeholder="璇烽�夋嫨搴撲綅"
+                     clearable
+                     style="width: 100%">
+            <el-option v-for="warehouse in warehouseList"
+                       :key="warehouse.id"
+                       :label="warehouse.warehouseName + ' - ' + warehouse.location"
+                       :value="warehouse.id" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鎵瑰彿"
+                      prop="batchNo">
+          <el-input v-model="formState.batchNo"
+                    placeholder="璇疯緭鍏ユ壒鍙�"
+                    :disabled="isEdit" />
+        </el-form-item>
+        <el-form-item label="搴撳瓨鏁伴噺"
+                      prop="qualitity">
+          <el-input-number v-model="formState.qualitity"
+                           :step="1"
+                           :min="1"
+                           style="width: 100%" />
+        </el-form-item>
+        <el-form-item v-if="isEdit"
+                      label="鏉ユ簮"
+                      prop="recordType">
+          <el-select v-model="formState.recordType"
+                     placeholder="璇烽�夋嫨鏉ユ簮"
+                     disabled>
+            <el-option v-for="item in stockRecordTypeOptions"
+                       :key="item.value"
+                       :label="item.label"
+                       :value="item.value" />
+          </el-select>
+        </el-form-item>
+        <el-form-item v-if="formState.type === 'qualified'"
+                      label="搴撳瓨棰勮鏁伴噺"
+                      prop="warnNum">
+          <el-input-number v-model="formState.warnNum"
+                           :step="1"
+                           :min="0"
+                           :max="formState.qualitity"
+                           style="width: 100%" />
+        </el-form-item>
+        <el-form-item label="搴撳瓨绫诲瀷"
+                      prop="type"
+                      :rules="[
+                        {
+                          required: true,
+                          message: '璇烽�夋嫨搴撳瓨绫诲瀷',
+                          trigger: 'change',
+                        }
+                      ]">
+          <el-select v-model="formState.type"
+                     placeholder="璇烽�夋嫨搴撳瓨绫诲瀷"
+                     :disabled="isEdit">
+            <el-option label="鍚堟牸搴撳瓨"
+                       value="qualified" />
+            <el-option label="涓嶅悎鏍煎簱瀛�"
+                       value="unqualified" />
+          </el-select>
+        </el-form-item>
+        <el-form-item label="澶囨敞"
+                      prop="remark">
+          <el-input v-model="formState.remark"
+                    type="textarea" />
+        </el-form-item>
+      </el-form>
+      <!-- 浜у搧閫夋嫨寮圭獥 -->
+      <ProductSelectDialog v-model="showProductSelect"
+                           @confirm="handleProductSelect"
+                           :top-product-parent-id="topParentProductId"
+                           single />
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button type="primary" @click="handleSubmit">纭</el-button>
+          <el-button @click="closeDialog">鍙栨秷</el-button>
+        </div>
+      </template>
+    </el-dialog>
   </div>
 </template>
 
 <script setup>
 import pagination from "@/components/PIMTable/Pagination.vue";
+import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue";
 import {
   ref,
   reactive,
   toRefs,
   onMounted,
   getCurrentInstance,
+  computed,
+  watch,
 } from "vue";
-import {ElMessageBox} from "element-plus";
+import { ElMessageBox, ElMessage } from "element-plus";
 import {
   getStockInRecordListPage,
-  batchDeleteStockInRecords,
+  batchDeletePendingStockInRecords,
+  batchApproveStockInRecords,
+  updateStockInRecord,
 } from "@/api/inventoryManagement/stockInRecord.js";
+import { addStockInRecordOnly } from "@/api/inventoryManagement/stockInventory.js";
+import { createStockUnInventory } from "@/api/inventoryManagement/stockUninventory.js";
 import {
   findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions,
 } from "@/api/basicData/enum.js";
+import { getWarehouseList } from "@/api/inventoryManagement/warehouse.js";
 
-const {proxy} = getCurrentInstance();
+const { proxy } = getCurrentInstance();
 
 const props = defineProps({
   type: {
     type: String,
     required: true,
     default: '0'
+  },
+  topParentProductId: {
+    type: [String, Number],
+    default: undefined
   }
 })
 
@@ -127,9 +289,11 @@
 const tableLoading = ref(false);
 // 鏉ユ簮绫诲瀷閫夐」
 const stockRecordTypeOptions = ref([]);
+// 浠撳簱鍒楄〃
+const warehouseList = ref([]);
 const page = reactive({
   current: 1,
-  size: 100,
+  size: 10,
 });
 const total = ref(0);
 
@@ -140,7 +304,43 @@
     recordType: "",
   },
 });
-const {searchForm} = toRefs(data);
+const { searchForm } = toRefs(data);
+
+// 瀵硅瘽妗嗙浉鍏�
+const dialogVisible = ref(false);
+const dialogType = ref('add'); // 'add' 鎴� 'edit'
+const dialogTitle = computed(() => dialogType.value === 'add' ? '鏂板鍏ュ簱璁板綍' : '缂栬緫鍏ュ簱璁板綍');
+const isEdit = computed(() => dialogType.value === 'edit');
+const formRef = ref();
+const showProductSelect = ref(false);
+
+// 琛ㄥ崟鏁版嵁锛堜豢鐓ew.vue浣跨敤formState锛�
+const formState = ref({
+  id: undefined,
+  productId: undefined,
+  productModelId: undefined,
+  productName: "",
+  productModelName: "",
+  unit: "",
+  type: undefined,
+  qualitity: 0,
+  batchNo: null,
+  warehouseInfoId: undefined,
+  warnNum: 0,
+  recordType: "",
+  remark: "",
+});
+
+// 鎵瑰彿涓虹┖鏃惰浆涓� null
+watch(
+  () => formState.value.batchNo,
+  val => {
+    if (val === "") {
+      formState.value.batchNo = null;
+    }
+  }
+);
+
 // 鏌ヨ鍒楄〃
 /** 鎼滅储鎸夐挳鎿嶄綔 */
 const handleQuery = () => {
@@ -152,6 +352,41 @@
   return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
 }
 
+const approvalStatusLabelMap = {
+  0: "寰呭鎵�",
+  1: "閫氳繃",
+  2: "椹冲洖",
+  pending: "寰呭鎵�",
+  approved: "閫氳繃",
+  rejected: "椹冲洖",
+  PENDING: "寰呭鎵�",
+  APPROVED: "閫氳繃",
+  REJECTED: "椹冲洖",
+};
+approvalStatusLabelMap[3] = "寰呯‘璁�";
+
+const getApprovalStatusLabel = (status) => {
+  if (status === null || status === undefined || status === "") {
+    return "寰呭鎵�";
+  }
+  return approvalStatusLabelMap[status] || "寰呭鎵�";
+};
+
+// 閫氳繃/椹冲洖鍥哄畾鑹诧紱鍏朵綑锛堝惈寰呭鎵广�佺┖鍊笺�佹湭鏄犲皠浣嗘枃妗堜负寰呭鎵癸級缁熶竴鐢� warning 棰勮鑹�
+const getApprovalStatusTagType = (status) => {
+  if (status === 1 || status === "1" || status === "approved" || status === "APPROVED") return "success";
+  if (status === 2 || status === "2" || status === "rejected" || status === "REJECTED") return "danger";
+  return "warning";
+};
+
+const isPendingApproval = status => {
+  return status === 0 || status === "0" || status === "pending" || status === "PENDING" || status === null || status === undefined || status === "";
+};
+
+const isRowSelectableForApprove = row => {
+  return isPendingApproval(row?.approvalStatus);
+};
+
 const pageProductChange = obj => {
   page.current = obj.page;
   page.size = obj.limit;
@@ -160,39 +395,227 @@
 
 const getList = () => {
   tableLoading.value = true;
-  const params = {...page, type: props.type};
+  const params = { ...page, topParentProductId: props.topParentProductId };
   params.timeStr = searchForm.value.timeStr;
   params.productName = searchForm.value.productName;
   params.recordType = searchForm.value.recordType;
   getStockInRecordListPage(params)
-      .then(res => {
-        tableData.value = res.data.records;
-      }).finally(() => {
-    tableLoading.value = false;
-  })
+    .then(res => {
+      tableData.value = res.data.records;
+      total.value = res.data.total || 0;
+    }).finally(() => {
+      tableLoading.value = false;
+    })
 };
 
 // 鑾峰彇鏉ユ簮绫诲瀷閫夐」
 const fetchStockRecordTypeOptions = () => {
   if (props.type === '0') {
     findAllQualifiedStockInRecordTypeOptions()
-        .then(res => {
-          stockRecordTypeOptions.value = res.data;
-        })
-    return
-  }
-  findAllUnQualifiedStockInRecordTypeOptions()
       .then(res => {
         stockRecordTypeOptions.value = res.data;
       })
+    return
+  }
+  findAllUnQualifiedStockInRecordTypeOptions()
+    .then(res => {
+      stockRecordTypeOptions.value = res.data;
+    })
 }
 
 // 琛ㄦ牸閫夋嫨鏁版嵁
 const handleSelectionChange = selection => {
-  selectedRows.value = selection.filter(item => item.id);
+  selectedRows.value = selection.filter(item => item.id && isPendingApproval(item.approvalStatus));
 };
 
 const expandedRowKeys = ref([]);
+
+// 鏂板
+const handleAdd = () => {
+  dialogType.value = 'add';
+  resetForm();
+  // 鏍规嵁褰撳墠tab璁剧疆榛樿搴撳瓨绫诲瀷
+  formState.value.type = props.type === '0' ? 'qualified' : 'unqualified';
+  dialogVisible.value = true;
+};
+
+// 缂栬緫
+const handleEdit = (row) => {
+  dialogType.value = 'edit';
+  resetForm();
+  // 濉厖琛ㄥ崟鏁版嵁
+  formState.value = {
+    id: row.id,
+    productId: row.productId,
+    productModelId: row.productModelId,
+    productName: row.productName,
+    productModelName: row.model,
+    unit: row.unit,
+    type: props.type === '0' ? 'qualified' : 'unqualified',
+    qualitity: row.stockInNum,
+    batchNo: row.batchNo,
+    warehouseInfoId: row.warehouseInfoId,
+    warnNum: row.warnNum || 0,
+    recordType: row.recordType,
+    remark: row.remark || "",
+  };
+  dialogVisible.value = true;
+};
+
+// 閲嶇疆琛ㄥ崟
+const resetForm = () => {
+  formState.value = {
+    id: undefined,
+    productId: undefined,
+    productModelId: undefined,
+    productName: "",
+    productModelName: "",
+    unit: "",
+    type: undefined,
+    qualitity: 0,
+    batchNo: null,
+    warehouseInfoId: undefined,
+    warnNum: 0,
+    recordType: "",
+    remark: "",
+  };
+};
+
+// 鍏抽棴瀵硅瘽妗�
+const closeDialog = () => {
+  dialogVisible.value = false;
+  resetForm();
+};
+
+// 浜у搧閫夋嫨澶勭悊锛堜豢鐓ew.vue锛�
+const handleProductSelect = async products => {
+  if (products && products.length > 0) {
+    const product = products[0];
+    formState.value.productId = product.productId;
+    formState.value.productName = product.productName;
+    formState.value.productModelName = product.model;
+    formState.value.productModelId = product.id;
+    formState.value.unit = product.unit;
+    showProductSelect.value = false;
+    // 瑙﹀彂琛ㄥ崟楠岃瘉鏇存柊
+    proxy.$refs["formRef"]?.validateField("productModelId");
+  }
+};
+
+// 鎻愪氦琛ㄥ崟锛堜豢鐓ew.vue锛�
+const handleSubmit = () => {
+  proxy.$refs["formRef"].validate(valid => {
+    if (valid) {
+      // 楠岃瘉鏄惁閫夋嫨浜嗕骇鍝佸拰瑙勬牸
+      if (!formState.value.productModelId) {
+        ElMessage.error("璇烽�夋嫨浜у搧");
+        return;
+      }
+
+      if (dialogType.value === 'add') {
+        submitAdd();
+      } else {
+        submitEdit();
+      }
+    }
+  });
+};
+
+// 鎻愪氦鏂板
+const submitAdd = () => {
+  const params = { ...formState.value };
+
+  if (formState.value.type === "qualified") {
+    addStockInRecordOnly(params).then(res => {
+      ElMessage.success("鏂板鎴愬姛");
+      closeDialog();
+      getList();
+    }).catch(() => {
+      ElMessage.error("鏂板澶辫触");
+    });
+  } else {
+    params.warnNum = 0;
+    createStockUnInventory(params).then(res => {
+      ElMessage.success("鏂板鎴愬姛");
+      closeDialog();
+      getList();
+    }).catch(() => {
+      ElMessage.error("鏂板澶辫触");
+    });
+  }
+};
+
+// 鑾峰彇浠撳簱鍒楄〃
+const fetchWarehouseList = () => {
+  getWarehouseList({ status: true }).then(res => {
+    warehouseList.value = res.data || [];
+  }).catch(() => {
+    ElMessage.error("鑾峰彇浠撳簱鍒楄〃澶辫触");
+  });
+};
+
+// 鎻愪氦缂栬緫
+const submitEdit = () => {
+  const params = {
+    productId: formState.value.productId,
+    productModelId: formState.value.productModelId,
+    productName: formState.value.productName,
+    model: formState.value.productModelName,
+    unit: formState.value.unit,
+    batchNo: formState.value.batchNo,
+    warehouseInfoId: formState.value.warehouseInfoId,
+    stockInNum: formState.value.qualitity,
+    recordType: formState.value.recordType,
+    remark: formState.value.remark,
+    warnNum: formState.value.warnNum,
+  };
+
+  updateStockInRecord(formState.value.id, params).then(() => {
+    ElMessage.success("缂栬緫鎴愬姛");
+    closeDialog();
+    getList();
+  }).catch(() => {
+    ElMessage.error("缂栬緫澶辫触");
+  });
+};
+
+const handleBatchApprove = () => {
+  if (selectedRows.value.length === 0) {
+    proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+    return;
+  }
+  const ids = selectedRows.value.map(item => item.id);
+  ElMessageBox.confirm("璇烽�夋嫨瀹℃壒缁撴灉", "瀹℃壒", {
+    confirmButtonText: "閫氳繃",
+    cancelButtonText: "椹冲洖",
+    type: "warning",
+    distinguishCancelAndClose: true,
+  })
+    .then(() => {
+      batchApproveStockInRecords({ ids, approvalStatus: 1 })
+        .then(() => {
+          proxy.$modal.msgSuccess("瀹℃壒閫氳繃鎴愬姛");
+          getList();
+        })
+        .catch(() => {
+          proxy.$modal.msgError("瀹℃壒閫氳繃澶辫触");
+        });
+    })
+    .catch((action) => {
+      if (action === "cancel") {
+        batchApproveStockInRecords({ ids, approvalStatus: 2 })
+          .then(() => {
+            proxy.$modal.msgSuccess("瀹℃壒椹冲洖鎴愬姛");
+            getList();
+          })
+          .catch(() => {
+            proxy.$modal.msgError("瀹℃壒椹冲洖澶辫触");
+          });
+        return;
+      }
+      proxy.$modal.msg("宸插彇娑�");
+    });
+};
 
 // 瀵煎嚭
 const handleOut = () => {
@@ -201,13 +624,13 @@
     cancelButtonText: "鍙栨秷",
     type: "warning",
   })
-      .then(() => {
-        // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
-        proxy.download("/stockInRecord/exportStockInRecord", {type: props.type}, props.type === '0' ? "鍚堟牸鍏ュ簱.xlsx" : "涓嶅悎鏍煎叆搴�.xlsx");
-      })
-      .catch(() => {
-        proxy.$modal.msg("宸插彇娑�");
-      });
+    .then(() => {
+      // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
+      proxy.download("/stockInRecord/exportStockInRecord", { type: props.type }, props.type === '0' ? "鍚堟牸鍏ュ簱.xlsx" : "涓嶅悎鏍煎叆搴�.xlsx");
+    })
+    .catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
 };
 
 // 鍒犻櫎
@@ -223,28 +646,34 @@
     cancelButtonText: "鍙栨秷",
     type: "warning",
   })
-      .then(() => {
-        batchDeleteStockInRecords(ids)
-            .then(() => {
-              proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-              getList();
-            })
-            .catch(() => {
-              proxy.$modal.msgError("鍒犻櫎澶辫触");
-            });
-      })
-      .catch(() => {
-        proxy.$modal.msg("宸插彇娑�");
-      });
+    .then(() => {
+      batchDeletePendingStockInRecords(ids)
+        .then(() => {
+          proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+          getList();
+        })
+        .catch(() => {
+          proxy.$modal.msgError("鍒犻櫎澶辫触");
+        });
+    })
+    .catch(() => {
+      proxy.$modal.msg("宸插彇娑�");
+    });
 };
 
 onMounted(() => {
   getList();
   fetchStockRecordTypeOptions();
+  fetchWarehouseList();
 });
+
+watch(
+  () => props.topParentProductId,
+  () => {
+    page.current = 1;
+    getList();
+  }
+);
 </script>
 
 <style scoped lang="scss"></style>
-
-
-

--
Gitblit v1.9.3