7/17 修复添加车辆上传样式,校验上传文件不能是exe;
This commit is contained in:
@@ -148,8 +148,7 @@ export const param2Obj = (url: string) => {
|
||||
const index = v.indexOf('=');
|
||||
if (index !== -1) {
|
||||
const name = v.substring(0, index);
|
||||
const val = v.substring(index + 1, v.length);
|
||||
obj[name] = val;
|
||||
obj[name] = v.substring(index + 1, v.length);
|
||||
}
|
||||
});
|
||||
return obj;
|
||||
@@ -222,47 +221,15 @@ export const getTime = (type: string) => {
|
||||
/**
|
||||
* 创建一个防抖函数,确保在指定的等待时间内只执行一次目标函数。
|
||||
*
|
||||
* @param func - 需要被防抖处理的目标函数
|
||||
* @param wait - 等待时间(毫秒),在此时间内重复调用将重置计时器
|
||||
* @param immediate - 是否立即执行。如果为 true,则在第一次调用时立即执行函数,并在等待期结束后才能再次触发;如果为 false,则在等待期结束后执行最后一次调用
|
||||
* @returns 返回一个新的防抖函数,该函数在被调用时会应用防抖逻辑
|
||||
*/
|
||||
export const debounce = (func: any, wait: number, immediate: boolean) => {
|
||||
let timeout: any, args: any, context: any, timestamp: any, result: any;
|
||||
|
||||
/**
|
||||
* 延迟执行的内部函数,用于判断是否真正执行目标函数
|
||||
*/
|
||||
const later = function () {
|
||||
// 据上一次触发时间间隔
|
||||
const last = +new Date() - timestamp;
|
||||
|
||||
// 上次被包装函数被调用时间间隔 last 小于设定时间间隔 wait
|
||||
if (last < wait && last > 0) {
|
||||
timeout = setTimeout(later, wait - last);
|
||||
} else {
|
||||
timeout = null;
|
||||
// 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用
|
||||
if (!immediate) {
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
}
|
||||
export function debounce<T extends (...args: any[]) => void>(fn: T, delay = 300) {
|
||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||
return (...args: Parameters<T>) => {
|
||||
timer && clearTimeout(timer);
|
||||
timer = setTimeout(() => fn(...args), delay);
|
||||
};
|
||||
|
||||
return (...args: any) => {
|
||||
context = this;
|
||||
timestamp = +new Date();
|
||||
const callNow = immediate && !timeout;
|
||||
// 如果延时不存在,重新设定延时
|
||||
if (!timeout) timeout = setTimeout(later, wait);
|
||||
if (callNow) {
|
||||
result = func.apply(context, args);
|
||||
context = args = null;
|
||||
}
|
||||
return result;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* This is just a simple version of deep copy
|
||||
@@ -395,6 +362,5 @@ export function buildTreeByLevel<T = any>(list: T[]): T[] {
|
||||
|
||||
export const splitImages = (url) => {
|
||||
if (!url) return '';
|
||||
const imgUrl = import.meta.env.VITE_IMG_URL + url;
|
||||
return imgUrl;
|
||||
return import.meta.env.VITE_IMG_URL + url;
|
||||
};
|
||||
|
||||
@@ -98,9 +98,20 @@ function toBig(num: string | number | undefined | null): Big {
|
||||
* @returns 保留2位小数字符串
|
||||
*/
|
||||
export function moneyAdd(a: number | string = 0, b: number | string = 0): string {
|
||||
return new Big(a).plus(b).toFixed(2);
|
||||
return toBig(a).plus(b).toFixed(2);
|
||||
}
|
||||
|
||||
// 数组高精度求和
|
||||
export function sum(arr: Array<string | number>): number {
|
||||
const total = arr.reduce((acc, cur) => acc.plus(toBig(cur)), new Big(0));
|
||||
return Number(total);
|
||||
}
|
||||
// 取较大值
|
||||
export function maxMoney(a: string | number, b: string | number): number {
|
||||
const bigA = toBig(a);
|
||||
const bigB = toBig(b);
|
||||
return Number(bigA.gt(bigB) ? bigA : bigB);
|
||||
}
|
||||
/**
|
||||
* 减法 a - b
|
||||
*/
|
||||
@@ -141,7 +152,6 @@ export function toFixedMoney(num: string | number, digit = 2): number {
|
||||
return Number(toBig(num).toFixed(digit, Big.roundHalfUp));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 智能金额格式化(带单位:元/万元/亿元)
|
||||
* 兼容:数字、字符串、null、undefined
|
||||
|
||||
Reference in New Issue
Block a user