From e260fd0a8474fe4fe4550baaec2a643121ed778a Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期一, 02 二月 2026 11:41:35 +0800
Subject: [PATCH] 事故上报分页

---
 src/views/safeProduction/hazardousMaterialsControl/index.vue |   81 ++++++++++++++++++++++++++++++++--------
 1 files changed, 65 insertions(+), 16 deletions(-)

diff --git a/src/views/safeProduction/hazardousMaterialsControl/index.vue b/src/views/safeProduction/hazardousMaterialsControl/index.vue
index cf1d731..b2048fe 100644
--- a/src/views/safeProduction/hazardousMaterialsControl/index.vue
+++ b/src/views/safeProduction/hazardousMaterialsControl/index.vue
@@ -244,9 +244,9 @@
       </el-form>
       <template #footer>
         <span class="dialog-footer">
-          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
           <el-button type="primary"
                      @click="submitForm">纭畾</el-button>
+          <el-button @click="dialogVisible = false">鍙栨秷</el-button>
         </span>
       </template>
     </el-dialog>
@@ -258,9 +258,14 @@
       <div>
         <el-table :data="safeHazardList"
                   border
+                  ref="safeHazardTableRef"
                   v-loading="safeHazardLoading"
-                  style="width: 100%"
-                  @row-click="handleSafeHazardSelect">
+                  :selection="selectedSafeHazardIds"
+                  @selection-change="handleSafeHazardSelectionChange"
+                  style="width: 100%">
+          <el-table-column type="selection"
+                           width="55"
+                           :selectable="isSelectable" />
           <el-table-column prop="code"
                            label="鍗遍櫓婧愮紪鐮�"
                            width="180"
@@ -302,6 +307,8 @@
       </div>
       <template #footer>
         <span class="dialog-footer">
+          <el-button type="primary"
+                     @click="handleSafeHazardSelect">纭畾</el-button>
           <el-button @click="safeHazardSelectVisible = false">鍙栨秷</el-button>
         </span>
       </template>
@@ -416,6 +423,12 @@
   // 琛ㄦ牸鍒楅厤缃�
   const tableColumn = ref([
     {
+      label: "棰嗙敤鍗曞彿",
+      prop: "materialRecordCode",
+      width: 130,
+      showOverflowTooltip: true,
+    },
+    {
       label: "鍗遍櫓婧愮紪鐮�",
       prop: "code",
       showOverflowTooltip: true,
@@ -484,16 +497,11 @@
       showOverflowTooltip: true,
     },
     {
-      label: "鍗曞彿",
-      prop: "materialRecordCode",
-      showOverflowTooltip: true,
-    },
-    {
       dataType: "action",
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: 200,
+      width: 130,
       operation: [
         {
           name: "褰掕繕",
@@ -540,11 +548,17 @@
     }
   };
   const handleApplyQtyChange = () => {
+    if (Number(form.value.applyQty) < 0) {
+      ElMessage.error("棰嗙敤鏁伴噺涓嶈兘灏忎簬0");
+      form.value.applyQty = 0;
+      return;
+    }
     if (form.value.applyQty > valueItem.value.stockQty) {
       ElMessage.error("棰嗙敤鏁伴噺涓嶈兘澶т簬搴撳瓨鏁伴噺");
       form.value.applyQty = "";
     }
   };
+  const selectedSafeHazardIds = ref([]);
 
   // 寮�濮嬭嚜鍔ㄥ埛鏂�
   const startAutoRefresh = () => {
@@ -579,7 +593,7 @@
   const fetchSafeHazardList = () => {
     safeHazardLoading.value = true;
     return safeHazardListPage({
-      page: safeHazardPage.value.current,
+      current: safeHazardPage.value.current,
       size: safeHazardPage.value.size,
     })
       .then(res => {
@@ -591,12 +605,36 @@
       });
   };
 
-  const handleSafeHazardSelect = item => {
+  const isSelectable = row => {
+    // 鍙湁搴撳瓨鏁伴噺澶т簬0鐨勮鎵嶈兘琚�夋嫨
+    return Number(row.stockQty) > 0;
+  };
+
+  const handleSafeHazardSelectionChange = selection => {
+    // 鍙繚鐣欐渶鍚庝竴涓�変腑鐨勯」
+    if (selection.length > 1) {
+      const lastSelected = selection[selection.length - 1];
+      selectedSafeHazardIds.value = [lastSelected];
+      proxy.$refs.safeHazardTableRef.clearSelection();
+      proxy.$refs.safeHazardTableRef.toggleRowSelection(lastSelected, true);
+    } else if (selection.length === 1) {
+      selectedSafeHazardIds.value = [selection[0]];
+    } else {
+      selectedSafeHazardIds.value = [];
+    }
+  };
+
+  const handleSafeHazardSelect = () => {
+    if (!selectedSafeHazardIds.value.length) {
+      ElMessage.error("璇烽�夋嫨涓�涓嵄闄╂簮");
+      return;
+    }
+
     valueItem.value = {
-      ...item,
+      ...selectedSafeHazardIds.value[0],
     };
     valueItem.value.type = getTypeLabel(valueItem.value.type);
-    form.value.safeHazardId = item.id;
+    form.value.safeHazardId = selectedSafeHazardIds.value[0].id;
     safeHazardSelectVisible.value = false;
   };
 
@@ -610,12 +648,20 @@
   const pagination1 = obj => {
     page.value.current = obj.page;
     page.value.size = obj.limit;
-    handleQuery();
+    getList();
   };
 
   // 閫夋嫨鍙樺寲澶勭悊
   const handleSelectionChange = selection => {
-    selectedIds.value = selection.map(item => item.id);
+    // 涓昏〃鏍间篃鍙繚鐣欐渶鍚庝竴涓�変腑鐨勯」
+    if (selection.length > 1) {
+      const lastSelected = selection[selection.length - 1];
+      selectedIds.value = [lastSelected.id];
+    } else if (selection.length === 1) {
+      selectedIds.value = [selection[0].id];
+    } else {
+      selectedIds.value = [];
+    }
   };
 
   // 鎵撳紑琛ㄥ崟
@@ -740,7 +786,7 @@
           .catch(err => {
             ElMessage.error(err.msg);
           });
-      } else {
+      } else if (dialogType.value === "edit") {
         await formRef1.value.validate();
         safeHazardRecordUpdate({ ...form.value })
           .then(res => {
@@ -753,6 +799,9 @@
           .catch(err => {
             ElMessage.error(err.msg);
           });
+      } else if (dialogType.value === "view") {
+        // 鏌ョ湅妯″紡涓嬩笉鎻愪氦琛ㄥ崟
+        dialogVisible.value = false;
       }
     } catch (error) {
       console.error("琛ㄥ崟楠岃瘉澶辫触:", error);

--
Gitblit v1.9.3