From 28edbc60ecab951a85c30efa5acea6c27646ca4b Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 30 一月 2026 10:11:28 +0800
Subject: [PATCH] 对接生成核算接口

---
 src/views/procurementManagement/procurementInvoiceLedger/index.vue |  310 ++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 241 insertions(+), 69 deletions(-)

diff --git a/src/views/procurementManagement/procurementInvoiceLedger/index.vue b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
index 4149e50..00ae65a 100644
--- a/src/views/procurementManagement/procurementInvoiceLedger/index.vue
+++ b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
@@ -47,56 +47,85 @@
         :tableLoading="loading"
         :tableData="dataList"
         :isSelection="true"
-        height="calc(100vh - 15em)"
+        height="calc(100vh - 19.5em)"
         :isShowSummary="true"
         :summaryMethod="summarizeMainTable"
         :page="{
           current: pagination.currentPage,
           size: pagination.pageSize,
-          total: 0,
+          total: pagination.total,
         }"
         @selection-change="handleSelectionChange"
         @pagination="changePage"
       >
-        <template #commonFilesRef="{ row }">
-          <el-dropdown
-            v-if="row.commonFiles.length !== 0"
-            @command="(command) => handleCommand(command, row)"
+        <template #operation="{ row }">
+          <el-button
+            type="primary"
+            link
+            @click="openEdit(row)"
           >
-            <el-button link :icon="Files" type="danger"> 闄勪欢 </el-button>
-            <template #dropdown>
-              <el-dropdown-menu>
-                <el-dropdown-item :icon="Download" command="download">
-                  涓嬭浇
-                </el-dropdown-item>
-                <el-dropdown-item :icon="Upload" command="upload">
-                  涓婁紶
-                </el-dropdown-item>
-              </el-dropdown-menu>
-            </template>
-          </el-dropdown>
-          <el-text v-else type="danger">鏆傛棤闄勪欢</el-text>
+            缂栬緫
+          </el-button>
+          <el-button
+            type="primary"
+            link
+            @click="downLoadFile(row)"
+          >
+            闄勪欢
+          </el-button>
+          <el-button
+            type="primary"
+            link
+            @click="handleDelete(row)"
+          >
+            鍒犻櫎
+          </el-button>
         </template>
       </PIMTable>
     </div>
-    <Modal ref="modalRef"></Modal>
+    <FileListDialog 
+      ref="fileListRef" 
+      v-model="fileListDialogVisible"
+      title="闄勪欢鍒楄〃"
+      :showUploadButton="true"
+      :showDeleteButton="true"
+      :deleteMethod="handleDeleteFile"
+      :uploadMethod="handleFileUpload"
+      :rulesRegulationsManagementId="currentRowId"
+    />
+    <EditModal ref="editmodalRef" @success="getTableData"></EditModal>
   </div>
 </template>
 
 <script setup>
 import { ref, getCurrentInstance } from "vue";
 import { usePaginationApi } from "@/hooks/usePaginationApi";
-import { Files, Download, Search, Upload } from "@element-plus/icons-vue";
-import { productRecordPage } from "@/api/procurementManagement/procurementInvoiceLedger.js";
+import {
+	Search,
+} from "@element-plus/icons-vue";
+import {
+	delRegistration,
+	productRecordPage,
+	delCommonFile,
+} from "@/api/procurementManagement/procurementInvoiceLedger.js";
+import request from "@/utils/request";
+import { getToken } from "@/utils/auth";
 import { onMounted } from "vue";
 import { ElMessageBox } from "element-plus";
-import Modal from "./Modal/UploadModal.vue";
+import EditModal from "./Modal/EditModal.vue";
+import FileListDialog from '@/components/Dialog/FileListDialog.vue';
+import useUserStore from "@/store/modules/user.js";
+const userStore = useUserStore();
 
 defineOptions({
   name: "鏉ョエ鍙拌处",
 });
 
