Commit 0a403c723059b7700c271a0f87603990a6fc92ce

Authored by “wangming”
1 parent 1c42c4b4

修复领导驾驶舱时间参数传递问题

- 修复营收与服务产出趋势分析的时间参数传递
- 修复业务统计数据接口的时间参数格式
- 确保时间参数正确传递到后端,避免时区转换问题
antis-ncc-admin/src/views/statisticsList/form9.vue
1 1 <template>
2   - <div class="business-report-page">
3   - <!-- 筛选条件 -->
4   - <div class="search-box-container">
5   - <el-card shadow="never">
6   - <el-form @submit.native.prevent :inline="true" class="search-form">
  2 + <div class="leadership-cockpit">
  3 + <!-- 顶部状态栏 & 筛选器 -->
  4 + <div class="cockpit-header">
  5 + <div class="header-left">
  6 + <h1 class="page-title">领导驾驶舱 <span class="subtitle">本月经营动态监测</span></h1>
  7 + </div>
  8 + <div class="header-right">
  9 + <el-form :inline="true" class="search-form-compact">
7 10 <el-form-item label="时间范围">
8   - <el-date-picker
9   - v-model="query.startTime"
10   - type="datetime"
11   - value-format="yyyy-MM-dd HH:mm:ss"
12   - format="yyyy-MM-dd HH:mm:ss"
13   - placeholder="开始时间"
14   - style="width: 220px;"
15   - />
16   - <span style="margin: 0 10px;">-</span>
17   - <el-date-picker
18   - v-model="query.endTime"
19   - type="datetime"
20   - value-format="yyyy-MM-dd HH:mm:ss"
21   - format="yyyy-MM-dd HH:mm:ss"
22   - placeholder="结束时间"
23   - style="width: 220px;"
24   - />
  11 + <el-date-picker v-model="query.month" type="month" value-format="yyyy-MM" placeholder="选择年月" size="mini"
  12 + style="width: 150px;" @change="handleMonthChange" />
25 13 </el-form-item>
26 14 <el-form-item label="门店">
27   - <el-select
28   - v-model="query.storeIds"
29   - multiple
30   - collapse-tags
31   - placeholder="全部门店"
32   - filterable
33   - style="width: 300px;">
34   - <el-option
35   - v-for="store in storeOptions"
36   - :key="store.id"
37   - :label="store.dm"
  15 + <el-select v-model="query.storeIds" multiple collapse-tags placeholder="全部门店" filterable clearable
  16 + size="mini" style="width: 180px;">
  17 + <el-option v-for="store in storeOptions" :key="store.id" :label="store.fullName || store.dm"
38 18 :value="store.id">
39 19 </el-option>
40 20 </el-select>
41 21 </el-form-item>
42 22 <el-form-item>
43   - <el-button type="primary" icon="el-icon-search" @click="search()">查询</el-button>
44   - <!-- <el-button icon="el-icon-refresh-right" @click="reset()">重置</el-button> -->
  23 + <el-button type="primary" size="mini" icon="el-icon-refresh" @click="search()">更新看板</el-button>
45 24 </el-form-item>
46 25 </el-form>
47   - </el-card>
  26 + </div>
48 27 </div>
49 28  
50   - <!-- 第一个报表:业务统计仪表盘 -->
51   - <el-card shadow="never" class="report-card" v-loading="loading1">
52   - <div slot="header" class="card-header">
53   - <i class="el-icon-data-analysis"></i>
54   - <span>业务统计</span>
55   - </div>
56   - <div class="gauge-dashboard" v-if="businessData">
57   - <div class="gauge-item-wrapper" v-for="(item, index) in gaugeItems" :key="index">
58   - <div class="gauge-item">
59   - <div class="gauge-chart-container">
60   - <div :id="`gaugeChart${index + 1}`" class="gauge-chart"></div>
61   - <div class="gauge-value-overlay">
62   - <div class="gauge-value-large">{{ item.displayValue }}</div>
63   - <div class="gauge-label-text">{{ item.title }}</div>
64   - </div>
  29 + <!-- 第一层:核心 KPI 指标 (6个) -->
  30 + <el-row :gutter="16" class="kpi-row">
  31 + <el-col :span="4" v-for="(kpi, index) in kpiList" :key="index">
  32 + <div class="kpi-card" :class="kpi.type">
  33 + <div class="kpi-icon"><i :class="kpi.icon"></i></div>
  34 + <div class="kpi-info">
  35 + <div class="kpi-label">{{ kpi.label }}</div>
  36 + <div class="kpi-value">
  37 + <span class="unit" v-if="kpi.isMoney">¥</span>
  38 + {{ kpi.value }}
  39 + <span class="unit" v-if="kpi.isPercent">%</span>
  40 + </div>
  41 + <div class="kpi-trend" v-if="kpi.target">
  42 + 目标: {{ kpi.target }} <i class="el-icon-top" v-if="kpi.status === 'up'"></i>
65 43 </div>
66 44 </div>
67 45 </div>
68   - </div>
69   - </el-card>
70   -
71   - <!-- 第二个报表:客户类型统计 -->
72   - <el-card shadow="never" class="report-card" v-loading="loading2">
73   - <div slot="header" class="card-header">
74   - <i class="el-icon-user"></i>
75   - <span>客户类型统计</span>
76   - </div>
77   - <div class="customer-stats-container" v-if="customerData">
78   - <div class="stats-grid">
79   - <div class="stat-card stat-card-purple">
80   - <div class="stat-icon">
81   - <i class="el-icon-star-on"></i>
82   - </div>
83   - <div class="stat-content">
84   - <div class="stat-label">拓客总人数</div>
85   - <div class="stat-value">{{ customerData.TotalInviteCount || 0 }}</div>
86   - </div>
  46 + </el-col>
  47 + </el-row>
  48 +
  49 + <!-- 第二层:深度分析区 (趋势 + 流量) -->
  50 + <el-row :gutter="16" class="analysis-row">
  51 + <!-- 营收/消耗趋势 -->
  52 + <el-col :span="16">
  53 + <el-card class="dashboard-card" shadow="hover">
  54 + <div slot="header" class="card-title">
  55 + <span><i class="el-icon-data-line"></i> 营收与服务产出趋势分析</span>
  56 + <el-radio-group v-model="trendType" size="mini" style="float: right" @change="handleTrendTypeChange">
  57 + <el-radio-button label="month">按月</el-radio-button>
  58 + <el-radio-button label="day">按天</el-radio-button>
  59 + <el-radio-button label="week">按周</el-radio-button>
  60 + </el-radio-group>
87 61 </div>
88   - <div class="stat-card stat-card-blue">
89   - <div class="stat-icon">
90   - <i class="el-icon-s-custom"></i>
91   - </div>
92   - <div class="stat-content">
93   - <div class="stat-label">新客数量</div>
94   - <div class="stat-value">{{ customerData.NewCustomerCount || 0 }}</div>
95   - </div>
  62 + <div id="revenueTrendChart" class="chart-box"></div>
  63 + </el-card>
  64 + </el-col>
  65 + <!-- 转化漏斗 -->
  66 + <el-col :span="8">
  67 + <el-card class="dashboard-card funnel-card" shadow="hover">
  68 + <div slot="header" class="card-title">
  69 + <span><i class="el-icon-filter"></i> 拓客全链路转化漏斗</span>
96 70 </div>
97   - <div class="stat-card stat-card-cyan">
98   - <div class="stat-icon">
99   - <i class="el-icon-user-solid"></i>
100   - </div>
101   - <div class="stat-content">
102   - <div class="stat-label">散客数</div>
103   - <div class="stat-value">{{ customerData.CasualCustomerCount || 0 }}</div>
104   - </div>
  71 + <div id="tkFunnelChart" class="chart-box"></div>
  72 + <div class="funnel-stats">
  73 + <div class="stat-mini">邀约率: <span>{{ formatPercent(getTkInviteRate()) }}%</span></div>
  74 + <div class="stat-mini">到店率: <span>{{ formatPercent(getInviteStoreRate()) }}%</span></div>
105 75 </div>
106   - <div class="stat-card stat-card-green">
107   - <div class="stat-icon">
108   - <i class="el-icon-user"></i>
109   - </div>
110   - <div class="stat-content">
111   - <div class="stat-label">会员数</div>
112   - <div class="stat-value">{{ customerData.MemberCount || 0 }}</div>
  76 + </el-card>
  77 + </el-col>
  78 + </el-row>
  79 +
  80 + <!-- 第三层:竞技排行区 (4个维度) -->
  81 + <el-row :gutter="16" class="ranking-row">
  82 + <!-- 门店排行榜 -->
  83 + <el-col :span="6">
  84 + <el-card class="dashboard-card" shadow="hover">
  85 + <div slot="header" class="card-title"><span><i class="el-icon-office-building"></i> 门店业绩琅琊榜</span></div>
  86 + <div class="rank-list">
  87 + <div class="rank-item" v-for="(item, idx) in storeRanking" :key="idx">
  88 + <span class="rank-no" :class="'top' + (idx + 1)">{{ idx + 1 }}</span>
  89 + <span class="rank-name">{{ item.StoreName }}</span>
  90 + <span class="rank-val">¥{{ formatMoney(item.TotalPerformance) }}</span>
113 91 </div>
114 92 </div>
115   - <!-- <div class="stat-card stat-card-orange">
116   - <div class="stat-icon">
117   - <i class="el-icon-goods"></i>
118   - </div>
119   - <div class="stat-content">
120   - <div class="stat-label">消耗数</div>
121   - <div class="stat-value">{{ customerData.ConsumeCount || 0 }}</div>
122   - </div>
123   - </div> -->
124   - <div class="conversion-rate-card">
125   - <div class="donut-wrapper">
126   - <div class="donut-chart" :style="getDonutStyle(customerData.MemberCount / customerData.TotalInviteCount)">
127   - <div class="donut-center">
128   - <div class="conversion-title">会员转化率</div>
129   - <div class="percentage">{{ formatPercent((customerData.MemberCount / customerData.TotalInviteCount) * 100) }}%</div>
130   - </div>
131   - </div>
132   - </div>
  93 + </el-card>
  94 + </el-col>
  95 + <!-- 健康师排行 (开单/消耗) -->
  96 + <el-col :span="12">
  97 + <el-card class="dashboard-card" shadow="hover">
  98 + <div slot="header" class="card-title">
  99 + <span><i class="el-icon-user"></i> 核心员效贡献矩阵</span>
  100 + <el-button-group style="float: right">
  101 + <el-button size="mini" :type="coachRankType === 'billing' ? 'primary' : ''"
  102 + @click="coachRankType = 'billing'">开单榜</el-button>
  103 + <el-button size="mini" :type="coachRankType === 'consume' ? 'primary' : ''"
  104 + @click="coachRankType = 'consume'">消耗榜</el-button>
  105 + <el-button size="mini" :type="coachRankType === 'refund' ? 'primary' : ''"
  106 + @click="coachRankType = 'refund'">客情警告</el-button>
  107 + </el-button-group>
133 108 </div>
134   - </div>
135   - </div>
136   - </el-card>
137   -
138   - <!-- 第三个和第四个报表:并排显示 -->
139   - <div class="charts-row">
140   - <!-- 第三个报表:门店业绩对比(柱状图) -->
141   - <el-card shadow="never" class="report-card half-width" v-loading="loading3">
142   - <div slot="header" class="card-header">
143   - <i class="el-icon-trophy"></i>
144   - <span>门店业绩对比</span>
145   - </div>
146   - <div
147   - id="storePerformanceChart"
148   - class="chart-container-half"
149   - v-if="performanceData && performanceData.length > 0">
150   - </div>
151   - </el-card>
152   -
153   - <!-- 第四个报表:品项统计对比(蝴蝶图) -->
154   - <el-card shadow="never" class="report-card half-width" v-loading="loading4">
155   - <div slot="header" class="card-header">
156   - <i class="el-icon-goods"></i>
157   - <span>品项统计对比</span>
158   - </div>
159   - <div class="butterfly-chart-container" v-if="itemStatisticsData && itemStatisticsData.length > 0">
160   - <!-- 图例 -->
161   - <div class="chart-legend">
162   - <div class="legend-item">
163   - <span class="legend-color legend-purple"></span>
164   - <span class="legend-text">开单金额</span>
165   - </div>
166   - <div class="legend-item">
167   - <span class="legend-color legend-orange"></span>
168   - <span class="legend-text">消耗金额</span>
  109 + <el-table :data="coachRanking" size="mini" style="width: 100%">
  110 + <el-table-column type="index" label="排名" width="50"></el-table-column>
  111 + <el-table-column prop="HealthCoachName" label="健康师"></el-table-column>
  112 + <el-table-column prop="Amount" label="业绩" align="right">
  113 + <template slot-scope="scope">¥{{ formatMoney(scope.row.Amount) }}</template>
  114 + </el-table-column>
  115 + <el-table-column label="占比" width="100">
  116 + <template slot-scope="scope">
  117 + <el-progress :percentage="scope.row.Percent" :show-text="false" :stroke-width="6"
  118 + :color="idx === 0 ? '#f56c6c' : '#409eff'"></el-progress>
  119 + </template>
  120 + </el-table-column>
  121 + </el-table>
  122 + </el-card>
  123 + </el-col>
  124 + <!-- 金三角排名 -->
  125 + <el-col :span="6">
  126 + <el-card class="dashboard-card" shadow="hover">
  127 + <div slot="header" class="card-title"><span><i class="el-icon-medal"></i> 金三角战队协同榜</span></div>
  128 + <div class="rank-list">
  129 + <div class="rank-item" v-for="(item, idx) in goldTriangleRankingTop10" :key="idx">
  130 + <span class="rank-no" :class="'top' + (idx + 1)">{{ idx + 1 }}</span>
  131 + <span class="rank-name">{{ item.GoldTriangleName }}</span>
  132 + <span class="rank-val">¥{{ formatMoney(item.TotalPerformance) }}</span>
169 133 </div>
170 134 </div>
171   -
172   - <!-- 图表内容 -->
173   - <div class="butterfly-chart-content">
174   - <div class="chart-left">
175   - <div
176   - v-for="(item, index) in sortedItemData"
177   - :key="index"
178   - class="chart-row">
179   - <div
180   - class="bar-left"
181   - :style="{width: getButterflyBarWidth(item.BillingAmount, maxValue) + '%'}">
182   - <span class="bar-value">{{ item.BillingAmount || 0 }}</span>
183   - </div>
184   - </div>
185   - </div>
186   -
187   - <div class="chart-center">
188   - <div
189   - v-for="(item, index) in sortedItemData"
190   - :key="index"
191   - class="category-name">
192   - {{ item.ItemName || item.ItemId }}
193   - </div>
194   - </div>
195   -
196   - <div class="chart-right">
197   - <div
198   - v-for="(item, index) in sortedItemData"
199   - :key="index"
200   - class="chart-row">
201   - <div
202   - class="bar-right"
203   - :style="{width: getButterflyBarWidth(item.ConsumeAmount, maxValue) + '%'}">
204   - <span class="bar-value">{{ item.ConsumeAmount || 0 }}</span>
205   - </div>
206   - </div>
  135 + </el-card>
  136 + </el-col>
  137 + </el-row>
  138 +
  139 + <!-- 第四层:细节洞察 (客情、项目、结构) -->
  140 + <el-row :gutter="16" class="insight-row">
  141 + <!-- 到店频次 -->
  142 + <el-col :span="8">
  143 + <el-card class="dashboard-card" shadow="hover">
  144 + <div slot="header" class="card-title"><span><i class="el-icon-view"></i> 会员到店频次分布</span></div>
  145 + <div id="visitFreqChart" class="chart-box"></div>
  146 + </el-card>
  147 + </el-col>
  148 + <!-- 消耗品项TOP10 -->
  149 + <el-col :span="8">
  150 + <el-card class="dashboard-card" shadow="hover">
  151 + <div slot="header" class="card-title"><span><i class="el-icon-present"></i> 消耗品项 TOP 10</span></div>
  152 + <div class="item-rank">
  153 + <div class="item-rank-row" v-for="(item, idx) in consumeItemTop10" :key="idx">
  154 + <span class="item-index">{{ idx + 1 }}</span>
  155 + <span class="item-name">{{ item.ItemName }}</span>
  156 + <el-progress :percentage="item.Percent" :stroke-width="12" color="#67C23A"
  157 + :show-text="false"></el-progress>
  158 + <span class="item-count">{{ item.Count }}</span>
207 159 </div>
208 160 </div>
209   - </div>
210   - </el-card>
211   - </div>
212   -
213   - <!-- 第六个和第九个报表:并排显示 -->
214   - <div class="charts-row">
215   - <!-- 第六个报表:客户到店次数分布 -->
216   - <el-card shadow="never" class="report-card half-width" v-loading="loading6">
217   - <div slot="header" class="card-header">
218   - <i class="el-icon-s-marketing"></i>
219   - <span>客户到店次数分布</span>
220   - </div>
221   - <div
222   - id="customerVisitFrequencyChart"
223   - class="chart-container-half"
224   - v-if="customerVisitFrequencyData && customerVisitFrequencyData.length > 0">
225   - </div>
226   - <div v-else style="text-align: center; padding: 40px; color: #909399;">
227   - 暂无数据
228   - </div>
229   - </el-card>
230   -
231   - <!-- 第九个报表:拓客转化漏斗图 -->
232   - <el-card shadow="never" class="report-card half-width" v-loading="loading9">
233   - <div slot="header" class="card-header">
234   - <i class="el-icon-data-line"></i>
235   - <span>拓客转化漏斗图</span>
236   - </div>
237   - <div v-if="tkStatisticsData" class="funnel-container">
238   - <!-- 漏斗图 -->
239   - <div id="tkFunnelChart" class="funnel-chart-container-half"></div>
240   -
241   - <!-- 转化率指标卡片 -->
242   - <div class="conversion-rate-cards">
243   - <div class="conversion-card">
244   - <div class="conversion-label">拓客邀约率</div>
245   - <div class="conversion-value">{{ formatPercent(getTkInviteRate()) }}%</div>
246   - <!-- <div class="conversion-detail">{{ tkStatisticsData.YaoyCount || 0 }} / {{ tkStatisticsData.TkCount || 0 }}</div> -->
247   - </div>
248   - <div class="conversion-card">
249   - <div class="conversion-label">邀约到店率</div>
250   - <div class="conversion-value">{{ formatPercent(getInviteStoreRate()) }}%</div>
251   - <!-- <div class="conversion-detail">{{ tkStatisticsData.DdCount || 0 }} / {{ tkStatisticsData.YaoyCount || 0 }}</div> -->
252   - </div>
253   - <div class="conversion-card">
254   - <div class="conversion-label">预约转化率</div>
255   - <div class="conversion-value">{{ formatPercent(getStoreConversionRate()) }}%</div>
256   - <!-- <div class="conversion-detail">{{ tkStatisticsData.XfCount || 0 }} / {{ tkStatisticsData.YyCount || 0 }}</div> -->
  161 + </el-card>
  162 + </el-col>
  163 + <!-- 开单品项TOP10 -->
  164 + <el-col :span="8">
  165 + <el-card class="dashboard-card" shadow="hover">
  166 + <div slot="header" class="card-title"><span><i class="el-icon-pie-chart"></i> 开单品项 TOP 10</span></div>
  167 + <div class="item-rank">
  168 + <div class="item-rank-row" v-for="(item, idx) in billingItemTop10" :key="idx">
  169 + <span class="item-index">{{ idx + 1 }}</span>
  170 + <span class="item-name">{{ item.ItemName }}</span>
  171 + <el-progress :percentage="item.Percent" :stroke-width="12" color="#409EFF"
  172 + :show-text="false"></el-progress>
  173 + <span class="item-count">{{ item.Count }}</span>
