34 lines
866 B
JavaScript
34 lines
866 B
JavaScript
import { ref } from "vue";
|
||
import dayjs from "dayjs";
|
||
|
||
/**
|
||
* 将分转成元
|
||
*
|
||
* @param price 分,例如说 100 分
|
||
* @returns {string} 元,例如说 1.00 元
|
||
*/
|
||
export function fen2yuan(price) {
|
||
return (price / 100.0).toFixed(2);
|
||
}
|
||
|
||
/**
|
||
* 格式化销量
|
||
* @param {'exact' | string} type 格式类型:exact=精确值,其它=大致数量
|
||
* @param {number} num 销量
|
||
* @return {string} 格式化后的销量字符串
|
||
*/
|
||
export function formatSales(type, num) {
|
||
let prefix = type !== "exact" && num < 10 ? "销量" : "已售";
|
||
return formatNum(prefix, type, num);
|
||
}
|
||
|
||
/**
|
||
* 格式化库存
|
||
* @param {'exact' | any} type 格式类型:exact=精确值,其它=大致数量
|
||
* @param {number} num 销量
|
||
* @return {string} 格式化后的销量字符串
|
||
*/
|
||
export function formatStock(type, num) {
|
||
return formatNum("库存", type, num);
|
||
}
|