-const modalRef = ref();
+const editmodalRef = ref();
+const fileListRef = ref(null);
+const fileListDialogVisible = ref(false);
+const currentRowId = ref(null); // 褰撳墠鏌ョ湅闄勪欢鐨勮ID
+
 const { proxy } = getCurrentInstance();
 const multipleVal = ref([]);
 const {
@@ -119,37 +148,42 @@
     {
       label: "閲囪喘鍚堝悓鍙�",
       prop: "purchaseContractNumber",
-      align: "center",
+      width: 150,
     },
     {
       label: "閿�鍞悎鍚屽彿",
       prop: "salesContractNo",
-      align: "center",
+      width: 150,
     },
     {
-      label: "瀹㈡埛鍚嶇О",
-      prop: "customerName",
-      align: "center",
+      label: "椤圭洰鍚嶇О",
+      prop: "projectName",
+      width: 240,
     },
     {
       label: "渚涘簲鍟嗗悕绉�",
       prop: "supplierName",
-      align: "center",
+      width: 240,
+    },
+    {
+      label: "浜у搧澶х被",
+      prop: "productCategory",
+      width: 150,
     },
     {
       label: "瑙勬牸鍨嬪彿",
       prop: "specificationModel",
-      align: "center",
+      width: 150,
     },
     {
       label: "鍙戠エ鍙�",
       prop: "invoiceNumber",
-      align: "center",
+      width: 200,
     },
     {
       label: "鍚堝悓閲戦(鍏�)",
       prop: "taxInclusiveTotalPrice",
-      align: "center",
+      width: 200,
       formatData: (cell) => {
         return cell ? parseFloat(cell).toFixed(2) : 0;
       },
@@ -157,12 +191,12 @@
     {
       label: "寮�绁ㄦ棩鏈�",
       prop: "createdAt",
-      align: "center",
+      width: 110,
     },
     {
       label: "寮�绁ㄩ噾棰�",
       prop: "ticketsAmount",
-      align: "center",
+      width: 200,
       formatData: (cell) => {
         return cell ? parseFloat(cell).toFixed(2) : 0;
       },
@@ -170,7 +204,7 @@
     {
       label: "涓嶅惈绋庨噾棰�",
       prop: "unTicketsPrice",
-      align: "center",
+      width: 200,
       formatData: (cell) => {
         return cell ? parseFloat(cell).toFixed(2) : 0;
       },
@@ -178,24 +212,21 @@
     {
       label: "澧炲�肩◣",
       prop: "invoiceAmount",
-      align: "center",
+      width: 200,
     },
     {
-      label: "闄勪欢",
-      align: "center",
-      prop: "commonFiles",
-      dataType: "slot",
-      slot: "commonFilesRef",
-      width: 150,
+      label: "褰曞叆浜�",
+      prop: "issUer",
+      width: 200,
     },
-    // {
-    //   fixed: "right",
-    //   width: 120,
-    //   label: "鎿嶄綔",
-    //   dataType: "slot",
-    //   slot: "operation",
-    //   align: "center",
-    // },
+    {
+      fixed: "right",
+      width: 200,
+      label: "鎿嶄綔",
+      dataType: "slot",
+      slot: "operation",
+      align: "center",
+    },
   ],
   {},
   {
@@ -242,31 +273,172 @@
     });
 };
 
-const handleFiles = (fileList) => {
-  fileList.forEach((e) => {
-    proxy.$download.name(e.url);
-  });
-};
-
-const changePage = ({ page }) => {
+const changePage = ({ page, limit }) => {
   pagination.currentPage = page;
+	pagination.pageSize = limit;
   onCurrentChange(page);
 };
 
-const handleCommand = (command, row) => {
-  switch (command) {
-    case "download":
-      handleFiles(row.commonFiles);
-      break;
-    case "upload":
-      console.log(row.commonFiles);
-      openModal();
-      break;
+const downLoadFile = row => {
+  currentRowId.value = row.id;
+  if (fileListRef.value) {
+    fileListRef.value.open(row.commonFiles || []);
   }
 };
 
-const openModal = () => {
-  modalRef.value.handleImport();
+// 涓婁紶闄勪欢锛堣嚜瀹氫箟涓婁紶鏂规硶锛�
+const handleFileUpload = async () => {
+  if (!currentRowId.value) {
+    proxy.$modal.msgWarning("缂哄皯鐧昏ID锛屾棤娉曚繚瀛橀檮浠�");
+    return;
+  }
+  
+  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);
+        formData.append('type', '4'); // type 鍙傛暟锛岀敤鎴锋湭鎸囧畾鍏蜂綋鍊硷紝鍏堜紶绌哄瓧绗︿覆
+        formData.append('id', currentRowId.value); // 褰撳墠琛岀殑 id
+        
+        const uploadRes = await request({
+          url: '/file/uploadByCommon',
+          method: 'post',
+          data: formData,
+          headers: {
+            'Content-Type': 'multipart/form-data',
+            Authorization: `Bearer ${getToken()}`
+          }
+        });
+        
+        if (uploadRes.code === 200) {
+          proxy.$modal.msgSuccess("闄勪欢涓婁紶鎴愬姛");
+          
+          // 鍒锋柊鍒楄〃鑾峰彇鏈�鏂版暟鎹�
+          await new Promise((resolveRefresh) => {
+            // 璋冪敤 API 鑾峰彇鏈�鏂板垪琛ㄦ暟鎹�
+            productRecordPage({
+              ...filters,
+              current: pagination.currentPage,
+              size: pagination.pageSize
+            }).then(({ code, data }) => {
+              if (code === 200) {
+                // 鏇存柊鏁版嵁鍒楄〃
+                dataList.value = data.records;
+                pagination.total = data.total;
+                
+                // 浠庡閮ㄦ暟鎹幏鍙� commonFiles
+                const currentRow = dataList.value.find(row => row.id === currentRowId.value);
+                if (currentRow && fileListRef.value) {
+                  // 鍒锋柊闄勪欢鍒楄〃锛屼娇鐢ㄤ粠澶栭儴鑾峰彇鐨勬渶鏂� commonFiles
+                  fileListRef.value.open(currentRow.commonFiles || []);
+                }
+                resolveRefresh();
+              } else {
+                resolveRefresh();
+              }
+            }).catch(() => {
+              resolveRefresh();
+            });
+          });
+          
+          resolve({
+            name: uploadRes.data?.originalName || file.name,
+            url: uploadRes.data?.tempPath || uploadRes.data?.url,
+            id: uploadRes.data?.id
+          });
+        } else {
+          proxy.$modal.msgError(uploadRes.msg || "鏂囦欢涓婁紶澶辫触");
+          resolve(null);
+        }
+      } catch (error) {
+        console.error("闄勪欢涓婁紶澶辫触:", error);
+        proxy.$modal.msgError("闄勪欢涓婁紶澶辫触");
+        resolve(null);
+      } finally {
+        document.body.removeChild(input);
+      }
+    };
+    
+    document.body.appendChild(input);
+    input.click();
+  });
+};
+
+// 鍒犻櫎闄勪欢
+const handleDeleteFile = async (file) => {
+  try {
+    await delCommonFile([file.id]);
+    proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
+    
+    // 鍒锋柊鍒楄〃鑾峰彇鏈�鏂版暟鎹�
+    await new Promise((resolveRefresh) => {
+      // 璋冪敤 API 鑾峰彇鏈�鏂板垪琛ㄦ暟鎹�
+      productRecordPage({
+        ...filters,
+        current: pagination.currentPage,
+        size: pagination.pageSize
+      }).then(({ code, data }) => {
+        if (code === 200) {
+          // 鏇存柊鏁版嵁鍒楄〃
+          dataList.value = data.records;
+          pagination.total = data.total;
+          
+          // 浠庡閮ㄦ暟鎹幏鍙� commonFiles
+          const currentRow = dataList.value.find(row => row.id === currentRowId.value);
+          if (currentRow && fileListRef.value) {
+            // 鍒锋柊闄勪欢鍒楄〃锛屼娇鐢ㄤ粠澶栭儴鑾峰彇鐨勬渶鏂� commonFiles
+            fileListRef.value.open(currentRow.commonFiles || []);
+          }
+          resolveRefresh();
+        } else {
+          resolveRefresh();
+        }
+      }).catch(() => {
+        resolveRefresh();
+      });
+    });
+    
+    return true;
+  } catch (error) {
+    proxy.$modal.msgError("鍒犻櫎澶辫触");
+    return false;
+  }
+};
+
+const openEdit = (row) => {
+  editmodalRef.value.open(row);
+};
+// 鍒犻櫎
+const handleDelete = (row) => {
+	let ids = [];
+	ids.push(row.id);
+	ElMessageBox.confirm("璇ュ紑绁ㄥ彴璐﹀皢琚垹闄�,鏄惁纭鍒犻櫎", {
+		confirmButtonText: "纭",
+		cancelButtonText: "鍙栨秷",
+		type: "warning",
+	})
+		.then(() => {
+			loading.value = true;
+			delRegistration(ids).then((res) => {
+				getTableData();
+			});
+			loading.value = false;
+		})
+		.catch(() => {
+			proxy.$modal.msg("宸插彇娑�");
+		});
 };
 
 onMounted(() => {

--
Gitblit v1.9.3