From 0fa627d021ee2683a8895e49080757c51990a6e1 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期五, 08 八月 2025 16:31:46 +0800
Subject: [PATCH] 导出,商品打标签

---
 manager/src/views/promotions/coupon/coupon-receive.vue |   41 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 40 insertions(+), 1 deletions(-)

diff --git a/manager/src/views/promotions/coupon/coupon-receive.vue b/manager/src/views/promotions/coupon/coupon-receive.vue
index 160d475..dab6836 100644
--- a/manager/src/views/promotions/coupon/coupon-receive.vue
+++ b/manager/src/views/promotions/coupon/coupon-receive.vue
@@ -67,6 +67,12 @@
           class="search-btn"
           >鎼滅储</Button
         >
+        <Button
+          @click="queryExportCoupon"
+          type="primary"
+          class="search-btn">
+          瀵煎嚭棰嗗彇璁板綍
+        </Button>
       </Form>
       <Table
         v-if="refreshTable"
@@ -97,7 +103,7 @@
   </div>
 </template>
 <script>
-import { getCouponReceiveList } from "@/api/promotion";
+import { getCouponReceiveList,queryExportCoupon } from "@/api/promotion";
 import {
   memberPromotionsStatusRender,
   promotionsScopeTypeRender,
@@ -254,6 +260,39 @@
     },
   },
   methods: {
+    queryExportCoupon(){
+      console.log(this.selectDate.length === 0);
+
+      if(this.selectDate.length === 0){
+        this.$Message.error("蹇呴』閫夋嫨鏃堕棿鑼冨洿锛屾悳绱㈠悗杩涜瀵煎嚭锛�");
+        this.searchForm.startTime = null;
+        this.searchForm.endTime = null;
+      }else{
+        this.searchForm.startTime = this.selectDate[0].getTime();
+        this.searchForm.endTime = this.selectDate[1].getTime();
+        queryExportCoupon(this.searchForm).then(res =>{
+          const blob = new Blob([res], {
+            type: "application/vnd.ms-excel;charset=utf-8",
+          });
+          //瀵逛簬<a>鏍囩锛屽彧鏈� Firefox 鍜� Chrome锛堝唴鏍革級 鏀寔 download 灞炴��
+          //IE10浠ヤ笂鏀寔blob浣嗘槸渚濈劧涓嶆敮鎸乨ownload
+          if ("download" in document.createElement("a")) {
+            //鏀寔a鏍囩download鐨勬祻瑙堝櫒
+            const link = document.createElement("a"); //鍒涘缓a鏍囩
+            link.download = "浼樻儬鍒搁鍙栬褰�.xlsx"; //a鏍囩娣诲姞灞炴��
+            link.style.display = "none";
+            link.href = URL.createObjectURL(blob);
+            document.body.appendChild(link);
+            link.click(); //鎵ц涓嬭浇
+            URL.revokeObjectURL(link.href); //閲婃斁url
+            document.body.removeChild(link); //閲婃斁鏍囩
+          } else {
+            navigator.msSaveBlob(blob, fileName);
+          }
+        })
+      }
+
+    },
     back() {
       this.$store.commit("removeTag", "coupon-receive");
       this.$router.go(-1);

--
Gitblit v1.8.0