lxf 3 mēneši atpakaļ
vecāks
revīzija
3505e5fbf8
1 mainītis faili ar 105 papildinājumiem un 82 dzēšanām
  1. 105 82
      src/views/salesMange/salesMange/performance/index.vue

+ 105 - 82
src/views/salesMange/salesMange/performance/index.vue

@@ -57,8 +57,10 @@
           </div> -->
         </div>
       </div>
+      <!-- <el-button type="primary" @click="downExcel">下载至Excel</el-button> -->
 
       <el-table v-loading="loading" :data="sourceList.data" max-height="calc(100vh - 300px)">
+        <!-- <el-table v-loading="loading" :data="sourceList.data" max-height="calc(100vh - 300px)" id="example" :summary-method="getSummaries" show-summary> -->
         <el-table-column label="合同编号">
           <el-table-column label="" prop="contractCode" width="160">
             <template #default="{ row }">
@@ -318,6 +320,8 @@ import byForm from "@/components/byForm/index";
 import useUserStore from "@/store/modules/user";
 import { ElMessage } from "element-plus";
 import ContractDetails from "@/components/contractCom/contractDetails.vue";
+import FileSaver from "file-saver";
+import XLSX from "xlsx";
 
 const { proxy } = getCurrentInstance();
 const accountCurrency = ref([]);
@@ -341,7 +345,7 @@ const sourceList = ref({
   pagination: {
     total: 0,
     pageNum: 1,
-    pageSize: 10,
+    pageSize: 999,
     keyword: "",
     settlementStatus: "",
     userId: "",
@@ -742,87 +746,106 @@ const openDetails = (row) => {
   currentContractId.value = row.contractId;
   openDetailsDialog.value = true;
 };
-// const getSummaries = (param) => {
-//   let obj = {
-//     3: {
-//       label: "contractAmount",
-//       num: 2,
-//     },
-//     4: {
-//       label: "contractArrival",
-//       num: 2,
-//     },
-//     5: {
-//       label: "taxReturnAmount",
-//       num: 2,
-//     },
-//     6: {
-//       label: "otherIncome",
-//       num: 2,
-//     },
-//     7: {
-//       label: "purchaseAmount",
-//       num: 2,
-//     },
-//     8: {
-//       label: "payForGoods",
-//       num: 2,
-//     },
-//     9: {
-//       label: "otherExpenses",
-//       num: 2,
-//     },
-//     10: {
-//       label: "totalIncome",
-//       num: 2,
-//     },
-//     11: {
-//       label: "totalExpenses",
-//       num: 2,
-//     },
-//     12: {
-//       label: "grossGrofit",
-//       num: 2,
-//     },
-//     13: {
-//       label: "afterSalesAmount",
-//       num: 2,
-//     },
-//     14: {
-//       label: "publicAmount",
-//       num: 2,
-//     },
-//     15: {
-//       label: "haveOverallAmount",
-//       num: 2,
-//     },
-//     16: {
-//       label: "departmentalCommission",
-//       num: 2,
-//     },
-//     17: {
-//       label: "personalCommission",
-//       num: 2,
-//     },
-//   };
-//   const { columns, data } = param;
-//   const sums = [];
-//   columns.forEach((column, index) => {
-//     if (index === 0) {
-//       sums[index] = "合计:";
-//     } else {
-//       if (obj[index] && obj[index].label) {
-//         let list = sourceList.value.data.map((item) => item[obj[index].label]);
-//         if (list && list.length > 0) {
-//           sums[index] = list.reduce((accumulator, currentValue) => accumulator + currentValue, 0).toFixed(obj[index].num);
-//         } else {
-//           sums[index] = 0;
-//         }
-//       }
-//     }
-//   });
-//   return sums;
-// };
+const getSummaries = (param) => {
+  let obj = {
+    3: {
+      label: "contractAmount",
+      num: 2,
+    },
+    4: {
+      label: "contractArrival",
+      num: 2,
+    },
+    5: {
+      label: "taxReturnAmount",
+      num: 2,
+    },
+    6: {
+      label: "otherIncome",
+      num: 2,
+    },
+    7: {
+      label: "purchaseAmount",
+      num: 2,
+    },
+    8: {
+      label: "payForGoods",
+      num: 2,
+    },
+    9: {
+      label: "otherExpenses",
+      num: 2,
+    },
+    10: {
+      label: "totalIncome",
+      num: 2,
+    },
+    11: {
+      label: "totalExpenses",
+      num: 2,
+    },
+    12: {
+      label: "grossGrofit",
+      num: 2,
+    },
+    13: {
+      label: "afterSalesAmount",
+      num: 2,
+    },
+    14: {
+      label: "publicAmount",
+      num: 2,
+    },
+    15: {
+      label: "haveOverallAmount",
+      num: 2,
+    },
+    16: {
+      label: "departmentalCommission",
+      num: 2,
+    },
+    17: {
+      label: "personalCommission",
+      num: 2,
+    },
+  };
+  const { columns, data } = param;
+  const sums = [];
+  columns.forEach((column, index) => {
+    if (index === 0) {
+      sums[index] = "合计:";
+    } else {
+      if (obj[index] && obj[index].label) {
+        let list = sourceList.value.data.map((item) => item[obj[index].label]);
+        if (list && list.length > 0) {
+          sums[index] = list.reduce((accumulator, currentValue) => accumulator + currentValue, 0).toFixed(obj[index].num);
+        } else {
+          sums[index] = 0;
+        }
+      }
+    }
+  });
+  return sums;
+};
+const downExcel = () => {
+  let et = XLSX.utils.table_to_book(document.getElementById("example")); //此处传入table的DOM节点
+  let etout = XLSX.write(et, {
+    bookType: "xlsx",
+    bookSST: true,
+    type: "array",
+  });
+  try {
+    FileSaver.saveAs(
+      new Blob([etout], {
+        type: "application/octet-stream",
+      }),
+      `导出文件.xlsx`
+    ); //导出的文件名
+  } catch (e) {
+    console.log(e, etout);
+  }
+  return etout;
+};
 </script>
 
 <style lang="scss" scoped>