From 6da8d7c3e2fb6aa02b14b0af63a8b5fadc0716bc Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期三, 29 四月 2026 17:24:13 +0800
Subject: [PATCH] 合格率加百分号

---
 src/views/inventoryManagement/receiptManagement/Record.vue |  143 +++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 131 insertions(+), 12 deletions(-)

diff --git a/src/views/inventoryManagement/receiptManagement/Record.vue b/src/views/inventoryManagement/receiptManagement/Record.vue
index ec64f17..d8bc1ea 100644
--- a/src/views/inventoryManagement/receiptManagement/Record.vue
+++ b/src/views/inventoryManagement/receiptManagement/Record.vue
@@ -15,12 +15,23 @@
                   style="width: 240px"
                   placeholder="璇疯緭鍏�"
                   clearable/>
+        <span class="search_title ml10">鏉ユ簮锛�</span>
+        <el-select v-model="searchForm.recordType"
+                  style="width: 240px"
+                  placeholder="璇烽�夋嫨"
+                  clearable>
+          <el-option v-for="item in stockRecordTypeOptions"
+                     :key="item.value"
+                     :label="item.label"
+                     :value="item.value"/>
+        </el-select>
         <el-button type="primary"
                    @click="handleQuery"
                    style="margin-left: 10px">鎼滅储
         </el-button>
       </div>
       <div>
+        <el-button type="primary" @click="handleBatchApprove">瀹℃壒</el-button>
         <el-button @click="handleOut">瀵煎嚭</el-button>
         <el-button type="danger"
                    plain
@@ -57,6 +68,9 @@
         <el-table-column label="瑙勬牸鍨嬪彿"
                          prop="model"
                          show-overflow-tooltip/>
+        <el-table-column label="鎵瑰彿"
+                         prop="batchNo"
+                         show-overflow-tooltip/>
         <el-table-column label="鍗曚綅"
                          prop="unit"
                          show-overflow-tooltip/>
@@ -66,6 +80,20 @@
         <el-table-column label="鍏ュ簱浜�"
                          prop="createBy"
                          show-overflow-tooltip/>
+        <el-table-column label="鏉ユ簮"
+                         prop="recordType"
+                         show-overflow-tooltip>
+          <template #default="scope">
+            {{ getRecordType(scope.row.recordType) }}
+          </template>
+        </el-table-column>
+        <el-table-column label="瀹℃壒鐘舵��"
+                         prop="approvalStatus"
+                         show-overflow-tooltip>
+          <template #default="scope">
+            {{ getApprovalStatusLabel(scope.row.approvalStatus) }}
+          </template>
+        </el-table-column>
       </el-table>
       <pagination v-show="total > 0"
                   :total="total"
@@ -85,13 +113,16 @@
   toRefs,
   onMounted,
   getCurrentInstance,
-  nextTick,
 } from "vue";
 import {ElMessageBox} from "element-plus";
 import {
   getStockInRecordListPage,
-  batchDeleteStockInRecords,
+  batchDeletePendingStockInRecords,
+  batchApproveStockInRecords,
 } from "@/api/inventoryManagement/stockInRecord.js";
+import {
+  findAllQualifiedStockInRecordTypeOptions, findAllUnQualifiedStockInRecordTypeOptions,
+} from "@/api/basicData/enum.js";
 
 const {proxy} = getCurrentInstance();
 
@@ -100,17 +131,21 @@
     type: String,
     required: true,
     default: '0'
+  },
+  topParentProductId: {
+    type: [String, Number],
+    default: undefined
   }
 })
 
 const tableData = ref([]);
 const selectedRows = ref([]);
 const tableLoading = ref(false);
-const activeTab = ref("production"); // 褰撳墠婵�娲荤殑 tab
-
+// 鏉ユ簮绫诲瀷閫夐」
+const stockRecordTypeOptions = ref([]);
 const page = reactive({
   current: 1,
-  size: 100,
+  size: 10,
 });
 const total = ref(0);
 
@@ -118,6 +153,7 @@
   searchForm: {
     productName: "",
     timeStr: "",
+    recordType: "",
   },
 });
 const {searchForm} = toRefs(data);
@@ -128,6 +164,29 @@
   getList();
 };
 
+const getRecordType = (recordType) => {
+  return stockRecordTypeOptions.value.find(item => item.value === recordType)?.label || ''
+}
+
+const approvalStatusLabelMap = {
+  0: "寰呭鎵�",
+  1: "閫氳繃",
+  2: "椹冲洖",
+  pending: "寰呭鎵�",
+  approved: "閫氳繃",
+  rejected: "椹冲洖",
+  PENDING: "寰呭鎵�",
+  APPROVED: "閫氳繃",
+  REJECTED: "椹冲洖",
+};
+
+const getApprovalStatusLabel = (status) => {
+  if (status === null || status === undefined || status === "") {
+    return "寰呭鎵�";
+  }
+  return approvalStatusLabelMap[status] || "寰呭鎵�";
+};
+
 const pageProductChange = obj => {
   page.current = obj.page;
   page.size = obj.limit;
@@ -136,16 +195,33 @@
 
 const getList = () => {
   tableLoading.value = true;
-  const params = {...page, type: props.type};
+  const params = {...page, type: props.type, 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;
+        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;
+      })
+}
 
 // 琛ㄦ牸閫夋嫨鏁版嵁
 const handleSelectionChange = selection => {
@@ -153,6 +229,44 @@
 };
 
 const expandedRowKeys = ref([]);
+
+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 = () => {
@@ -163,11 +277,7 @@
   })
       .then(() => {
         // 鏍规嵁涓嶅悓鐨� tab 绫诲瀷璋冪敤涓嶅悓鐨勫鍑烘帴鍙�
-        let exportUrl = "/stockin/export";
-        if (activeTab.value === "production") {
-          exportUrl = "/stockin/exportOne";
-        }
-        proxy.download(exportUrl, {}, "鍏ュ簱鍙拌处.xlsx");
+        proxy.download("/stockInRecord/exportStockInRecord", {type: props.type}, props.type === '0' ? "鍚堟牸鍏ュ簱.xlsx" : "涓嶅悎鏍煎叆搴�.xlsx");
       })
       .catch(() => {
         proxy.$modal.msg("宸插彇娑�");
@@ -188,7 +298,7 @@
     type: "warning",
   })
       .then(() => {
-        batchDeleteStockInRecords(ids)
+        batchDeletePendingStockInRecords(ids)
             .then(() => {
               proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
               getList();
@@ -204,7 +314,16 @@
 
 onMounted(() => {
   getList();
+  fetchStockRecordTypeOptions();
 });
+
+watch(
+  () => props.topParentProductId,
+  () => {
+    page.current = 1;
+    getList();
+  }
+);
 </script>
 
 <style scoped lang="scss"></style>

--
Gitblit v1.9.3