提交统计查询

This commit is contained in:
2025-04-28 10:43:28 +08:00
parent 95ee4bcebf
commit 13bd58a932
2 changed files with 91 additions and 42 deletions

View File

@@ -21,9 +21,7 @@
label-width="20px"
style="width: 80px !important"
>
<el-button @click="getAssociatedGoodsList(dataForm)" size="mini"
>查询</el-button
>
<el-button @click="search()" size="mini">查询</el-button>
<!-- <el-button @click="handleCommonShopReset()" size="mini"
>重置</el-button
> -->
@@ -87,7 +85,7 @@
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
:current-page="current"
:page-sizes="[50, 100, 200]"
:page-sizes="pageSizes ? pageSizes : [50, 100, 200]"
:page-size="limit"
layout="total, sizes, prev, pager, next, jumper"
:total="total"
@@ -139,7 +137,8 @@
</div>
</template>
<script>import axios from 'axios'
<script>
import axios from "axios";
// import chooseBook from './chooseBook.vue'
// import AddOrUpdate from './shopproduct-add-or-update'
export default {
@@ -156,7 +155,8 @@ export default {
"isShowPagination",
"axiosType",
"otherInfo",
"CustomEdit"
"CustomEdit",
"pageSizes"
],
data() {
return {
@@ -212,25 +212,77 @@ export default {
// await this.getGoodsTypeList();
},
methods: {
async handleExport() {
var filename = "downloaded_file.xlsx";
async mounted() {
this.current = 1;
this.limit = 50;
this.multipleSelection = [];
if (this.otherInfo.statisticsQuery) {
await this.statisticsQuery();
} else {
await this.getAssociatedGoodsList({ ...this.dataForm });
}
// await this.getGoodsTypeList();
},
methods: {
search() {
this.current = 1;
this.limit = 50;
this.getAssociatedGoodsList(this.dataForm);
},
getNowTimestamp() {
const now = new Date();
const year = now.getFullYear();
const month = String(now.getMonth() + 1).padStart(2, "0");
const day = String(now.getDate()).padStart(2, "0");
const hour = String(now.getHours()).padStart(2, "0");
const minute = String(now.getMinutes()).padStart(2, "0");
const second = String(now.getSeconds()).padStart(2, "0");
return `${year}${month}${day}${hour}${minute}${second}`;
},
async handleExport() {
var filename = `湖分统计下载文件_${this.getNowTimestamp()}.xlsx`;
this.$message({
message: "湖分统计查询中,查询成功后文件会自动下载,请耐心等待...",
type: "info",
duration: 6000,
showClose: true
});
try {
this.$http({
url: this.$http.adornUrl(/master/userContribution/exportContributionStatQuery),
method: "post",
data: this.$http.adornData({
current: this.current,
limit: this.limit
},{
responseType: "blob" // 关键点:告诉 axios 返回的是二进制文件
})
}).then(res=>{
console.log('res at line 230:', res)
})
url: this.$http.adornUrl(
"/master/userContribution/exportContributionStatQuery"
),
method: "post",
data: this.$http.adornData({
current: "1",
limit: "99999"
}),
responseType: "blob" // ⚡⚡⚡一定要加上
}).then(res => {
this.$message({
message: "湖分统计文件下载中,下载完成后文件会自动下载,请耐心等待...",
type: "info",
duration: 6000,
showClose: true
});
const blob = new Blob([res.data], {
type:
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
});
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
link.click();
window.URL.revokeObjectURL(link.href); // 释放内存
this.$message({
message: "湖分统计文件下载完成,请注意查看!",
type: "success",
duration: 3000,
showClose: true
});
});
// const res = await axios.post(
// window.SITE_CONFIG.baseUrl+"/master/userContribution/exportContributionStatQuery",
// {
@@ -238,20 +290,13 @@ export default {
// limit: this.limit
// },
// {
// responseType: "blob" // 关键点:告诉 axios 返回的是二进制文件
// }
// );
const blob = new Blob([res.data]);
const link = document.createElement("a");
link.href = window.URL.createObjectURL(blob);
link.download = filename;
link.click();
window.URL.revokeObjectURL(link.href); // 释放内存
} catch (err) {
console.error("文件下载失败", err);
this.$message.error("文件下载失败!");
// console.error("文件下载失败:", err);
}
},
async handleSizeChange(val) {
@@ -402,6 +447,10 @@ export default {
});
},
clear() {
this.limit = 50;
this.current = 1;
this.dataForm = {};
this.$forceUpdate();
// this.$refs.table.clearSelection();
// this.multipleSelection = [];
},