From 980f0357c171322ee044cf6af43c757ac8852644 Mon Sep 17 00:00:00 2001
From: gyq <875626088@qq.com>
Date: Mon, 24 Nov 2025 16:37:49 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=95=B0=E6=8D=AE=E7=BB=9F?=
=?UTF-8?q?=E8=AE=A1=E7=9A=84=E4=BC=A0=E5=8F=82=E4=BB=A5=E5=8F=8A=E9=83=A8?=
=?UTF-8?q?=E5=88=86=E5=B1=95=E7=A4=BA=E5=AD=97=E6=AE=B5=E4=BB=A5=E4=BC=98?=
=?UTF-8?q?=E5=8C=96?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/views/data/index.vue | 127 ++++++--------------
src/views/data/sales.vue | 97 ++++-----------
src/views/data/table.vue | 103 +++++-----------
src/views/data/utils/index.js | 50 ++++++++
src/views/order/index/components/detail.vue | 13 +-
5 files changed, 151 insertions(+), 239 deletions(-)
create mode 100644 src/views/data/utils/index.js
diff --git a/src/views/data/index.vue b/src/views/data/index.vue
index cf1dfec..92809fd 100644
--- a/src/views/data/index.vue
+++ b/src/views/data/index.vue
@@ -52,22 +52,23 @@
营业
-
+
- 今天
- 昨天
- 最近7天
- 最近30天
- 本周
- 本月
+ 今天
+ 昨天
+ 最近7天
+ 最近30天
+ 本周
+ 本月
自定义
@@ -309,13 +310,13 @@
-
-
+
+
-
+
@@ -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,
diff --git a/src/views/data/sales.vue b/src/views/data/sales.vue
index 425af50..b36c63d 100644
--- a/src/views/data/sales.vue
+++ b/src/views/data/sales.vue
@@ -11,7 +11,7 @@
-
+
@@ -25,13 +25,13 @@
- 全部
- 今天
- 昨天
- 最近7天
- 最近30天
- 本周
- 本月
+
+ 今天
+ 昨天
+ 最近7天
+ 最近30天
+ 本周
+ 本月
自定义