Commit 4afc657d by Lin

feat: 策略分析看板类型分布接口联调

1 parent de2ecc49
......@@ -10,29 +10,20 @@
<div class="top-content">
<div class="kpi-row">
<el-row :gutter="20">
<el-col :span="12">
<div class="kpi-bg-wrapper">
<div class="kpi-card-content">
<div class="kpi-label">策略总数</div>
<div class="kpi-value">
3456
<span style="font-size: 16px; color: #2A58AD;">个</span>
</div>
<div class="kpi-sub">
本月策略总数 <span class="trend-up">200个 </span>
</div>
</div>
</div>
</el-col>
<el-col :span="12">
<el-col
v-for="(item, index) in kpiList"
:key="index"
:span="getKpiColSpan"
>
<div class="kpi-bg-wrapper">
<div class="kpi-card-content">
<div class="kpi-label">门店总数</div>
<div class="kpi-label">{{ item.label }}</div>
<div class="kpi-value">
567 <span style="font-size: 16px; color: #2A58AD;">家</span>
{{ item.value }}
<span style="font-size: 16px; color: #2A58AD;">{{ item.unit }}</span>
</div>
<div class="kpi-sub">
本月门店总数 <span class="trend-up">200个</span>
{{ item.subLabel }} <span :class="item.trendClass">{{ item.subValue }}</span>
</div>
</div>
</div>
......@@ -174,6 +165,7 @@
:get-list-api="getListApi"
:before-search-fn="beforeSearchFn"
@pageChange="handlePageChange"
:has-page="false"
>
<div slot="areaOperator" slot-scope="scope">
......@@ -196,8 +188,9 @@
import HeaderCustom from '../strategyCentre/compoments/headerCustom.vue';
import SelectCustom from '../strategyCentre/compoments/selectCustom.vue';
import * as echarts from 'echarts';
import { getBIMatterList } from "@/api/earlyWarningManager";
import { getBIMatterList,getStrategyTotal,getStrategyTypeDist } from "@/api/earlyWarningManager";
import { Util, deepClone } from "@/common/util";
import dayjs from 'dayjs';
export default {
name: 'strategyAnalysis',
......@@ -207,12 +200,36 @@ export default {
},
data() {
return {
currentTab: {label:'延保',value:0},
currentTab: {label:'延保',value:1},
tabs: [
{label:'延保',value:0},
{label:'延保',value:1},
],
// KPI 指标数据列表
kpiList: [
{
label: '策略总数',
value: 3456,
unit: '个',
subLabel: '本月策略总数',
subValue: '200个',
trendClass: 'trend-up'
},
{
label: '门店总数',
value: 567,
unit: '家',
subLabel: '本月门店总数',
subValue: '200个',
trendClass: 'trend-up'
}
],
operatorFilter: 'all',
myChart: null,
// 日期范围
startDate: dayjs().startOf('month').format('YYYY-MM-DD'),
endDate: dayjs().format('YYYY-MM-DD'),
// 策略总数数据
strategyTotalData: null,
// 运营人员列表
operatorList: [
{ label: '全部', value: 'all' },
......@@ -406,6 +423,10 @@ export default {
window.addEventListener('resize', this.resizeChart);
// 启用页面滚动
this.enablePageScroll();
// 调用策略总数接口
this.fetchStrategyTotal();
// 调用策略类型分布接口
this.fetchStrategyTypeDist();
},
beforeDestroy() {
if (this.myChart) {
......@@ -424,7 +445,7 @@ export default {
* 处理运营人员选择变化
*/
handleOperatorChange(value) {
this.updateChartData(value);
this.fetchStrategyTypeDist();
},
/**
* 更新图表数据
......@@ -592,6 +613,61 @@ export default {
this.currentIndicatorType = item.label;
// 这里可以触发数据更新逻辑
console.log('选择指标类型:', item.label);
},
/**
* 获取策略总数
*/
async fetchStrategyTotal() {
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: 1
};
const res = await getStrategyTotal(params);
if (res && res.code === 200) {
this.strategyTotalData = res.data;
// 可以在这里处理返回的数据,更新页面显示
console.log('策略总数数据:', this.strategyTotalData);
}
} catch (error) {
console.error('获取策略总数失败:', error);
}
},
/**
* 获取策略类型分布
*/
async fetchStrategyTypeDist() {
try {
const params = {
startDate: this.startDate,
endDate: this.endDate,
businessType: this.currentTab.value,
uuid: this.operatorFilter
};
const res = await getStrategyTypeDist(params);
// 处理返回的数据,更新图表
if (res.data && Array.isArray(res.data)) {
// 计算总数和百分比
const total = res.data.reduce((sum, item) => sum + (item.value || item.count || 0), 0);
const processedData = res.data.map((item, index) => {
const value = item.value || item.count || 0;
const percent = total > 0 ? Math.round((value / total) * 100) : 0;
// 使用预设的颜色,如果没有则使用默认颜色
const colors = ['#409EFF', '#36CBCB', '#67C23A', '#B3E19D', '#E6A23C', '#FFD666', '#9254DE'];
return {
name: item.name || item.typeName || `类型${index + 1}`,
value: value,
percent: percent,
color: item.color || colors[index % colors.length]
};
});
this.pieData = processedData;
this.updateChart();
}
} catch (error) {
console.error('获取策略类型分布失败:', error);
}
}
}
};
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!