From 65b213e7daa1d03746e5ce9a333890b1480e6113 Mon Sep 17 00:00:00 2001
From: gaoluyang <2820782392@qq.com>
Date: 星期四, 29 一月 2026 14:33:48 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_New' into dev_New

---
 src/views/procurementManagement/procurementInvoiceLedger/index.vue |  290 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 251 insertions(+), 39 deletions(-)

diff --git a/src/views/procurementManagement/procurementInvoiceLedger/index.vue b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
index e5565a5..00ae65a 100644
--- a/src/views/procurementManagement/procurementInvoiceLedger/index.vue
+++ b/src/views/procurementManagement/procurementInvoiceLedger/index.vue
@@ -47,7 +47,7 @@
         :tableLoading="loading"
         :tableData="dataList"
         :isSelection="true"
-        height="calc(100vh - 18.5em)"
+        height="calc(100vh - 19.5em)"
         :isShowSummary="true"
         :summaryMethod="summarizeMainTable"
         :page="{
@@ -56,31 +56,75 @@
           total: pagination.total,
         }"
         @selection-change="handleSelectionChange"
-        @pagination="onCurrentChange"
+        @pagination="changePage"
       >
-        <template #commonFilesRef="{ row }">
-          <div v-for="item in row.commonFiles">
-            <el-tag type="primary" class="tagBox">
-              {{ item.name }}
-            </el-tag>
-          </div>
+        <template #operation="{ row }">
+          <el-button
+            type="primary"
+            link
+            @click="openEdit(row)"
+          >
+            缂栬緫
+          </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>
+    <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 { Search } 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 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 editmodalRef = ref();
+const fileListRef = ref(null);
+const fileListDialogVisible = ref(false);
+const currentRowId = ref(null); // 褰撳墠鏌ョ湅闄勪欢鐨勮ID
 
 const { proxy } = getCurrentInstance();
 const multipleVal = ref([]);
@@ -104,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;
       },
@@ -142,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;
       },
@@ -155,7 +204,7 @@
     {
       label: "涓嶅惈绋庨噾棰�",
       prop: "unTicketsPrice",
-      align: "center",
+      width: 200,
       formatData: (cell) => {
         return cell ? parseFloat(cell).toFixed(2) : 0;
       },
@@ -163,24 +212,21 @@
     {
       label: "澧炲�肩◣",
       prop: "invoiceAmount",
-      align: "center",
-    },
-    {
-      label: "闄勪欢",
-      align: "center",
-      prop: "commonFiles",
-      dataType: "slot",
-      slot: "commonFilesRef",
       width: 200,
     },
-    // {
-    //   fixed: "right",
-    //   width: 120,
-    //   label: "鎿嶄綔",
-    //   dataType: "slot",
-    //   slot: "operation",
-    //   align: "center",
-    // },
+    {
+      label: "褰曞叆浜�",
+      prop: "issUer",
+      width: 200,
+    },
+    {
+      fixed: "right",
+      width: 200,
+      label: "鎿嶄綔",
+      dataType: "slot",
+      slot: "operation",
+      align: "center",
+    },
   ],
   {},
   {
@@ -227,7 +273,173 @@
     });
 };
 
-// const handleEdit = () => {};
+const changePage = ({ page, limit }) => {
+  pagination.currentPage = page;
+	pagination.pageSize = limit;
+  onCurrentChange(page);
+};
+
+const downLoadFile = row => {
+  currentRowId.value = row.id;
+  if (fileListRef.value) {
+    fileListRef.value.open(row.commonFiles || []);
+  }
+};
+
+// 涓婁紶闄勪欢锛堣嚜瀹氫箟涓婁紶鏂规硶锛�
+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(() => {
   getTableData();

--
Gitblit v1.9.3