From 3ae1ca33ba75f90ef643a19df6da6a6cd4c8fdd7 Mon Sep 17 00:00:00 2001 From: zchengo <1933757688@qq.com> Date: Tue, 3 Jan 2023 21:42:59 +0800 Subject: [PATCH] feat: customer industry distribution --- server/models/dashboard.go | 18 ++++++--- server/service/dashboard.go | 2 + web/src/views/Dashboard.vue | 73 +++++++++++++++++++++++++++++++------ 3 files changed, 76 insertions(+), 17 deletions(-) diff --git a/server/models/dashboard.go b/server/models/dashboard.go index 42cf68f..eff6684 100644 --- a/server/models/dashboard.go +++ b/server/models/dashboard.go @@ -1,10 +1,16 @@ package models type DashboardSum struct { - Customers int `json:"customers"` - Contracts int `json:"contracts"` - ContractAmount float64 `json:"contractAmount"` - Products int `json:"products"` - Date []string `json:"date"` - Amount []float64 `json:"amount"` + Customers int `json:"customers"` + Contracts int `json:"contracts"` + ContractAmount float64 `json:"contractAmount"` + Products int `json:"products"` + Date []string `json:"date"` + Amount []float64 `json:"amount"` + CustomerIndustry []*CustomerIndustry `json:"customerIndustry"` +} + +type CustomerIndustry struct { + Name string `json:"name"` + Value int `json:"value"` } diff --git a/server/service/dashboard.go b/server/service/dashboard.go index 386f0f8..741dfc4 100644 --- a/server/service/dashboard.go +++ b/server/service/dashboard.go @@ -28,6 +28,8 @@ func (d *DashboardService) Summary(uid int64, days int) models.DashboardSum { ds.Date[i] = time.Unix(day, 0).Format("01-02") d-- } + s := "industry as name, count(*) as value" + global.Db.Model(&models.Customer{}).Select(s).Where("creator = ?", uid).Group("industry").Find(&ds.CustomerIndustry) return ds } diff --git a/web/src/views/Dashboard.vue b/web/src/views/Dashboard.vue index bd9e36f..b42772b 100644 --- a/web/src/views/Dashboard.vue +++ b/web/src/views/Dashboard.vue @@ -63,8 +63,8 @@ - - + + 合同金额完成情况 @@ -75,13 +75,27 @@ - - 最近7天 - 最近14天 - 最近30天 - + + 最近7天 + 最近14天 + 最近30天 + - + + + + + + + 客户行业分布 + + + 客户所在行业,单位(个) + + + + + @@ -91,7 +105,7 @@