mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 09:49:19 +08:00
feat: 统一工作台与概览页筛选器,商品概览支持按店铺过滤
This commit is contained in:
@@ -45,16 +45,37 @@ export function normalizeOverviewRangePickerChange(
|
||||
|
||||
const START_Q = 'startDate';
|
||||
const END_Q = 'endDate';
|
||||
const SHOP_Q = 'shopId';
|
||||
|
||||
/** 概览页跳转(店铺/商品)时附带的 query,与全店概览一致 */
|
||||
export function buildOverviewRouteQuery(dateRange: [Dayjs, Dayjs]): {
|
||||
export type OverviewRouteQuery = {
|
||||
startDate: string;
|
||||
endDate: string;
|
||||
} {
|
||||
return {
|
||||
shopId?: string;
|
||||
};
|
||||
|
||||
/** 概览页跳转(店铺/商品)时附带的 query,与全店概览一致 */
|
||||
export function buildOverviewRouteQuery(
|
||||
dateRange: [Dayjs, Dayjs],
|
||||
options?: { shopId?: number },
|
||||
): OverviewRouteQuery {
|
||||
const query: OverviewRouteQuery = {
|
||||
startDate: dateRange[0].format('YYYY-MM-DD'),
|
||||
endDate: dateRange[1].format('YYYY-MM-DD'),
|
||||
};
|
||||
if (options?.shopId != null && options.shopId > 0) {
|
||||
query.shopId = String(options.shopId);
|
||||
}
|
||||
return query;
|
||||
}
|
||||
|
||||
/** 从路由 query 解析工作台/概览带入的店铺 ID */
|
||||
export function parseOverviewShopIdFromQuery(
|
||||
query: Record<string, unknown>,
|
||||
): number | undefined {
|
||||
const raw = query[SHOP_Q];
|
||||
const s = Array.isArray(raw) ? raw[0] : raw;
|
||||
const id = Number(s);
|
||||
return Number.isFinite(id) && id > 0 ? id : undefined;
|
||||
}
|
||||
|
||||
/** 从当前地址栏读取概览日期 query(含 replaceState 写入、未反映到 Vue Router 的情况) */
|
||||
|
||||
Reference in New Issue
Block a user