added pargar

This commit is contained in:
2026-07-05 20:49:01 +03:30
parent e4d92831c2
commit 51e3c3f0cb
7 changed files with 326 additions and 147 deletions
@@ -1,17 +1 @@
export function usePrice(price: number, digit = true, unit = 'ریال') {
let _price = price.toString()
if (digit) {
_price = _price.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ',')
}
return `${_price} ${unit}`
}
export function useTowDecimal(num: string | number): string | number {
const temp = num.toString().match(/^-?\d+(?:\.\d{0,2})?/)
if (temp && temp.length > 0) return temp[0]
return Math.round(+num * 100) / 100
}
export function useFormat(num: string | number, unit = '') {
return usePrice(Math.abs(+useTowDecimal(num)), true, unit)
}
export { usePrice, usePriceWithoutType, useTowDecimal, useFormat } from '@/utils/usePrice'