From 07f9f8657d057a38792c3822acc9b08d83478967 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 07 五月 2026 14:23:10 +0800
Subject: [PATCH] 合并代码

---
 src/views/safeProduction/dangerInvestigation/index.vue |  178 +++--------------------------------------------------------
 1 files changed, 9 insertions(+), 169 deletions(-)

diff --git a/src/views/safeProduction/dangerInvestigation/index.vue b/src/views/safeProduction/dangerInvestigation/index.vue
index 49965e9..cb09e52 100644
--- a/src/views/safeProduction/dangerInvestigation/index.vue
+++ b/src/views/safeProduction/dangerInvestigation/index.vue
@@ -415,17 +415,12 @@
         </el-row>
       </el-form>
     </FormDialog>
-    <!-- 闄勪欢鍒楄〃寮圭獥 -->
-    <FileListDialog ref="fileListRef"
-                    v-model="fileListDialogVisible"
-                    :show-upload-button="true"
-                    :show-delete-button="true"
-                    :is-show-pagination="true"
-                    :page="filePagination"
-                    :upload-method="handleUpload"
-                    :delete-method="handleFileDelete"
-                    @pagination="paginationSearch"
-                    title="闄勪欢鍒楄〃" />
+    <FileListDialog
+        v-if="fileListDialogVisible"
+        :record-id="currentRecordId"
+        record-type="safe_hidden"
+        v-model:visible="fileListDialogVisible"/>
+
   </div>
 </template>
 
@@ -436,7 +431,6 @@
   import { ElMessageBox, ElMessage } from "element-plus";
   import useUserStore from "@/store/modules/user";
   import { userListNoPage } from "@/api/system/user.js";
-  import FileListDialog from "@/components/Dialog/FileListDialog.vue";
   import FormDialog from "@/components/Dialog/FormDialog.vue";
   import { getQuotationList } from "@/api/salesManagement/salesQuotation.js";
   import {
@@ -445,13 +439,9 @@
     safeHiddenUpdate,
     safeHiddenDel,
     fileListPage,
-    safeHiddenFileAdd,
-    safeHiddenFileDel,
   } from "@/api/safeProduction/dangerInvestigation.js";
   import useFormData from "@/hooks/useFormData.js";
-  import request from "@/utils/request";
   import dayjs from "dayjs";
-  import { get } from "@vueuse/core";
 
   const userStore = useUserStore();
   const { proxy } = getCurrentInstance();
@@ -459,6 +449,7 @@
   const selectedRows = ref([]);
   const userList = ref([]);
   const tableLoading = ref(false);
+  const currentRecordId = ref(0);
   const page = reactive({
     current: 1,
     size: 100,
@@ -943,18 +934,8 @@
   const fileListDialogVisible = ref(false);
   const currentFileRow = ref(null);
   const downLoadFile = row => {
-    currentFileRow.value = row;
-    fileListPage({
-      safeHiddenId: row.id,
-      current: filePagination.value.current,
-      size: filePagination.value.size,
-    }).then(res => {
-      if (fileListRef.value) {
-        fileListRef.value.open(res.data.records || []);
-        console.log("res.data", res.data);
-        filePagination.value.total = res.data.total || 0;
-      }
-    });
+    currentRecordId.value = row.id;
+    fileListDialogVisible.value = true;
   };
   const currentUserId = ref("");
   const currentUserName = ref("");
@@ -990,147 +971,6 @@
       userList.value = res.data;
     });
   });