257 174 </div>
258 175 </div>
259   - </div>
260   - <div v-else style="text-align: center; padding: 40px; color: #909399;">
261   - 暂无数据
262   - </div>
263   - </el-card>
264   - </div>
265   - <!-- 第五个报表:门店项目统计 -->
266   - <el-card shadow="never" class="report-card" v-loading="loading5">
267   - <div slot="header" class="card-header">
268   - <div style="display: flex; align-items: center; justify-content: space-between; width: 100%;">
269   - <div style="display: flex; align-items: center;">
270   - <i class="el-icon-s-data"></i>
271   - <span>门店项目统计</span>
272   - </div>
273   - <el-button
274   - type="text"
275   - icon="el-icon-setting"
276   - style="padding: 0; margin-left: 20px;"
277   - @click="showFieldConfigDialog = true">
278   - 字段配置
279   - </el-button>
280   - </div>
281   - </div>
282   - <div v-if="storeItemStatisticsData && storeItemStatisticsData.length > 0">
283   - <el-table
284   - :data="storeItemStatisticsData"
285   - border
286   - stripe
287   - style="width: 100%"
288   - :header-cell-style="{ background: '#f5f7fa', color: '#303133', fontWeight: '600' }"
289   - @sort-change="handleSortChange">
290   - <el-table-column
291   - v-if="isFieldVisible('StoreName')"
292   - prop="StoreName"
293   - label="门店名称"
294   - min-width="150"
295   - align="center">
296   - </el-table-column>
297   - <el-table-column
298   - v-if="isFieldVisible('BillingAmount')"
299   - prop="BillingAmount"
300   - label="开单金额"
301   - min-width="120"
302   - align="center"
303   - sortable="custom">
304   - <template slot-scope="scope">
305   - <span>¥{{ formatMoney(scope.row.BillingAmount) }}</span>
306   - </template>
307   - </el-table-column>
308   - <el-table-column
309   - v-if="isFieldVisible('ConsumePersonCount')"
310   - prop="ConsumePersonCount"
311   - label="消耗人次"
312   - min-width="120"
313   - align="center"
314   - sortable="custom">
315   - </el-table-column>
316   - <el-table-column
317   - v-if="isFieldVisible('ConsumeProjectCount')"
318   - prop="ConsumeProjectCount"
319   - label="消耗项目数"
320   - min-width="120"
321   - align="center"
322   - sortable="custom">
323   - </el-table-column>
324   - <el-table-column
325   - v-if="isFieldVisible('AvgProjectPerConsume')"
326   - prop="AvgProjectPerConsume"
327   - label="客单项目数"
328   - min-width="120"
329   - align="center"
330   - sortable="custom">
331   - <template slot-scope="scope">
332   - <span>{{ formatMoney(scope.row.AvgProjectPerConsume) }}</span>
333   - </template>
334   - </el-table-column>
335   - <el-table-column
336   - v-if="isFieldVisible('ConsumeAmount')"
337   - prop="ConsumeAmount"
338   - label="消耗金额"
339   - min-width="120"
340   - align="center"
341   - sortable="custom">
342   - <template slot-scope="scope">
343   - <span>¥{{ formatMoney(scope.row.ConsumeAmount) }}</span>
344   - </template>
345   - </el-table-column>
346   - <el-table-column
347   - v-if="isFieldVisible('AvgAmountPerConsume')"
348   - prop="AvgAmountPerConsume"
349   - label="消耗客单价"
350   - min-width="120"
351   - align="center"
352   - sortable="custom">
353   - <template slot-scope="scope">
354   - <span>¥{{ formatMoney(scope.row.AvgAmountPerConsume) }}</span>
355   - </template>
356   - </el-table-column>
357   - <el-table-column
358   - v-if="isFieldVisible('ConsumeRate')"
359   - prop="ConsumeRate"
360   - label="消耗率"
361   - min-width="120"
362   - align="center"
363   - sortable="custom">
364   - <template slot-scope="scope">
365   - <span>{{ formatPercent((scope.row.ConsumeRate || 0) ) }}%</span>
366   - </template>
367   - </el-table-column>
368   - </el-table>
  176 + </el-card>
  177 + </el-col>
  178 + </el-row>
  179 +
  180 + <!-- 配置对话框 (保留原有功能) -->
  181 + <el-dialog title="看板字段配置" :visible.sync="showFieldConfigDialog" width="600px" append-to-body>
  182 + <el-checkbox-group v-model="selectedFields">
  183 + <el-checkbox v-for="field in availableFields" :key="field.prop" :label="field.prop">
  184 + {{ field.label }}
  185 + </el-checkbox>
  186 + </el-checkbox-group>
  187 + <div slot="footer">
  188 + <el-button size="mini" @click="selectAllFields">全选</el-button>
  189 + <el-button size="mini" @click="unselectAllFields">反选</el-button>
  190 + <el-button type="primary" size="mini" @click="confirmFieldConfig">确 定</el-button>
369 191 </div>
370   - <div v-else style="text-align: center; padding: 40px; color: #909399;">
371   - 暂无数据
372   - </div>
373   -
374   - <!-- 字段配置对话框 -->
375   - <el-dialog
376   - title="字段配置"
377   - :visible.sync="showFieldConfigDialog"
378   - width="500px"
379   - :close-on-click-modal="false">
380   - <div class="field-config-content">
381   - <div class="field-config-actions" style="margin-bottom: 15px;">
382   - <el-button type="text" size="small" @click="selectAllFields">全选</el-button>
383   - <el-button type="text" size="small" @click="unselectAllFields">全不选</el-button>
384   - </div>
385   - <el-checkbox-group v-model="selectedFields">
386   - <div
387   - v-for="field in availableFields"
388   - :key="field.prop"
389   - class="field-config-item">
390   - <el-checkbox :label="field.prop">{{ field.label }}</el-checkbox>
391   - </div>
392   - </el-checkbox-group>
393   - </div>
394   - <span slot="footer" class="dialog-footer">
395   - <el-button @click="showFieldConfigDialog = false">取消</el-button>
396   - <el-button type="primary" @click="confirmFieldConfig">确定</el-button>
397   - </span>
398   - </el-dialog>
399   - </el-card>
400   -
401   -
402   - <!-- 第七个报表:健康师开单排名 -->
403   - <el-card shadow="never" class="report-card" v-loading="loading7">
404   - <div slot="header" class="card-header">
405   - <i class="el-icon-trophy"></i>
406   - <span>健康师开单排名</span>
407   - </div>
408   - <div v-if="healthCoachBillingRankingData && healthCoachBillingRankingData.length > 0">
409   - <el-table
410   - :data="healthCoachBillingRankingData"
411   - border
412   - stripe
413   - style="width: 100%"
414   - :header-cell-style="{ background: '#f5f7fa', color: '#303133', fontWeight: '600' }">
415   - <el-table-column type="index" label="排名" width="80" align="center" :index="getRankIndex"></el-table-column>
416   - <el-table-column prop="HealthCoachName" label="健康师姓名" min-width="150" align="center"></el-table-column>
417   - <el-table-column prop="BillingPerformance" label="开单业绩" min-width="120" align="center">
418   - <template slot-scope="scope">
419   - <span>¥{{ formatMoney(scope.row.BillingPerformance) }}</span>
420   - </template>
421   - </el-table-column>
422   - <el-table-column prop="ConsumePerformance" label="消耗业绩" min-width="120" align="center">
423   - <template slot-scope="scope">
424   - <span>¥{{ formatMoney(scope.row.ConsumePerformance) }}</span>
425   - </template>
426   - </el-table-column>
427   - <el-table-column prop="RefundPerformance" label="退款业绩" min-width="120" align="center">
428   - <template slot-scope="scope">
429   - <span>¥{{ formatMoney(scope.row.RefundPerformance) }}</span>
430   - </template>
431   - </el-table-column>
432   - <el-table-column prop="BillingProjectCount" label="开单项目数" min-width="120" align="center"></el-table-column>
433   - <el-table-column prop="ConsumeProjectCount" label="消耗项目数" min-width="120" align="center"></el-table-column>
434   - <el-table-column prop="RefundProjectCount" label="退款项目数" min-width="120" align="center"></el-table-column>
435   - </el-table>
436   - </div>
437   - <div v-else style="text-align: center; padding: 40px; color: #909399;">
438   - 暂无数据
439   - </div>
440   - </el-card>
441   -
442   - <!-- 第八个报表:门店剩余权益统计 -->
443   - <el-card shadow="never" class="report-card" v-loading="loading8">
444   - <div slot="header" class="card-header">
445   - <i class="el-icon-wallet"></i>
446   - <span>门店剩余权益统计</span>
447   - </div>
448   - <div v-if="storeRemainingRightsData && storeRemainingRightsData.length > 0">
449   - <el-table
450   - :data="storeRemainingRightsData"
451   - border
452   - stripe
453   - style="width: 100%"
454   - :header-cell-style="{ background: '#f5f7fa', color: '#303133', fontWeight: '600' }">
455   - <el-table-column prop="StoreName" label="门店名称" min-width="200" align="center"></el-table-column>
456   - <el-table-column prop="RemainingRightsAmount" label="剩余权益累计金额" min-width="180" align="center">
457   - <template slot-scope="scope">
458   - <span>¥{{ formatMoney(scope.row.RemainingRightsAmount) }}</span>
459   - </template>
460   - </el-table-column>
461   - <el-table-column prop="RemainingRightsPersonCount" label="剩余权益累计人数" min-width="180" align="center"></el-table-column>
462   - </el-table>
463   - </div>
464   - <div v-else style="text-align: center; padding: 40px; color: #909399;">
465   - 暂无数据
466   - </div>
467   - </el-card>
  192 + </el-dialog>
468 193 </div>
469 194 </template>
470 195  
471 196 <script>
472 197 import request from '@/utils/request'
473 198 import * as echarts from 'echarts'
  199 +import dayjs from 'dayjs'
