优化数据统计的传参以及部分展示字段以优化

This commit is contained in:
gyq
2025-11-24 16:37:49 +08:00
parent 7f76996829
commit 980f0357c1
5 changed files with 151 additions and 239 deletions

View File

@@ -8,21 +8,21 @@
<el-form :model="query" inline label-position="left">
<div class="u-flex gap-10" style="flex-wrap: wrap;">
<el-radio-group v-model="timeValue" @change="timeChange">
<el-radio-button value="">全部</el-radio-button>
<el-radio-button value="0">今天</el-radio-button>
<el-radio-button value="-1">昨天</el-radio-button>
<el-radio-button value="-7">最近7天</el-radio-button>
<el-radio-button value="-30">最近30天</el-radio-button>
<el-radio-button value="week">本周</el-radio-button>
<el-radio-button value="month">本月</el-radio-button>
<!-- <el-radio-button value="">全部</el-radio-button> -->
<el-radio-button value="today">今天</el-radio-button>
<el-radio-button value="yesterday">昨天</el-radio-button>
<el-radio-button value="last_7_days">最近7天</el-radio-button>
<el-radio-button value="last_30_days">最近30天</el-radio-button>
<el-radio-button value="this_week">本周</el-radio-button>
<el-radio-button value="this_month">本月</el-radio-button>
<el-radio-button value="custom">自定义</el-radio-button>
</el-radio-group>
<div>
<div v-if="timeValue == 'custom'">
<el-date-picker v-model="query.createdAt" type="daterange" range-separator="至" start-placeholder="开始日期"
end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss"></el-date-picker>
end-placeholder="结束日期" value-format="YYYY-MM-DD"></el-date-picker>
</div>
<div>
<el-select v-model="shopId" v-if="isHeadShop == 1&& loginType == 0" placeholder="选择分店"
<el-select v-model="shopId" v-if="isHeadShop == 1 && loginType == 0" placeholder="选择分店"
style="width: 200px; margin-right: 10px">
<el-option v-for="item in branchList" :key="item.shopId" :label="item.shopName" :value="item.shopId" />
</el-select>
@@ -99,24 +99,27 @@
</template>
<script>
import _ from "lodash";
import tableSummaryApi from "@/api/order/table-summary";
import ShopApi from "@/api/account/shop";
import dayjs from "dayjs";
import { downloadFile } from "@/utils/index";
import { formatDateRange } from './utils/index.js'
export default {
data() {
return {
timeValue: "",
timeValue: "today",
resetQuery: null,
orderType: "1",
categorys: [],
query: {
createdAt: [],
createdAt: [dayjs().format("YYYY-MM-DD"), dayjs().format("YYYY-MM-DD")],
proName: "",
cateId: "",
},
tableData: {
totalList: [],
data: [],
page: 1,
size: 10,
@@ -129,8 +132,8 @@ export default {
shopId: null,
branchList: [],
isHeadShop: JSON.parse(localStorage.getItem("userInfo")).isHeadShop,
loginType: localStorage.getItem("loginType")
loginType: localStorage.getItem("loginType"),
shopInfo: JSON.parse(localStorage.getItem("userInfo"))
};
},
filters: {
@@ -196,23 +199,26 @@ export default {
// 分页回调
paginationChange(e) {
this.tableData.page = e;
this.getTableData();
this.tableData.data = this.tableData.totalList[this.tableData.page - 1] || [];
// this.getTableData();
},
async getTableData() {
this.tableData.loading = true;
try {
if (this.query.createdAt[1]) {
this.query.createdAt.splice(1, 1, this.query.createdAt[1].replace("00:00:00", "23:59:59"))
}
// if (this.query.createdAt[1]) {
// this.query.createdAt.splice(1, 1, this.query.createdAt[1].replace("00:00:00", "23:59:59"))
// }
const res = await tableSummaryApi.list({
page: this.tableData.page,
size: this.tableData.size,
// page: this.tableData.page,
// size: this.tableData.size,
rangeType: this.timeValue,
beginDate: this.query.createdAt[0],
endDate: this.query.createdAt[1],
shopId: this.shopId
shopId: this.shopInfo.id
});
this.tableData.loading = false;
this.tableData.data = res;
this.tableData.totalList = _.chunk(res, this.tableData.size);
this.tableData.data = this.tableData.totalList[this.tableData.page - 1] || [];
this.tableData.total = res.length;
} catch (error) {
console.log(error);
@@ -220,58 +226,7 @@ export default {
},
// 切换时间
timeChange(e) {
const format = ["YYYY-MM-DD 00:00:00", "YYYY-MM-DD 23:59:59"];
switch (e) {
case "":
// 全部
this.query.createdAt = [];
break;
case "0":
// 今天
this.query.createdAt = [dayjs().format(format[0]), dayjs().format(format[1])];
break;
case "-1":
// 昨天
this.query.createdAt = [
dayjs().add(-1, "d").format(format[0]),
dayjs().add(-1, "d").format(format[1]),
];
break;
case "-7":
// 最近7天
this.query.createdAt = [
dayjs().add(-7, "d").format(format[0]),
dayjs().format(format[1]),
];
break;
case "-30":
// 最近7天
this.query.createdAt = [
dayjs().add(-30, "d").format(format[0]),
dayjs().format(format[1]),
];
break;
case "week":
// 本周
this.query.createdAt = [
dayjs().startOf("week").format(format[0]),
dayjs().endOf("week").format(format[1]),
];
break;
case "month":
// 本周
this.query.createdAt = [
dayjs().startOf("month").format(format[0]),
dayjs().endOf("month").format(format[1]),
];
break;
case "custom":
// 自定义
this.query.createdAt = [];
break;
default:
break;
}
this.query.createdAt = formatDateRange(e)
},
},
};