number wan split

This commit is contained in:
Timi
2026-09-19 16:46:00 +08:00
parent 6c488a4731
commit 79d9efad73
12 changed files with 35 additions and 19 deletions
+3 -2
View File
@@ -51,6 +51,7 @@ import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
import type { PointAccount as PointAccountData } from "@/types/Point"; import type { PointAccount as PointAccountData } from "@/types/Point";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
defineOptions({ defineOptions({
@@ -149,7 +150,7 @@ async function toAdjust(): Promise<void> {
// ---------- 展示 ---------- // ---------- 展示 ----------
function formatPoints(value?: number): string { function formatPoints(value?: number): string {
return `${(value ?? 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
function formatTimestamp(timestamp?: number): string { function formatTimestamp(timestamp?: number): string {
@@ -165,7 +166,7 @@ function formatTimestamp(timestamp?: number): string {
function formatSignedPoints(value?: number): string { function formatSignedPoints(value?: number): string {
const pointValue = value ?? 0; const pointValue = value ?? 0;
return pointValue < 0 ? `扣除 ${Math.abs(pointValue).toLocaleString("zh-CN")} 分` : `增加 ${pointValue.toLocaleString("zh-CN")} 分`; return pointValue < 0 ? `扣除 ${formatWanInteger(Math.abs(pointValue))} 分` : `增加 ${formatWanInteger(pointValue)} 分`;
} }
onMounted(async () => { onMounted(async () => {
+2 -1
View File
@@ -64,6 +64,7 @@ import CustomerSelector from "@/components/CustomerSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
import type { PointAccount, PointAccountPage } from "@/types/Point"; import type { PointAccount, PointAccountPage } from "@/types/Point";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
defineOptions({ defineOptions({
@@ -196,7 +197,7 @@ async function load(): Promise<void> {
// ---------- 展示 ---------- // ---------- 展示 ----------
function formatPoints(value?: number): string { function formatPoints(value?: number): string {
return `${(value ?? 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
function getBalanceTheme(value?: number): string { function getBalanceTheme(value?: number): string {
+2 -1
View File
@@ -83,6 +83,7 @@ import { useCurrentStoreStore } from "@/store/currentStoreStore";
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
import type { PointAccount } from "@/types/Point"; import type { PointAccount } from "@/types/Point";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
defineOptions({ defineOptions({
@@ -113,7 +114,7 @@ const selectedCustomerId = ref(String(route.query.customerId || ""));
const selectedCustomer = ref<Customer>(); const selectedCustomer = ref<Customer>();
const account = ref<PointAccount>(); const account = ref<PointAccount>();
const selectorVisible = ref(false); const selectorVisible = ref(false);
const balanceText = computed(() => `当前余额:${(account.value?.balance ?? 0).toLocaleString("zh-CN")} 分`); const balanceText = computed(() => `当前余额:${formatWanInteger(account.value?.balance ?? 0)} 分`);
async function handleCustomerChange(value: string | string[]): Promise<void> { async function handleCustomerChange(value: string | string[]): Promise<void> {
selectedCustomerId.value = Array.isArray(value) ? String(value[0] || "") : value; selectedCustomerId.value = Array.isArray(value) ? String(value[0] || "") : value;
+5 -4
View File
@@ -91,6 +91,7 @@ import type { EventItem } from "@/types/EventItem";
import type { EventRecord } from "@/types/EventRecord"; import type { EventRecord } from "@/types/EventRecord";
import type { PointLedger, PointRule, PointRuleStatus } from "@/types/Point"; import type { PointLedger, PointRule, PointRuleStatus } from "@/types/Point";
import { formatEventNumberValue, getEventValueUnitText } from "@/utils/eventValue"; import { formatEventNumberValue, getEventValueUnitText } from "@/utils/eventValue";
import { formatWanInteger } from "@/utils/money";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
defineOptions({ defineOptions({
@@ -220,18 +221,18 @@ function getPointDeltaText(pointDelta?: number): string {
if (pointDelta === undefined || pointDelta === null) { if (pointDelta === undefined || pointDelta === null) {
return "-"; return "-";
} }
return `${0 < pointDelta ? "获得" : "消耗"} ${Math.abs(pointDelta)} 分`; return `${0 < pointDelta ? "获得" : "消耗"} ${formatWanInteger(Math.abs(pointDelta))} 分`;
} }
function getPointText(value?: number | null): string { function getPointText(value?: number | null): string {
return value === undefined || value === null ? "-" : `${value} 分`; return value === undefined || value === null ? "-" : `${formatWanInteger(value)} 分`;
} }
function getSignedPointText(value?: number | null): string { function getSignedPointText(value?: number | null): string {
if (value === undefined || value === null) { if (value === undefined || value === null) {
return "-"; return "-";
} }
return `${0 < value ? "获得" : "消耗"} ${Math.abs(value)} 分`; return `${0 < value ? "获得" : "消耗"} ${formatWanInteger(Math.abs(value))} 分`;
} }
function getEventValueTypeText(event: EventItem): string { function getEventValueTypeText(event: EventItem): string {
@@ -252,7 +253,7 @@ function getRulePointText(rule: PointRule): string {
if (rule.pointValue === undefined || rule.pointValue === null) { if (rule.pointValue === undefined || rule.pointValue === null) {
return "-"; return "-";
} }
return `${0 < rule.pointValue ? "发放" : "消耗"} ${Math.abs(rule.pointValue)} 分`; return `${0 < rule.pointValue ? "发放" : "消耗"} ${formatWanInteger(Math.abs(rule.pointValue))} 分`;
} }
function getRuleScriptText(rule: PointRule): string { function getRuleScriptText(rule: PointRule): string {
+7 -2
View File
@@ -96,7 +96,7 @@
<span>时间:</span> <span>时间:</span>
<pass-time-label :timestamp="item.occurredAt" underline /> <pass-time-label :timestamp="item.occurredAt" underline />
</div> </div>
<div v-text="`余额:${item.balanceBefore ?? 0} → ${item.balanceAfter ?? 0}`" /> <div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
<div v-text="item.remark" /> <div v-text="item.remark" />
</div> </div>
</template> </template>
@@ -153,6 +153,7 @@ import type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/type
import { getCustomerPhotoURL } from "@/utils/customer"; import { getCustomerPhotoURL } from "@/utils/customer";
import { buildPresetDateRange, parseDateTime } from "@/utils/date"; import { buildPresetDateRange, parseDateTime } from "@/utils/date";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
type DateFilter = "all" | "today" | "last7" | "last30" | "custom"; type DateFilter = "all" | "today" | "last7" | "last30" | "custom";
@@ -386,7 +387,11 @@ function buildListOptions(): { storeId: string } {
function getLedgerDelta(item: PointLedger): string { function getLedgerDelta(item: PointLedger): string {
const value = item.pointDelta ?? 0; const value = item.pointDelta ?? 0;
return `${0 < value ? "+" : "-"}${Math.abs(value)} 分`; return `${0 < value ? "+" : "-"}${formatWanInteger(Math.abs(value))} 分`;
}
function formatPointValue(value?: number): string {
return value === undefined || value === null ? "-" : formatWanInteger(value);
} }
function getLedgerShortType(item: PointLedger): string { function getLedgerShortType(item: PointLedger): string {
+2 -1
View File
@@ -66,6 +66,7 @@ import PointAPI from "@/api/PointAPI";
import { useNavBarStore } from "@/store/navBarStore"; import { useNavBarStore } from "@/store/navBarStore";
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point"; import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { getProductPhotoURL } from "@/utils/product"; import { getProductPhotoURL } from "@/utils/product";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
@@ -129,7 +130,7 @@ const reloadByKeyword = Toolkit.debounce(async () => {
}, false); }, false);
function formatPoint(value?: number): string { function formatPoint(value?: number): string {
return `${(value || 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
function getProductPhoto(item: PointRedeemSku): string { function getProductPhoto(item: PointRedeemSku): string {
+4 -3
View File
@@ -41,7 +41,7 @@
v-entrance-transition v-entrance-transition
/> />
<t-form-item v-if="customer" label="积分余额" content-align="right"> <t-form-item v-if="customer" label="积分余额" content-align="right">
<span v-text="pointBalanceText" /> <span class="orange" v-text="pointBalanceText" />
</t-form-item> </t-form-item>
<t-form-item label="兑换商品" required-mark content-align="right" arrow @click="skuVisible = true"> <t-form-item label="兑换商品" required-mark content-align="right" arrow @click="skuVisible = true">
<span v-text="skuName || '请选择兑换商品'" /> <span v-text="skuName || '请选择兑换商品'" />
@@ -122,6 +122,7 @@ import type { PhotoItem } from "@/types/Photo";
import type { PointAccount, PointRedeemSku } from "@/types/Point"; import type { PointAccount, PointRedeemSku } from "@/types/Point";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { normalizePackageQuantity } from "@/utils/package"; import { normalizePackageQuantity } from "@/utils/package";
import { getProductQuantityStep } from "@/utils/product"; import { getProductQuantityStep } from "@/utils/product";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
@@ -163,7 +164,7 @@ const pointBalanceText = computed(() => {
if (!canReadPointAccount.value) { if (!canReadPointAccount.value) {
return "无余额读取权限"; return "无余额读取权限";
} }
return pointAccountLoading.value ? "正在加载" : `${(pointAccount.value?.balance ?? 0).toLocaleString("zh-CN")} 分`; return pointAccountLoading.value ? "正在加载" : `${formatWanInteger(pointAccount.value?.balance ?? 0)} 分`;
}); });
const scannerVisible = ref(false); const scannerVisible = ref(false);
const scanStatus = ref("点击扫码开始识别。"); const scanStatus = ref("点击扫码开始识别。");
@@ -302,7 +303,7 @@ async function save(): Promise<void> {
} }
function formatPoint(value?: number): string { function formatPoint(value?: number): string {
return `${(value || 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
onMounted(async () => { onMounted(async () => {
+2 -1
View File
@@ -88,6 +88,7 @@ import type { PhotoItem } from "@/types/Photo";
import type { PointRedemption, PointRedemptionReturn, PointRedemptionStatus } from "@/types/Point"; import type { PointRedemption, PointRedemptionReturn, PointRedemptionStatus } from "@/types/Point";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { comparePackageQuantity, getPackageQuantityText, normalizePackageQuantity } from "@/utils/package"; import { comparePackageQuantity, getPackageQuantityText, normalizePackageQuantity } from "@/utils/package";
import { uploadPhotoList } from "@/utils/photo"; import { uploadPhotoList } from "@/utils/photo";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
@@ -193,7 +194,7 @@ async function submitReturn(): Promise<void> {
} }
function formatPoint(value?: number): string { function formatPoint(value?: number): string {
return `${(value || 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
function quantityText(value?: number | string): string { function quantityText(value?: number | string): string {
+2 -1
View File
@@ -160,6 +160,7 @@ import type { Customer } from "@/types/Customer";
import type { PointRedemption, PointRedemptionStatus } from "@/types/Point"; import type { PointRedemption, PointRedemptionStatus } from "@/types/Point";
import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date"; import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/utils/date";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { getPackageQuantityText } from "@/utils/package"; import { getPackageQuantityText } from "@/utils/package";
import { getCustomerPhotoURL } from "@/utils/customer"; import { getCustomerPhotoURL } from "@/utils/customer";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
@@ -258,7 +259,7 @@ async function load(): Promise<void> {
} }
function formatPoint(value?: number): string { function formatPoint(value?: number): string {
return `${(value || 0).toLocaleString("zh-CN")} 分`; return `${formatWanInteger(value ?? 0)} 分`;
} }
function quantityText(value?: number | string): string { function quantityText(value?: number | string): string {
+2 -1
View File
@@ -101,6 +101,7 @@ import type { EventItem } from "@/types/EventItem";
import type { PointRule, PointRuleStatus } from "@/types/Point"; import type { PointRule, PointRuleStatus } from "@/types/Point";
import { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
defineOptions({ defineOptions({
@@ -217,7 +218,7 @@ function formatPointValue(value?: number | null): string {
if (value === 0) { if (value === 0) {
return "不产生积分流水"; return "不产生积分流水";
} }
return `${0 < value ? "发放" : "消耗"} ${Math.abs(value)} 分`; return `${0 < value ? "发放" : "消耗"} ${formatWanInteger(Math.abs(value))} 分`;
} }
function formatNumber(value?: number): string { function formatNumber(value?: number): string {
+2 -1
View File
@@ -70,6 +70,7 @@ import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem"; import type { EventItem } from "@/types/EventItem";
import type { NavBarAction } from "@/types/NavBarAction"; import type { NavBarAction } from "@/types/NavBarAction";
import type { PointRule, PointRuleStatus } from "@/types/Point"; import type { PointRule, PointRuleStatus } from "@/types/Point";
import { formatWanInteger } from "@/utils/money";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { type Page, type PageResult, useUserStore } from "timi-web-api"; import { type Page, type PageResult, useUserStore } from "timi-web-api";
import { Message } from "@/utils/message.ts"; import { Message } from "@/utils/message.ts";
@@ -242,7 +243,7 @@ function getPointText(rule: PointRule): string {
if (rule.pointValue === undefined || rule.pointValue === null) { if (rule.pointValue === undefined || rule.pointValue === null) {
return "?"; return "?";
} }
return `${0 < rule.pointValue ? "+" : "-"}${Math.abs(rule.pointValue)}`; return `${0 < rule.pointValue ? "+" : "-"}${formatWanInteger(Math.abs(rule.pointValue))}`;
} }
function getStatusText(status?: PointRuleStatus): string { function getStatusText(status?: PointRuleStatus): string {
+2 -1
View File
@@ -52,6 +52,7 @@ import PointAPI from "@/api/PointAPI";
import { useNavBarStore } from "@/store/navBarStore"; import { useNavBarStore } from "@/store/navBarStore";
import type { EventItem } from "@/types/EventItem"; import type { EventItem } from "@/types/EventItem";
import type { PointRule } from "@/types/Point"; import type { PointRule } from "@/types/Point";
import { formatWanInteger } from "@/utils/money";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
defineOptions({ name: "PointRuleSort" }); defineOptions({ name: "PointRuleSort" });
@@ -72,7 +73,7 @@ function getPointText(rule: PointRule): string {
if (rule.pointValue === undefined || rule.pointValue === null) { if (rule.pointValue === undefined || rule.pointValue === null) {
return "未配置"; return "未配置";
} }
return (0 < rule.pointValue ? "+" : "") + rule.pointValue; return (0 < rule.pointValue ? "+" : "") + formatWanInteger(rule.pointValue);
} }
async function loadData(): Promise<void> { async function loadData(): Promise<void> {