!194 refactor: (web-ele)优化移动端组件代码结构

Merge pull request !194 from 痴货/master
This commit is contained in:
芋道源码
2025-08-16 13:12:10 +00:00
committed by Gitee
137 changed files with 13128 additions and 69 deletions

View File

@@ -42,3 +42,14 @@ export function isDate(value: any): value is Date {
export function isDayjsObject(value: any): value is dayjs.Dayjs {
return dayjs.isDayjs(value);
}
/**
* element plus 的时间 Formatter 实现,使用 YYYY-MM-DD HH:mm:ss 格式
*
* @param _row
* @param _column
* @param cellValue 字段值
*/
export function dateFormatter(_row: any, _column: any, cellValue: any): string {
return cellValue ? formatDate(cellValue)?.toString() || '' : '';
}

View File

@@ -75,6 +75,11 @@ export function fenToYuan(price: number | string): string {
return formatToFraction(price);
}
// 格式化金额【分转元】
export const fenToYuanFormat = (_: any, __: any, cellValue: any, ___: any) => {
return `${floatToFixed2(cellValue)}`;
};
/**
* 计算环比
*

View File

@@ -44,11 +44,27 @@ export function getNestedValue<T>(obj: T, path: string): any {
}
/**
* 获取 URL 参数值
* @param key - 参数键
* @returns 参数值,或者未找到时返回空字符串
* 获取链接的参数值(值类型)
* @param key 参数键
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export function getUrlValue(key: string): string {
const url = new URL(decodeURIComponent(location.href));
export const getUrlNumberValue = (
key: string,
urlStr: string = location.href,
): number => {
return Number(getUrlValue(key, urlStr));
};
/**
* 获取链接的参数值
* @param key 参数键名
* @param urlStr 链接地址,默认为当前浏览器的地址
*/
export const getUrlValue = (
key: string,
urlStr: string = location.href,
): string => {
if (!urlStr || !key) return '';
const url = new URL(decodeURIComponent(urlStr));
return url.searchParams.get(key) ?? '';
}
};