Compare commits
7
Commits
54c86a6f39
...
fd4146476b
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fd4146476b | ||
|
|
c4d71078b3 | ||
|
|
9d5f04bf7c | ||
|
|
997e779af9 | ||
|
|
0f0b3a2821 | ||
|
|
6b63b4372b | ||
|
|
0b77634de1 |
@@ -136,3 +136,9 @@ auto-imports.d.ts
|
||||
components.d.ts
|
||||
.eslintrc-auto-import.json
|
||||
|
||||
# ---> WorkBuddy 本地工作目录
|
||||
# 内含 AI 工作记忆与每日日志:写明本机绝对路径与调试上下文,且每次会话都在追加,
|
||||
# 提交只会污染 diff 与 blame,多人还会在同一文件上产生无意义的行级冲突。
|
||||
# 需要团队共享的结论请写入 AGENTS.md 或 .serena/memories/,不要放这里。
|
||||
/.workbuddy/
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
<div v-if="customer" class="customer-profile-card">
|
||||
<div v-if="photoURL" class="avatar-trigger" @click="handlePhotoClick">
|
||||
<t-image :src="photoURL" :alt="customerName" fit="cover" class="avatar" />
|
||||
<div @click.stop>
|
||||
<teleport to="body">
|
||||
<t-image-viewer
|
||||
v-model:visible="photoViewerVisible"
|
||||
:images="photoViewerImages"
|
||||
show-index
|
||||
/>
|
||||
</div>
|
||||
</teleport>
|
||||
</div>
|
||||
<div v-else class="avatar fallback" v-text="avatarText" />
|
||||
<div class="content">
|
||||
|
||||
@@ -34,11 +34,13 @@
|
||||
<t-icon name="close" size="1rem" />
|
||||
</t-button>
|
||||
</div>
|
||||
<teleport to="body">
|
||||
<t-image-viewer
|
||||
v-model:visible="photoViewerVisible"
|
||||
:images="photoViewerImages"
|
||||
show-index
|
||||
/>
|
||||
</teleport>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@
|
||||
@left-button-click="close"
|
||||
>
|
||||
<div class="popup">
|
||||
<div class="products">
|
||||
<div class="search-wrap">
|
||||
<t-input v-model="keyword" class="search" borderless placeholder="搜索产品名称或编码" />
|
||||
</div>
|
||||
@@ -32,14 +31,14 @@
|
||||
@change="handleProductChange"
|
||||
>
|
||||
<t-collapse-panel
|
||||
class="item"
|
||||
v-for="(product, productIndex) in visibleProductList"
|
||||
:key="getProductKey(product, productIndex)"
|
||||
:value="getProductKey(product, productIndex)"
|
||||
class="panel"
|
||||
placement="bottom"
|
||||
>
|
||||
<template #header>
|
||||
<div class="product-header">
|
||||
<div class="header">
|
||||
<t-image
|
||||
v-if="getProductPhotoURL(product)"
|
||||
:src="getProductPhotoURL(product)"
|
||||
@@ -48,10 +47,7 @@
|
||||
class="avatar"
|
||||
/>
|
||||
<div v-else class="avatar fallback" v-text="(product.name || product.code || '产').slice(0, 1)" />
|
||||
<div class="product-info">
|
||||
<strong v-text="product.name || '未命名产品'" />
|
||||
<span v-text="`${product.code || '-'} · ${product.skuList?.length || 0} 个 SKU`" />
|
||||
</div>
|
||||
<strong class="clip-text" v-text="product.name || '未命名产品'" />
|
||||
</div>
|
||||
</template>
|
||||
<div v-if="isExpandedProduct(product, productIndex)" class="selection">
|
||||
@@ -72,10 +68,6 @@
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="matchedSku" class="sku-card">
|
||||
<div class="sku-title">
|
||||
<strong v-text="matchedSku.name || matchedSku.specSummary || '默认 SKU'" />
|
||||
<span v-if="matchedSku.code" v-text="matchedSku.code" />
|
||||
</div>
|
||||
<div class="units">
|
||||
<t-button
|
||||
v-for="unit in saleableUnits(matchedSku)"
|
||||
@@ -97,7 +89,6 @@
|
||||
<div v-else class="empty" v-text="loading ? '正在加载可售产品' : '暂无可售产品'" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</bottom-popup>
|
||||
</template>
|
||||
|
||||
@@ -253,69 +244,10 @@ function selectUnit(sku: ProductSku, skuUnitId: string): void {
|
||||
|
||||
.popup {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
padding: 1rem 0;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.selection {
|
||||
overflow-y: auto;
|
||||
|
||||
.specs {
|
||||
gap: 1rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.spec {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.values,
|
||||
.units {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sku-card {
|
||||
padding: .75rem;
|
||||
background: var(--td-bg-color-secondarycontainer);
|
||||
border-radius: .875rem;
|
||||
|
||||
.sku-title {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
align-items: baseline;
|
||||
justify-content: space-between;
|
||||
|
||||
span {
|
||||
color: var(--td-text-color-secondary);
|
||||
font-size: .75rem;
|
||||
}
|
||||
}
|
||||
|
||||
.units {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
margin-top: .75rem;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.price {
|
||||
margin-left: .25rem;
|
||||
font-size: .75rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.products {
|
||||
height: 100%;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.search-wrap {
|
||||
@@ -339,42 +271,63 @@ function selectUnit(sku: ProductSku, skuUnitId: string): void {
|
||||
|
||||
.collapse {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.product-header {
|
||||
.item {
|
||||
--td-collapse-content-padding: .25rem 1rem .75rem 1rem;
|
||||
|
||||
.header {
|
||||
gap: .75rem;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
align-items: center;
|
||||
|
||||
.avatar {
|
||||
width: 3.5rem;
|
||||
height: 3.5rem;
|
||||
flex: 0 0 auto;
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
border-radius: .75rem !important;
|
||||
}
|
||||
}
|
||||
|
||||
.product-info {
|
||||
gap: .25rem;
|
||||
.selection {
|
||||
overflow-y: auto;
|
||||
|
||||
.specs {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
flex-direction: column;
|
||||
|
||||
strong,
|
||||
span {
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
.spec {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.values,
|
||||
.units {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
span {
|
||||
color: var(--td-text-color-secondary);
|
||||
.sku-card {
|
||||
padding: .5rem;
|
||||
border: 1px dashed var(--td-brand-color);
|
||||
margin-top: .5rem;
|
||||
border-radius: .875rem;
|
||||
|
||||
.units {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
|
||||
.price {
|
||||
margin-left: .25rem;
|
||||
font-size: .75rem;
|
||||
}
|
||||
}
|
||||
|
||||
&:active {
|
||||
opacity: .7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
playsinline
|
||||
preload="metadata"
|
||||
/>
|
||||
<span class="video-play" aria-hidden="true">▶</span>
|
||||
<t-icon class="play" name="play-circle-filled" size="2rem" />
|
||||
</div>
|
||||
<t-image
|
||||
v-else
|
||||
@@ -101,18 +101,10 @@ const emit = defineEmits<{
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.video-play {
|
||||
.play {
|
||||
inset: 50% auto auto 50%;
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
color: #fff;
|
||||
opacity: .7;
|
||||
position: absolute;
|
||||
display: flex;
|
||||
font-size: 1.125rem;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
background: rgba(15, 23, 42, .68);
|
||||
border-radius: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
<template>
|
||||
<teleport to="body">
|
||||
<t-image-viewer
|
||||
v-model:visible="viewerVisible"
|
||||
:images="images"
|
||||
@@ -88,6 +89,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</t-image-viewer>
|
||||
</teleport>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
|
||||
@@ -175,7 +175,7 @@ defineOptions({
|
||||
name: "CustomerList"
|
||||
});
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "lastWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
@@ -201,7 +201,7 @@ const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
|
||||
@@ -153,7 +153,7 @@ import { buildPresetDateRange, parseDateFilterType, parseDateTime } from "@/util
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "lastWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type VerificationFilter = "ALL" | VerificationStatus;
|
||||
|
||||
defineOptions({
|
||||
@@ -168,7 +168,7 @@ const userStore = useUserStore();
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
|
||||
@@ -138,7 +138,7 @@ import { formatEventNumberValue } from "@/utils/eventValue";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { Message } from "@/utils/message.ts";
|
||||
|
||||
type DateFilterType = "all" | "today" | "yesterday" | "lastWeek" | "thisMonth" | "custom";
|
||||
type DateFilterType = "all" | "today" | "yesterday" | "thisWeek" | "thisMonth" | "custom";
|
||||
|
||||
defineOptions({
|
||||
name: "EventRecordRank"
|
||||
@@ -157,7 +157,7 @@ const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
];
|
||||
|
||||
@@ -145,6 +145,7 @@ import {
|
||||
toPackageBaseQuantity
|
||||
} from "@/utils/package";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import type { ProductStockPreviewItem } from "@/utils/productStock";
|
||||
@@ -539,6 +540,8 @@ async function save(): Promise<void> {
|
||||
const result = directVerify.value
|
||||
? await FulfillmentAPI.createAndVerify(request)
|
||||
: await FulfillmentAPI.create(request);
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, request.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
Message.success(directVerify.value ? "履约单创建并核销成功" : "履约单已提交");
|
||||
await router.replace(`/management/order-fulfillments/${result.id}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -14,8 +14,7 @@
|
||||
<t-cell title="处理人" :note="fulfillment.verifier?.name || fulfillment.verifierUserId || '未处理'" />
|
||||
<t-cell v-if="fulfillment.reason" title="原因" :note="fulfillment.reason" />
|
||||
<t-cell v-if="fulfillment.remark" title="备注" :note="fulfillment.remark" />
|
||||
</t-cell-group>
|
||||
<div class="photos" v-entrance-transition="35">
|
||||
<div class="photo-wrap bg-white">
|
||||
<media-selector
|
||||
:model-value="fulfillmentPhotoURLList"
|
||||
:photo-items="fulfillmentPhotoItems"
|
||||
@@ -25,13 +24,12 @@
|
||||
title="履约照片"
|
||||
/>
|
||||
</div>
|
||||
</t-cell-group>
|
||||
<t-cell-group class="items" title="履约明细" theme="card" v-entrance-transition="70">
|
||||
<t-cell
|
||||
class="item"
|
||||
v-for="item in fulfillment.itemList || []"
|
||||
:key="item.id"
|
||||
:title="item.productNameSnapshot || '未命名产品'"
|
||||
:note="getFulfillmentQuantityText(item)"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-image
|
||||
@@ -47,17 +45,21 @@
|
||||
v-text="(item.productNameSnapshot || '产').slice(0, 1)"
|
||||
/>
|
||||
</template>
|
||||
<template #description>
|
||||
<div class="item-description">
|
||||
<template #title>
|
||||
<div class="title">
|
||||
<span class="clip-text" v-text="item.productNameSnapshot || '未命名产品'" />
|
||||
<t-tag v-if="isGiftedFulfillmentItem(item)" size="small" theme="success" content="赠送" />
|
||||
<product-sku-tags
|
||||
class="tags"
|
||||
:product-name="item.productNameSnapshot"
|
||||
:snapshot="item.skuSpecSnapshot"
|
||||
:fallback="item.specSummarySnapshot || item.skuNameSnapshot || '默认 SKU'"
|
||||
:unit="item.unitSnapshot"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
<template #note>
|
||||
<span class="keep-text" v-text="getFulfillmentQuantityText(item)" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell v-if="!fulfillment.itemList?.length" title="暂无履约明细" />
|
||||
</t-cell-group>
|
||||
@@ -136,6 +138,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import { addPackageQuantity, getPackageQuantityText } from "@/utils/package";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { getProductPhotoURL } from "@/utils/product";
|
||||
import { getFulfillmentStatusText, getSalesOrderItemTypeText, getStatusTheme } from "@/utils/salesOrder";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -300,6 +303,8 @@ async function prepareStock(): Promise<void> {
|
||||
operating.value = true;
|
||||
try {
|
||||
fulfillment.value = await FulfillmentAPI.prepareStock({ fulfillmentId: fulfillment.value.id, reason: "库存已备齐" });
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, fulfillment.value.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
Message.success("库存准备已提交");
|
||||
await loadData();
|
||||
} catch (error) { Message.error(getErrorMessage(error, "库存准备失败")); }
|
||||
@@ -311,6 +316,8 @@ async function verify(): Promise<void> {
|
||||
operating.value = true;
|
||||
try {
|
||||
fulfillment.value = await FulfillmentAPI.verify({ fulfillmentId: fulfillment.value.id, reason: "" });
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, fulfillment.value.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
Message.success("履约已核销");
|
||||
await loadData();
|
||||
} catch (error) { Message.error(getErrorMessage(error, "履约核销失败")); }
|
||||
@@ -325,6 +332,8 @@ async function submitReason(): Promise<void> {
|
||||
fulfillment.value = reasonAction.value === "reject"
|
||||
? await FulfillmentAPI.reject(payload)
|
||||
: await FulfillmentAPI.cancel(payload);
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, fulfillment.value.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
reasonVisible.value = false;
|
||||
Message.success(reasonAction.value === "reject" ? "履约已拒绝" : "履约已撤销");
|
||||
await loadData();
|
||||
@@ -342,6 +351,59 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.photo-wrap {
|
||||
padding: .75rem 1rem;
|
||||
}
|
||||
|
||||
.items {
|
||||
|
||||
.item {
|
||||
padding: 10px;
|
||||
|
||||
:deep(.t-cell__title) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 2rem;
|
||||
height: 2rem;
|
||||
border-radius: .5rem !important;
|
||||
}
|
||||
|
||||
.title {
|
||||
gap: .375rem;
|
||||
display: flex;
|
||||
min-width: 0;
|
||||
flex-wrap: nowrap;
|
||||
align-items: center;
|
||||
|
||||
.tags {
|
||||
flex-wrap: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.stock-preview {
|
||||
margin: 0 1rem;
|
||||
padding: 1rem .5rem .75rem;
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: var(--td-shadow-1);
|
||||
border-radius: 1.25rem;
|
||||
|
||||
.title {
|
||||
padding: 0 .5rem .5rem;
|
||||
font-size: .875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.t-loading) {
|
||||
justify-content: center;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
.actions {
|
||||
--td-button-border-radius: 1rem;
|
||||
|
||||
@@ -364,52 +426,6 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
|
||||
.t-button { flex: 1 1 auto; }
|
||||
}
|
||||
|
||||
.photos {
|
||||
margin: 0 1rem;
|
||||
padding: 1rem;
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: var(--td-shadow-1);
|
||||
border-radius: 1.25rem;
|
||||
}
|
||||
|
||||
.stock-preview {
|
||||
margin: 0 1rem;
|
||||
padding: 1rem .5rem .75rem;
|
||||
background: var(--td-bg-color-container, #fff);
|
||||
box-shadow: var(--td-shadow-1);
|
||||
border-radius: 1.25rem;
|
||||
|
||||
.title {
|
||||
padding: 0 .5rem .5rem;
|
||||
font-size: .875rem;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
:deep(.t-loading) {
|
||||
justify-content: center;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
}
|
||||
|
||||
.items {
|
||||
|
||||
.item {
|
||||
padding: 10px;
|
||||
|
||||
.item-description {
|
||||
gap: .375rem;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.avatar {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@@ -171,11 +171,11 @@ const actions = computed<NavBarAction[]>(() => [
|
||||
action: toPackageOrderList
|
||||
}
|
||||
]);
|
||||
type DateFilterType = "today" | "yesterday" | "lastWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
|
||||
@@ -107,7 +107,7 @@ function getUserName(user: OrderFulfillment["operator"], userId: string | undefi
|
||||
function getProductText(item: OrderFulfillmentItem): string {
|
||||
const quantity = getPackageQuantityText(item.quantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@ import MediaSelector from "@/components/mediaSelector/MediaSelector.vue";
|
||||
import type { OrderFulfillment } from "@/types/Fulfillment";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { createPackageRequestNo } from "@/utils/package";
|
||||
import { Message } from "@/utils/message";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
@@ -157,6 +158,8 @@ async function submit(): Promise<void> {
|
||||
attachmentList
|
||||
});
|
||||
visible.value = false;
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, props.fulfillment.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
Message.success("履约单已冲正");
|
||||
emit("success");
|
||||
} catch (error) {
|
||||
|
||||
@@ -193,7 +193,7 @@ function getStatusTheme(statusValue?: PackageConfigStatus): "success" | "warning
|
||||
function getProductRightText(item: PackageConfigItem): string {
|
||||
const quantity = getPackageQuantityText(item.defaultQuantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -180,7 +180,7 @@ function getStatusTheme(statusValue?: PackageConfigStatus): "success" | "warning
|
||||
function getProductText(item: PackageConfigItem): string {
|
||||
const quantity = getPackageQuantityText(item.defaultQuantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
|
||||
@@ -65,13 +65,12 @@
|
||||
<div class="description" v-text="config.description" />
|
||||
</div>
|
||||
</t-form-item>
|
||||
<t-form-item label="成交价" label-width="6rem" required-mark>
|
||||
<t-form-item v-if="canPriceOverride" label="成交价" label-width="6rem" required-mark>
|
||||
<t-input
|
||||
v-model.trim="saleAmountText"
|
||||
type="number"
|
||||
align="right"
|
||||
borderless
|
||||
:readonly="!canPriceOverride"
|
||||
placeholder="请输入成交价"
|
||||
/>
|
||||
</t-form-item>
|
||||
@@ -188,21 +187,21 @@
|
||||
@update:model-value="paymentAmountText = String($event)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="已全额收款和核销" content-align="right">
|
||||
<t-form-item v-if="canReceiveImmediately" label="已全额收款和核销" content-align="right">
|
||||
<t-switch
|
||||
v-model="receiveFullPayment"
|
||||
size="small"
|
||||
:disabled="!canReceiveImmediately"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="已全部产品履约和核销" content-align="right">
|
||||
<t-form-item v-if="canFulfillImmediately" label="已全部产品履约和核销" content-align="right">
|
||||
<t-switch
|
||||
v-model="fulfillAll"
|
||||
size="small"
|
||||
:disabled="!canFulfillImmediately || isStockChecking"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<t-form-item v-if="canFulfillImmediately" label-width="0">
|
||||
<div class="stock-tips">
|
||||
<div class="tips red">全部履约会同步启用全额收款;请先准备充足的库存,任意一步失败都会下单失败。</div>
|
||||
<product-stock-preview v-if="stockPreviewList.length" :items="stockPreviewList" />
|
||||
@@ -349,6 +348,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import type { GaoPackageConfig, PackageAttachment, PackageConfigItem, PackagePurchaseItem } from "@/types/Package";
|
||||
import type { Product, ProductSku, ProductSkuUnit } from "@/types/Product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import {
|
||||
addPackageQuantity,
|
||||
convertPackageQuantity,
|
||||
@@ -603,7 +603,7 @@ const unitPickerOptions = computed(() => {
|
||||
function getConfigProductText(item: PackageConfigItem): string {
|
||||
const quantity = getPackageQuantityText(item.defaultQuantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
return `${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
|
||||
function getItemLabel(item: PackagePurchaseItem): string {
|
||||
@@ -898,6 +898,8 @@ async function purchasePackage(): Promise<void> {
|
||||
Message.error("套餐购买成功但未返回完整订单关联,请联系管理员");
|
||||
return;
|
||||
}
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, result.salesOrderId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
await settingStore.playRegisterSuccessSound();
|
||||
Message.success(fulfillAll.value ? "套餐、收款及履约已完成" : paymentVerified.value ? "套餐及已核销收款已完成" : receiveFullPayment.value ? "套餐及全额收款已完成" : "套餐购买已提交");
|
||||
await router.replace({
|
||||
|
||||
@@ -171,11 +171,11 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const navBarStore = useNavBarStore();
|
||||
const result = reactive({ total: 0, list: [] as PointRedemption[] });
|
||||
type DateFilterType = "today" | "yesterday" | "lastWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "全部", value: "all" },
|
||||
|
||||
@@ -136,6 +136,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import type { Product, ProductSku } from "@/types/Product";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import {
|
||||
getProductPhotoURL,
|
||||
getProductQuantityText,
|
||||
@@ -254,6 +255,8 @@ function disable(): void {
|
||||
onConfirm: async () => {
|
||||
try {
|
||||
await ProductAPI.disable(id);
|
||||
emitListDataChanged(listDataEventKeys.productChanged, id);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged, id);
|
||||
await load();
|
||||
Message.success("产品已停用");
|
||||
} catch (error) {
|
||||
|
||||
@@ -222,6 +222,7 @@ import type { ProductAttachmentItem, ProductForm, ProductSkuForm as SkuForm, Pro
|
||||
import { compressUploadImage } from "@/utils/imageCompression";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { formatProductAmount, getProductStatusText, getProductTypeText, normalizeProductQuantity, parseProductAmount } from "@/utils/product";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
@@ -1005,6 +1006,8 @@ async function save(): Promise<void> {
|
||||
generateSkuList([], true);
|
||||
}
|
||||
const productId = await ProductAPI.create(buildProductPayload(form.skuList.map(buildSkuPayload), true));
|
||||
emitListDataChanged(listDataEventKeys.productChanged, productId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged, productId);
|
||||
Message.success("产品已创建");
|
||||
await router.replace(`/management/products/${productId}`);
|
||||
return;
|
||||
@@ -1030,6 +1033,8 @@ async function save(): Promise<void> {
|
||||
const retainedSkuIdSet = new Set(form.skuList.map(sku => sku.id).filter((id): id is string => !!id));
|
||||
const disabledSkuIdList = [...previousSkuIdSet].filter(id => !retainedSkuIdSet.has(id));
|
||||
await Promise.all(disabledSkuIdList.map(async skuId => await ProductAPI.skuDisable(skuId)));
|
||||
emitListDataChanged(listDataEventKeys.productChanged, productId);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged, productId);
|
||||
Message.success(isCreateMode.value ? "产品已创建" : "产品已保存");
|
||||
await router.replace(`/management/products/${productId}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -95,6 +95,7 @@ import type { NavBarAction } from "@/types/NavBarAction";
|
||||
import type { Product, ProductCategory, ProductStatus, ProductType } from "@/types/Product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { getProductPhotoURL, getProductStatusText, getProductStatusTheme, getProductTypeText } from "@/utils/product";
|
||||
import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPayload } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -128,6 +129,10 @@ const isNoMore = ref(false);
|
||||
let keywordTimer: number | undefined;
|
||||
let requestToken = 0;
|
||||
let savedPageScrollTop: number | undefined;
|
||||
let eventRefreshPromise: Promise<void> | undefined;
|
||||
let hasPendingEventRefresh = false;
|
||||
let unregisterProductListEvent: (() => void) | undefined;
|
||||
let isDisposed = false;
|
||||
|
||||
function getProductListPage(): HTMLElement | null {
|
||||
return productListRef.value?.closest<HTMLElement>(".page") || null;
|
||||
@@ -186,20 +191,56 @@ async function loadCategories(): Promise<void> {
|
||||
categoryList.value = result.list || [];
|
||||
}
|
||||
|
||||
async function fetch(reset = false): Promise<void> {
|
||||
async function fetch(reset = false, preserveScroll = false): Promise<void> {
|
||||
if (!reset && (isLoading.value || isNoMore.value)) {
|
||||
return;
|
||||
}
|
||||
const loadedPageCount = reset && preserveScroll ? Math.max(pageIndex.value, 1) : 1;
|
||||
const preserveScrollTop = preserveScroll ? getProductListPage()?.scrollTop : undefined;
|
||||
if (reset) {
|
||||
pageIndex.value = 0;
|
||||
productList.value = [];
|
||||
total.value = 0;
|
||||
isNoMore.value = false;
|
||||
if (!preserveScroll) {
|
||||
const page = getProductListPage();
|
||||
if (page) {
|
||||
page.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
const token = ++requestToken;
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const pageSize = 15;
|
||||
if (reset && preserveScroll) {
|
||||
const nextList: Product[] = [];
|
||||
let nextTotal = 0;
|
||||
let nextPageIndex = 0;
|
||||
for (let index = 0; index < loadedPageCount; index += 1) {
|
||||
const result = await ProductAPI.list({
|
||||
index,
|
||||
size: pageSize,
|
||||
keyword: keyword.value || undefined,
|
||||
status: status.value === "ALL" ? undefined : status.value as ProductStatus,
|
||||
productType: productType.value === "ALL" ? undefined : productType.value as ProductType,
|
||||
categoryIdList: categoryIdList.value.includes("ALL") ? undefined : categoryIdList.value
|
||||
});
|
||||
if (token !== requestToken) {
|
||||
return;
|
||||
}
|
||||
const list = result.list || [];
|
||||
nextList.push(...list);
|
||||
nextTotal = result.total || 0;
|
||||
nextPageIndex += 1;
|
||||
if (list.length < pageSize || nextTotal <= nextList.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
productList.value = nextList;
|
||||
total.value = nextTotal;
|
||||
pageIndex.value = nextPageIndex;
|
||||
isNoMore.value = nextList.length < pageSize || nextList.length === nextTotal || nextTotal < nextList.length;
|
||||
} else {
|
||||
const result = await ProductAPI.list({
|
||||
index: pageIndex.value,
|
||||
size: pageSize,
|
||||
@@ -216,6 +257,15 @@ async function fetch(reset = false): Promise<void> {
|
||||
total.value = result.total || 0;
|
||||
pageIndex.value += 1;
|
||||
isNoMore.value = list.length < pageSize || productList.value.length === total.value || total.value < productList.value.length;
|
||||
}
|
||||
if (preserveScrollTop !== undefined) {
|
||||
requestAnimationFrame(() => {
|
||||
const page = getProductListPage();
|
||||
if (page) {
|
||||
page.scrollTop = preserveScrollTop;
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (token === requestToken) {
|
||||
isLoading.value = false;
|
||||
@@ -223,6 +273,32 @@ async function fetch(reset = false): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function startEventRefresh(): void {
|
||||
if (isDisposed) {
|
||||
return;
|
||||
}
|
||||
eventRefreshPromise = fetch(true, true)
|
||||
.catch(error => Message.error(getErrorMessage(error, "产品列表加载失败")))
|
||||
.finally(() => {
|
||||
eventRefreshPromise = undefined;
|
||||
if (!isDisposed && hasPendingEventRefresh) {
|
||||
hasPendingEventRefresh = false;
|
||||
startEventRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function requestEventRefresh(payload?: ListDataChangedPayload): void {
|
||||
if (!isCurrentStoreEvent(payload)) {
|
||||
return;
|
||||
}
|
||||
if (eventRefreshPromise) {
|
||||
hasPendingEventRefresh = true;
|
||||
return;
|
||||
}
|
||||
startEventRefresh();
|
||||
}
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
try {
|
||||
await fetch(true);
|
||||
@@ -299,6 +375,7 @@ async function toDetail(item: Product): Promise<void> {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
unregisterProductListEvent = events.register(listDataEventKeys.productChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
||||
syncNavBar();
|
||||
try {
|
||||
await Promise.all([loadCategories(), fetch(true)]);
|
||||
@@ -333,6 +410,9 @@ onBeforeRouteLeave(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
isDisposed = true;
|
||||
unregisterProductListEvent?.();
|
||||
unregisterProductListEvent = undefined;
|
||||
navBarStore.clearRight();
|
||||
window.clearTimeout(keywordTimer);
|
||||
requestToken += 1;
|
||||
|
||||
@@ -70,6 +70,7 @@ import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { ProductStockProduct } from "@/types/Product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
|
||||
import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPayload } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -90,6 +91,10 @@ const isNoMore = ref(false);
|
||||
let keywordTimer: number | undefined;
|
||||
let requestToken = 0;
|
||||
let savedPageScrollTop: number | undefined;
|
||||
let eventRefreshPromise: Promise<void> | undefined;
|
||||
let hasPendingEventRefresh = false;
|
||||
let unregisterProductStockListEvent: (() => void) | undefined;
|
||||
let isDisposed = false;
|
||||
|
||||
function getProductStockListPage(): HTMLElement | null {
|
||||
return productStockListRef.value?.closest<HTMLElement>(".page") || null;
|
||||
@@ -127,20 +132,53 @@ function getCurrentRouteDepth(): number {
|
||||
return Number(route.meta.depth ?? 0);
|
||||
}
|
||||
|
||||
async function fetch(reset = false): Promise<void> {
|
||||
async function fetch(reset = false, preserveScroll = false): Promise<void> {
|
||||
if (!reset && (isLoading.value || isNoMore.value)) {
|
||||
return;
|
||||
}
|
||||
const loadedPageCount = reset && preserveScroll ? Math.max(pageIndex.value, 1) : 1;
|
||||
const preserveScrollTop = preserveScroll ? getProductStockListPage()?.scrollTop : undefined;
|
||||
if (reset) {
|
||||
pageIndex.value = 0;
|
||||
productList.value = [];
|
||||
total.value = 0;
|
||||
isNoMore.value = false;
|
||||
if (!preserveScroll) {
|
||||
const page = getProductStockListPage();
|
||||
if (page) {
|
||||
page.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
const token = ++requestToken;
|
||||
isLoading.value = true;
|
||||
try {
|
||||
const pageSize = 15;
|
||||
if (reset && preserveScroll) {
|
||||
const nextList: ProductStockProduct[] = [];
|
||||
let nextTotal = 0;
|
||||
let nextPageIndex = 0;
|
||||
for (let index = 0; index < loadedPageCount; index += 1) {
|
||||
const result = await ProductAPI.stockProductList({
|
||||
index,
|
||||
size: pageSize,
|
||||
keyword: keyword.value || undefined
|
||||
});
|
||||
if (token !== requestToken) {
|
||||
return;
|
||||
}
|
||||
const list = result.list || [];
|
||||
nextList.push(...list);
|
||||
nextTotal = result.total || 0;
|
||||
nextPageIndex += 1;
|
||||
if (list.length < pageSize || nextTotal <= nextList.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
productList.value = nextList;
|
||||
total.value = nextTotal;
|
||||
pageIndex.value = nextPageIndex;
|
||||
isNoMore.value = nextList.length < pageSize || nextList.length === nextTotal || nextTotal < nextList.length;
|
||||
} else {
|
||||
const result = await ProductAPI.stockProductList({
|
||||
index: pageIndex.value,
|
||||
size: pageSize,
|
||||
@@ -154,6 +192,15 @@ async function fetch(reset = false): Promise<void> {
|
||||
total.value = result.total || 0;
|
||||
pageIndex.value += 1;
|
||||
isNoMore.value = list.length < pageSize || productList.value.length === total.value || total.value < productList.value.length;
|
||||
}
|
||||
if (preserveScrollTop !== undefined) {
|
||||
requestAnimationFrame(() => {
|
||||
const page = getProductStockListPage();
|
||||
if (page) {
|
||||
page.scrollTop = preserveScrollTop;
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (token === requestToken) {
|
||||
isLoading.value = false;
|
||||
@@ -161,6 +208,32 @@ async function fetch(reset = false): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
function startEventRefresh(): void {
|
||||
if (isDisposed) {
|
||||
return;
|
||||
}
|
||||
eventRefreshPromise = fetch(true, true)
|
||||
.catch(error => Message.error(getErrorMessage(error, "产品列表加载失败")))
|
||||
.finally(() => {
|
||||
eventRefreshPromise = undefined;
|
||||
if (!isDisposed && hasPendingEventRefresh) {
|
||||
hasPendingEventRefresh = false;
|
||||
startEventRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function requestEventRefresh(payload?: ListDataChangedPayload): void {
|
||||
if (!isCurrentStoreEvent(payload)) {
|
||||
return;
|
||||
}
|
||||
if (eventRefreshPromise) {
|
||||
hasPendingEventRefresh = true;
|
||||
return;
|
||||
}
|
||||
startEventRefresh();
|
||||
}
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
try {
|
||||
await fetch(true);
|
||||
@@ -191,6 +264,7 @@ async function toSkuList(item: ProductStockProduct): Promise<void> {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
unregisterProductStockListEvent = events.register(listDataEventKeys.productStockChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
||||
navBarStore.clearRight();
|
||||
if (!userStore.hasPermissions(permissionCodes.productStock.read)) {
|
||||
return;
|
||||
@@ -227,6 +301,9 @@ onBeforeRouteLeave(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
isDisposed = true;
|
||||
unregisterProductStockListEvent?.();
|
||||
unregisterProductStockListEvent = undefined;
|
||||
navBarStore.clearRight();
|
||||
window.clearTimeout(keywordTimer);
|
||||
requestToken += 1;
|
||||
|
||||
@@ -108,6 +108,7 @@ import type {
|
||||
StockOperationType
|
||||
} from "@/types/Product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { createProductRequestNo, getStockOperationText } from "@/utils/product";
|
||||
import { Message } from "@/utils/message";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
@@ -260,6 +261,7 @@ async function submit(): Promise<void> {
|
||||
break;
|
||||
}
|
||||
visible.value = false;
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged, props.product.id);
|
||||
Message.success("库存操作已提交");
|
||||
emit("success");
|
||||
} catch (error) {
|
||||
|
||||
@@ -144,6 +144,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import type { StockBizType, StockRecord } from "@/types/Product";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { createProductRequestNo, getProductQuantityText, getStockOperationText } from "@/utils/product";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
@@ -279,6 +280,7 @@ async function submitManualRevoke(): Promise<void> {
|
||||
attachmentList: buildAttachments()
|
||||
});
|
||||
revokeVisible.value = false;
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged, record.value.id);
|
||||
Message.success("手工库存流水已冲正");
|
||||
await loadData();
|
||||
} catch (error) {
|
||||
|
||||
@@ -196,7 +196,7 @@ import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
defineOptions({ name: "ConsumptionRecordList" });
|
||||
|
||||
type DateFilterType = "today" | "yesterday" | "lastWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
type DateFilterType = "today" | "yesterday" | "thisWeek" | "thisMonth" | "lastMonth" | "all" | "custom";
|
||||
|
||||
const pageSize = 20;
|
||||
const route = useRoute();
|
||||
@@ -207,7 +207,7 @@ const dateOptions: Array<{ label: string; value: DateFilterType }> = [
|
||||
{ label: "全部时间", value: "all" },
|
||||
{ label: "今天", value: "today" },
|
||||
{ label: "昨天", value: "yesterday" },
|
||||
{ label: "上周", value: "lastWeek" },
|
||||
{ label: "本周", value: "thisWeek" },
|
||||
{ label: "本月", value: "thisMonth" },
|
||||
{ label: "上个月", value: "lastMonth" },
|
||||
{ label: "自定义范围", value: "custom" }
|
||||
|
||||
@@ -130,6 +130,7 @@ import type { FundRecord, FundRecordStatus } from "@/types/SalesOrder";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { formatPackageAmount } from "@/utils/package";
|
||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||
import { Message } from "@/utils/message";
|
||||
@@ -262,6 +263,7 @@ async function verifyReceive(): Promise<void> {
|
||||
isOperating.value = true;
|
||||
try {
|
||||
await SalesOrderAPI.verifyPayment(record.value!.id!);
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, record.value?.bizId);
|
||||
await refreshRelatedPackage();
|
||||
Message.success("收款已核销");
|
||||
await loadData();
|
||||
@@ -304,6 +306,7 @@ async function submitReason(): Promise<void> {
|
||||
} else {
|
||||
await SalesOrderAPI.cancelPayment({ fundRecordId: record.value.id, reason: reasonText.value.trim() });
|
||||
}
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, record.value.bizId);
|
||||
reasonDialogVisible.value = false;
|
||||
await refreshRelatedPackage();
|
||||
Message.success(reasonAction.value === "reject" ? "收款已拒绝" : "收款已撤销");
|
||||
|
||||
@@ -94,6 +94,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount } from "@/utils/package";
|
||||
import { getFundOperationText, getFundStatusText } from "@/utils/salesOrder";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
@@ -224,6 +225,7 @@ async function save(): Promise<void> {
|
||||
attachmentList: buildAttachments(),
|
||||
remark: remark.value.trim() || null
|
||||
});
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, record.value.bizId);
|
||||
Message.success("资金记录已冲正");
|
||||
if (record.value.bizId) {
|
||||
await router.replace(`/management/sales-orders/${record.value.bizId}`);
|
||||
|
||||
@@ -60,6 +60,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { getSalesOrderStatusText } from "@/utils/salesOrder";
|
||||
@@ -131,6 +132,7 @@ async function save(): Promise<void> {
|
||||
saving.value = true;
|
||||
try {
|
||||
await SalesOrderAPI.cancel({ salesOrderId: order.value.id, reason: reason.value.trim() });
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, order.value.id);
|
||||
Message.success("订单已取消");
|
||||
await router.replace(`/management/sales-orders/${order.value.id}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -62,13 +62,12 @@
|
||||
required-mark
|
||||
@update:model-value="applyProduct(index, $event)"
|
||||
/>
|
||||
<t-form-item :label="canPriceOverride ? '成交单价' : '单价'">
|
||||
<t-form-item v-if="canPriceOverride" label="成交单价">
|
||||
<t-input
|
||||
v-model.trim="item.unitPriceText"
|
||||
type="number"
|
||||
align="right"
|
||||
borderless
|
||||
:readonly="!canPriceOverride"
|
||||
:placeholder="getItemUnitPricePlaceholder(item)"
|
||||
/>
|
||||
<template #help>
|
||||
@@ -151,21 +150,21 @@
|
||||
@update:model-value="paymentAmountText = String($event)"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="已全额收款和核销" content-align="right">
|
||||
<t-form-item v-if="canReceiveImmediately" label="已全额收款和核销" content-align="right">
|
||||
<t-switch
|
||||
v-model="receiveFullPayment"
|
||||
size="small"
|
||||
:disabled="!canReceiveImmediately"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label="已全部产品履约和核销" content-align="right">
|
||||
<t-form-item v-if="canFulfillImmediately" label="已全部产品履约和核销" content-align="right">
|
||||
<t-switch
|
||||
v-model="fulfillAll"
|
||||
size="small"
|
||||
:disabled="!canFulfillImmediately || isStockChecking"
|
||||
/>
|
||||
</t-form-item>
|
||||
<t-form-item label-width="0">
|
||||
<t-form-item v-if="canFulfillImmediately" label-width="0">
|
||||
<div class="stock-tips">
|
||||
<div class="tips red">全部履约会同步启用全额收款;请先准备充足的库存,任意一步失败都会下单失败。</div>
|
||||
<product-stock-preview v-if="stockPreviewList.length" :items="stockPreviewList" />
|
||||
@@ -238,6 +237,7 @@ import type { DirectProductOrderItemRequest } from "@/types/SalesOrder";
|
||||
import { createPackageRequestNo, normalizePackageQuantity, parsePackageAmount, toPackageBaseQuantity } from "@/utils/package";
|
||||
import { formatProductAmount, getProductQuantityStep } from "@/utils/product";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { buildProductStockPreview, getProductStockShortageMessage, mergeProductStockRequirements } from "@/utils/productStock";
|
||||
@@ -600,6 +600,8 @@ async function submitOrder(): Promise<void> {
|
||||
} : undefined,
|
||||
remark: remark.value.trim() || null
|
||||
});
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, result.id);
|
||||
emitListDataChanged(listDataEventKeys.productStockChanged);
|
||||
Message.success(fulfillAll.value ? "订单、收款及履约已完成" : paymentVerified.value ? "订单及已核销收款已完成" : receiveFullPayment.value ? "订单及全额收款已完成" : "销售订单已创建");
|
||||
await router.replace(`/management/sales-orders/${result.id}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -232,6 +232,7 @@ import type { PhotoItem } from "@/types/Photo";
|
||||
import { convertPackageQuantity, formatPackageAmount, getPackageQuantityText } from "@/utils/package";
|
||||
import { getAttachmentReadURL } from "@/utils/attachment";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { getProductPhotoURL } from "@/utils/product";
|
||||
import {
|
||||
getSalesOrderStatusText,
|
||||
@@ -418,6 +419,7 @@ async function saveEdit(): Promise<void> {
|
||||
attachmentList: buildAttachmentList(),
|
||||
remark: editRemark.value.trim() || null
|
||||
});
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, orderId);
|
||||
order.value = result;
|
||||
editRemark.value = result.remark || "";
|
||||
photoItems.value = toPhotoItems(result.attachmentList);
|
||||
|
||||
@@ -132,6 +132,7 @@ import {
|
||||
} from "@/types/SalesOrderFilter";
|
||||
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPayload } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -153,6 +154,10 @@ const canRefund = computed(() => userStore.hasPermissions(permissionCodes.fund.r
|
||||
const canStoreManager = computed(() => userStore.hasRoles(gaoRoleCodes.storeManager));
|
||||
let savedPageScrollTop: number | undefined;
|
||||
let shouldReloadOnActivate = false;
|
||||
let eventRefreshPromise: Promise<void> | undefined;
|
||||
let hasPendingEventRefresh = false;
|
||||
let unregisterSalesOrderListEvent: (() => void) | undefined;
|
||||
let isDisposed = false;
|
||||
|
||||
function getSalesOrderPage(): HTMLElement | null {
|
||||
return salesOrderListRef.value?.closest<HTMLElement>(".page") || null;
|
||||
@@ -216,6 +221,7 @@ const selectedPackageName = computed(() => selectedPackage.value?.name || queryV
|
||||
const filterVisible = ref(false);
|
||||
const appliedFilter = ref<SalesOrderListFilter>(createDefaultSalesOrderFilter());
|
||||
const filterStorageKey = computed(() => `${SALES_ORDER_FILTER_STORAGE_KEY}:${currentStoreStore.currentStoreId || "default"}:${packageConfigId.value || "all"}`);
|
||||
let cachedPackageConfigId = "";
|
||||
const orderTypeOptions: Array<{ label: string; value: GaoSalesOrderType }> = [
|
||||
{ label: "套餐订单", value: "PACKAGE" },
|
||||
{ label: "产品订单", value: "DIRECT_PRODUCT" }
|
||||
@@ -333,6 +339,12 @@ function applyRouteFilters(): void {
|
||||
appliedFilter.value = nextFilter;
|
||||
}
|
||||
|
||||
function syncCachedRouteContext(): void {
|
||||
if (route.name === "SalesOrderList") {
|
||||
cachedPackageConfigId = packageConfigId.value;
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRoutePackage(): Promise<void> {
|
||||
selectedPackage.value = undefined;
|
||||
if (!packageConfigId.value) {
|
||||
@@ -385,6 +397,7 @@ function resetForProductTab(): void {
|
||||
refreshing.value = false;
|
||||
noMore.value = false;
|
||||
savedPageScrollTop = undefined;
|
||||
cachedPackageConfigId = "";
|
||||
localStorage.removeItem(filterStorageKey.value);
|
||||
const page = getSalesOrderPage();
|
||||
if (page) {
|
||||
@@ -407,35 +420,65 @@ function getPaymentStatusValues(valueList: SalesOrderPaymentFilter[]): GaoSalesP
|
||||
return paymentStatusValues.filter(value => valueSet.has(value));
|
||||
}
|
||||
|
||||
function buildPageFilter(): SalesOrderPage {
|
||||
function buildPageFilter(index = pageIndex.value): SalesOrderPage {
|
||||
const filter = appliedFilter.value;
|
||||
const [beginText, endText] = filter.dateRange;
|
||||
const currentPackageConfigId = cachedPackageConfigId || packageConfigId.value;
|
||||
return {
|
||||
customerId: customerId.value || undefined,
|
||||
packageConfigId: packageConfigId.value || undefined,
|
||||
packageConfigId: currentPackageConfigId || undefined,
|
||||
keyword: keyword.value || undefined,
|
||||
orderTypeList: packageConfigId.value ? ["PACKAGE"] : getEffectiveList(filter.orderTypeList, orderTypeOptions.map(item => item.value)),
|
||||
orderTypeList: currentPackageConfigId ? ["PACKAGE"] : getEffectiveList(filter.orderTypeList, orderTypeOptions.map(item => item.value)),
|
||||
statusList: getEffectiveList(filter.statusList, statusOptions.map(item => item.value)),
|
||||
paymentStatusList: getEffectiveList(getPaymentStatusValues(filter.paymentStatusList), paymentStatusValues),
|
||||
refundStatusList: getEffectiveList(filter.refundStatusList, refundOptions.map(item => item.value)),
|
||||
beginAt: beginText ? parseDateTime(beginText, false).getTime() : undefined,
|
||||
endAt: endText ? parseDateTime(endText, true).getTime() : undefined,
|
||||
index: pageIndex.value,
|
||||
index,
|
||||
size: pageSize
|
||||
};
|
||||
}
|
||||
|
||||
async function fetchList(reset: boolean): Promise<void> {
|
||||
if (loading.value || (!reset && noMore.value)) return;
|
||||
async function fetchList(reset: boolean, preserveScroll = false): Promise<void> {
|
||||
if (!reset && (loading.value || noMore.value)) return;
|
||||
const loadedPageCount = reset && preserveScroll ? Math.max(pageIndex.value, 1) : 1;
|
||||
const preserveScrollTop = preserveScroll ? getSalesOrderPage()?.scrollTop : undefined;
|
||||
if (reset) {
|
||||
pageIndex.value = 0;
|
||||
total.value = 0;
|
||||
noMore.value = false;
|
||||
list.value = [];
|
||||
if (!preserveScroll) {
|
||||
const page = getSalesOrderPage();
|
||||
if (page) {
|
||||
page.scrollTop = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
const requestId = ++listRequestId;
|
||||
loading.value = true;
|
||||
try {
|
||||
if (reset && preserveScroll) {
|
||||
const nextList: SalesOrder[] = [];
|
||||
let nextTotal = 0;
|
||||
let nextPageIndex = 0;
|
||||
for (let index = 0; index < loadedPageCount; index += 1) {
|
||||
const result = await SalesOrderAPI.list(buildPageFilter(index));
|
||||
if (requestId !== listRequestId) {
|
||||
return;
|
||||
}
|
||||
const rows = result.list || [];
|
||||
nextList.push(...rows);
|
||||
nextTotal = result.total || 0;
|
||||
nextPageIndex += 1;
|
||||
if (rows.length < pageSize || nextTotal <= nextList.length) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
list.value = nextList;
|
||||
total.value = nextTotal;
|
||||
pageIndex.value = nextPageIndex;
|
||||
noMore.value = nextList.length < pageSize || nextTotal <= nextList.length;
|
||||
} else {
|
||||
const result = await SalesOrderAPI.list(buildPageFilter());
|
||||
if (requestId !== listRequestId) {
|
||||
return;
|
||||
@@ -445,6 +488,15 @@ async function fetchList(reset: boolean): Promise<void> {
|
||||
total.value = result.total || 0;
|
||||
pageIndex.value += 1;
|
||||
noMore.value = rows.length < pageSize || total.value <= list.value.length;
|
||||
}
|
||||
if (preserveScrollTop !== undefined) {
|
||||
requestAnimationFrame(() => {
|
||||
const page = getSalesOrderPage();
|
||||
if (page) {
|
||||
page.scrollTop = preserveScrollTop;
|
||||
}
|
||||
});
|
||||
}
|
||||
} finally {
|
||||
if (requestId === listRequestId) {
|
||||
loading.value = false;
|
||||
@@ -452,9 +504,35 @@ async function fetchList(reset: boolean): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function reloadList(): Promise<void> {
|
||||
async function reloadList(preserveScroll = false): Promise<void> {
|
||||
await customerOrderSummaryRef.value?.refresh();
|
||||
await fetchList(true);
|
||||
await fetchList(true, preserveScroll);
|
||||
}
|
||||
|
||||
function startEventRefresh(): void {
|
||||
if (isDisposed) {
|
||||
return;
|
||||
}
|
||||
eventRefreshPromise = reloadList(true)
|
||||
.catch(error => Message.error(getErrorMessage(error, "销售订单加载失败")))
|
||||
.finally(() => {
|
||||
eventRefreshPromise = undefined;
|
||||
if (!isDisposed && hasPendingEventRefresh) {
|
||||
hasPendingEventRefresh = false;
|
||||
startEventRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function requestEventRefresh(payload?: ListDataChangedPayload): void {
|
||||
if (!isCurrentStoreEvent(payload)) {
|
||||
return;
|
||||
}
|
||||
if (eventRefreshPromise) {
|
||||
hasPendingEventRefresh = true;
|
||||
return;
|
||||
}
|
||||
startEventRefresh();
|
||||
}
|
||||
|
||||
async function refresh(): Promise<void> {
|
||||
@@ -550,6 +628,7 @@ watch(routeFilterKey, async value => {
|
||||
return;
|
||||
}
|
||||
lastAppliedRouteFilterKey = value;
|
||||
syncCachedRouteContext();
|
||||
applyRouteFilters();
|
||||
try {
|
||||
await loadRouteCustomer();
|
||||
@@ -574,6 +653,8 @@ watch(() => currentStoreStore.currentStoreId, async (value, oldValue) => {
|
||||
});
|
||||
|
||||
onMounted(async () => {
|
||||
unregisterSalesOrderListEvent = events.register(listDataEventKeys.salesOrderChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
||||
syncCachedRouteContext();
|
||||
navBarStore.clearRight();
|
||||
navBarStore.setCustomRightVisible(!!actions.value.length);
|
||||
applyRouteFilters();
|
||||
@@ -589,6 +670,7 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
onActivated(async () => {
|
||||
syncCachedRouteContext();
|
||||
if (shouldReloadOnActivate) {
|
||||
shouldReloadOnActivate = false;
|
||||
applyRouteFilters();
|
||||
@@ -625,6 +707,9 @@ onBeforeRouteLeave(to => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
isDisposed = true;
|
||||
unregisterSalesOrderListEvent?.();
|
||||
unregisterSalesOrderListEvent = undefined;
|
||||
navBarStore.clearRight();
|
||||
search.cancel();
|
||||
});
|
||||
|
||||
@@ -14,6 +14,7 @@ import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
|
||||
@@ -33,6 +34,7 @@ async function save(): Promise<void> {
|
||||
saving.value = true;
|
||||
try {
|
||||
await SalesOrderAPI.confirmNoRefund({ salesOrderId: order.value.id, reason: reason.value.trim() });
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, order.value.id);
|
||||
Message.success("已确认无需退款");
|
||||
await router.replace(`/management/sales-orders/${order.value.id}`);
|
||||
} catch (error) { Message.error(getErrorMessage(error, "确认失败,请刷新后重试")); }
|
||||
|
||||
@@ -101,6 +101,7 @@ import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
@@ -201,6 +202,7 @@ async function save(): Promise<void> {
|
||||
const record = directVerify.value
|
||||
? await SalesOrderAPI.receivePaymentAndVerify(request)
|
||||
: await SalesOrderAPI.receivePayment(request);
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, order.value.id);
|
||||
Message.success(directVerify.value ? "收款登记并核销成功" : "收款登记已提交");
|
||||
await router.replace(record.id && userStore.hasPermissions(permissionCodes.fundReceive.create)
|
||||
? `/management/fund-records/${record.id}`
|
||||
|
||||
@@ -123,6 +123,7 @@ import type { SalesOrder } from "@/types/SalesOrder";
|
||||
import type { PhotoItem } from "@/types/Photo";
|
||||
import { createPackageRequestNo, formatPackageAmount, formatPackageAmountInput, parsePackageAmount } from "@/utils/package";
|
||||
import { getErrorMessage } from "@/utils/error";
|
||||
import { emitListDataChanged, listDataEventKeys } from "@/utils/listDataEvents";
|
||||
import { Message } from "@/utils/message";
|
||||
import { permissionCodes } from "@/utils/permission";
|
||||
import { uploadPhotoList } from "@/utils/photo";
|
||||
@@ -239,6 +240,7 @@ async function save(): Promise<void> {
|
||||
attachmentList,
|
||||
remark: remark.value.trim() || null
|
||||
});
|
||||
emitListDataChanged(listDataEventKeys.salesOrderChanged, order.value.id);
|
||||
Message.success("退款登记已提交");
|
||||
await router.replace(`/management/sales-orders/${order.value.id}`);
|
||||
} catch (error) {
|
||||
|
||||
@@ -233,7 +233,7 @@ function getProductText(item: NonNullable<SalesOrder["itemList"]>[number]): stri
|
||||
const quantity = getPackageQuantityText(item.quantity);
|
||||
const skuText = getProductSkuSnapshotText(item.productNameSnapshot, item.skuNameSnapshot, item.specSummarySnapshot);
|
||||
const giftText = item.gifted ? "赠送 · " : "";
|
||||
return `${giftText}${item.productNameSnapshot || "未命名产品"}${skuText ? ` · ${skuText}` : ""} × ${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
return `${giftText}${item.productNameSnapshot || "未命名产品"}${skuText ? `(${skuText})` : " "}${quantity}${item.unitSnapshot ? ` ${item.unitSnapshot}` : ""}`;
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { Events as EventsClass } from "timi-web";
|
||||
import { getCurrentStoreId } from "@/utils/store";
|
||||
|
||||
export const listDataEventKeys = {
|
||||
productChanged: "gao:list:product-changed",
|
||||
productStockChanged: "gao:list:product-stock-changed",
|
||||
salesOrderChanged: "gao:list:sales-order-changed"
|
||||
} as const;
|
||||
|
||||
export type ListDataEventKey = typeof listDataEventKeys[keyof typeof listDataEventKeys];
|
||||
|
||||
export interface ListDataChangedPayload {
|
||||
storeId?: string;
|
||||
entityId?: string;
|
||||
}
|
||||
|
||||
interface ListDataEventMap {
|
||||
[listDataEventKeys.productChanged]: [payload: ListDataChangedPayload];
|
||||
[listDataEventKeys.productStockChanged]: [payload: ListDataChangedPayload];
|
||||
[listDataEventKeys.salesOrderChanged]: [payload: ListDataChangedPayload];
|
||||
}
|
||||
|
||||
export const events = new EventsClass<ListDataEventMap>();
|
||||
|
||||
export function emitListDataChanged(key: ListDataEventKey, entityId?: string): void {
|
||||
events.emit(key, {
|
||||
storeId: getCurrentStoreId(),
|
||||
entityId
|
||||
});
|
||||
}
|
||||
|
||||
export function isCurrentStoreEvent(payload?: ListDataChangedPayload): boolean {
|
||||
return !payload?.storeId || payload.storeId === getCurrentStoreId();
|
||||
}
|
||||
@@ -14,4 +14,4 @@ export { default as Cooker } from "../../../timi-web/src/utils/Cooker";
|
||||
export { default as Storage } from "../../../timi-web/src/utils/Storage";
|
||||
export { default as WebToolkit } from "../../../timi-web/src/utils/WebToolkit";
|
||||
|
||||
export { Text, Time, Toolkit } from "../../../timi-ts/src/index";
|
||||
export { Events, Text, Time, Toolkit } from "../../../timi-ts/src/index";
|
||||
|
||||
Reference in New Issue
Block a user