Commit 39e070bb by baihong

导出早起活动

parent 2eaafe08
......@@ -5,6 +5,9 @@ export const activityClocks = (data) => {
export const getActivityConfigByPay = (data) => {
return $http.get('/cms/configs/getActivityConfigByPay', data)
}
export const exportList = (data) => {
return $http.getExport('/cms/activityClocks/exportList', data)
}
//奖励列表
export const configAwards = (data) => {
return $http.get('/cms/configs/configAwards?type='+ data)
......
......@@ -144,6 +144,21 @@ const _HttpService = {
config = Object.assign({}, _selfConfig, config);
return _http.get(url, config);
},
getExport: (url, data, config) => {
const _selfConfig = {
headers: {
language: "cn",
"Content-Type": "application/x-download",
"X-Access-Token":
sessionStorage.getItem("token") || "1b8cc15a59947ce27dd62b"
},
responseType: 'blob',
params: data,
setLoading: true
};
config = Object.assign({}, _selfConfig, config);
return _http.get(url, config);
},
delete: (url, data, config) => {
const _selfConfig = {
headers: {
......
......@@ -21,7 +21,7 @@
<Button type="primary" ghost>重 置</Button>
</div>
<div class="right">
<Button type="primary">导 出</Button>
<Button type="primary" @click="exportlist">导 出</Button>
</div>
</div>
<Table
......@@ -35,7 +35,9 @@
<span>{{ row.activity_date | format }}</span>
</template>
<template slot-scope="{ row }" slot="status">
<span>{{ row.status===0 ? '未开始':row.status===1?'进行中':'已结束' }}</span>
<span>{{
row.status === 0 ? "未开始" : row.status === 1 ? "进行中" : "已结束"
}}</span>
</template>
<template slot-scope="{ row }" slot="created_at">
<span>{{ row.created_at | format }}</span>
......@@ -53,17 +55,17 @@
</template>
<script>
import { activityClocks } from "@/api/clock/activityClocks";
import { formatDate } from '@/libs/util'
import { activityClocks, exportList } from "@/api/clock/activityClocks";
import { formatDate } from "@/libs/util";
import Pager from "@/view/common/Pager.vue";
export default {
name: "categories",
components: {
Pager
},
filters: {
format (value) {
return formatDate(value)
filters: {
format(value) {
return formatDate(value);
}
},
data() {
......@@ -117,7 +119,22 @@ export default {
};
activityClocks(params).then(res => {
this.config.total = res.total;
this.data = res.data
this.data = res.data;
});
},
exportlist() {
exportList().then(res => {
if (res) {
const xlsx = "application/vnd.ms-excel";
const blob = new Blob([res], { type: xlsx });
const a = document.createElement("a"); // 转换完成,创建一个a标签用于下载
a.download = "早起活动.xls";
a.href = window.URL.createObjectURL(blob);
a.click();
a.remove();
} else {
this.$message.error("导出失败");
}
});
},
handlePager(pager) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment