|
@@ -12,7 +12,7 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
<ul class="login-info">
|
|
|
- <li>上次登录时间:<span>2008-12-12</span></li>
|
|
|
+ <li>当前时间:<span>{{this.time}}</span></li>
|
|
|
<li>上次登录地址:<span>日本-我孙子市</span></li>
|
|
|
</ul>
|
|
|
</el-card>
|
|
@@ -71,10 +71,16 @@
|
|
|
|
|
|
<script>
|
|
|
import * as echarts from "echarts";
|
|
|
-
|
|
|
+import * as DateUtil from "/src/utils/DateUtil";
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ user:[], //用户本地信息
|
|
|
+ XYData:{monthX:[],barProductNames:[],
|
|
|
+ barLastMonthAmount:[],barLastMonthCount:[], //上月
|
|
|
+ barCurMonthAmount:[] ,barCurMonthCount:[] // 本月
|
|
|
+ }, //月份X轴 | 产品列表 |
|
|
|
+ YMax:{saleMax:0}, //店铺营销额Y轴
|
|
|
labelToday:{
|
|
|
productName:"商品名称",
|
|
|
productTypeName:"商品类型",
|
|
@@ -82,6 +88,8 @@ export default {
|
|
|
amount: "今日金额",
|
|
|
},
|
|
|
todayData:[], // 当天的订单列表
|
|
|
+ factData:[],
|
|
|
+ pieData:[],
|
|
|
countData: [
|
|
|
{
|
|
|
name: "今日支付订单",
|
|
@@ -120,10 +128,14 @@ export default {
|
|
|
color: "#5ab1ef",
|
|
|
},
|
|
|
],
|
|
|
+ time:new Date(),
|
|
|
};
|
|
|
},
|
|
|
- mounted() {
|
|
|
- this.loadData()
|
|
|
+
|
|
|
+ async mounted() {
|
|
|
+
|
|
|
+ this.user = JSON.parse(localStorage.getItem('xm-user') || '{}') // 重新获取下用户的最新信息
|
|
|
+ await this.loadData()
|
|
|
// 基于准备好的dom,初始化echarts实例
|
|
|
var bar = echarts.init(document.getElementById("bar"));
|
|
|
var pie = echarts.init(document.getElementById("pie"));
|
|
@@ -188,27 +200,14 @@ export default {
|
|
|
interval: 0, //设置 X 轴数据间隔几个显示一个,为0表示都显示
|
|
|
},
|
|
|
boundaryGap: false, //数据从 Y 轴起始
|
|
|
- data: [
|
|
|
- "1月",
|
|
|
- "2月",
|
|
|
- "3月",
|
|
|
- "4月",
|
|
|
- "5月",
|
|
|
- "6月",
|
|
|
- "7月",
|
|
|
- "8月",
|
|
|
- "9月",
|
|
|
- "10月",
|
|
|
- "11月",
|
|
|
- "12月",
|
|
|
- ],
|
|
|
+ data: this.XYData.monthX,
|
|
|
},
|
|
|
|
|
|
yAxis: {
|
|
|
- name: "人次",
|
|
|
+ name: "金额",
|
|
|
type: "value",
|
|
|
min: 0, // 配置 Y 轴刻度最小值
|
|
|
- max: 4000, // 配置 Y 轴刻度最大值
|
|
|
+ max: this.YMax.saleMax, // 配置 Y 轴刻度最大值
|
|
|
splitNumber: 7, // 配置 Y 轴数值间隔
|
|
|
axisLine: {
|
|
|
lineStyle: {
|
|
@@ -260,7 +259,7 @@ export default {
|
|
|
|
|
|
{
|
|
|
name: "实际",
|
|
|
- data: this.randomList(120,1200,12),
|
|
|
+ data: this.factData,
|
|
|
type: "line",
|
|
|
symbol: "circle", // 实心圆点
|
|
|
smooth: 0.5, // 设置折线弧度
|
|
@@ -294,12 +293,12 @@ export default {
|
|
|
dataset: {
|
|
|
source: [
|
|
|
["quarter", "一季度", "二季度", "三季度", "四季度"],
|
|
|
- ["完美世界", 25.74, 25.7, 29.18, 21.58],
|
|
|
+ ["销售金额", ...this.pieData],
|
|
|
],
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
- name: "完美世界",
|
|
|
+ name: "销售金额",
|
|
|
type: "pie",
|
|
|
seriesLayoutBy: "row",
|
|
|
encode: {
|
|
@@ -321,10 +320,10 @@ export default {
|
|
|
color: ["#9462e5", "#e1bb22"],
|
|
|
tooltip: {},
|
|
|
legend: {
|
|
|
- data: ["销量", "退货"],
|
|
|
+ data: ["上月金额", "本月金额"],
|
|
|
},
|
|
|
xAxis: {
|
|
|
- data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
|
|
|
+ data: this.XYData.barProductNames , //["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
|
|
|
},
|
|
|
yAxis: {
|
|
|
axisLine: {
|
|
@@ -342,14 +341,14 @@ export default {
|
|
|
},
|
|
|
series: [
|
|
|
{
|
|
|
- name: "销量",
|
|
|
+ name: "上月金额",
|
|
|
type: "bar",
|
|
|
- data: [550, 120, 336, 110, 430, 420],
|
|
|
+ data: this.XYData.barLastMonthAmount,//[550, 120, 336, 110, 430, 420]
|
|
|
},
|
|
|
{
|
|
|
- name: "退货",
|
|
|
+ name: "本月金额",
|
|
|
type: "bar",
|
|
|
- data: [155, 20, 36, 30, 90, 140],
|
|
|
+ data: this.XYData.barCurMonthAmount,//[155, 20, 36, 30, 90, 140]
|
|
|
},
|
|
|
],
|
|
|
});
|
|
@@ -365,13 +364,28 @@ export default {
|
|
|
/**
|
|
|
* 数据加载
|
|
|
*/
|
|
|
- loadData(){
|
|
|
+ async loadData() {
|
|
|
const that = this
|
|
|
+ async function f1() {
|
|
|
+ that.todayData = await that.loadAccountByBatch([1, 2], "2024-01-01", "2024-05-03")
|
|
|
|
|
|
- async function f1(){
|
|
|
- that.todayData = await that.loadAccountByBatch([1,2],"2024-01-01","2024-05-03")
|
|
|
+ // 加载月销量数据
|
|
|
+ const monthAndSeason = await that.loadFactData();
|
|
|
+ that.factData = monthAndSeason["monthAccount"]
|
|
|
+ that.updateMonthList(that.factData.length) //更新营销表的X轴
|
|
|
+ that.YMax.saleMax = that.factData.max
|
|
|
+ that.pieData = monthAndSeason["seasonAccount"]
|
|
|
+
|
|
|
+ const {lastMonth,lastTwoMonth,curMonth} = await that.loadAllSaleCondition() // 获取所有产品的销售信息
|
|
|
+ that.XYData.barLastMonthAmount = lastMonth.map(item=>item.amount);
|
|
|
+ that.XYData.barLastMonthCount = lastMonth.map(item=>item.count);
|
|
|
+ that.XYData.barCurMonthAmount = curMonth.map(item=>item.amount);
|
|
|
+ that.XYData.barCurMonthCount = curMonth.map(item=>item.count);
|
|
|
+ that.XYData.barProductNames=lastMonth.map(item=>item.productName);
|
|
|
+ console.log(lastMonth)
|
|
|
}
|
|
|
- f1();
|
|
|
+
|
|
|
+ await f1();
|
|
|
},
|
|
|
async loadAccountByPId(productId){
|
|
|
const res = await this.$request.get("/saleStatement/getByPId",{
|
|
@@ -380,10 +394,8 @@ export default {
|
|
|
timeStart: "2024-04-28",
|
|
|
timeOver: "2024-05-03"
|
|
|
}})
|
|
|
- // this.$message(res.data[0].count + "")
|
|
|
},
|
|
|
async loadAccountByBatch( list,from,end){
|
|
|
- console.log("1")
|
|
|
const res = await this.$request.post("/saleStatement/getByPIdBatch",{
|
|
|
productIds:list,
|
|
|
timeStart: from,
|
|
@@ -391,6 +403,33 @@ export default {
|
|
|
})
|
|
|
return res.data;
|
|
|
},
|
|
|
+ async loadFactData(){// 加载月销量数据和
|
|
|
+ const res = await this.$request.post("/saleStatement/getAllSeasonSale",{
|
|
|
+ shopId:this.user?.storeId,
|
|
|
+ timeStart: DateUtil.getLastYearEndDate(),
|
|
|
+ timeOver:DateUtil.getCurrentDate()
|
|
|
+ })
|
|
|
+ console.log(res.data,"FactData")
|
|
|
+ return res.data;
|
|
|
+ },
|
|
|
+ async loadAllSaleCondition(){ // 本月售卖情况
|
|
|
+ const res = await this.$request.get(`/saleStatement/getShopPdAccount/${this.user?.storeId}`,{
|
|
|
+ params:{
|
|
|
+ timeStart: DateUtil.getLastMonthStartDate(),
|
|
|
+ timeOver: DateUtil.getLastMonthEndDate()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ const resCur = await this.$request.get(`/saleStatement/getShopPdAccount/${this.user?.storeId}`,{
|
|
|
+ params:{
|
|
|
+ timeStart:DateUtil.getLastMonthEndDate() ,
|
|
|
+ timeOver: DateUtil.getCurrentDate()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ return {
|
|
|
+ curMonth:resCur.data,
|
|
|
+ lastMonth:res.data,
|
|
|
+ };
|
|
|
+ },
|
|
|
/** 随机left ~ right 范围内的数字 @param left @param right @returns {*} */
|
|
|
randomRange(left,right){
|
|
|
const floor = Math.floor(right-left);
|
|
@@ -402,6 +441,11 @@ export default {
|
|
|
for(let i = 0;i<nums;i++)
|
|
|
res.push(this.randomRange(left,right))
|
|
|
return res;
|
|
|
+ },
|
|
|
+ updateMonthList(end){
|
|
|
+ const res =[];
|
|
|
+ for(let i = 1;i<=end;i++){res.push(i+"月")}
|
|
|
+ this.XYData.monthX = res;
|
|
|
}
|
|
|
}
|
|
|
|