فهرست منبع

添加商品统计导出

wangningfei 2 سال پیش
والد
کامیت
0c1b553e48
2فایلهای تغییر یافته به همراه42 افزوده شده و 1 حذف شده
  1. 10 0
      vue-admin-template-master/src/api/order.js
  2. 32 1
      vue-admin-template-master/src/views/orders/list/index.vue

+ 10 - 0
vue-admin-template-master/src/api/order.js

@@ -59,6 +59,16 @@ export function export_order(data) {
   });
 }
 
+//导出订单
+export function export_goods(data) {
+  return request({
+    url: "dashboard/statistics_export",
+    method: "post",
+    data,
+    responseType: "arraybuffer"
+  });
+}
+
 //订单统计
 export function statistics_shopday(data) {
   return request({

+ 32 - 1
vue-admin-template-master/src/views/orders/list/index.vue

@@ -18,6 +18,13 @@
           @click="exportBtn"
           >导出</el-button
         >
+        <el-button
+          style="margin-left: 10px"
+          :loading="exportLoading1"
+          type="primary"
+          @click="exportBtn1"
+          >商品统计</el-button
+        >
       </div>
       <!-- show-overflow-tooltip -->
       <el-table
@@ -276,7 +283,7 @@
 </template>
 
 <script>
-import { getOrderList, export_order } from "@/api/order";
+import { getOrderList, export_order, export_goods } from "@/api/order";
 export default {
   name: "List",
   filters: {
@@ -333,6 +340,7 @@ export default {
         }
       },
       exportLoading: false,
+      exportLoading1: false,
       timeValue: "",
       total: 0,
       listLoading: true,
@@ -381,6 +389,29 @@ export default {
           this.$message.error("导出失败,请稍后重试!");
         });
     },
+    exportBtn1() {
+      if (!this.timeValue.length) {
+        return this.$message.error("请选择日期范围");
+      }
+      this.exportLoading1 = true;
+      export_goods({
+        starttime: this.timeValue[0],
+        endtime: this.timeValue[1]
+      })
+        .then(res => {
+          let blob = new Blob([res], { type: "application/x-xls" });
+          let link = document.createElement("a");
+          link.href = window.URL.createObjectURL(blob);
+          link.download = "商品统计.xlsx";
+          link.click();
+
+          this.exportLoading1 = false;
+        })
+        .catch(err => {
+          this.exportLoading1 = false;
+          this.$message.error("导出失败,请稍后重试!");
+        });
+    },
     getList() {
       this.listLoading = true;
       getOrderList({