优化数据统计的传参以及部分展示字段以优化
This commit is contained in:
@@ -52,22 +52,23 @@
|
||||
<span>营业</span>
|
||||
</div>
|
||||
<div class="u-flex" style="flex-wrap: wrap">
|
||||
<el-select v-if="isHeadShop == 1&&loginType == 0" v-model="shopId" placeholder="选择分店" style="width: 200px; margin-right: 10px;" @change="shopChange">
|
||||
<el-select v-if="isHeadShop == 1 && loginType == 0" v-model="shopId" placeholder="选择分店"
|
||||
style="width: 200px; margin-right: 10px;" @change="shopChange">
|
||||
<el-option v-for="item in branchList" :key="item.shopId" :label="item.shopName" :value="item.shopId" />
|
||||
</el-select>
|
||||
<div class="time_wrap u-flex" style="flex-shrink: 0">
|
||||
<el-radio-group v-model="timeValue" class="m-r-5" @change="timeChange">
|
||||
<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="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 class="u-flex">
|
||||
<el-date-picker v-if="timeValue == 'custom'" v-model="query.createdAt" type="daterange"
|
||||
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD HH:mm:ss"
|
||||
range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期" value-format="YYYY-MM-DD"
|
||||
@change="summarytrade" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -309,13 +310,13 @@
|
||||
<el-table v-loading="saleTableLoading" :data="saleTable" style="width: 100%">
|
||||
<!-- <el-table-column label="排名" prop="productId"></el-table-column> -->
|
||||
<el-table-column label="商品名称" prop="productName" />
|
||||
<el-table-column label="数量" prop="number" />
|
||||
<el-table-column label="金额" prop="amount" />
|
||||
<el-table-column label="数量" prop="saleCount" />
|
||||
<el-table-column label="金额" prop="saleAmount" />
|
||||
</el-table>
|
||||
<div class="head-container" style="padding-top: 20px; display: flex; justify-content: flex-end">
|
||||
<!-- <div class="head-container" style="padding-top: 20px; display: flex; justify-content: flex-end">
|
||||
<el-pagination :total="saleTableTotal" :page-size="saleTableSize" :current-page="saleTablePage"
|
||||
layout="total, prev, pager, next, jumper" @current-change="paginationChange" />
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -342,6 +343,7 @@ import ShopApi from "@/api/account/shop";
|
||||
import dayjs from "dayjs";
|
||||
import * as echarts from "echarts";
|
||||
import { debounce, formatDecimal } from "@/utils/tools";
|
||||
import { formatDateRange } from './utils/index.js'
|
||||
export default {
|
||||
name: "home",
|
||||
data() {
|
||||
@@ -418,9 +420,9 @@ export default {
|
||||
productCountChart: null,
|
||||
productSumChart: null,
|
||||
lineChartType: 0,
|
||||
timeValue: "0",
|
||||
timeValue: "today",
|
||||
query: {
|
||||
createdAt: "",
|
||||
createdAt: [dayjs().format("YYYY-MM-DD"), dayjs().format("YYYY-MM-DD")],
|
||||
},
|
||||
tradeLoading: false,
|
||||
tradeSale: {
|
||||
@@ -429,7 +431,8 @@ export default {
|
||||
tradeVip: "",
|
||||
tradeCount: "",
|
||||
isHeadShop: JSON.parse(localStorage.getItem("userInfo")).isHeadShop,
|
||||
loginType: localStorage.getItem("loginType")
|
||||
loginType: localStorage.getItem("loginType"),
|
||||
shopInfo: JSON.parse(localStorage.getItem("userInfo")),
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -461,7 +464,7 @@ export default {
|
||||
this.dateAmount();
|
||||
this.dateProduct();
|
||||
// this.summaryDateGet();
|
||||
this.timeChange("0");
|
||||
this.timeChange(this.timeValue);
|
||||
|
||||
this.__resizeHandler = debounce(() => {
|
||||
if (this.saleChart) {
|
||||
@@ -495,67 +498,14 @@ export default {
|
||||
let res = await ShopApi.getBranchList()
|
||||
this.branchList = res;
|
||||
},
|
||||
shopChange(){
|
||||
shopChange() {
|
||||
this.summarytrade();
|
||||
this.lineChartTypeChange(this.lineChartType)
|
||||
this.dateProduct()
|
||||
},
|
||||
// 切换时间
|
||||
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 = [
|
||||
dayjs().add(-30, "d").format(format[0]),
|
||||
dayjs().format(format[1]),];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
this.query.createdAt = formatDateRange(e)
|
||||
if (e != "custom") {
|
||||
this.summarytrade();
|
||||
}
|
||||
@@ -564,13 +514,14 @@ export default {
|
||||
async summarytrade() {
|
||||
try {
|
||||
this.tradeLoading = true;
|
||||
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 dataSummaryApi.trade({
|
||||
beginDate: this.query.createdAt[0],
|
||||
endDate: this.query.createdAt[1],
|
||||
shopId: this.shopId
|
||||
rangeType: this.timeValue,
|
||||
shopId: this.shopInfo.id
|
||||
});
|
||||
this.trade = res;
|
||||
this.tradeLoading = false;
|
||||
@@ -894,22 +845,22 @@ export default {
|
||||
async dateAmount() {
|
||||
try {
|
||||
this.saleLoading = true;
|
||||
const res = await dataSummaryApi.dateAmount({ day: this.saleActive,shopId: this.shopId });
|
||||
const data = res.total.map((item) => {
|
||||
const res = await dataSummaryApi.dateAmount({ day: this.saleActive, shopId: this.shopId });
|
||||
const data = res.map((item) => {
|
||||
return {
|
||||
orderAmount: item.orderAmount,
|
||||
// actualAmount: item.actualAmount,
|
||||
// discountAmount: item.discountAmount
|
||||
};
|
||||
});
|
||||
const time = res.total.map((item) => item.tradeDay);
|
||||
const time = res.map((item) => item.tradeDay);
|
||||
this.initSaleChart(time, data);
|
||||
setTimeout(() => {
|
||||
this.saleLoading = false;
|
||||
}, 300);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
setTimeout(() => {
|
||||
this.saleLoading = false;
|
||||
}, 300);
|
||||
},
|
||||
paginationChange(e) {
|
||||
this.saleTablePage = e;
|
||||
@@ -921,13 +872,11 @@ export default {
|
||||
this.saleTableLoading = true;
|
||||
const res = await dataSummaryApi.productSaleDate({
|
||||
day: this.saleTableActive,
|
||||
page: this.saleTablePage,
|
||||
size: this.saleTableSize,
|
||||
shopId: this.shopId
|
||||
shopId: this.shopInfo.id,
|
||||
});
|
||||
this.saleTable = res.records;
|
||||
this.saleTableTotal = res.totalRow * 1;
|
||||
this.summaryDateGet(res.countList);
|
||||
this.saleTable = res;
|
||||
this.saleTableTotal = res.length;
|
||||
// this.summaryDateGet(res.countList);
|
||||
setTimeout(() => {
|
||||
this.saleTableLoading = false;
|
||||
}, 300);
|
||||
@@ -939,8 +888,8 @@ export default {
|
||||
async datePayType() {
|
||||
try {
|
||||
this.payChartLoading = true;
|
||||
const res = await dataSummaryApi.datePayType({ day: this.saleActive,shopId: this.shopId });
|
||||
const data = res.countPayType.map((item) => {
|
||||
const res = await dataSummaryApi.datePayType({ day: this.saleActive, shopId: this.shopInfo.id });
|
||||
const data = res.map((item) => {
|
||||
return {
|
||||
value: item.count,
|
||||
name: item.payType,
|
||||
|
||||
Reference in New Issue
Block a user