-  // 涓婁紶闄勪欢
-  const handleUpload = async () => {
-    if (!currentFileRow.value) {
-      proxy.$modal.msgWarning("璇峰厛閫夋嫨鏁版嵁");
-      return null;
-    }
-
-    return new Promise(resolve => {
-      // 鍒涘缓涓�涓殣钘忕殑鏂囦欢杈撳叆鍏冪礌
-      const input = document.createElement("input");
-      input.type = "file";
-      input.style.display = "none";
-      input.onchange = async e => {
-        const file = e.target.files[0];
-        if (!file) {
-          resolve(null);
-          return;
-        }
-
-        try {
-          // 浣跨敤 FormData 涓婁紶鏂囦欢
-          const formData = new FormData();
-          formData.append("file", file);
-
-          const uploadRes = await request({
-            url: "/file/upload",
-            method: "post",
-            data: formData,
-            headers: {
-              "Content-Type": "multipart/form-data",
-              Authorization: `Bearer ${getToken()}`,
-            },
-          });
-
-          if (uploadRes.code === 200) {
-            // 淇濆瓨闄勪欢淇℃伅
-            const fileData = {
-              safeHiddenId: currentFileRow.value.id,
-              name: uploadRes.data.originalName || file.name,
-              url: uploadRes.data.tempPath || uploadRes.data.url,
-            };
-
-            const saveRes = await safeHiddenFileAdd(fileData);
-            if (saveRes.code === 200) {
-              proxy.$modal.msgSuccess("鏂囦欢涓婁紶鎴愬姛");
-              // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
-              const listRes = await fileListPage({
-                safeHiddenId: currentFileRow.value.id,
-                current: filePagination.value.current,
-                size: filePagination.value.size,
-              });
-              if (listRes.code === 200 && fileListRef.value) {
-                const fileList = (listRes.data?.records || []).map(item => ({
-                  name: item.name,
-                  url: item.url,
-                  id: item.id,
-                  ...item,
-                }));
-                fileListRef.value.setList(fileList);
-                filePagination.value.total = listRes.data?.total || 0;
-              }
-              // 杩斿洖鏂版枃浠朵俊鎭�
-              resolve({
-                name: fileData.name,
-                url: fileData.url,
-                id: saveRes.data?.id,
-              });
-            } else {
-              proxy.$modal.msgError(saveRes.msg || "鏂囦欢淇濆瓨澶辫触");
-              resolve(null);
-            }
-          } else {
-            proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触");
-            resolve(null);
-          }
-        } catch (error) {
-          proxy.$modal.msgError("鏂囦欢涓婁紶澶辫触");
-          resolve(null);
-        } finally {
-          document.body.removeChild(input);
-        }
-      };
-
-      document.body.appendChild(input);
-      input.click();
-    });
-  };
-  // 鍒嗛〉鏌ヨ鏂囦欢鍒楄〃
-  const paginationSearch = async (page, size) => {
-    filePagination.value.current = page;
-    filePagination.value.size = size;
-    const listRes = await fileListPage({
-      safeHiddenId: currentFileRow.value.id,
-      current: filePagination.value.current,
-      size: filePagination.value.size,
-    });
-    if (listRes.code === 200) {
-      const fileList = (listRes.data?.records || []).map(item => ({
-        name: item.name,
-        url: item.url,
-        id: item.id,
-        ...item,
-      }));
-      fileListRef.value.setList(fileList);
-      filePagination.value.total = listRes.data?.total || 0;
-    }
-  };
-  // 鍒犻櫎闄勪欢
-  const handleFileDelete = async row => {
-    try {
-      const res = await safeHiddenFileDel([row.id]);
-      if (res.code === 200) {
-        proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
-        // 閲嶆柊鍔犺浇鏂囦欢鍒楄〃
-        if (currentFileRow.value && fileListRef.value) {
-          const listRes = await fileListPage({
-            safeHiddenId: currentFileRow.value.id,
-            current: filePagination.value.current,
-            size: filePagination.value.size,
-          });
-          if (listRes.code === 200) {
-            const fileList = (listRes.data?.records || []).map(item => ({
-              name: item.name,
-              url: item.url,
-              id: item.id,
-              ...item,
-            }));
-            fileListRef.value.setList(fileList);
-            filePagination.value.total = listRes.data?.total || 0;
-          }
-        }
-        return true; // 杩斿洖 true 琛ㄧず鍒犻櫎鎴愬姛锛岀粍浠朵細鏇存柊鍒楄〃
-      } else {
-        proxy.$modal.msgError(res.msg || "鍒犻櫎澶辫触");
-        return false;
-      }
-    } catch (error) {
-      proxy.$modal.msgError("鍒犻櫎澶辫触");
-      return false;
-    }
-  };
 </script>
 
 <style scoped lang="scss">

--
Gitblit v1.9.3