| | |
| | | class="search-btn" |
| | | >搜索</Button |
| | | > |
| | | <Button |
| | | @click="queryExportCoupon" |
| | | type="primary" |
| | | class="search-btn"> |
| | | 导出领取记录 |
| | | </Button> |
| | | </Form> |
| | | <Table |
| | | v-if="refreshTable" |
| | |
| | | </div> |
| | | </template> |
| | | <script> |
| | | import { getCouponReceiveList } from "@/api/promotion"; |
| | | import { getCouponReceiveList,queryExportCoupon } from "@/api/promotion"; |
| | | import { |
| | | memberPromotionsStatusRender, |
| | | promotionsScopeTypeRender, |
| | |
| | | }, |
| | | }, |
| | | 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但是依然不支持download |
| | | 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); |