diff --git a/.env.development b/.env.development index 7230ff9..1b230d8 100644 --- a/.env.development +++ b/.env.development @@ -9,9 +9,9 @@ VITE_APP_ENV='development' # 开发环境 VITE_APP_BASE_API='/dev-api' # # 开发环境 接口代理地址 -#VITE_APP_PROXY_API='http://192.168.1.222:8080' +VITE_APP_PROXY_API='http://192.168.1.222:8080' # 开发环境 接口代理地址 -VITE_APP_PROXY_API='http://192.168.1.6:8080' +#VITE_APP_PROXY_API='http://192.168.1.6:8080' # 图片基础地址 VITE_IMG_URL='http://192.168.1.222:8080' diff --git a/src/api/system/SdbCashier/index.ts b/src/api/system/SdbCashier/index.ts index 4bbbd6c..a605128 100644 --- a/src/api/system/SdbCashier/index.ts +++ b/src/api/system/SdbCashier/index.ts @@ -83,9 +83,13 @@ export type BillPrintType = { 'useCount': string; 'account': string; 'payType': string; + 'singleDiscountAmount': string; + 'actualAccount': string; 'remark': string; }[]; 'printDate': string; + totalDiscountAmount: string; + totalActualAccount: string; 'HouseName': string; 'title': string; }; diff --git a/src/utils/index.ts b/src/utils/index.ts index f30badc..e47bb64 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -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 void>(fn: T, delay = 300) { + let timer: ReturnType | null = null; + return (...args: Parameters) => { + 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(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; }; diff --git a/src/utils/money.ts b/src/utils/money.ts index a3bb8cf..cc8b8a7 100644 --- a/src/utils/money.ts +++ b/src/utils/money.ts @@ -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): 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 diff --git a/src/views/system/Sdb/SdbCashier/index.vue b/src/views/system/Sdb/SdbCashier/index.vue index bbd9f16..8901af5 100644 --- a/src/views/system/Sdb/SdbCashier/index.vue +++ b/src/views/system/Sdb/SdbCashier/index.vue @@ -67,19 +67,25 @@
- 收费 - 打印票据 + 收费 + 打印票据
- + - + - + - - - - + + + + +