陆运产品价无费名时默认陆运费;看板指标与工单列表共用起止日,趋势按日铺点。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/**
|
||||
* 分析看板 API。
|
||||
* 显式传 dateFrom/dateTo,与工单列表日期筛选同源;range 仅作无日期时的回退。
|
||||
*/
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
@@ -7,5 +8,20 @@ enum Api {
|
||||
metrics = '/inquiry/dashboard/metrics',
|
||||
}
|
||||
|
||||
export const getDashboardMetrics = (range = 'today') =>
|
||||
defHttp.get({ url: Api.metrics, params: { range } });
|
||||
export type DashboardMetricsParams = {
|
||||
range?: string;
|
||||
dateFrom?: string;
|
||||
dateTo?: string;
|
||||
};
|
||||
|
||||
export const getDashboardMetrics = (params: DashboardMetricsParams | string = 'today') => {
|
||||
const query =
|
||||
typeof params === 'string'
|
||||
? { range: params }
|
||||
: {
|
||||
range: params.range || 'today',
|
||||
dateFrom: params.dateFrom,
|
||||
dateTo: params.dateTo,
|
||||
};
|
||||
return defHttp.get({ url: Api.metrics, params: query });
|
||||
};
|
||||
|
||||
@@ -56,11 +56,15 @@ const activePoint = ref<string | null>(null);
|
||||
const INQUIRY_PLOT_TOP = 36;
|
||||
const INQUIRY_PLOT_BOTTOM = 188;
|
||||
|
||||
/**
|
||||
* 粗粒度 range 仅作后端无 dateFrom/dateTo 时的回退;正式请求一律带显式日期。
|
||||
* 注意:不可再把「单日」映射成 today——today 是日历今天,不是所选那一天。
|
||||
*/
|
||||
function resolveRange(): string {
|
||||
const from = new Date(dateFrom.value);
|
||||
const to = new Date(dateTo.value);
|
||||
const days = Math.max(0, Math.round((to.getTime() - from.getTime()) / 86400000));
|
||||
if (days <= 0) return "today";
|
||||
if (days <= 0) return "1d";
|
||||
if (days <= 6) return "7d";
|
||||
return "30d";
|
||||
}
|
||||
@@ -88,7 +92,12 @@ function onDateRangeChange() {
|
||||
async function loadMetrics() {
|
||||
loading.value = true;
|
||||
try {
|
||||
const res: any = await getDashboardMetrics(resolveRange());
|
||||
const req = {
|
||||
range: resolveRange(),
|
||||
dateFrom: dateFrom.value,
|
||||
dateTo: dateTo.value,
|
||||
};
|
||||
const res: any = await getDashboardMetrics(req);
|
||||
const data = res?.result || res || {};
|
||||
todayMetrics.value = (data.metrics || []) as MetricCard[];
|
||||
inquiryTrend.value = ((data.trend || []) as any[]).map((p) => ({
|
||||
|
||||
Reference in New Issue
Block a user