Commit 084e290c authored by 赵乐's avatar 赵乐

首页优化

parent e49cf676
...@@ -74,12 +74,7 @@ ...@@ -74,12 +74,7 @@
<div class="top top_2"> <div class="top top_2">
<div> <div>
<PieChart <PieChart :data="homeInfoKhxzdjzbqk" :total="200" tooltipTip="客户性质等级占比情况" />
:data="homeInfoKhxzdjzbqk"
:total="200"
tooltipTip="客户性质等级占比情况"
/>
</div> </div>
<div> <div>
<BarChart_1 <BarChart_1
...@@ -92,27 +87,13 @@ ...@@ -92,27 +87,13 @@
</div> </div>
<div class="top top_3"> <div class="top top_3">
<div> <div>
<PieChart <PieChart :data="homeInfoKhbffszbqk" :total="200" tooltipTip="客户拜访方式占比情况" />
:data="homeInfoKhbffszbqk"
:total="200"
tooltipTip="客户拜访方式占比情况"
/>
</div> </div>
<div> <div>
<PieChart <PieChart :data="homeInfoKhbmzbqk" :total="200" tooltipTip="客户部门占比情况" />
:data="homeInfoKhbmzbqk"
:total="200"
tooltipTip="客户部门占比情况"
/>
</div> </div>
<div> <div>
<PieChart <PieChart :data="homeInfoKhbflxzbqk" :total="200" tooltipTip="客户拜访类型占比情况" />
:data="homeInfoKhbflxzbqk"
:total="200"
tooltipTip="客户拜访类型占比情况"
/>
</div> </div>
</div> </div>
<BarChart_1 <BarChart_1
...@@ -212,7 +193,7 @@ const homeInfoBfrtjVal = ref('拜访日统计') ...@@ -212,7 +193,7 @@ const homeInfoBfrtjVal = ref('拜访日统计')
// 获取图表数据 // 获取图表数据
const getEcharts = async () => { const getEcharts = async () => {
error.value = '' error.value = ''
if (loading.value) return; // ✅ 防止重复调用 if (loading.value) return // ✅ 防止重复调用
loading.value = true loading.value = true
const params: any = { const params: any = {
...@@ -238,6 +219,20 @@ const getEcharts = async () => { ...@@ -238,6 +219,20 @@ const getEcharts = async () => {
}), }),
homesApi.getHomeInfoKhxzdjzbqk(params).then((res) => { homesApi.getHomeInfoKhxzdjzbqk(params).then((res) => {
if (res.list.length) {
const allNum = res.list.map((item) => item.value) // [20, 30]
const sum = allNum.reduce((acc, cur) => acc + cur, 0) // 50
res.list.forEach((item: any, index: number) => {
// 防御性获取 allNum 值
const allNumVal = allNum?.[index] ?? '未知'
// 避免除以 0
const ratio = sum !== 0 ? ((item.value / sum) * 100).toFixed(1) + '%' : '0%'
// 拼接名称(清晰分隔符)
item.name = `${item.name} ${allNumVal} ${ratio}`
})
}
homeInfoKhxzdjzbqk.value = res.list homeInfoKhxzdjzbqk.value = res.list
console.log('客户性质等级占比:', res.list) console.log('客户性质等级占比:', res.list)
}), }),
...@@ -248,21 +243,77 @@ const getEcharts = async () => { ...@@ -248,21 +243,77 @@ const getEcharts = async () => {
}), }),
homesApi.getHomeInfoKhbffszbqk(params).then((res) => { homesApi.getHomeInfoKhbffszbqk(params).then((res) => {
if (res.list.length) {
const allNum = res.list.map((item) => item.value) // [20, 30]
const sum = allNum.reduce((acc, cur) => acc + cur, 0) // 50
res.list.forEach((item: any, index: number) => {
// 防御性获取 allNum 值
const allNumVal = allNum?.[index] ?? '未知'
// 避免除以 0
const ratio = sum !== 0 ? ((item.value / sum) * 100).toFixed(1) + '%' : '0%'
// 拼接名称(清晰分隔符)
item.name = `${item.name} ${allNumVal} ${ratio}`
})
}
homeInfoKhbffszbqk.value = res.list homeInfoKhbffszbqk.value = res.list
console.log('客户拜访方式占比:', res) console.log('客户拜访方式占比:', res)
}), }),
homesApi.getHomeInfoKhbmzbqk(params).then((res) => { homesApi.getHomeInfoKhbmzbqk(params).then((res) => {
if (res.list.length) {
const allNum = res.list.map((item) => item.value) // [20, 30]
const sum = allNum.reduce((acc, cur) => acc + cur, 0) // 50
res.list.forEach((item: any, index: number) => {
// 防御性获取 allNum 值
const allNumVal = allNum?.[index] ?? '未知'
// 避免除以 0
const ratio = sum !== 0 ? ((item.value / sum) * 100).toFixed(1) + '%' : '0%'
// 拼接名称(清晰分隔符)
item.name = `${item.name} ${allNumVal} ${ratio}`
})
}
homeInfoKhbmzbqk.value = res.list homeInfoKhbmzbqk.value = res.list
console.log('客户部门占比:', res) console.log('客户部门占比:', res)
}), }),
homesApi.getHomeInfoKhbflxzbqk(params).then((res) => { homesApi.getHomeInfoKhbflxzbqk(params).then((res) => {
if (res.list.length) {
const allNum = res.list.map((item) => item.value) // [20, 30]
const sum = allNum.reduce((acc, cur) => acc + cur, 0) // 50
res.list.forEach((item: any, index: number) => {
// 防御性获取 allNum 值
const allNumVal = allNum?.[index] ?? '未知'
// 避免除以 0
const ratio = sum !== 0 ? ((item.value / sum) * 100).toFixed(1) + '%' : '0%'
// 拼接名称(清晰分隔符)
item.name = `${item.name} ${allNumVal} ${ratio}`
})
}
homeInfoKhbflxzbqk.value = res.list homeInfoKhbflxzbqk.value = res.list
console.log('客户拜访类型占比:', res) console.log('客户拜访类型占比:', res)
}), }),
homesApi.getHomeInfoBfcplxzbqk(params).then((res) => { homesApi.getHomeInfoBfcplxzbqk(params).then((res) => {
if (res.list.length) {
const allNum = res.list.map((item) => item.value) // [20, 30]
const sum = allNum.reduce((acc, cur) => acc + cur, 0) // 50
res.list.forEach((item: any, index: number) => {
// 防御性获取 allNum 值
const allNumVal = allNum?.[index] ?? '未知'
// 避免除以 0
const ratio = sum !== 0 ? ((item.value / sum) * 100).toFixed(1) + '%' : '0%'
// 拼接名称(清晰分隔符)
item.name = `${item.name} ${allNumVal} ${ratio}`
})
}
homeInfoBfcplxzbqk.value = res.list homeInfoBfcplxzbqk.value = res.list
console.log('拜访产品类型占比:', res) console.log('拜访产品类型占比:', res)
}) })
......
...@@ -87,14 +87,14 @@ const chartOption = computed(() => { ...@@ -87,14 +87,14 @@ const chartOption = computed(() => {
name: props.tooltipTip, name: props.tooltipTip,
type: 'pie', type: 'pie',
radius: ['40%', '70%'], // 环形图内外半径 radius: ['40%', '70%'], // 环形图内外半径
center: ['35%', '50%'], // 图表中心位置,留出右侧图例空间 center: ['30%', '50%'], // 图表中心位置,留出右侧图例空间
label: { label: {
show: false // 隐藏饼图扇区默认标签 show: false // 隐藏饼图扇区默认标签
}, },
labelLine: { labelLine: {
show: false // 隐藏标签连线 show: false // 隐藏标签连线
}, },
data: props.data.map((item) => ({ data: props.data.map((item:any) => ({
name: item.name, name: item.name,
value: item.value, value: item.value,
itemStyle: { itemStyle: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment