lxf il y a 3 mois
Parent
commit
e91ef7b4c8
1 fichiers modifiés avec 30 ajouts et 1 suppressions
  1. 30 1
      src/views/finance/fundManage/depExpenses/index.vue

+ 30 - 1
src/views/finance/fundManage/depExpenses/index.vue

@@ -12,7 +12,12 @@
         :table-events="{
           select: select,
         }"
-        :action-list="[]"
+        :action-list="[
+          {
+            text: '导出Excel',
+            action: () => deriveExcel(),
+          },
+        ]"
         @moreSearch="moreSearch"
         @get-list="getList">
         <template #amount="{ item }">
@@ -574,6 +579,30 @@ const submitSearch = () => {
   sourceList.value.pagination.pageNum = 1;
   getList();
 };
+const deriveExcel = () => {
+  let queryParams = proxy.deepClone(sourceList.value.pagination);
+  proxy.postTwo("/accountDeptRunningWater/export", queryParams).then((res) => {
+    exportData(res, "部门费用管理.xlsx");
+  });
+};
+const exportData = (res, name) => {
+  const content = res;
+  const blob = new Blob([content], { type: "application/ms-excel" });
+  const fileName = name;
+  if ("download" in document.createElement("a")) {
+    // 非IE下载
+    const elink = document.createElement("a");
+    elink.download = fileName;
+    elink.style.display = "none";
+    elink.href = URL.createObjectURL(blob);
+    document.body.appendChild(elink);
+    elink.click();
+    URL.revokeObjectURL(elink.href); // 释放URL 对象
+    document.body.removeChild(elink);
+  } else {
+    navigator.msSaveBlob(blob, fileName);
+  }
+};
 </script>
 
 <style lang="scss" scoped>