474 200  
475 201 export default {
476   - name: 'BusinessReport',
  202 + name: 'LeadershipCockpit',
477 203 data() {
478 204 return {
479 205 query: {
480   - startTime: undefined,
481   - endTime: undefined,
  206 + month: dayjs().format('YYYY-MM'), // 默认当前年月
482 207 storeIds: []
483 208 },
484 209 storeOptions: [],
485   - businessData: null,
486   - customerData: null,
487   - performanceData: [],
488   - itemStatisticsData: [],
489   - storeItemStatisticsData: [],
490   - customerVisitFrequencyData: [],
491   - healthCoachBillingRankingData: [],
492   - storeRemainingRightsData: [],
  210 + // 核心 KPI 数据
  211 + kpiData: {},
  212 + trendType: 'month',
  213 + coachRankType: 'billing',
  214 + // 看板核心数据
  215 + trendData: [],
  216 + storeRanking: [],
  217 + coachRankings: {
  218 + billing: [],
  219 + consume: [],
  220 + refund: []
  221 + },
  222 + goldTriangleRankings: [],
  223 + consumeItemTop10: [], // 消耗品项TOP10
  224 + billingItemTop10: [], // 开单品项TOP10
493 225 tkStatisticsData: null,
494   - loading1: false,
495   - loading2: false,
496   - loading3: false,
497   - loading4: false,
498   - loading5: false,
499   - loading6: false,
500   - loading7: false,
501   - loading8: false,
502   - loading9: false,
503   - gaugeItems: [],
504   - // 门店项目统计字段配置
  226 + customerVisitFrequencyData: [],
  227 + // 内部状态
  228 + loading: false,
505 229 showFieldConfigDialog: false,
506 230 availableFields: [
507 231 { prop: 'StoreName', label: '门店名称' },
508 232 { prop: 'BillingAmount', label: '开单金额' },
509   - { prop: 'ConsumePersonCount', label: '消耗人次' },
510   - { prop: 'ConsumeProjectCount', label: '消耗项目数' },
511   - { prop: 'AvgProjectPerConsume', label: '客单项目数' },
512   - { prop: 'ConsumeAmount', label: '消耗金额' },
513   - { prop: 'AvgAmountPerConsume', label: '消耗客单价' },
514   - { prop: 'ConsumeRate', label: '消耗率' }
  233 + { prop: 'ConsumeAmount', label: '消耗金额' }
515 234 ],
516   - selectedFields: ['StoreName', 'BillingAmount', 'ConsumePersonCount', 'ConsumeProjectCount', 'AvgProjectPerConsume', 'ConsumeAmount', 'AvgAmountPerConsume', 'ConsumeRate'],
517   - sortParams: {
518   - prop: null,
519   - order: null
520   - },
521   - originalStoreItemStatisticsData: [] // 保存原始数据,用于取消排序时恢复
  235 + selectedFields: ['StoreName', 'BillingAmount', 'ConsumeAmount'],
  236 + charts: {}
522 237 }
523 238 },
524 239 computed: {
525   - sortedItemData() {
526   - if (!this.itemStatisticsData || this.itemStatisticsData.length === 0) return []
527   - return [...this.itemStatisticsData]
528   - .sort((a, b) => (b.BillingAmount || 0) - (a.BillingAmount || 0))
  240 + // 6大核心 KPI 装饰器
  241 + kpiList() {
  242 + const d = this.kpiData || {}
  243 + return [
  244 + { label: '本月成交总额', value: this.formatMoney(d.TotalBillingAmount), icon: 'el-icon-wallet', type: 'primary', isMoney: true },
  245 + { label: '本月消耗价值', value: this.formatMoney(d.TotalConsumeAmount), icon: 'el-icon-medal', type: 'success', isMoney: true },
  246 + { label: '完成业绩(净额)', value: this.formatMoney(d.CompletedBillingAmount), icon: 'el-icon-trophy', type: 'warning', isMoney: true },
  247 + { label: '开单目标达成', value: d.BillingCompletionRate || 0, icon: 'el-icon-pie-chart', type: 'info', isPercent: true, target: this.formatMoney(d.TargetBillingAmount), status: (d.BillingCompletionRate >= 100) ? 'up' : 'down' },
  248 + { label: '本月拓客人数', value: (this.tkStatisticsData && this.tkStatisticsData.TkCount) ? this.tkStatisticsData.TkCount : 0, icon: 'el-icon-user-solid', type: 'danger', isPercent: false, target: null, status: null },
  249 + { label: '退卡总计', value: this.formatMoney(d.TotalRefundAmount), icon: 'el-icon-warning-outline', type: 'error', isMoney: true }
  250 + ]
  251 + },
  252 + // 健康师排行榜数据切换
  253 + coachRanking() {
  254 + const list = this.coachRankings[this.coachRankType] || []
  255 + const max = list.length > 0 ? Math.max(...list.map(i => i.Amount || 1)) : 100
  256 + return list.map(item => ({
  257 + ...item,
  258 + Percent: Math.min(100, Math.round((item.Amount / max) * 100))
  259 + })).slice(0, 10)
  260 + },
  261 + // 金三角排行榜Top10
  262 + goldTriangleRankingTop10() {
  263 + if (!this.goldTriangleRankings || this.goldTriangleRankings.length === 0) {
  264 + return []
  265 + }
  266 + return [...this.goldTriangleRankings]
  267 + .sort((a, b) => (b.F_TotalPerformance || b.TotalPerformance || 0) - (a.F_TotalPerformance || a.TotalPerformance || 0))
529 268 .slice(0, 10)
  269 + .map(item => ({
  270 + GoldTriangleName: item.F_GoldTriangleName || item.GoldTriangleName || '未知',
  271 + TotalPerformance: item.F_TotalPerformance || item.TotalPerformance || 0
  272 + }))
  273 + }
  274 + },
  275 + watch: {
  276 + coachRankType() {
  277 + // 切换排行榜类型时不需要重载 API,已经预加载
  278 + },
  279 + trendType() {
  280 + // 趋势类型改变时重新加载数据
  281 + this.search()
530 282 },
531   - maxValue() {
532   - if (!this.itemStatisticsData || this.itemStatisticsData.length === 0) return 1
533   - const maxBilling = Math.max(...this.itemStatisticsData.map(item => item.BillingAmount || 0))
534   - const maxConsume = Math.max(...this.itemStatisticsData.map(item => item.ConsumeAmount || 0))
535   - return Math.max(maxBilling, maxConsume)
  283 + query: {
  284 + deep: true,
  285 + handler() {
  286 + // 条件变化不自动触发,手动点更新
  287 + }
536 288 }
537 289 },
538   - created() {
  290 + async mounted() {
539 291 this.setDefaultTimeRange()
540   - this.initStoreOptions()
541   - this.$nextTick(() => {
542   - this.search()
543   - })
  292 + await this.initStoreOptions()
  293 + this.search()
  294 + window.addEventListener('resize', this.handleResize)
  295 + },
  296 + beforeDestroy() {
  297 + window.removeEventListener('resize', this.handleResize)
  298 + Object.values(this.charts).forEach(c => c && c.dispose())
544 299 },
545 300 methods: {
546   - // 设置默认时间范围(本月1号到现在)
  301 + // 设置默认查询范围:本月
547 302 setDefaultTimeRange() {
548   - const now = new Date()
549   - const firstDayOfMonth = new Date(now.getFullYear(), now.getMonth(), 1)
550   -
551   - this.query.startTime = this.formatDateTime(firstDayOfMonth.getTime())
552   - this.query.endTime = this.formatDateTime(now.getTime())
  303 + this.query.month = dayjs().format('YYYY-MM')
553 304 },
554   -
555   - // 初始化门店选项
556   - initStoreOptions() {
557   - return request({
558   - url: '/api/Extend/LqMdxx',
559   - method: 'GET',
560   - data: {
561   - currentPage: 1,
562   - pageSize: 1000
563   - }
564   - }).then(res => {
565   - this.storeOptions = res.data.list || []
566   - return this.storeOptions
567   - }).catch(err => {
568   - console.error('获取门店列表失败:', err)
569   - this.storeOptions = []
570   - return []
571   - })
  305 + // 年月选择器变化处理
  306 + handleMonthChange() {
  307 + // 自动触发查询
  308 + this.search()
572 309 },
573 310  
574   - // 查询所有数据
575   - async search() {
576   - await this.loadHealthCoachBillingRanking()
577   - await this.loadBusinessStatistics()
578   - await this.loadCustomerTypeStatistics()
579   - await this.loadStorePerformanceComparison()
580   - await this.loadStoreItemStatistics()
581   - await this.loadCustomerVisitFrequency()
582   - await this.loadTkStatistics()
583   - //await this.loadStoreRemainingRights()
  311 + // 将日期转换为月份格式 (YYYYMM)
  312 + formatDateToMonth(dateStr) {
  313 + if (!dateStr) return null
  314 + const date = dayjs(dateStr)
  315 + return date.format('YYYYMM')
584 316 },
585   -
586   - // 获取业务统计数据
587   - loadBusinessStatistics() {
588   - this.loading1 = true
589   - const params = {
590   - startTime: this.query.startTime,
591   - endTime: this.query.endTime,
592   - storeIds: this.query.storeIds || []
  317 + // 将日期字符串转换为DateTime对象格式
  318 + formatDateToDateTime(dateStr, isEnd = false) {
  319 + if (!dateStr) return null
  320 + const date = dayjs(dateStr)
  321 + if (isEnd) {
  322 + return date.endOf('day').format('YYYY-MM-DD HH:mm:ss')
593 323 }
594   -
595   - request({
596   - url: '/api/Extend/lqreport/get-business-statistics',
597   - method: 'POST',
598   - data: params
599   - }).then(res => {
600   - this.businessData = res.data || null
601   - if (this.businessData) {
602   - this.initGaugeItems()
603   - this.$nextTick(() => {
604   - this.initGaugeCharts()
605   - })
606   - }
607   - this.loading1 = false
608   - }).catch(err => {
609   - console.error('获取业务统计数据失败:', err)
610   - this.$message.error('获取业务统计数据失败')
611   - this.loading1 = false
612   - })
  324 + return date.startOf('day').format('YYYY-MM-DD HH:mm:ss')
613 325 },
  326 + // 搜索逻辑
  327 + async search() {
  328 + this.loading = true
  329 +
  330 + // 从年月选择器获取月份,转换为开始和结束时间
  331 + const selectedMonth = this.query.month || dayjs().format('YYYY-MM')
  332 + // 确保开始时间是选择月份的第一天 00:00:00,结束时间是最后一天 23:59:59
  333 + const monthStart = dayjs(selectedMonth + '-01').startOf('day')
  334 + const monthEnd = dayjs(selectedMonth + '-01').endOf('month').endOf('day')
  335 +
  336 + // 获取当前月份(YYYYMM格式,用于需要月份格式的接口)
  337 + const currentMonth = monthStart.format('YYYYMM')
  338 +
  339 + // 构建不同接口需要的参数格式
  340 + // 确保开始时间是选择月份的第一天 00:00:00,结束时间是最后一天 23:59:59
  341 + const dateParams = {
  342 + startTime: monthStart.startOf('day').format('YYYY-MM-DD HH:mm:ss'),
  343 + endTime: monthEnd.endOf('day').format('YYYY-MM-DD HH:mm:ss'),
  344 + storeIds: this.query.storeIds || []
  345 + }
614 346  
615   - // 初始化仪表盘数据
616   - initGaugeItems() {
617   - const billingValue = this.businessData.TotalBillingAmount - this.businessData.TotalRefundAmount || 0
618   - const countValue = this.businessData.BillingCount || 0
619   - const consumeValue = this.businessData.TotalConsumeAmount || 0
620   - const targetValue = this.businessData.TargetConsumeAmount || 0
621   - const completionRate = this.businessData.BillingCompletionRate || 0
622   -
623   - this.gaugeItems = [
624   - {
625   - title: '现金业绩',
626   - icon: 'el-icon-wallet',
627   - displayValue: `¥${this.formatMoney(billingValue)}`,
628   - value: billingValue,
629   - max: billingValue > 0 ? Math.floor(billingValue * 0.87) : 100000,
630   - isAmount: true
631   - },
632   - {
633   - title: '人头',
634   - icon: 'el-icon-s-custom',
635   - displayValue: countValue || 0,
636   - value: countValue,
637   - max: countValue > 0 ? Math.floor(countValue * 0.84) : 100,
638   - isAmount: false
639   - },
640   - {
641   - title: '消耗业绩',
642   - icon: 'el-icon-coin',
643   - displayValue: `¥${this.formatMoney(consumeValue)}`,
644   - value: consumeValue,
645   - max: consumeValue > 0 ? Math.floor(consumeValue * 0.85) : 50000,
646   - isAmount: true
647   - },
648   - {
649   - title: '目标值',
650   - icon: 'el-icon-coin',
651   - displayValue: `¥${this.formatMoney(targetValue)}`,
652   - value: targetValue,
653   - max: targetValue > 0 ? Math.floor(targetValue * 0.85) : 50000,
654   - isAmount: true
655   - },
656   - {
657   - title: '完成率',
658   - icon: 'el-icon-coin',
659   - displayValue: `${this.formatMoney(completionRate)}%`,
660   - value: completionRate,
661   - max: completionRate > 0 ? Math.floor(completionRate * 0.85) : 50000,
662   - isAmount: true
  347 + // 根据趋势类型构建不同的查询参数
  348 + let trendParams = {}
  349 + if (this.trendType === 'month') {
  350 + // 按月:查询最近12个月
  351 + const trendStartMonth = monthStart.subtract(11, 'month').format('YYYYMM')
  352 + const trendEndMonth = currentMonth
  353 + trendParams = {
  354 + startMonth: trendStartMonth,
  355 + endMonth: trendEndMonth,
  356 + periodType: 'month',
  357 + storeIds: this.query.storeIds || []
  358 + }
  359 + } else if (this.trendType === 'day') {
  360 + // 按天:查询本月
  361 + const monthStartDate = monthStart.format('YYYY-MM-DD')
  362 + const monthEndDate = monthEnd.format('YYYY-MM-DD')
  363 + trendParams = {
  364 + startMonth: monthStartDate,
  365 + endMonth: monthEndDate,
  366 + periodType: 'day',
  367 + storeIds: this.query.storeIds || []
  368 + }
  369 + } else if (this.trendType === 'week') {
  370 + // 按周:查询最近4周
  371 + const weekStartDate = monthStart.subtract(27, 'day').format('YYYY-MM-DD')
  372 + const weekEndDate = monthEnd.format('YYYY-MM-DD')
  373 + trendParams = {
  374 + startMonth: weekStartDate,
  375 + endMonth: weekEndDate,
  376 + periodType: 'week',
  377 + storeIds: this.query.storeIds || []
663 378 }
664   - ]
665   - },
666   -
667   - // 初始化仪表盘图表
668   - initGaugeCharts() {
669   - if (!this.businessData || this.gaugeItems.length === 0) return
670   -
671   - this.gaugeItems.forEach((item, index) => {
672   - this.initGaugeChart(`gaugeChart${index + 1}`, item, `range${index + 1}`)
673   - })
674   - },
675   -
676   - // 初始化单个仪表盘
677   - initGaugeChart(chartId, item, rangeId) {
678   - const chartDom = document.getElementById(chartId)
679   - if (!chartDom) return
680   -
681   - const myChart = echarts.init(chartDom)
682   -
683   - const percentage = item.max > 0 ? (item.value / item.max) : 1
684   - const displayPercentage = percentage > 1 ? 1 : percentage
685   -
686   - const option = {
687   - series: [
688   - {
689   - name: item.title,
690   - type: 'gauge',
691   - startAngle: 180,
692   - endAngle: 0,
693   - radius: '88%',
694   - min: 0,
695   - max: item.max || 1,
696   - splitNumber: 0,
697   - center: ['50%', '60%'],
698   - axisLine: {
699   - lineStyle: {
700   - width: 22,
701   - color: [[displayPercentage, '#FF6B35'], [1, '#E5E7EB']]
702   - }
703   - },
704   - pointer: {
705   - show: false
706   - },
707   - axisLabel: {
708   - show: false
709   - },
710   - splitLine: {
711   - show: false
712   - },
713   - axisTick: {
714   - show: false
715   - },
716   - title: {
717   - show: false
718   - },
719   - detail: {
720   - show: false
721   - }
722   - }
723   - ]
724   - }
725   -
726   - myChart.setOption(option)
727   -
728   - // 设置范围显示
729   - const rangeElement = document.getElementById(rangeId)
730   - if (rangeElement) {
731   - const displayMax = item.isAmount ? `¥${this.formatMoney(item.max)}` : item.max
732   - rangeElement.textContent = displayMax
733 379 }
734   -
735   - window.addEventListener('resize', () => {
736   - myChart.resize()
737   - })
738   - },
739 380  
740   - // 获取客户类型统计数据
741   - loadCustomerTypeStatistics() {
742   - this.loading2 = true
743   - const params = {
744   - startTime: this.query.startTime,
745   - endTime: this.query.endTime,
  381 + const monthParams = {
  382 + startMonth: currentMonth,
  383 + endMonth: currentMonth,
  384 + statisticsMonth: currentMonth,
746 385 storeIds: this.query.storeIds || []
747 386 }
748   -
749   - request({
750   - url: '/api/Extend/lqreport/get-customer-type-statistics',
751   - method: 'POST',
752   - data: params
753   - }).then(res => {
754   - this.customerData = res.data || null
755   - this.loading2 = false
756   - }).catch(err => {
757   - console.error('获取客户类型统计数据失败:', err)
758   - this.$message.error('获取客户类型统计数据失败')
759   - this.loading2 = false
760   - })
761   - },
762 387  
763   - // 获取门店业绩对比数据
764   - loadStorePerformanceComparison() {
765   - this.loading3 = true
766   - this.loading4 = true
767   - const params = {
768   - startTime: this.query.startTime,
769   - endTime: this.query.endTime,
770   - storeIds: this.query.storeIds || []
  388 + try {
  389 + await Promise.all([
  390 + this.loadKPIs(dateParams),
  391 + this.loadTrends(trendParams),
  392 + this.loadTkFunnel(dateParams),
  393 + this.loadRankings({ ...monthParams, ...dateParams }),
  394 + this.loadInsights(dateParams)
  395 + ])
  396 + // 确保数据加载完成后再渲染图表
  397 + await this.$nextTick()
  398 + this.initAllCharts()
  399 + } catch (e) {
  400 + console.error('LeadershipCockpit Load Error:', e)
  401 + const errorMsg = (e.response && e.response.data && e.response.data.msg) || e.message || '未知错误'
  402 + this.$message.error('数据加载异常,请检查网络或重试: ' + errorMsg)
  403 + } finally {
  404 + this.loading = false
771 405 }
772   -
773   - // 获取门店业绩对比数据
774   - request({
775   - url: '/api/Extend/lqreport/get-store-performance-comparison',
776   - method: 'POST',
777   - data: params
778   - }).then(res => {
779   - // 只取前10条数据
780   - this.performanceData = (res.data || []).slice(0, 10)
781   - this.$nextTick(() => {
782   - this.initStorePerformanceChart()
783   - })
784   - this.loading3 = false
785   - }).catch(err => {
786   - console.error('获取门店业绩对比数据失败:', err)
787   - this.$message.error('获取门店业绩对比数据失败')
788   - this.loading3 = false
789   - })
790   -
791   - // 获取品项统计数据
792   - request({
793   - url: '/api/Extend/lqreport/get-item-statistics',
794   - method: 'POST',
795   - data: params
796   - }).then(res => {
797   - this.itemStatisticsData = res.data || []
798   - this.loading4 = false
799   - }).catch(err => {
800   - console.error('获取品项统计数据失败:', err)
801   - this.$message.error('获取品项统计数据失败')
802   - this.loading4 = false
803   - })
804 406 },
805 407  
806   - // 获取门店项目统计数据
807   - loadStoreItemStatistics() {
808   - this.loading5 = true
809   - const params = {
810   - startTime: this.query.startTime,
811   - endTime: this.query.endTime,
812   - storeIds: this.query.storeIds || []
813   - }
814   -
815   - request({
816   - url: '/api/Extend/lqreport/get-store-item-statistics',
817   - method: 'POST',
818   - data: params
819   - }).then(res => {
820   - const data = res.data || []
821   - // 保存原始数据
822   - this.originalStoreItemStatisticsData = JSON.parse(JSON.stringify(data))
823   - this.storeItemStatisticsData = data
824   - // 如果有排序参数,重新应用排序
825   - if (this.sortParams.prop && this.sortParams.order) {
826   - this.sortTableData()
827   - }
828   - this.loading5 = false
829   - }).catch(err => {
830   - console.error('获取门店项目统计数据失败:', err)
831   - this.$message.error('获取门店项目统计数据失败')
832   - this.loading5 = false
833   - })
834   - },
  408 + // --- 数据加载器 ---
  409 + async loadKPIs(p) {
  410 + try {
  411 + // 将时间字符串转换为 Date 对象,确保使用北京时间
  412 + const startTimeDate = p.startTime ? dayjs(p.startTime).startOf('day').toDate() : null
  413 + const endTimeDate = p.endTime ? dayjs(p.endTime).endOf('day').toDate() : null
835 414  
836   - // 获取客户到店次数分布数据
837   - loadCustomerVisitFrequency() {
838   - this.loading6 = true
839   - const params = {
840   - startTime: this.query.startTime,
841   - endTime: this.query.endTime,
842   - storeIds: this.query.storeIds || []
843   - }
844   -
845   - request({
846   - url: '/api/Extend/lqreport/get-customer-visit-frequency',
847   - method: 'POST',
848   - data: params
849   - }).then(res => {
850   - this.customerVisitFrequencyData = res.data || []
851   - this.$nextTick(() => {
852   - this.initCustomerVisitFrequencyChart()
  415 + const res = await request({
  416 + url: '/api/Extend/LqReport/get-business-statistics',
  417 + method: 'POST',
  418 + data: {
  419 + startTime: p.startTime,
  420 + endTime: p.endTime,
  421 + storeIds: p.storeIds || []
  422 + }
853 423 })
854   - this.loading6 = false
855   - }).catch(err => {
856   - console.error('获取客户到店次数分布数据失败:', err)
857   - this.$message.error('获取客户到店次数分布数据失败')
858   - this.loading6 = false
859   - })
860   - },
861   -
862   - // 获取健康师开单排名数据
863   - loadHealthCoachBillingRanking() {
864   - this.loading7 = true
865   - const params = {
866   - startTime: this.query.startTime,
867   - endTime: this.query.endTime,
868   - storeIds: this.query.storeIds || []
  424 + // 接口返回的数据格式
  425 + const data = res.data || {}
  426 + this.kpiData = {
  427 + TotalBillingAmount: data.TotalBillingAmount || data.billing_amount || 0,
  428 + TotalConsumeAmount: data.TotalConsumeAmount || data.consume_amount || 0,
  429 + CompletedBillingAmount: (data.TotalBillingAmount || data.billing_amount || 0) - (data.TotalRefundAmount || data.refund_amount || 0),
  430 + BillingCompletionRate: data.BillingCompletionRate || 0,
  431 + ConsumeCompletionRate: data.ConsumeCompletionRate || 0,
  432 + TargetBillingAmount: data.TargetBillingAmount || data.target_billing_amount || 0,
  433 + TargetConsumeAmount: data.TargetConsumeAmount || data.target_consume_amount || 0,
  434 + TotalRefundAmount: data.TotalRefundAmount || data.refund_amount || 0
  435 + }
  436 + } catch (error) {
  437 + console.error('加载KPI数据失败:', error)
  438 + this.kpiData = {}
869 439 }
870   -
871   - request({
872   - url: '/api/Extend/lqreport/get-health-coach-billing-ranking',
873   - method: 'POST',
874   - data: params
875   - }).then(res => {
876   - // 按开单业绩降序排序
877   - const data = res.data || []
878   - this.healthCoachBillingRankingData = data.sort((a, b) => (b.BillingPerformance || 0) - (a.BillingPerformance || 0))
879   - this.loading7 = false
880   - }).catch(err => {
881   - console.error('获取健康师开单排名数据失败:', err)
882   - this.$message.error('获取健康师开单排名数据失败')
883   - this.loading7 = false
884   - })
885 440 },
  441 + async loadTrends(p) {
  442 + try {
  443 + const res = await request({
  444 + url: '/api/Extend/LqReport/get-store-performance-trend',
  445 + method: 'POST',
  446 + data: {
  447 + startMonth: p.startMonth,
  448 + endMonth: p.endMonth,
  449 + periodType: p.periodType || 'month',
  450 + storeIds: p.storeIds || []
  451 + }
  452 + })
  453 + // 接口返回格式: { Success: true, Data: [...], Message: "..." }
  454 + console.log('趋势接口返回数据:', res.data)
  455 + if (res.data && res.data.Success && res.data.Data && Array.isArray(res.data.Data)) {
  456 + // 将数据转换为图表需要的格式(按日期汇总)
  457 + const allData = []
  458 + res.data.Data.forEach(store => {
  459 + if (store && store.Data && Array.isArray(store.Data)) {
  460 + store.Data.forEach(item => {
  461 + if (item && item.Month) {
  462 + allData.push({
  463 + Date: item.Month,
  464 + BillingAmount: parseFloat(item.TotalPerformance || 0),
  465 + ConsumeAmount: parseFloat(item.ConsumeAmount || 0)
  466 + })
  467 + }
  468 + })
  469 + }
  470 + })
  471 + // 按日期分组汇总
  472 + const grouped = {}
  473 + allData.forEach(item => {
  474 + if (!grouped[item.Date]) {
  475 + grouped[item.Date] = { Date: item.Date, BillingAmount: 0, ConsumeAmount: 0 }
  476 + }
  477 + grouped[item.Date].BillingAmount += item.BillingAmount
  478 + grouped[item.Date].ConsumeAmount += item.ConsumeAmount
  479 + })
  480 + this.trendData = Object.values(grouped).sort((a, b) => a.Date.localeCompare(b.Date))
886 481  
887   - // 获取门店剩余权益统计数据(按门店循环查询)
888   - loadStoreRemainingRights() {
889   - this.loading8 = true
890   - this.storeRemainingRightsData = []
891   -
892   - // 如果门店列表为空,先获取门店列表
893   - const getStoresToQuery = () => {
894   - if (this.query.storeIds && this.query.storeIds.length > 0) {
895   - // 如果选择了门店,只查询选中的门店
896   - return this.storeOptions.filter(store => this.query.storeIds.includes(store.id))
  482 + console.log('处理后的趋势数据:', this.trendData)
  483 +
  484 + // 调试日志
  485 + if (this.trendData.length === 0) {
  486 + console.warn('趋势数据为空,接口返回:', res.data)
  487 + }
897 488 } else {
898   - // 如果没有选择门店,查询所有门店
899   - return this.storeOptions || []
  489 + console.warn('趋势数据格式不正确,接口返回:', res.data)
  490 + this.trendData = []
900 491 }
  492 + } catch (error) {
  493 + console.error('加载趋势数据失败:', error)
  494 + this.trendData = []
901 495 }
902   -
903   - // 获取要查询的门店列表
904   - let storesToQuery = getStoresToQuery()
905   -
906   - // 如果门店列表为空,先加载门店列表
907   - if (storesToQuery.length === 0 && (!this.storeOptions || this.storeOptions.length === 0)) {
908   - this.initStoreOptions().then(() => {
909   - storesToQuery = getStoresToQuery()
910   - if (storesToQuery.length === 0) {
911   - this.loading8 = false
912   - return
913   - }
914   - this.queryStoresRemainingRights(storesToQuery)
915   - }).catch(() => {
916   - this.loading8 = false
917   - })
918   - return
919   - }
920   -
921   - if (storesToQuery.length === 0) {
922   - this.loading8 = false
923   - return
924   - }
925   -
926   - this.queryStoresRemainingRights(storesToQuery)
927 496 },
928   -
929   - // 查询门店剩余权益数据
930   - queryStoresRemainingRights(storesToQuery) {
931   - // 使用 Promise.all 并发查询所有门店
932   - const requests = storesToQuery.map(store => {
933   - const params = {
934   - startTime: this.query.startTime,
935   - endTime: this.query.endTime,
936   - storeIds: [store.id]
937   - }
938   -
939   - return request({
940   - url: '/api/Extend/lqreport/get-store-remaining-rights',
  497 + async loadTkFunnel(p) {
  498 + try {
  499 + const res = await request({
  500 + url: '/api/Extend/LqTkjlb/get-tk-statistics',
941 501 method: 'POST',
942   - data: params
943   - }).then(res => {
944   - const data = res.data || []
945   - return data
946   - }).catch(err => {
947   - console.error(`获取门店 ${store.dm || store.id} 剩余权益统计数据失败:`, err)
948   - return []
949   - })
950   - })
951   -
952   - Promise.all(requests).then(results => {
953   - // 合并所有门店的查询结果
954   - const allData = []
955   - results.forEach(data => {
956   - if (data && data.length > 0) {
957   - allData.push(...data)
  502 + data: {
  503 + startTime: p.startTime ? dayjs(p.startTime).toDate() : null,
  504 + endTime: p.endTime ? dayjs(p.endTime).toDate() : null,
  505 + storeId: p.storeIds || []
958 506 }
959 507 })
960   - this.storeRemainingRightsData = allData
961   - this.loading8 = false
962   - }).catch(err => {
963   - console.error('获取门店剩余权益统计数据失败:', err)
964   - this.$message.error('获取门店剩余权益统计数据失败')
965   - this.loading8 = false
966   - })
  508 + this.tkStatisticsData = res.data || null
  509 + } catch (error) {
  510 + console.error('加载拓客漏斗数据失败:', error)
  511 + this.tkStatisticsData = null
  512 + }
967 513 },
  514 + async loadRankings(p) {
  515 + try {
  516 + const [store, bill, cons, refu, gold] = await Promise.all([
  517 + request({
  518 + url: '/api/Extend/LqReport/get-store-performance-ranking',
  519 + method: 'POST',
  520 + data: {
  521 + statisticsMonth: p.statisticsMonth,
  522 + topCount: 10
  523 + }
  524 + }),
  525 + request({
  526 + url: '/api/Extend/LqReport/get-health-coach-billing-ranking',
  527 + method: 'POST',
  528 + data: {
  529 + startTime: p.startTime,
  530 + endTime: p.endTime,
  531 + storeIds: p.storeIds
  532 + }
  533 + }),
  534 + request({
  535 + url: '/api/Extend/LqReport/get-health-coach-consume-ranking',
  536 + method: 'POST',
  537 + data: {
  538 + startTime: p.startTime,
  539 + endTime: p.endTime,
  540 + storeIds: p.storeIds
  541 + }
  542 + }),
  543 + request({
  544 + url: '/api/Extend/LqReport/get-health-coach-refund-ranking',
  545 + method: 'POST',
  546 + data: {
  547 + startTime: p.startTime,
  548 + endTime: p.endTime,
  549 + storeIds: p.storeIds
  550 + }
  551 + }),
  552 + request({
  553 + url: '/api/Extend/LqReport/get-gold-triangle-performance-ranking',
  554 + method: 'POST',
  555 + data: {
  556 + statisticsMonth: p.statisticsMonth,
  557 + topCount: 10
  558 + }
  559 + })
  560 + ])
  561 +
  562 + // 解析门店排行榜数据
  563 + if (store.data && store.data.Success && store.data.Data) {
  564 + this.storeRanking = store.data.Data.map(item => ({
  565 + StoreName: item.StoreName,
  566 + TotalPerformance: item.TotalPerformance || 0
  567 + }))
  568 + } else {
  569 + this.storeRanking = []
  570 + }
968 571  
969   - // 获取拓客统计数据
970   - loadTkStatistics() {
971   - this.loading9 = true
972   - const params = {
973   - startTime: this.query.startTime,
974   - endTime: this.query.endTime,
975   - storeIds: this.query.storeIds || []
  572 + // 解析健康师排行榜数据
  573 + const billData = (bill.data && bill.data.Success && bill.data.Data) ? bill.data.Data : (bill.data || [])
  574 + const consData = (cons.data && cons.data.Success && cons.data.Data) ? cons.data.Data : (cons.data || [])
  575 + const refuData = (refu.data && refu.data.Success && refu.data.Data) ? refu.data.Data : (refu.data || [])
  576 +
  577 + this.coachRankings.billing = billData.map(i => ({
  578 + HealthCoachName: i.HealthCoachName || i.Name || '未知',
  579 + Amount: i.BillingPerformance || i.Performance || 0
  580 + }))
  581 + this.coachRankings.consume = consData.map(i => ({
  582 + HealthCoachName: i.HealthCoachName || i.Name || '未知',
  583 + Amount: i.ConsumePerformance || i.Performance || 0
  584 + }))
  585 + this.coachRankings.refund = refuData.map(i => ({
  586 + HealthCoachName: i.HealthCoachName || i.Name || '未知',
  587 + Amount: i.RefundPerformance || i.Performance || 0
  588 + }))
  589 +
  590 + // 解析金三角排行榜数据
  591 + if (gold.data && gold.data.Success && gold.data.Data) {
  592 + this.goldTriangleRankings = gold.data.Data.map(item => ({
  593 + F_GoldTriangleName: item.GoldTriangleName,
  594 + F_TotalPerformance: item.TotalPerformance || 0
  595 + }))
  596 + } else {
  597 + this.goldTriangleRankings = []
  598 + }
  599 + } catch (error) {
  600 + console.error('加载排行榜数据失败:', error)
  601 + this.storeRanking = []
  602 + this.coachRankings = { billing: [], consume: [], refund: [] }
  603 + this.goldTriangleRankings = []
976 604 }
977   -
978   - return request({
979   - url: '/api/Extend/lqtkjlb/get-tk-statistics',
980   - method: 'POST',
981   - data: params
982   - }).then(res => {
983   - this.tkStatisticsData = res.data || null
984   - if (this.tkStatisticsData) {
985   - this.$nextTick(() => {
986   - this.initTkFunnelChart()
  605 + },
  606 + async loadInsights(p) {
  607 + try {
  608 + const [freq, item] = await Promise.all([
  609 + request({
  610 + url: '/api/Extend/LqReport/get-customer-visit-frequency',
  611 + method: 'POST',
  612 + data: {
  613 + startTime: p.startTime ? dayjs(p.startTime).toDate() : null,
  614 + endTime: p.endTime ? dayjs(p.endTime).toDate() : null,
  615 + storeIds: p.storeIds || []
  616 + }
  617 + }),
  618 + request({
  619 + url: '/api/Extend/LqReport/get-item-statistics',
  620 + method: 'POST',
  621 + data: {
  622 + startTime: p.startTime ? dayjs(p.startTime).toDate() : null,
  623 + endTime: p.endTime ? dayjs(p.endTime).toDate() : null,
  624 + storeIds: p.storeIds || []
  625 + }
987 626 })
988   - }
989   - this.loading9 = false
990   - }).catch(err => {
991   - console.error('获取拓客统计数据失败:', err)
992   - this.$message.error('获取拓客统计数据失败')
993   - this.loading9 = false
994   - })
  627 + ])
  628 +
  629 + // 解析客户到店频次数据
  630 + this.customerVisitFrequencyData = (freq.data || []).map(item => ({
  631 + VisitCount: item.VisitCount || 0,
  632 + CustomerCount: item.CustomerCount || 0
  633 + }))
  634 +
  635 + // 解析品项统计数据
  636 + const raw = item.data || []
  637 +
  638 + // 消耗品项TOP10(按消耗数量排序)
  639 + const consumeMax = raw.length ? Math.max(...raw.map(i => (i.ConsumeCount || 0)), 1) : 100
  640 + this.consumeItemTop10 = raw
  641 + .filter(i => (i.ConsumeCount || 0) > 0)
  642 + .sort((a, b) => (b.ConsumeCount || 0) - (a.ConsumeCount || 0))
  643 + .slice(0, 10)
  644 + .map(i => ({
  645 + ItemName: i.ItemName || '未知品项',
  646 + Count: i.ConsumeCount || 0,
  647 + Percent: Math.round(((i.ConsumeCount || 0) / consumeMax) * 100)
  648 + }))
  649 +
  650 + // 开单品项TOP10(按开单数量排序)
  651 + const billingMax = raw.length ? Math.max(...raw.map(i => (i.BillingCount || 0)), 1) : 100
  652 + this.billingItemTop10 = raw
  653 + .filter(i => (i.BillingCount || 0) > 0)
  654 + .sort((a, b) => (b.BillingCount || 0) - (a.BillingCount || 0))
  655 + .slice(0, 10)
  656 + .map(i => ({
  657 + ItemName: i.ItemName || '未知品项',
  658 + Count: i.BillingCount || 0,
  659 + Percent: Math.round(((i.BillingCount || 0) / billingMax) * 100)
  660 + }))
  661 + } catch (error) {
  662 + console.error('加载洞察数据失败:', error)
  663 + this.customerVisitFrequencyData = []
  664 + this.consumeItemTop10 = []
  665 + this.billingItemTop10 = []
  666 + }
995 667 },
996 668  
997   - // 初始化拓客转化漏斗图
998   - initTkFunnelChart() {
999   - if (!this.tkStatisticsData) return
1000   -
1001   - const chartDom = document.getElementById('tkFunnelChart')
1002   - if (!chartDom) return
1003   -
1004   - const myChart = echarts.init(chartDom)
1005   -
1006   - const tkCount = this.tkStatisticsData.TkCount || 0
1007   - const yaoyCount = this.tkStatisticsData.YaoyCount || 0
1008   - const yyCount = this.tkStatisticsData.YyCount || 0
1009   - const ddCount = this.tkStatisticsData.DdCount || 0
1010   - const kdCount = this.tkStatisticsData.KdCount || 0
1011   - const xfCount = this.tkStatisticsData.XfCount || 0
1012   -
1013   - // 计算百分比(以拓客人数为基准100%)
1014   - const maxValue = tkCount || 1
1015   - const getPercent = (value) => {
1016   - return tkCount > 0 ? ((value / tkCount) * 100).toFixed(1) : '0.0'
  669 + // --- 图表引擎 ---
  670 + initAllCharts() {
  671 + this.renderTrendChart()
  672 + this.renderFunnelChart()
  673 + // renderGoldChart 已移除,改为列表显示
  674 + this.renderVisitChart()
  675 + // renderCategoryChart 已移除,改为列表显示
  676 + },
  677 + renderTrendChart() {
  678 + const chart = this.getChart('revenueTrendChart')
  679 + console.log('渲染趋势图表,数据:', this.trendData)
  680 +
  681 + if (!this.trendData || this.trendData.length === 0) {
  682 + chart.setOption({
  683 + title: { text: '暂无数据', left: 'center', top: 'middle', textStyle: { color: '#909399' } }
  684 + })
  685 + return
1017 686 }
1018   -
1019   - const funnelData = [
1020   - { value: tkCount, name: '拓客人数', percent: '100.0%' },
1021   - { value: yaoyCount, name: '邀约人头', percent: getPercent(yaoyCount) + '%' },
1022   - { value: yyCount, name: '预约人头', percent: getPercent(yyCount) + '%' },
1023   - { value: ddCount, name: '到店人头', percent: getPercent(ddCount) + '%' },
1024   - { value: kdCount, name: '开单人头', percent: getPercent(kdCount) + '%' },
1025   - { value: xfCount, name: '消费人头', percent: getPercent(xfCount) + '%' }
1026   - ]
1027   -
1028   - // 判断是否为并排显示(容器是否有 half 类)
1029   - const isHalfWidth = chartDom.closest('.half-width') !== null
1030   - const legendTop = isHalfWidth ? '2%' : '5%'
1031   - const funnelTop = isHalfWidth ? '18%' : '15%'
1032   - const funnelBottom = isHalfWidth ? '5%' : '10%'
1033   - const labelFontSize = isHalfWidth ? 10 : 12
1034   -
1035   - const option = {
1036   - tooltip: {
1037   - trigger: 'item',
1038   - formatter: function(params) {
1039   - return params.name + '<br/>人数: ' + params.value + '<br/>占比: ' + params.percent
  687 +
  688 + // 格式化日期显示
  689 + const dates = this.trendData.map(i => {
  690 + const date = i.Date
  691 + if (!date) return ''
  692 +
  693 + if (this.trendType === 'month') {
  694 + // 按月:YYYYMM格式,转换为 YYYY-MM
  695 + if (date.length === 6) {
  696 + return date.substring(0, 4) + '-' + date.substring(4, 6)
1040 697 }
1041   - },
1042   - legend: {
1043   - top: legendTop,
1044   - left: 'center',
1045   - data: funnelData.map(item => item.name),
1046   - textStyle: {
1047   - fontSize: isHalfWidth ? 10 : 12,
1048   - color: '#606266'
1049   - },
1050   - itemWidth: isHalfWidth ? 12 : 14,
1051   - itemHeight: isHalfWidth ? 8 : 10,
1052   - itemGap: isHalfWidth ? 8 : 10
1053   - },
1054   - series: [
1055   - {
1056   - name: '拓客转化漏斗',
1057   - type: 'funnel',
1058   - left: '10%',
1059   - top: funnelTop,
1060   - bottom: funnelBottom,
1061   - width: '80%',
1062   - min: 0,
1063   - max: maxValue,
1064   - minSize: '0%',
1065   - maxSize: '100%',
1066   - sort: 'descending',
1067   - gap: 2,
1068   - label: {
1069   - show: true,
1070   - position: 'inside',
1071   - formatter: function(params) {
1072   - return params.name + '\n' + params.value + '人\n' + params.percent
1073   - },
1074   - fontSize: labelFontSize,
1075   - color: '#fff',
1076   - fontWeight: 'bold'
1077   - },
1078   - labelLine: {
1079   - length: 10,
1080   - lineStyle: {
1081   - width: 1,
1082   - type: 'solid'
1083   - }
1084   - },
1085   - itemStyle: {
1086   - borderColor: '#fff',
1087   - borderWidth: 1
1088   - },
1089   - emphasis: {
1090   - label: {
1091   - fontSize: labelFontSize + 2
1092   - }
1093   - },
1094   - data: funnelData,
1095   - color: ['#87CEEB', '#4682B4', '#5F9EA0', '#90EE90', '#FFD700', '#FFA500']
  698 + } else if (this.trendType === 'day') {
  699 + // 按天:YYYY-MM-DD格式,只显示日期部分
  700 + if (date.length >= 10) {
  701 + return date.substring(5, 10) // MM-DD
1096 702 }
1097   - ]
1098   - }
1099   -
1100   - myChart.setOption(option)
1101   -
1102   - window.addEventListener('resize', () => {
1103   - myChart.resize()
1104   - })
1105   - },
  703 + } else if (this.trendType === 'week') {
  704 + // 按周:YYYY-WXX格式,转换为更友好的显示
  705 + if (date.includes('-W')) {
  706 + return date.replace('-W', ' 第') + '周'
  707 + }
  708 + }
1106 709  
1107   - // 计算拓客邀约率
1108   - getTkInviteRate() {
1109   - if (!this.tkStatisticsData || !this.tkStatisticsData.TkCount || this.tkStatisticsData.TkCount === 0) return 0
1110   - const rate = (this.tkStatisticsData.YaoyCount || 0) / this.tkStatisticsData.TkCount * 100
1111   - return rate
1112   - },
  710 + return date
  711 + })
1113 712  
1114   - // 计算邀约到店率
1115   - getInviteStoreRate() {
1116   - if (!this.tkStatisticsData || !this.tkStatisticsData.YaoyCount || this.tkStatisticsData.YaoyCount === 0) return 0
1117   - const rate = (this.tkStatisticsData.DdCount || 0) / this.tkStatisticsData.YaoyCount * 100
1118   - return rate
1119   - },
  713 + const billingData = this.trendData.map(i => parseFloat(i.BillingAmount || 0))
  714 + const consumeData = this.trendData.map(i => parseFloat(i.ConsumeAmount || 0))
1120 715  
1121   - // 计算到店转化率
1122   - getStoreConversionRate() {
1123   - if (!this.tkStatisticsData || !this.tkStatisticsData.YyCount || this.tkStatisticsData.YyCount === 0) return 0
1124   - const rate = (this.tkStatisticsData.XfCount || 0) / this.tkStatisticsData.YyCount * 100
1125   - return rate
1126   - },
  716 + console.log('图表数据 - 日期:', dates, '成交额:', billingData, '服务产出:', consumeData)
1127 717  
1128   - // 初始化门店业绩对比柱状图
1129   - initStorePerformanceChart() {
1130   - if (!this.performanceData || this.performanceData.length === 0) return
1131   -
1132   - const chartDom = document.getElementById('storePerformanceChart')
1133   - if (!chartDom) return
1134   -
1135   - const myChart = echarts.init(chartDom)
1136   - console.error(this.performanceData)
1137   - const storeNames = this.performanceData.map(item => item.StoreName)
1138   - const targetPerformance = this.performanceData.map(item => item.ActualPerformance || 0)
1139   - const actualPerformance = this.performanceData.map(item => item.ActualConsumePerformance || 0)
1140   - console.error(actualPerformance)
1141   - const option = {
  718 + chart.setOption({
1142 719 tooltip: {
1143 720 trigger: 'axis',
1144   - axisPointer: {
1145   - type: 'shadow'
1146   - },
1147   - formatter: function(params) {
1148   - let result = params[0].name + '<br/>'
1149   - params.forEach(item => {
1150   - result += item.seriesName + ': ¥' + item.value + '<br/>'
  721 + backgroundColor: 'rgba(255,255,255,0.95)',
  722 + borderWidth: 1,
  723 + borderColor: '#E4E7ED',
  724 + textStyle: { color: '#303133' },
  725 + shadowBlur: 10,
  726 + formatter: function (params) {
  727 + let result = '<div style="color: #303133; font-weight: bold;">' + params[0].name + '</div>'
  728 + params.forEach(param => {
  729 + const value = param.value >= 10000 ? (param.value / 10000).toFixed(2) + '万' : '¥' + param.value.toLocaleString()
  730 + result += '<div style="margin-top: 4px;">' + param.marker + '<span style="color: #606266;">' + param.seriesName + '</span>: <span style="color: #303133; font-weight: bold;">' + value + '</span></div>'
1151 731 })
1152 732 return result
1153 733 }
1154 734 },
1155   - legend: {
1156   - data: ['现金业绩', '消耗业绩'],
1157   - bottom: 10,
1158   - textStyle: {
1159   - fontSize: 14
1160   - }
1161   - },
1162   - grid: {
1163   - left: '3%',
1164   - right: '4%',
1165   - bottom: '15%',
1166   - top: '5%',
1167   - containLabel: true
1168   - },
  735 + legend: { top: 0, textStyle: { color: '#303133', fontSize: 12 }, itemGap: 20 },
  736 + grid: { left: '3%', right: '4%', bottom: '3%', containLabel: true },
1169 737 xAxis: {
1170 738 type: 'category',
1171   - data: storeNames,
1172   - axisLabel: {
1173   - rotate: 45,
1174   - interval: 0,
1175   - fontSize: 12
1176   - }
  739 + boundaryGap: false,
  740 + data: dates,
  741 + axisLine: { lineStyle: { color: '#E4E7ED' } },
  742 + axisLabel: { color: '#303133', fontSize: 12 }
1177 743 },
1178 744 yAxis: {
1179 745 type: 'value',
  746 + splitLine: { lineStyle: { type: 'dashed', color: '#E4E7ED' } },
  747 + axisLine: { lineStyle: { color: '#E4E7ED' } },
1180 748 axisLabel: {
1181   - formatter: function(value) {
1182   - return '¥' + value
  749 + color: '#303133',
  750 + fontSize: 12,
  751 + formatter: function (value) {
  752 + if (value >= 10000) {
  753 + return (value / 10000).toFixed(1) + '万'
  754 + }
  755 + return value
1183 756 }
1184 757 }
1185 758 },
1186 759 series: [
1187 760 {
1188   - name: '现金业绩',
1189   - type: 'bar',
1190   - data: targetPerformance,
1191   - itemStyle: {
1192   - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
1193   - { offset: 0, color: '#8A2BE2' },
1194   - { offset: 1, color: '#9D4EDD' }
1195   - ])
1196   - },
1197   - barWidth: '30%',
1198   - label: {
1199   - show: false,
1200   - position: 'inside',
1201   - formatter: (params) => {
1202   - // 将数字转换为纵向显示
1203   - const value = params.value;
1204   - return String(value).split('').join('\n');
1205   - },
1206   - fontSize: 10,
1207   - color: '#efefef',
1208   - fontWeight: 'bold'
1209   - }
  761 + name: '成交额',
  762 + type: 'line',
  763 + smooth: true,
  764 + showSymbol: dates.length === 1 ? true : dates.length <= 7 ? true : false,
  765 + symbol: 'circle',
  766 + symbolSize: 6,
  767 + areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(64,158,255,0.3)' }, { offset: 1, color: 'rgba(64,158,255,0)' }]) },
  768 + data: billingData,
  769 + color: '#409EFF',
  770 + lineStyle: { width: 2 }
1210 771 },
1211 772 {
1212   - name: '消耗业绩',
1213   - type: 'bar',
1214   - data: actualPerformance,
1215   - itemStyle: {
1216   - color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
1217   - { offset: 0, color: '#FFA500' },
1218   - { offset: 1, color: '#FF8C00' }
1219   - ])
1220   - },
1221   - barWidth: '30%',
1222   - label: {
1223   - show: false,
1224   - position: 'inside',
1225   - formatter: (params) => {
1226   - // 将数字转换为纵向显示
1227   - const value = params.value;
1228   - return String(value).split('').join('\n');
1229   - },
1230   - fontSize: 10,
1231   - color: '#efefef',
1232   - fontWeight: 'bold'
1233   - }
  773 + name: '服务产出',
  774 + type: 'line',
  775 + smooth: true,
  776 + showSymbol: dates.length === 1 ? true : dates.length <= 7 ? true : false,
  777 + symbol: 'circle',
  778 + symbolSize: 6,
  779 + areaStyle: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: 'rgba(103,194,58,0.3)' }, { offset: 1, color: 'rgba(103,194,58,0)' }]) },
  780 + data: consumeData,
  781 + color: '#67C23A',
  782 + lineStyle: { width: 2 }
1234 783 }
1235 784 ]
  785 + })
  786 + },
  787 + renderFunnelChart() {
  788 + if (!this.tkStatisticsData) return
  789 + const chart = this.getChart('tkFunnelChart')
  790 + const d = this.tkStatisticsData
  791 + chart.setOption({
  792 + tooltip: { trigger: 'item' },
  793 + series: [{
  794 + type: 'funnel', left: '10%', top: 20, bottom: 20, width: '80%',
  795 + label: { show: true, position: 'inside', formatter: '{b}\n{c}人', color: '#fff' },
  796 + itemStyle: { borderWidth: 0, shadowBlur: 10, shadowColor: 'rgba(0,0,0,0.1)' },
  797 + data: [
  798 + { value: d.TkCount, name: '获客' },
  799 + { value: d.YaoyCount, name: '邀约' },
  800 + { value: d.DdCount, name: '到店' },
  801 + { value: d.XfCount, name: '成交' }
  802 + ],
  803 + color: ['#409EFF', '#67C23A', '#E6A23C', '#F56C6C']
  804 + }]
  805 + })
  806 + },
  807 + renderGoldChart() {
  808 + const chart = this.getChart('goldTriangleChart')
  809 + if (!this.goldTriangleRankings || this.goldTriangleRankings.length === 0) {
  810 + chart.setOption({
  811 + title: { text: '暂无数据', left: 'center', top: 'middle', textStyle: { color: '#909399' } }
  812 + })
  813 + return
1236 814 }
1237   -
1238   - myChart.setOption(option)
1239   -
1240   - window.addEventListener('resize', () => {
1241   - myChart.resize()
  815 +
  816 + const sorted = [...this.goldTriangleRankings]
  817 + .sort((a, b) => (b.F_TotalPerformance || b.TotalPerformance || 0) - (a.F_TotalPerformance || a.TotalPerformance || 0))
  818 + .slice(0, 5)
  819 +
  820 + chart.setOption({
  821 + tooltip: { trigger: 'axis' },
  822 + grid: { left: '25%', right: '10%', top: 10, bottom: 20 },
  823 + xAxis: { type: 'value', show: false },
  824 + yAxis: {
  825 + type: 'category',
  826 + data: sorted.map(i => i.F_GoldTriangleName || i.GoldTriangleName || '未知'),
  827 + axisLine: { show: false },
  828 + axisTick: { show: false },
  829 + axisLabel: { fontSize: 11, color: '#909399' }
  830 + },
  831 + series: [{
  832 + type: 'bar',
  833 + data: sorted.map(i => i.F_TotalPerformance || i.TotalPerformance || 0),
  834 + barWidth: 10,
  835 + itemStyle: { borderRadius: 5, color: '#E6A23C' },
  836 + showBackground: true,
  837 + backgroundStyle: { color: '#F2F6FC', borderRadius: 5 }
  838 + }]
1242 839 })
1243 840 },
  841 + renderVisitChart() {
  842 + const chart = this.getChart('visitFreqChart')
  843 + if (!this.customerVisitFrequencyData || this.customerVisitFrequencyData.length === 0) {
  844 + chart.setOption({
  845 + title: { text: '暂无数据', left: 'center', top: 'middle', textStyle: { color: '#909399' } }
  846 + })
  847 + return
  848 + }
  849 +
  850 + const data = this.customerVisitFrequencyData
  851 + .sort((a, b) => (a.VisitCount || 0) - (b.VisitCount || 0))
  852 + .slice(0, 8)
1244 853  
1245   - // 初始化客户到店次数分布柱状图
1246   - initCustomerVisitFrequencyChart() {
1247   - if (!this.customerVisitFrequencyData || this.customerVisitFrequencyData.length === 0) return
1248   -
1249   - const chartDom = document.getElementById('customerVisitFrequencyChart')
1250   - if (!chartDom) return
1251   -
1252   - // 按 VisitCount 降序排序(从高到低)
1253   - const sortedData = [...this.customerVisitFrequencyData].sort((a, b) => (b.VisitCount || 0) - (a.VisitCount || 0))
1254   -
1255   - const visitCounts = sortedData.map(item => `${item.VisitCount || 0}次`)
1256   - const customerCounts = sortedData.map(item => item.CustomerCount || 0)
1257   -
1258   - const myChart = echarts.init(chartDom)
1259   -
1260   - const option = {
  854 + chart.setOption({
1261 855 tooltip: {
1262 856 trigger: 'axis',
1263   - axisPointer: {
1264   - type: 'shadow'
1265   - },
1266   - formatter: function(params) {
  857 + formatter: function (params) {
1267 858 const param = params[0]
1268   - return `${param.name}<br/>人数: ${param.value}`
  859 + return param.name + '<br/>' + param.seriesName + ': ' + param.value + '人'
1269 860 }
1270 861 },
1271   - grid: {
1272   - left: '3%',
1273   - right: '4%',
1274   - bottom: '10%',
1275   - top: '7%',
1276   - containLabel: true
1277   - },
  862 + grid: { left: '15%', right: '10%', top: '10%', bottom: '15%' },
1278 863 xAxis: {
1279 864 type: 'category',
1280   - data: visitCounts,
1281   - axisLabel: {
1282   - fontSize: 12,
1283   - color: '#606266'
1284   - },
1285   - axisLine: {
1286   - lineStyle: {
1287   - color: '#DCDFE6'
1288   - }
1289   - }
  865 + data: data.map(i => (i.VisitCount || 0) + '次'),
  866 + axisLine: { show: true, lineStyle: { color: '#E4E7ED' } },
  867 + axisTick: { show: false },
  868 + axisLabel: { color: '#606266', fontSize: 12 }
1290 869 },
1291 870 yAxis: {
1292 871 type: 'value',
1293   - name: '人数',
1294   - nameTextStyle: {
1295   - color: '#606266',
1296   - fontSize: 12
1297   - },
1298   - axisLabel: {
1299   - fontSize: 12,
1300   - color: '#606266'
1301   - },
1302   - axisLine: {
1303   - lineStyle: {
1304   - color: '#DCDFE6'
1305   - }
1306   - },
1307   - splitLine: {
1308   - lineStyle: {
1309   - color: '#EBEEF5',
1310   - type: 'dashed'
1311   - }
1312   - }
  872 + show: true,
  873 + axisLine: { show: false },
  874 + axisTick: { show: false },
  875 + splitLine: { lineStyle: { type: 'dashed', color: '#E4E7ED' } },
  876 + axisLabel: { color: '#909399', fontSize: 12 }
1313 877 },
1314   - series: [
1315   - {
1316   - name: '人数',
1317   - type: 'bar',
1318   - data: customerCounts,
1319   - itemStyle: {
1320   - color: '#409EFF'
1321   - },
1322   - barWidth: '50%',
1323   - label: {
1324   - show: true,
1325   - position: 'top',
1326   - fontSize: 12,
1327   - color: '#303133',
1328   - fontWeight: '500'
1329   - }
  878 + series: [{
  879 + type: 'bar',
  880 + name: '客户数',
  881 + data: data.map(i => i.CustomerCount || 0),
  882 + color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
  883 + { offset: 0, color: '#409EFF' },
  884 + { offset: 1, color: '#67C23A' }
  885 + ]),
  886 + barWidth: '50%',
  887 + itemStyle: { borderRadius: [4, 4, 0, 0] },
  888 + label: {
  889 + show: true,
  890 + position: 'top',
  891 + color: '#303133',
  892 + fontSize: 12
1330 893 }
1331   - ]
1332   - }
1333   -
1334   - myChart.setOption(option)
1335   -
1336   - window.addEventListener('resize', () => {
1337   - myChart.resize()
  894 + }]
1338 895 })
1339 896 },
1340   -
1341   - // 获取环形图样式
1342   - getDonutStyle(rate) {
1343   - // rate 是小数形式(如 0.75 表示 75%),需要转换为百分比
1344   - const percentage = (rate || 0) * 100
1345   - return {
1346   - background: `conic-gradient(#EC4899 0% ${percentage}%, #E5E7EB ${percentage}% 100%)`
1347   - }
  897 + renderCategoryChart() {
  898 + // 这个图表已经改为开单品项TOP10列表,不再需要渲染图表
  899 + // 保留方法避免报错
1348 900 },
1349   -
1350   - // 计算进度条宽度
1351   - getProgressWidth(value) {
1352   - if (!value && value !== 0) return '0%'
1353   - // 假设最大值为500
1354   - const maxValue = 500
1355   - const percentage = (value / maxValue) * 100
1356   - return Math.min(percentage, 100) + '%'
  901 + getChart(id) {
  902 + const dom = document.getElementById(id)
  903 + if (!dom) return { setOption: () => { } }
  904 + if (this.charts[id]) this.charts[id].dispose()
  905 + this.charts[id] = echarts.init(dom)
  906 + return this.charts[id]
1357 907 },
1358   -
1359   - // 计算柱状图宽度(用于蝴蝶图)
1360   - getButterflyBarWidth(value, maxValue) {
1361   - if (!value && value !== 0 || !maxValue || maxValue === 0) return 0
1362   - const percentage = (value / maxValue) * 100
1363   - return Math.min(percentage, 100)
1364   - },
1365   -
1366   - // 重置查询条件
1367   - reset() {
1368   - this.query = {
1369   - startTime: undefined,
1370   - endTime: undefined,
1371   - storeIds: []
  908 + handleResize() { Object.values(this.charts).forEach(c => c && c.resize()) },
  909 + async initStoreOptions() {
  910 + try {
  911 + const res = await request({ url: '/api/Extend/LqMdxx/Selector', method: 'GET' })
  912 + // 接口返回格式: { list: [...] }
  913 + this.storeOptions = (res.data && res.data.list) ? res.data.list : []
  914 + } catch (error) {
  915 + console.error('加载门店列表失败:', error)
  916 + this.storeOptions = []
1372 917 }
1373   - this.setDefaultTimeRange()
1374   - this.businessData = null
1375   - this.customerData = null
1376   - this.performanceData = []
1377   - this.itemStatisticsData = []
1378   - this.storeItemStatisticsData = []
1379   - this.customerVisitFrequencyData = []
1380   - this.healthCoachBillingRankingData = []
1381   - this.storeRemainingRightsData = []
1382   - this.tkStatisticsData = null
1383   - this.gaugeItems = []
1384   - },
1385   -
1386   - // 获取排名索引(从1开始)
1387   - getRankIndex(index) {
1388   - return index + 1
1389   - },
1390   -
1391   - // 格式化金额
1392   - formatMoney(amount) {
1393   - if (!amount && amount !== 0) return '0.00'
1394   - return Number(amount).toFixed(2)
1395   - },
1396   -
1397   - // 格式化百分比
1398   - formatPercent(ratio) {
1399   - if (!ratio && ratio !== 0) return '0.00'
1400   - return Number(ratio).toFixed(2)
1401   - },
1402   -
1403   - // 格式化日期时间(用于API传参)
1404   - formatDateTime(timestamp) {
1405   - if (!timestamp) return ''
1406   - const date = new Date(timestamp)
1407   - const year = date.getFullYear()
1408   - const month = String(date.getMonth() + 1).padStart(2, '0')
1409   - const day = String(date.getDate()).padStart(2, '0')
1410   - const hours = String(date.getHours()).padStart(2, '0')
1411   - const minutes = String(date.getMinutes()).padStart(2, '0')
1412   - const seconds = String(date.getSeconds()).padStart(2, '0')
1413   - return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
1414   - },
1415   -
1416   - // 字段配置相关方法
1417   - // 判断字段是否可见
1418   - isFieldVisible(fieldProp) {
1419   - return this.selectedFields.includes(fieldProp)
1420   - },
1421   -
1422   - // 全选字段
1423   - selectAllFields() {
1424   - this.selectedFields = this.availableFields.map(field => field.prop)
1425   - },
1426   -
1427   - // 全不选字段
1428   - unselectAllFields() {
1429   - this.selectedFields = []
1430 918 },
1431   -
1432   - // 确认字段配置
1433   - confirmFieldConfig() {
1434   - if (this.selectedFields.length === 0) {
1435   - this.$message.warning('至少需要选择一个字段')
1436   - return
1437   - }
1438   - this.showFieldConfigDialog = false
  919 + formatMoney(v) { return Number(v || 0).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 }) },
  920 + formatPercent(v) { return Number(v || 0).toFixed(1) },
  921 + getTkInviteRate() {
  922 + if (!this.tkStatisticsData || !this.tkStatisticsData.TkCount) return 0
  923 + return (this.tkStatisticsData.YaoyCount / this.tkStatisticsData.TkCount * 100)
1439 924 },
1440   -
1441   - // 处理排序变化
1442   - handleSortChange({ column, prop, order }) {
1443   - if (!order) {
1444   - // 取消排序,恢复到原始数据顺序
1445   - this.sortParams = { prop: null, order: null }
1446   - this.storeItemStatisticsData = JSON.parse(JSON.stringify(this.originalStoreItemStatisticsData))
1447   - return
1448   - }
1449   - this.sortParams = { prop, order }
1450   - this.sortTableData()
  925 + getInviteStoreRate() {
  926 + if (!this.tkStatisticsData || !this.tkStatisticsData.YaoyCount) return 0
  927 + return (this.tkStatisticsData.DdCount / this.tkStatisticsData.YaoyCount * 100)
1451 928 },
1452   -
1453   - // 对表格数据进行排序
1454   - sortTableData() {
1455   - if (!this.sortParams.prop || !this.sortParams.order) {
1456   - return
1457   - }
1458   -
1459   - const { prop, order } = this.sortParams
1460   - const data = [...this.storeItemStatisticsData]
1461   -
1462   - data.sort((a, b) => {
1463   - let valA = a[prop]
1464   - let valB = b[prop]
1465   -
1466   - // 处理空值
1467   - if (valA == null) valA = 0
1468   - if (valB == null) valB = 0
1469   -
1470   - // 确保是数字类型
1471   - valA = Number(valA) || 0
1472   - valB = Number(valB) || 0
1473   -
1474   - if (order === 'ascending') {
1475   - return valA - valB
1476   - } else {
1477   - return valB - valA
1478   - }
1479   - })
1480   -
1481   - this.storeItemStatisticsData = data
1482   - }
  929 + confirmFieldConfig() { this.showFieldConfigDialog = false },
  930 + selectAllFields() { this.selectedFields = this.availableFields.map(f => f.prop) },
  931 + unselectAllFields() { this.selectedFields = [] }
1483 932 }
1484 933 }
1485 934 </script>
1486 935  
1487 936 <style lang="scss" scoped>
1488   -.business-report-page {
1489   - padding: 20px;
1490   - background: #f5f6fa;
  937 +.leadership-cockpit {
  938 + padding: 16px;
  939 + background-color: #f5f7fa;
1491 940 min-height: 100vh;
1492   -}
1493   -
1494   -.search-box-container {
1495   - margin-bottom: 20px;
1496   -}
  941 + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
1497 942  
1498   -.search-form {
1499   - display: flex;
1500   - align-items: center;
1501   -}
1502   -
1503   -.report-card {
1504   - margin-bottom: 20px;
1505   - border-radius: 8px;
1506   -
1507   - .card-header {
  943 + .cockpit-header {
1508 944 display: flex;
  945 + justify-content: space-between;
1509 946 align-items: center;
1510   - font-size: 18px;
1511   - font-weight: 600;
1512   - color: #303133;
1513   -
1514   - i {
1515   - margin-right: 10px;
  947 + margin-bottom: 20px;
  948 + background: #fff;
  949 + padding: 12px 20px;
  950 + border-radius: 8px;
  951 + box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
  952 +
  953 + .page-title {
  954 + margin: 0;
1516 955 font-size: 20px;
1517   - color: #409EFF;
1518   - }
1519   - }
1520   -}
  956 + color: #303133;
  957 + font-weight: 600;
1521 958  
1522   -/* 业务统计仪表盘 */
1523   -.gauge-dashboard {
1524   - display: grid;
1525   - grid-template-columns: repeat(5, 1fr);
1526   - gap: 30px;
1527   - padding: 30px 0;
1528   -}
  959 + .subtitle {
  960 + font-size: 13px;
  961 + color: #909399;
  962 + font-weight: normal;
  963 + margin-left: 12px;
  964 + }
  965 + }
1529 966  
1530   -.gauge-item-wrapper {
1531   - position: relative;
1532   -}
  967 + .search-form-compact {
  968 + .el-form-item {
  969 + margin-bottom: 0;
  970 + margin-right: 15px;
  971 + }
1533 972  
1534   -.gauge-item {
1535   - background: linear-gradient(135deg, #fff 0%, #f9fafb 100%);
1536   - border-radius: 12px;
1537   - padding: 0 20px;
1538   - text-align: center;
1539   - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
1540   - transition: all 0.3s ease;
1541   -
1542   - &:hover {
1543   - transform: translateY(-5px);
1544   - box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  973 + .range-separator {
  974 + margin: 0 8px;
  975 + color: #DCDFE6;
  976 + }
  977 + }
1545 978 }
1546   -}
1547   -
1548   -.gauge-chart-container {
1549   - position: relative;
1550   - margin: 10px 0;
1551   - min-height: 240px;
1552   -}
1553 979  
1554   -.gauge-chart {
1555   - height: 240px;
1556   -}
  980 + /* KPI Cards */
  981 + .kpi-row {
  982 + margin-bottom: 16px;
  983 + }
1557 984  
1558   -.gauge-value-overlay {
1559   - position: absolute;
1560   - top: 0;
1561   - left: 0;
1562   - right: 0;
1563   - bottom: 0;
1564   - display: flex;
1565   - flex-direction: column;
1566   - align-items: center;
1567   - justify-content: center;
1568   - pointer-events: none;
1569   - padding-top: 40px;
1570   -
1571   - .gauge-icon-wrapper {
1572   - width: 55px;
1573   - height: 55px;
1574   - border-radius: 50%;
1575   - background: linear-gradient(135deg, #409EFF, #67C23A);
  985 + .kpi-card {
  986 + background: #fff;
  987 + padding: 20px;
  988 + border-radius: 8px;
1576 989 display: flex;
1577 990 align-items: center;
1578   - justify-content: center;
1579   - margin-bottom: 12px;
1580   - box-shadow: 0 4px 12px rgba(64, 158, 255, 0.3);
1581   -
1582   - i {
1583   - font-size: 26px;
1584   - color: #fff;
  991 + position: relative;
  992 + overflow: hidden;
  993 + height: 100px;
  994 + box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.04);
  995 + transition: transform 0.3s;
  996 +
  997 + &:hover {
  998 + transform: translateY(-4px);
1585 999 }
1586   - }
1587   -
1588   - .gauge-value-large {
1589   - font-size: 26px;
1590   - font-weight: bold;
1591   - color: #303133;
1592   - margin-bottom: 6px;
1593   - letter-spacing: 0;
1594   - text-align: center;
1595   - line-height: 1.2;
1596   - max-width: 280px;
1597   - word-wrap: break-word;
1598   - overflow-wrap: break-word;
1599   - }
1600   -
1601   - .gauge-label-text {
1602   - font-size: 14px;
1603   - color: #909399;
1604   - font-weight: 500;
1605   - }
1606   -}
1607 1000  
1608   -.gauge-range-info {
1609   - display: flex;
1610   - align-items: center;
1611   - justify-content: center;
1612   - margin-top: 10px;
1613   -
1614   - .range-label,
1615   - .range-value {
1616   - font-size: 12px;
1617   - color: #909399;
1618   - }
1619   -
1620   - .range-divider {
1621   - flex: 1;
1622   - height: 1px;
1623   - background: #DCDFE6;
1624   - margin: 0 10px;
1625   - }
1626   -}
  1001 + &.primary {
  1002 + border-left: 4px solid #409EFF;
1627 1003  
1628   -/* 客户类型统计 */
1629   -.customer-stats-container {
1630   - padding: 20px 0;
1631   -}
  1004 + .kpi-icon {
  1005 + color: #409EFF;
  1006 + background: rgba(64, 158, 255, 0.1);
  1007 + }
  1008 + }
1632 1009  
1633   -.stats-grid {
1634   - display: grid;
1635   - grid-template-columns: repeat(5, 1fr);
1636   - gap: 20px;
1637   -}
  1010 + &.success {
  1011 + border-left: 4px solid #67C23A;
1638 1012  
1639   -.stat-card {
1640   - background: linear-gradient(135deg, #fff 0%, #f9fafb 100%);
1641   - border-radius: 12px;
1642   - padding: 20px;
1643   - display: flex;
1644   - align-items: center;
1645   - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
1646   - transition: all 0.3s ease;
1647   - min-height: 100px;
1648   -
1649   - &:hover {
1650   - transform: translateY(-3px);
1651   - box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
1652   - }
1653   -
1654   - &.stat-card-purple {
1655   - .stat-icon {
1656   - background: linear-gradient(135deg, #8A2BE2, #A855F7);
1657   - }
1658   - .progress-bar {
1659   - background: linear-gradient(90deg, #8A2BE2, #A855F7);
1660   - }
1661   - }
1662   -
1663   - &.stat-card-blue {
1664   - .stat-icon {
1665   - background: linear-gradient(135deg, #3B82F6, #60A5FA);
1666   - }
1667   - .progress-bar {
1668   - background: linear-gradient(90deg, #3B82F6, #60A5FA);
1669   - }
1670   - }
1671   -
1672   - &.stat-card-green {
1673   - .stat-icon {
1674   - background: linear-gradient(135deg, #10B981, #34D399);
1675   - }
1676   - .progress-bar {
1677   - background: linear-gradient(90deg, #10B981, #34D399);
1678   - }
1679   - }
1680   -
1681   - &.stat-card-cyan {
1682   - .stat-icon {
1683   - background: linear-gradient(135deg, #06B6D4, #22D3EE);
1684   - }
1685   - .progress-bar {
1686   - background: linear-gradient(90deg, #06B6D4, #22D3EE);
1687   - }
1688   - }
1689   -
1690   - &.stat-card-orange {
1691   - .stat-icon {
1692   - background: linear-gradient(135deg, #F97316, #FB923C);
1693   - }
1694   - .progress-bar {
1695   - background: linear-gradient(90deg, #F97316, #FB923C);
1696   - }
1697   - }
1698   -
1699   - &.stat-card-pink {
1700   - .stat-icon {
1701   - background: linear-gradient(135deg, #EC4899, #F472B6);
1702   - }
1703   - .progress-bar {
1704   - background: linear-gradient(90deg, #EC4899, #F472B6);
  1013 + .kpi-icon {
  1014 + color: #67C23A;
  1015 + background: rgba(103, 194, 58, 0.1);
  1016 + }
1705 1017 }
1706   - }
1707   -}
1708 1018  
1709   -.stat-icon {
1710   - width: 48px;
1711   - height: 48px;
1712   - border-radius: 12px;
1713   - display: flex;
1714   - align-items: center;
1715   - justify-content: center;
1716   - margin-right: 12px;
1717   - flex-shrink: 0;
1718   -
1719   - i {
1720   - font-size: 22px;
1721   - color: #fff;
1722   - }
1723   -}
  1019 + &.warning {
  1020 + border-left: 4px solid #E6A23C;
1724 1021  
1725   -.stat-content {
1726   - flex: 1;
1727   -}
  1022 + .kpi-icon {
  1023 + color: #E6A23C;
  1024 + background: rgba(230, 162, 60, 0.1);
  1025 + }
  1026 + }
1728 1027  
1729   -.stat-label {
1730   - font-size: 13px;
1731   - color: #909399;
1732   - margin-bottom: 6px;
1733   - white-space: nowrap;
1734   -}
  1028 + &.info {
  1029 + border-left: 4px solid #909399;
1735 1030  
1736   -.stat-value {
1737   - font-size: 24px;
1738   - font-weight: bold;
1739   - color: #303133;
1740   - line-height: 1.2;
1741   -}
  1031 + .kpi-icon {
  1032 + color: #909399;
  1033 + background: rgba(144, 147, 153, 0.1);
  1034 + }
  1035 + }
1742 1036  
1743   -.stat-progress {
1744   - height: 6px;
1745   - background: #E5E7EB;
1746   - border-radius: 3px;
1747   - overflow: hidden;
1748   -}
  1037 + &.danger {
  1038 + border-left: 4px solid #F56C6C;
1749 1039  
1750   -.progress-bar {
1751   - height: 100%;
1752   - border-radius: 3px;
1753   - transition: width 0.8s ease;
1754   -}
  1040 + .kpi-icon {
  1041 + color: #F56C6C;
  1042 + background: rgba(245, 108, 108, 0.1);
  1043 + }
  1044 + }
1755 1045  
1756   -.conversion-rate-card {
1757   - background: linear-gradient(135deg, #fff 0%, #f9fafb 100%);
1758   - border-radius: 12px;
1759   - padding: 15px;
1760   - display: flex;
1761   - align-items: center;
1762   - justify-content: center;
1763   - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
1764   - transition: all 0.3s ease;
1765   - min-height: 100px;
1766   -
1767   - &:hover {
1768   - transform: translateY(-3px);
1769   - box-shadow: 0 8px 24px rgba(236, 72, 153, 0.2);
1770   - }
1771   -}
  1046 + &.error {
  1047 + border-left: 4px solid #f5222d;
1772 1048  
1773   -.donut-wrapper {
1774   - width: 100%;
1775   - height: 100%;
1776   - position: relative;
1777   - display: flex;
1778   - align-items: center;
1779   - justify-content: center;
1780   -}
  1049 + .kpi-icon {
  1050 + color: #f5222d;
  1051 + background: rgba(245, 34, 45, 0.1);
  1052 + }
  1053 + }
1781 1054  
1782   -.donut-chart {
1783   - width: 120px;
1784   - height: 120px;
1785   - border-radius: 50%;
1786   - display: flex;
1787   - align-items: center;
1788   - justify-content: center;
1789   - padding: 8px;
1790   - background: #fff;
1791   - box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
1792   -
1793   - .donut-center {
1794   - width: 104px;
1795   - height: 104px;
1796   - border-radius: 50%;
1797   - background: #fff;
1798   - display: flex;
1799   - flex-direction: column;
1800   - align-items: center;
1801   - justify-content: center;
1802   - padding: 8px;
1803   -
1804   - .conversion-title {
1805   - font-size: 12px;
  1055 + .kpi-icon {
  1056 + width: 48px;
  1057 + height: 48px;
  1058 + border-radius: 50%;
  1059 + display: flex;
  1060 + align-items: center;
  1061 + justify-content: center;
  1062 + font-size: 24px;
  1063 + margin-right: 15px;
  1064 + }
  1065 +
  1066 + .kpi-label {
  1067 + font-size: 13px;
1806 1068 color: #909399;
1807 1069 margin-bottom: 6px;
1808   - font-weight: 500;
1809   - text-align: center;
1810   - white-space: nowrap;
1811 1070 }
1812   -
1813   - .percentage {
  1071 +
  1072 + .kpi-value {
1814 1073 font-size: 20px;
1815 1074 font-weight: bold;
1816   - color: #EC4899;
1817   - line-height: 1;
1818   - text-align: center;
1819   - }
1820   - }
1821   -}
1822   -
1823   -/* 图表行容器 */
1824   -.charts-row {
1825   - display: grid;
1826   - grid-template-columns: 1fr 1fr;
1827   - gap: 20px;
1828   - margin-bottom: 20px;
1829   -}
1830   -
1831   -.half-width {
1832   - margin-bottom: 0;
1833   -}
1834   -
1835   -/* 图表容器 */
1836   -.chart-container {
1837   - width: 100%;
1838   - height: 500px;
1839   - margin-top: 20px;
1840   -}
1841   -
1842   -.chart-container-half {
1843   - width: 100%;
1844   - height: 400px;
1845   - margin-top: 20px;
1846   -}
  1075 + color: #303133;
1847 1076  
1848   -/* 蝴蝶图样式 */
1849   -.butterfly-chart-container {
1850   - padding: 10px 0;
1851   -}
  1077 + .unit {
  1078 + font-size: 13px;
  1079 + margin: 0 2px;
  1080 + }
  1081 + }
1852 1082  
1853   -.chart-legend {
1854   - display: flex;
1855   - justify-content: center;
1856   - gap: 20px;
1857   - margin-bottom: 15px;
1858   -}
  1083 + .kpi-trend {
  1084 + font-size: 11px;
  1085 + color: #c0c4cc;
  1086 + margin-top: 4px;
1859 1087  
1860   -.legend-item {
1861   - display: flex;
1862   - align-items: center;
1863   - gap: 8px;
1864   -}
1865   -
1866   -.legend-color {
1867   - width: 50px;
1868   - height: 20px;
1869   - border-radius: 4px;
1870   -}
  1088 + i {
  1089 + color: #67C23A;
  1090 + }
  1091 + }
  1092 + }
1871 1093  
1872   -.legend-purple {
1873   - background: linear-gradient(90deg, #8A2BE2, #9D4EDD);
1874   -}
  1094 + /* Dashboard Cards */
  1095 + .dashboard-card {
  1096 + border: none;
  1097 + border-radius: 8px;
  1098 + margin-bottom: 16px;
1875 1099  
1876   -.legend-orange {
1877   - background: linear-gradient(90deg, #FFA500, #FF8C00);
1878   -}
1879   -
1880   -.legend-text {
1881   - font-size: 14px;
1882   - color: #303133;
1883   - font-weight: 500;
1884   -}
  1100 + &::v-deep .el-card__header {
  1101 + padding: 12px 20px;
  1102 + border-bottom: 1px solid #f0f2f5;
  1103 + }
1885 1104  
1886   -.chart-axis {
1887   - padding: 0 50px;
1888   - margin-bottom: 10px;
1889   -}
  1105 + .card-title {
  1106 + font-size: 15px;
  1107 + font-weight: 600;
  1108 + color: #303133;
1890 1109  
1891   -.axis-labels {
1892   - display: grid;
1893   - grid-template-columns: repeat(14, 1fr);
1894   - gap: 0;
1895   -}
  1110 + i {
  1111 + color: #409EFF;
  1112 + margin-right: 8px;
  1113 + }
  1114 + }
  1115 + }
1896 1116  
1897   -.axis-label {
1898   - font-size: 11px;
1899   - color: #909399;
1900   - text-align: center;
1901   -}
  1117 + .chart-box {
  1118 + height: 320px;
  1119 + width: 100%;
  1120 + }
1902 1121  
1903   -.butterfly-chart-content {
1904   - display: grid;
1905   - grid-template-columns: 1fr auto 1fr;
1906   - gap: 8px;
1907   - align-items: center;
1908   - padding: 0 20px;
1909   -}
  1122 + .chart-box-mini {
  1123 + height: 180px;
  1124 + width: 100%;
  1125 + }
1910 1126  
1911   -.chart-left,
1912   -.chart-right {
1913   - display: flex;
1914   - flex-direction: column;
1915   - justify-content: space-around;
1916   -}
  1127 + /* 统一卡片高度 */
  1128 + .analysis-row {
  1129 + .dashboard-card {
  1130 + height: 400px;
  1131 + display: flex;
  1132 + flex-direction: column;
  1133 +
  1134 + &::v-deep .el-card__body {
  1135 + flex: 1;
  1136 + display: flex;
  1137 + flex-direction: column;
  1138 + overflow: hidden;
  1139 + }
1917 1140  
1918   -.chart-row {
1919   - height: 32px;
1920   - margin-bottom: 6px;
1921   - display: flex;
1922   - align-items: center;
1923   -}
  1141 + .chart-box {
  1142 + flex: 1;
  1143 + min-height: 0;
  1144 + }
  1145 + }
1924 1146  
1925   -.chart-left .chart-row {
1926   - justify-content: flex-end;
1927   -}
  1147 + .funnel-card {
  1148 + &::v-deep .el-card__body {
  1149 + padding-bottom: 50px;
  1150 + }
  1151 + }
  1152 + }
1928 1153  
1929   -.chart-right .chart-row {
1930   - justify-content: flex-start;
1931   -}
  1154 + .ranking-row {
  1155 + .dashboard-card {
  1156 + height: 540px;
  1157 + display: flex;
  1158 + flex-direction: column;
  1159 +
  1160 + &::v-deep .el-card__body {
  1161 + flex: 1;
  1162 + display: flex;
  1163 + flex-direction: column;
  1164 + overflow: hidden;
  1165 + padding: 20px;
  1166 + }
1932 1167  
1933   -.bar-left,
1934   -.bar-right {
1935   - height: 28px;
1936   - display: flex;
1937   - align-items: center;
1938   - border-radius: 4px;
1939   - min-width: 50px;
1940   -}
  1168 + .rank-list {
  1169 + flex: 1;
  1170 + overflow-y: auto;
  1171 + max-height: 100%;
  1172 + }
1941 1173  
1942   -.bar-left {
1943   - background: linear-gradient(90deg, #8A2BE2, #9D4EDD);
1944   - justify-content: flex-end;
1945   - padding-right: 10px;
1946   -}
  1174 + &::v-deep .el-table {
  1175 + flex: 1;
  1176 + overflow: hidden;
  1177 + }
1947 1178  
1948   -.bar-right {
1949   - background: linear-gradient(90deg, #FFA500, #FF8C00);
1950   - justify-content: flex-start;
1951   - padding-left: 10px;
1952   -}
  1179 + &::v-deep .el-table__body-wrapper {
  1180 + max-height: calc(100% - 40px);
  1181 + overflow-y: auto;
  1182 + }
  1183 + }
  1184 + }
1953 1185  
1954   -.bar-value {
1955   - font-size: 11px;
1956   - font-weight: 500;
1957   - color: #fff;
1958   -}
  1186 + /* Rankings */
  1187 + .rank-list {
  1188 + .rank-item {
  1189 + display: flex;
  1190 + align-items: center;
  1191 + padding: 12px 0;
  1192 + border-bottom: 1px dotted #EBEEF5;
1959 1193  
1960   -.chart-center {
1961   - min-width: 100px;
1962   - display: flex;
1963   - flex-direction: column;
1964   - justify-content: space-around;
1965   - align-items: center;
1966   - padding: 0 10px;
1967   -}
  1194 + &:last-child {
  1195 + border-bottom: none;
  1196 + }
1968 1197  
1969   -.category-name {
1970   - height: 32px;
1971   - font-size: 12px;
1972   - color: #303133;
1973   - display: flex;
1974   - align-items: center;
1975   - margin-bottom: 6px;
1976   - text-align: center;
1977   - line-height: 1.4;
1978   -}
  1198 + .rank-no {
  1199 + width: 20px;
  1200 + height: 20px;
  1201 + border-radius: 4px;
  1202 + background: #909399;
  1203 + color: #fff;
  1204 + font-size: 12px;
  1205 + display: flex;
  1206 + align-items: center;
  1207 + justify-content: center;
  1208 + margin-right: 12px;
  1209 +
  1210 + &.top1 {
  1211 + background: #F56C6C;
  1212 + }
1979 1213  
1980   -/* 字段配置对话框样式 */
1981   -.field-config-content {
1982   - max-height: 400px;
1983   - overflow-y: auto;
1984   -}
  1214 + &.top2 {
  1215 + background: #E6A23C;
  1216 + }
1985 1217  
1986   -.field-config-actions {
1987   - display: flex;
1988   - justify-content: flex-end;
1989   - gap: 10px;
1990   - padding-bottom: 10px;
1991   - border-bottom: 1px solid #EBEEF5;
1992   -}
  1218 + &.top3 {
  1219 + background: #409EFF;
  1220 + }
  1221 + }
1993 1222  
1994   -.field-config-item {
1995   - padding: 10px 0;
1996   - border-bottom: 1px solid #F5F7FA;
  1223 + .rank-name {
  1224 + flex: 1;
  1225 + color: #606266;
  1226 + font-size: 14px;
  1227 + }
1997 1228  
1998   - &:last-child {
1999   - border-bottom: none;
  1229 + .rank-val {
  1230 + font-weight: 600;
  1231 + color: #303133;
  1232 + font-size: 14px;
  1233 + }
  1234 + }
2000 1235 }
2001 1236  
2002   - ::v-deep .el-checkbox {
2003   - width: 100%;
  1237 + /* Funnel Stats */
  1238 + .funnel-stats {
  1239 + display: flex;
  1240 + justify-content: space-around;
  1241 + padding: 10px 0;
2004 1242  
2005   - .el-checkbox__label {
2006   - font-size: 14px;
2007   - color: #303133;
  1243 + .stat-mini {
  1244 + font-size: 12px;
  1245 + color: #909399;
  1246 +
  1247 + span {
  1248 + color: #303133;
  1249 + font-weight: 600;
  1250 + margin-left: 6px;
  1251 + }
2008 1252 }
2009 1253 }
2010   -}
2011 1254  
2012   -/* 拓客转化漏斗图样式 */
2013   -.funnel-container {
2014   - padding: 10px 0;
2015   -}
  1255 + /* Item Rank */
  1256 + .item-rank {
  1257 + .item-rank-row {
  1258 + display: flex;
  1259 + align-items: center;
  1260 + margin-bottom: 12px;
  1261 +
  1262 + .item-index {
  1263 + font-weight: bold;
  1264 + color: #C0C4CC;
  1265 + margin-right: 10px;
  1266 + font-style: italic;
  1267 + flex-shrink: 0;
  1268 + width: 20px;
  1269 + }
2016 1270  
2017   -.funnel-chart-container {
2018   - width: 100%;
2019   - height: 500px;
2020   - margin-bottom: 30px;
2021   -}
  1271 + .item-name {
  1272 + display: inline-block;
  1273 + font-size: 13px;
  1274 + color: #606266;
  1275 + margin-right: 10px;
  1276 + flex-shrink: 0;
  1277 + min-width: 80px;
  1278 + max-width: 120px;
  1279 + overflow: hidden;
  1280 + text-overflow: ellipsis;
  1281 + white-space: nowrap;
  1282 + }
2022 1283  
2023   -.funnel-chart-container-half {
2024   - width: 100%;
2025   - height: 300px;
2026   - margin-bottom: 15px;
2027   -}
  1284 + &::v-deep .el-progress {
  1285 + flex: 1;
  1286 + margin-right: 10px;
  1287 + }
2028 1288  
2029   -.conversion-rate-cards {
2030   - display: grid;
2031   - grid-template-columns: repeat(3, 1fr);
2032   - gap: 10px;
2033   - margin-top: 10px;
2034   -}
  1289 + &::v-deep .el-progress-bar__outer {
  1290 + background-color: #F2F6FC;
  1291 + }
2035 1292  
2036   -.conversion-card {
2037   - background: linear-gradient(135deg, #fff 0%, #f9fafb 100%);
2038   - border-radius: 12px;
2039   - padding: 12px;
2040   - text-align: center;
2041   - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
2042   - transition: all 0.3s ease;
2043   -
2044   - &:hover {
2045   - transform: translateY(-3px);
2046   - box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  1293 + .item-count {
  1294 + flex-shrink: 0;
  1295 + font-size: 13px;
  1296 + color: #606266;
  1297 + font-weight: 600;
  1298 + white-space: nowrap;
  1299 + min-width: 60px;
  1300 + text-align: right;
  1301 + }
  1302 + }
2047 1303 }
2048 1304 }
2049   -
2050   -.conversion-label {
2051   - font-size: 12px;
2052   - color: #909399;
2053   - margin-bottom: 8px;
2054   - font-weight: 500;
2055   -}
2056   -
2057   -.conversion-value {
2058   - font-size: 24px;
2059   - font-weight: bold;
2060   - color: #409EFF;
2061   - margin-bottom: 4px;
2062   - line-height: 1.2;
2063   -}
2064   -
2065   -.conversion-detail {
2066   - font-size: 12px;
2067   - color: #909399;
2068   -}
2069 1305 </style>
2070 1306 \ No newline at end of file
... ...
netcore/src/Modularity/Extend/NCC.Extend.Interfaces/LqReport/ILqReportService.cs
... ... @@ -66,12 +66,12 @@ namespace NCC.Extend.Interfaces.LqReport
66 66 public class StorePerformanceTrendInput
67 67 {
68 68 /// <summary>
69   - /// 开始月份(YYYYMM格式)
  69 + /// 开始月份(YYYYMM格式)或开始日期(YYYY-MM-DD格式)
70 70 /// </summary>
71 71 public string StartMonth { get; set; }
72 72  
73 73 /// <summary>
74   - /// 结束月份(YYYYMM格式)
  74 + /// 结束月份(YYYYMM格式)或结束日期(YYYY-MM-DD格式)
75 75 /// </summary>
76 76 public string EndMonth { get; set; }
77 77  
... ... @@ -79,6 +79,11 @@ namespace NCC.Extend.Interfaces.LqReport
79 79 /// 门店ID列表(可选)
80 80 /// </summary>
81 81 public List<string> StoreIds { get; set; }
  82 +
  83 + /// <summary>
  84 + /// 时间维度类型:month(按月)、day(按天)、week(按周)
  85 + /// </summary>
  86 + public string PeriodType { get; set; } = "month";
82 87 }
83 88  
84 89 /// <summary>
... ...
netcore/src/Modularity/Extend/NCC.Extend/LqReportService.cs
... ... @@ -88,45 +88,258 @@ namespace NCC.Extend
88 88 {
89 89 try
90 90 {
91   - var sql = @"
92   - SELECT
93   - s.F_StoreId,
94   - s.F_StoreName,
95   - s.F_StatisticsMonth,
96   - s.F_TotalPerformance,
97   - s.F_TotalOrderPerformance,
98   - s.F_FirstOrderCount,
99   - s.F_UpgradeOrderCount,
100   - s.F_ItemQuantity
101   - FROM lq_statistics_store_total_performance s
102   - WHERE s.F_StatisticsMonth >= @startMonth
103   - AND s.F_StatisticsMonth <= @endMonth";
104   -
105   - object parameters = new { startMonth = input.StartMonth, endMonth = input.EndMonth };
  91 + var periodType = string.IsNullOrEmpty(input.PeriodType) ? "month" : input.PeriodType.ToLower();
  92 + List<dynamic> data = new List<dynamic>();
  93 + Dictionary<string, decimal> consumeDataDict = new Dictionary<string, decimal>();
106 94  
107   - if (input.StoreIds != null && input.StoreIds.Any())
  95 + if (periodType == "month")
108 96 {
109   - var storeIdsStr = string.Join("','", input.StoreIds);
110   - sql += $" AND s.F_StoreId IN ('{storeIdsStr}')";
  97 + // 按月查询:查询12个月的数据
  98 + // 如果提供了StartMonth,使用StartMonth和EndMonth;否则从EndMonth往前推11个月
  99 + DateTime startMonth, endMonth;
  100 + if (!string.IsNullOrEmpty(input.StartMonth))
  101 + {
  102 + startMonth = DateTime.ParseExact(input.StartMonth, "yyyyMM", null);
  103 + endMonth = DateTime.ParseExact(input.EndMonth, "yyyyMM", null);
  104 + }
  105 + else
  106 + {
  107 + endMonth = DateTime.ParseExact(input.EndMonth, "yyyyMM", null);
  108 + startMonth = endMonth.AddMonths(-11); // 最近12个月
  109 + }
  110 + var startMonthStr = startMonth.ToString("yyyyMM");
  111 + var endMonthStr = endMonth.ToString("yyyyMM");
  112 +
  113 + // 先尝试从统计表查询
  114 + var sql = $@"
  115 + SELECT
  116 + s.F_StoreId,
  117 + s.F_StoreName,
  118 + s.F_StatisticsMonth,
  119 + s.F_TotalPerformance,
  120 + s.F_TotalOrderPerformance,
  121 + s.F_FirstOrderCount,
  122 + s.F_UpgradeOrderCount,
  123 + s.F_ItemQuantity
  124 + FROM lq_statistics_store_total_performance s
  125 + WHERE s.F_StatisticsMonth >= '{startMonthStr}'
  126 + AND s.F_StatisticsMonth <= '{endMonthStr}'";
  127 +
  128 + if (input.StoreIds != null && input.StoreIds.Any())
  129 + {
  130 + var storeIdsStr = string.Join("','", input.StoreIds);
  131 + sql += $" AND s.F_StoreId IN ('{storeIdsStr}')";
  132 + }
  133 +
  134 + sql += " ORDER BY s.F_StoreName, s.F_StatisticsMonth";
  135 +
  136 + data = await _db.Ado.SqlQueryAsync<dynamic>(sql);
  137 +
  138 + // 如果统计表没有数据,则实时查询
  139 + var currentMonth = DateTime.Now.ToString("yyyyMM");
  140 + if (!data.Any() && (startMonthStr == currentMonth || endMonthStr == currentMonth))
  141 + {
  142 + var realTimeSql = $@"
  143 + SELECT
  144 + kd.djmd as F_StoreId,
  145 + mdxx.dm as F_StoreName,
  146 + DATE_FORMAT(kd.kdrq, '%Y%m') as F_StatisticsMonth,
  147 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalPerformance,
  148 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalOrderPerformance,
  149 + 0 as F_FirstOrderCount,
  150 + 0 as F_UpgradeOrderCount,
  151 + 0 as F_ItemQuantity
  152 + FROM lq_kd_kdjlb kd
  153 + LEFT JOIN lq_mdxx mdxx ON kd.djmd = mdxx.F_Id
  154 + WHERE kd.F_IsEffective = 1
  155 + AND DATE_FORMAT(kd.kdrq, '%Y%m') >= '{startMonthStr}'
  156 + AND DATE_FORMAT(kd.kdrq, '%Y%m') <= '{endMonthStr}'";
  157 +
  158 + if (input.StoreIds != null && input.StoreIds.Any())
  159 + {
  160 + var storeIdsStr = string.Join("','", input.StoreIds);
  161 + realTimeSql += $" AND kd.djmd IN ('{storeIdsStr}')";
  162 + }
  163 +
  164 + realTimeSql += @"
  165 + GROUP BY kd.djmd, mdxx.dm, DATE_FORMAT(kd.kdrq, '%Y%m')
  166 + ORDER BY mdxx.dm, DATE_FORMAT(kd.kdrq, '%Y%m')";
  167 +
  168 + data = await _db.Ado.SqlQueryAsync<dynamic>(realTimeSql);
  169 + }
  170 +
  171 + // 查询消耗数据
  172 + var consumeSql = $@"
  173 + SELECT
  174 + xh.md as StoreId,
  175 + DATE_FORMAT(xh.hksj, '%Y%m') as Month,
  176 + COALESCE(SUM(CAST(xh.xfje AS DECIMAL(18,2))), 0) as ConsumeAmount
  177 + FROM lq_xh_hyhk xh
  178 + WHERE xh.F_IsEffective = 1
  179 + AND DATE_FORMAT(xh.hksj, '%Y%m') >= '{startMonthStr}'
  180 + AND DATE_FORMAT(xh.hksj, '%Y%m') <= '{endMonthStr}'";
  181 +
  182 + if (input.StoreIds != null && input.StoreIds.Any())
  183 + {
  184 + var storeIdsStr = string.Join("','", input.StoreIds);
  185 + consumeSql += $" AND xh.md IN ('{storeIdsStr}')";
  186 + }
  187 +
  188 + consumeSql += @"
  189 + GROUP BY xh.md, DATE_FORMAT(xh.hksj, '%Y%m')";
  190 +
  191 + var consumeData = await _db.Ado.SqlQueryAsync<dynamic>(consumeSql);
  192 + foreach (var item in consumeData)
  193 + {
  194 + var key = $"{item.StoreId?.ToString()}_{item.Month?.ToString()}";
  195 + consumeDataDict[key] = Convert.ToDecimal(item.ConsumeAmount ?? 0);
  196 + }
111 197 }
  198 + else if (periodType == "day")
  199 + {
  200 + // 按天查询:查询本月的数据
  201 + var startDate = DateTime.ParseExact(input.StartMonth, "yyyy-MM-dd", null);
  202 + var endDate = DateTime.ParseExact(input.EndMonth, "yyyy-MM-dd", null);
  203 +
  204 + var billingSql = $@"
  205 + SELECT
  206 + kd.djmd as F_StoreId,
  207 + mdxx.dm as F_StoreName,
  208 + DATE_FORMAT(kd.kdrq, '%Y-%m-%d') as F_StatisticsMonth,
  209 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalPerformance,
  210 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalOrderPerformance,
  211 + 0 as F_FirstOrderCount,
  212 + 0 as F_UpgradeOrderCount,
  213 + 0 as F_ItemQuantity
  214 + FROM lq_kd_kdjlb kd
  215 + LEFT JOIN lq_mdxx mdxx ON kd.djmd = mdxx.F_Id
  216 + WHERE kd.F_IsEffective = 1
  217 + AND kd.kdrq >= '{startDate:yyyy-MM-dd}'
  218 + AND kd.kdrq < DATE_ADD('{endDate:yyyy-MM-dd}', INTERVAL 1 DAY)";
  219 +
  220 + if (input.StoreIds != null && input.StoreIds.Any())
  221 + {
  222 + var storeIdsStr = string.Join("','", input.StoreIds);
  223 + billingSql += $" AND kd.djmd IN ('{storeIdsStr}')";
  224 + }
112 225  
113   - sql += " ORDER BY s.F_StoreName, s.F_StatisticsMonth";
  226 + billingSql += @"
  227 + GROUP BY kd.djmd, mdxx.dm, DATE_FORMAT(kd.kdrq, '%Y-%m-%d')
  228 + ORDER BY mdxx.dm, DATE_FORMAT(kd.kdrq, '%Y-%m-%d')";
114 229  
115   - var data = await _db.Ado.SqlQueryAsync<dynamic>(sql, parameters);
  230 + data = await _db.Ado.SqlQueryAsync<dynamic>(billingSql);
  231 +
  232 + // 查询消耗数据
  233 + var consumeSql = $@"
  234 + SELECT
  235 + xh.md as StoreId,
  236 + DATE_FORMAT(xh.hksj, '%Y-%m-%d') as Month,
  237 + COALESCE(SUM(CAST(xh.xfje AS DECIMAL(18,2))), 0) as ConsumeAmount
  238 + FROM lq_xh_hyhk xh
  239 + WHERE xh.F_IsEffective = 1
  240 + AND xh.hksj >= '{startDate:yyyy-MM-dd}'
  241 + AND xh.hksj < DATE_ADD('{endDate:yyyy-MM-dd}', INTERVAL 1 DAY)";
  242 +
  243 + if (input.StoreIds != null && input.StoreIds.Any())
  244 + {
  245 + var storeIdsStr = string.Join("','", input.StoreIds);
  246 + consumeSql += $" AND xh.md IN ('{storeIdsStr}')";
  247 + }
  248 +
  249 + consumeSql += @"
  250 + GROUP BY xh.md, DATE_FORMAT(xh.hksj, '%Y-%m-%d')";
  251 +
  252 + var consumeData = await _db.Ado.SqlQueryAsync<dynamic>(consumeSql);
  253 + foreach (var item in consumeData)
  254 + {
  255 + var key = $"{item.StoreId?.ToString()}_{item.Month?.ToString()}";
  256 + consumeDataDict[key] = Convert.ToDecimal(item.ConsumeAmount ?? 0);
  257 + }
  258 + }
  259 + else if (periodType == "week")
  260 + {
  261 + // 按周查询:查询最近4周的数据
  262 + var endDate = DateTime.ParseExact(input.EndMonth, "yyyy-MM-dd", null);
  263 + var startDate = endDate.AddDays(-27); // 最近4周(28天)
  264 +
  265 + var billingSql = $@"
  266 + SELECT
  267 + kd.djmd as F_StoreId,
  268 + mdxx.dm as F_StoreName,
  269 + CONCAT(YEAR(kd.kdrq), '-W', LPAD(WEEK(kd.kdrq, 1), 2, '0')) as F_StatisticsMonth,
  270 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalPerformance,
  271 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalOrderPerformance,
  272 + 0 as F_FirstOrderCount,
  273 + 0 as F_UpgradeOrderCount,
  274 + 0 as F_ItemQuantity
  275 + FROM lq_kd_kdjlb kd
  276 + LEFT JOIN lq_mdxx mdxx ON kd.djmd = mdxx.F_Id
  277 + WHERE kd.F_IsEffective = 1
  278 + AND kd.kdrq >= '{startDate:yyyy-MM-dd}'
  279 + AND kd.kdrq < DATE_ADD('{endDate:yyyy-MM-dd}', INTERVAL 1 DAY)";
  280 +
  281 + if (input.StoreIds != null && input.StoreIds.Any())
  282 + {
  283 + var storeIdsStr = string.Join("','", input.StoreIds);
  284 + billingSql += $" AND kd.djmd IN ('{storeIdsStr}')";
  285 + }
  286 +
  287 + billingSql += @"
  288 + GROUP BY kd.djmd, mdxx.dm, CONCAT(YEAR(kd.kdrq), '-W', LPAD(WEEK(kd.kdrq, 1), 2, '0'))
  289 + ORDER BY mdxx.dm, CONCAT(YEAR(kd.kdrq), '-W', LPAD(WEEK(kd.kdrq, 1), 2, '0'))";
  290 +
  291 + data = await _db.Ado.SqlQueryAsync<dynamic>(billingSql);
  292 +
  293 + // 查询消耗数据
  294 + var consumeSql = $@"
  295 + SELECT
  296 + xh.md as StoreId,
  297 + CONCAT(YEAR(xh.hksj), '-W', LPAD(WEEK(xh.hksj, 1), 2, '0')) as Month,
  298 + COALESCE(SUM(CAST(xh.xfje AS DECIMAL(18,2))), 0) as ConsumeAmount
  299 + FROM lq_xh_hyhk xh
  300 + WHERE xh.F_IsEffective = 1
  301 + AND xh.hksj >= '{startDate:yyyy-MM-dd}'
  302 + AND xh.hksj < DATE_ADD('{endDate:yyyy-MM-dd}', INTERVAL 1 DAY)";
  303 +
  304 + if (input.StoreIds != null && input.StoreIds.Any())
  305 + {
  306 + var storeIdsStr = string.Join("','", input.StoreIds);
  307 + consumeSql += $" AND xh.md IN ('{storeIdsStr}')";
  308 + }
  309 +
  310 + consumeSql += @"
  311 + GROUP BY xh.md, CONCAT(YEAR(xh.hksj), '-W', LPAD(WEEK(xh.hksj, 1), 2, '0'))";
  312 +
  313 + var consumeData = await _db.Ado.SqlQueryAsync<dynamic>(consumeSql);
  314 + foreach (var item in consumeData)
  315 + {
  316 + var key = $"{item.StoreId?.ToString()}_{item.Month?.ToString()}";
  317 + consumeDataDict[key] = Convert.ToDecimal(item.ConsumeAmount ?? 0);
  318 + }
  319 + }
116 320  
117 321 // 按门店分组处理数据
118   - var result = data.GroupBy(x => x.F_StoreName)
  322 + var result = data.GroupBy(x => x.F_StoreName?.ToString() ?? "未知门店")
119 323 .Select(g => new
120 324 {
121 325 StoreName = g.Key,
122   - Data = g.OrderBy(x => x.F_StatisticsMonth).Select(x => new
  326 + Data = g.OrderBy(x => x.F_StatisticsMonth?.ToString()).Select(x =>
123 327 {
124   - Month = x.F_StatisticsMonth,
125   - TotalPerformance = x.F_TotalPerformance,
126   - OrderPerformance = x.F_TotalOrderPerformance,
127   - FirstOrderCount = x.F_FirstOrderCount,
128   - UpgradeOrderCount = x.F_UpgradeOrderCount,
129   - ItemQuantity = x.F_ItemQuantity
  328 + var period = x.F_StatisticsMonth?.ToString() ?? "";
  329 + var storeId = x.F_StoreId?.ToString() ?? "";
  330 + var consumeKey = $"{storeId}_{period}";
  331 + var consumeAmount = consumeDataDict.ContainsKey(consumeKey) ? consumeDataDict[consumeKey] : 0m;
  332 +
  333 + return new
  334 + {
  335 + Month = period,
  336 + TotalPerformance = x.F_TotalPerformance != null ? Convert.ToDecimal(x.F_TotalPerformance) : 0m,
  337 + OrderPerformance = x.F_TotalOrderPerformance != null ? Convert.ToDecimal(x.F_TotalOrderPerformance) : 0m,
  338 + ConsumeAmount = consumeAmount,
  339 + FirstOrderCount = x.F_FirstOrderCount != null ? Convert.ToInt32(x.F_FirstOrderCount) : 0,
  340 + UpgradeOrderCount = x.F_UpgradeOrderCount != null ? Convert.ToInt32(x.F_UpgradeOrderCount) : 0,
  341 + ItemQuantity = x.F_ItemQuantity != null ? Convert.ToInt32(x.F_ItemQuantity) : 0
  342 + };
130 343 }).ToList()
131 344 }).ToList();
132 345  
... ... @@ -139,7 +352,7 @@ namespace NCC.Extend
139 352 }
140 353 catch (Exception ex)
141 354 {
142   - _logger.LogError(ex, $"获取门店业绩趋势数据失败 - 开始月份: {input?.StartMonth}, 结束月份: {input?.EndMonth}");
  355 + _logger.LogError(ex, $"获取门店业绩趋势数据失败 - 开始: {input?.StartMonth}, 结束: {input?.EndMonth}, 类型: {input?.PeriodType}");
143 356 throw NCCException.Oh($"获取门店业绩趋势数据失败: {ex.Message}");
144 357 }
145 358 }
... ... @@ -173,6 +386,7 @@ namespace NCC.Extend
173 386 {
174 387 try
175 388 {
  389 + // 先尝试从统计表查询
176 390 var sql = @"
177 391 SELECT
178 392 s.F_StoreId,
... ... @@ -181,10 +395,8 @@ namespace NCC.Extend
181 395 s.F_TotalOrderPerformance,
182 396 s.F_FirstOrderCount,
183 397 s.F_UpgradeOrderCount,
184   - s.F_ItemQuantity,
185   - (@row_number := @row_number + 1) as Ranking
  398 + s.F_ItemQuantity
186 399 FROM lq_statistics_store_total_performance s
187   - CROSS JOIN (SELECT @row_number := 0) r
188 400 WHERE s.F_StatisticsMonth = @statisticsMonth
189 401 ORDER BY s.F_TotalPerformance DESC";
190 402  
... ... @@ -195,16 +407,48 @@ namespace NCC.Extend
195 407  
196 408 var data = await _db.Ado.SqlQueryAsync<dynamic>(sql, new { statisticsMonth = input.StatisticsMonth });
197 409  
198   - var result = data.Select(x => new
  410 + // 如果统计表没有数据,则实时查询(针对当前月份)
  411 + var currentMonth = DateTime.Now.ToString("yyyyMM");
  412 + if (!data.Any() && input.StatisticsMonth == currentMonth)
  413 + {
  414 + var startDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1);
  415 + var endDate = DateTime.Now;
  416 +
  417 + var realTimeSql = $@"
  418 + SELECT
  419 + kd.djmd as F_StoreId,
  420 + mdxx.dm as F_StoreName,
  421 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalPerformance,
  422 + COALESCE(SUM(CAST(kd.sfyj AS DECIMAL(18,2))), 0) as F_TotalOrderPerformance,
  423 + 0 as F_FirstOrderCount,
  424 + 0 as F_UpgradeOrderCount,
  425 + 0 as F_ItemQuantity
  426 + FROM lq_kd_kdjlb kd
  427 + LEFT JOIN lq_mdxx mdxx ON kd.djmd = mdxx.F_Id
  428 + WHERE kd.F_IsEffective = 1
  429 + AND kd.kdrq >= '{startDate:yyyy-MM-dd 00:00:00}'
  430 + AND kd.kdrq <= '{endDate:yyyy-MM-dd HH:mm:ss}'
  431 + GROUP BY kd.djmd, mdxx.dm
  432 + ORDER BY F_TotalPerformance DESC";
  433 +
  434 + if (input.TopCount > 0)
  435 + {
  436 + realTimeSql += $" LIMIT {input.TopCount}";
  437 + }
  438 +
  439 + data = await _db.Ado.SqlQueryAsync<dynamic>(realTimeSql);
  440 + }
  441 +
  442 + var result = data.Select((x, index) => new
199 443 {
200   - Ranking = x.Ranking,
201   - StoreId = x.F_StoreId,
202   - StoreName = x.F_StoreName,
203   - TotalPerformance = x.F_TotalPerformance,
204   - OrderPerformance = x.F_TotalOrderPerformance,
205   - FirstOrderCount = x.F_FirstOrderCount,
206   - UpgradeOrderCount = x.F_UpgradeOrderCount,
207   - ItemQuantity = x.F_ItemQuantity
  444 + Ranking = index + 1,
  445 + StoreId = x.F_StoreId?.ToString() ?? "",
  446 + StoreName = x.F_StoreName?.ToString() ?? "未知门店",
  447 + TotalPerformance = x.F_TotalPerformance != null ? Convert.ToDecimal(x.F_TotalPerformance) : 0m,
  448 + OrderPerformance = x.F_TotalOrderPerformance != null ? Convert.ToDecimal(x.F_TotalOrderPerformance) : 0m,
  449 + FirstOrderCount = x.F_FirstOrderCount != null ? Convert.ToInt32(x.F_FirstOrderCount) : 0,
  450 + UpgradeOrderCount = x.F_UpgradeOrderCount != null ? Convert.ToInt32(x.F_UpgradeOrderCount) : 0,
  451 + ItemQuantity = x.F_ItemQuantity != null ? Convert.ToInt32(x.F_ItemQuantity) : 0
208 452 }).ToList();
209 453  
210 454 return new
... ... @@ -433,10 +677,8 @@ namespace NCC.Extend
433 677 g.F_StoreId,
434 678 g.F_StoreName,
435 679 g.F_TotalPerformance,
436   - g.F_OrderCount,
437   - (@row_number := @row_number + 1) as Ranking
  680 + g.F_OrderCount
438 681 FROM lq_statistics_gold_triangle g
439   - CROSS JOIN (SELECT @row_number := 0) r
440 682 WHERE g.F_StatisticsMonth = @statisticsMonth
441 683 ORDER BY g.F_TotalPerformance DESC";
442 684  
... ... @@ -447,15 +689,25 @@ namespace NCC.Extend
447 689  
448 690 var data = await _db.Ado.SqlQueryAsync<dynamic>(sql, new { statisticsMonth = input.StatisticsMonth });
449 691  
450   - var result = data.Select(x => new
  692 + if (data == null || !data.Any())
451 693 {
452   - Ranking = x.Ranking,
453   - GoldTriangleId = x.F_GoldTriangleId,
454   - GoldTriangleName = x.F_GoldTriangleName,
455   - StoreId = x.F_StoreId,
456   - StoreName = x.F_StoreName,
457   - TotalPerformance = x.F_TotalPerformance,
458   - OrderCount = x.F_OrderCount
  694 + return new
  695 + {
  696 + Success = true,
  697 + Data = new List<object>(),
  698 + Message = "金三角业绩排行榜获取成功(无数据)"
  699 + };
  700 + }
  701 +
  702 + var result = data.Select((x, index) => new
  703 + {
  704 + Ranking = index + 1,
  705 + GoldTriangleId = x.F_GoldTriangleId?.ToString() ?? "",
  706 + GoldTriangleName = x.F_GoldTriangleName?.ToString() ?? "未知",
  707 + StoreId = x.F_StoreId?.ToString() ?? "",
  708 + StoreName = x.F_StoreName?.ToString() ?? "未知",
  709 + TotalPerformance = x.F_TotalPerformance != null ? Convert.ToDecimal(x.F_TotalPerformance) : 0m,
  710 + OrderCount = x.F_OrderCount != null ? Convert.ToInt32(x.F_OrderCount) : 0
459 711 }).ToList();
460 712  
461 713 return new
... ... @@ -807,24 +1059,9 @@ namespace NCC.Extend
807 1059 var refundCount = Convert.ToInt32(refundResult?.FirstOrDefault()?.refund_count ?? 0);
808 1060 var refundAmount = Convert.ToDecimal(refundResult?.FirstOrDefault()?.refund_amount ?? 0m);
809 1061  
810   - // 第四步:获取消耗目标业绩(从lq_md_target表获取)
  1062 + // 第四步:获取开单目标业绩(从lq_md_target表获取)
811 1063 // 根据开始时间确定查询的月份(只取开始时间所在的月份)
812 1064 var month = startTime.ToString("yyyyMM");
813   - var targetConsumeSql = $@"
814   - SELECT COALESCE(SUM(CAST(target.F_StoreConsumeTarget AS DECIMAL(18,2))), 0) as target_consume_amount
815   - FROM lq_md_target target
816   - WHERE target.F_Month = '{month}'";
817   -
818   - if (input.StoreIds != null && input.StoreIds.Any())
819   - {
820   - var storeIdsStr = string.Join("','", input.StoreIds);
821   - targetConsumeSql += $" AND target.F_StoreId IN ('{storeIdsStr}')";
822   - }
823   -
824   - var targetConsumeResult = await _db.Ado.SqlQueryAsync<dynamic>(targetConsumeSql);
825   - var targetConsumeAmount = Convert.ToDecimal(targetConsumeResult?.FirstOrDefault()?.target_consume_amount ?? 0m);
826   -
827   - // 第五步:获取开单目标业绩(从lq_md_target表获取)
828 1065 var targetBillingSql = $@"
829 1066 SELECT COALESCE(SUM(CAST(target.F_StoreTarget AS DECIMAL(18,2))), 0) as target_billing_amount
830 1067 FROM lq_md_target target
... ... @@ -842,14 +1079,7 @@ namespace NCC.Extend
842 1079 // 计算开单完成业绩(开单总金额 - 退卡总金额)
843 1080 var completedBillingAmount = billingAmount - refundAmount;
844 1081  
845   - // 计算完成率
846   - var consumeCompletionRate = 0m;
847   - if (targetConsumeAmount > 0)
848   - {
849   - consumeCompletionRate = (consumeAmount / targetConsumeAmount) * 100m;
850   - consumeCompletionRate = decimal.Round(consumeCompletionRate, 2);
851   - }
852   -
  1082 + // 计算开单完成率
853 1083 var billingCompletionRate = 0m;
854 1084 if (targetBillingAmount > 0)
855 1085 {
... ... @@ -865,8 +1095,8 @@ namespace NCC.Extend
865 1095 BillingCount = billingCount,
866 1096 ConsumeCount = consumeCount,
867 1097 RefundCount = refundCount,
868   - TargetConsumeAmount = targetConsumeAmount,
869   - ConsumeCompletionRate = consumeCompletionRate,
  1098 + TargetConsumeAmount = 0m,
  1099 + ConsumeCompletionRate = 0m,
870 1100 TargetBillingAmount = targetBillingAmount,
871 1101 CompletedBillingAmount = completedBillingAmount,
872 1102 BillingCompletionRate = billingCompletionRate
... ... @@ -1972,7 +2202,7 @@ namespace NCC.Extend
1972 2202 /// <response code="400">参数错误</response>
1973 2203 /// <response code="500">服务器错误</response>
1974 2204 [HttpPost("get-health-coach-billing-ranking")]
1975   - public async Task<List<HealthCoachStatisticsOutput>> GetHealthCoachBillingRanking(HealthCoachStatisticsInput input)
  2205 + public async Task<object> GetHealthCoachBillingRanking(HealthCoachStatisticsInput input)
1976 2206 {
1977 2207 try
1978 2208 {
... ... @@ -2019,7 +2249,12 @@ namespace NCC.Extend
2019 2249  
2020 2250 if (!rankingIds.Any())
2021 2251 {
2022   - return new List<HealthCoachStatisticsOutput>();
  2252 + return new
  2253 + {
  2254 + Success = true,
  2255 + Data = new List<HealthCoachStatisticsOutput>(),
  2256 + Message = "健康师开单业绩排行榜获取成功(无数据)"
  2257 + };
2023 2258 }
2024 2259  
2025 2260 // 第二步:为这些健康师查询完整的三个业绩数据
... ... @@ -2150,7 +2385,12 @@ namespace NCC.Extend
2150 2385 })
2151 2386 .ToList();
2152 2387  
2153   - return ranking;
  2388 + return new
  2389 + {
  2390 + Success = true,
  2391 + Data = ranking,
  2392 + Message = "健康师开单业绩排行榜获取成功"
  2393 + };
2154 2394 }
2155 2395 catch (Exception ex)
2156 2396 {
... ... @@ -2180,7 +2420,7 @@ namespace NCC.Extend
2180 2420 /// <response code="400">参数错误</response>
2181 2421 /// <response code="500">服务器错误</response>
2182 2422 [HttpPost("get-health-coach-consume-ranking")]
2183   - public async Task<List<HealthCoachStatisticsOutput>> GetHealthCoachConsumeRanking(HealthCoachStatisticsInput input)
  2423 + public async Task<object> GetHealthCoachConsumeRanking(HealthCoachStatisticsInput input)
2184 2424 {
2185 2425 try
2186 2426 {
... ... @@ -2358,7 +2598,12 @@ namespace NCC.Extend
2358 2598 })
2359 2599 .ToList();
2360 2600  
2361   - return ranking;
  2601 + return new
  2602 + {
  2603 + Success = true,
  2604 + Data = ranking,
  2605 + Message = "健康师耗卡业绩排行榜获取成功"
  2606 + };
2362 2607 }
2363 2608 catch (Exception ex)
2364 2609 {
... ... @@ -2388,7 +2633,7 @@ namespace NCC.Extend
2388 2633 /// <response code="400">参数错误</response>
2389 2634 /// <response code="500">服务器错误</response>
2390 2635 [HttpPost("get-health-coach-refund-ranking")]
2391   - public async Task<List<HealthCoachStatisticsOutput>> GetHealthCoachRefundRanking(HealthCoachStatisticsInput input)
  2636 + public async Task<object> GetHealthCoachRefundRanking(HealthCoachStatisticsInput input)
2392 2637 {
2393 2638 try
2394 2639 {
... ... @@ -2435,7 +2680,12 @@ namespace NCC.Extend
2435 2680  
2436 2681 if (!rankingIds.Any())
2437 2682 {
2438   - return new List<HealthCoachStatisticsOutput>();
  2683 + return new
  2684 + {
  2685 + Success = true,
  2686 + Data = new List<HealthCoachStatisticsOutput>(),
  2687 + Message = "健康师退卡业绩排行榜获取成功(无数据)"
  2688 + };
2439 2689 }
2440 2690  
2441 2691 // 第二步:为这些健康师查询完整的三个业绩数据
... ... @@ -2566,7 +2816,12 @@ namespace NCC.Extend
2566 2816 })
2567 2817 .ToList();
2568 2818  
2569   - return ranking;
  2819 + return new
  2820 + {
  2821 + Success = true,
  2822 + Data = ranking,
  2823 + Message = "健康师退卡业绩排行榜获取成功"
  2824 + };
2570 2825 }
2571 2826 catch (Exception ex)
2572 2827 {
... ...