Просмотр исходного кода

fix:利润分析添加导出功能

刘恒 1 год назад
Родитель
Сommit
2474bde99b
2 измененных файлов с 64 добавлено и 2 удалено
  1. 52 1
      src/pages/profit/profit.vue
  2. 12 1
      src/services/profit.js

+ 52 - 1
src/pages/profit/profit.vue

@@ -31,6 +31,14 @@
         </div>
       </div>
       <div class="table">
+        <div style="padding: 10px;display: flex;justify-content: flex-end;">
+          <a-button type="primary"  @click="exportList"
+            >应收金额导出明细</a-button
+          >
+          <a-button type="primary" style="margin-left: 10px;"  @click="payAmountExcel"
+            >利润分析实付金额</a-button
+          >
+        </div>
         <standard-table
           bordered
           :columns="columns"
@@ -267,6 +275,8 @@ export default {
         yearAndMonth: "",
         type: "",
       },
+      process: process.env.VUE_APP_API_BASE_URL,
+
     };
   },
   mounted() {
@@ -275,6 +285,47 @@ export default {
     // }, 1000);
   },
   methods: {
+    exportList(){
+      this.$API.profit.receivableExcel({
+        dateType: this.formState.dateType,
+          year:
+            this.time != ""
+              ? this.time._d.getFullYear()
+              : new Date().getFullYear(),
+      }).then(res=>{
+        if (res.data.code == 200) {
+            let url = this.process + res.data.data; // 3.创建一个临时的url指向blob对象
+            let a = document.createElement("a");
+            a.href = url;
+            a.download = "导出文件.xlsx";
+            a.click();
+            window.URL.revokeObjectURL(url);
+          } else {
+            this.$message.error(res.msg);
+          }
+      })
+     
+    },
+    payAmountExcel(){
+      this.$API.profit.payAmountExcel({
+        dateType: this.formState.dateType,
+          year:
+            this.time != ""
+              ? this.time._d.getFullYear()
+              : new Date().getFullYear(),
+      }).then(res=>{
+        if (res.data.code == 200) {
+            let url = this.process + res.data.data; // 3.创建一个临时的url指向blob对象
+            let a = document.createElement("a");
+            a.href = url;
+            a.download = "导出文件.xlsx";
+            a.click();
+            window.URL.revokeObjectURL(url);
+          } else {
+            this.$message.error(res.msg);
+          }
+      })
+    },
     sortTable(pagination, filters, sorter) {
       console.log(sorter);
       if (sorter.order) {
@@ -297,7 +348,7 @@ export default {
           orderBy: this.orderBy,
         })
         .then((res) => {
-          console.log(res);
+      
           if (res.data.code === 200) {
             this.detailsLoading = false;
 

+ 12 - 1
src/services/profit.js

@@ -10,9 +10,20 @@ export async function getProfitList(data) {
 export async function getDetails(data) {
     return request("/profitAnalysis/getProfitAnalysisQueryDetailsList", METHOD.POST, data)
 }
+//应收金额导出明细
+export async function receivableExcel(data) {
+    return request("/profitAnalysis/receivableExcel", METHOD.POST, data)
+}
+//利润分析实付金额
+export async function payAmountExcel(data) {
+    return request("/profitAnalysis/payAmountExcel", METHOD.POST, data)
+}
+
 
 
 export default {
     getProfitList,
-    getDetails
+    getDetails,
+    receivableExcel,
+    payAmountExcel 
 }