v1.6.0 #13

Merged
timi merged 28 commits from dev into master 2026-11-20 06:30:23 +00:00
Showing only changes of commit e54f1af252 - Show all commits
+280 -167
View File
@@ -7,181 +7,215 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.salesOrder.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="filters glass">
<t-input
class="keyword"
:value="customerDisplayText"
readonly
borderless
placeholder="选择或扫码客户"
@click="customerSelectorVisible = true"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
:content="scannerVisible ? '关闭扫码' : '扫码'"
@click.stop="toggleScanner"
/>
</div>
</template>
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="sourceType"
label="消费来源"
:options="sourceTypeOptions"
@change="reloadRecords"
/>
<t-dropdown-item
v-model="status"
label="消费状态"
:options="statusOptions"
@change="reloadRecords"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<div v-if="scannerVisible" class="scanner-wrap">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="记录数" :note="`共 ${total} 条`" />
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
:arrow="canOpenSource(item)"
v-entrance-transition="{ step: 30 }"
@click="openSource(item)"
<master-detail-page
v-can="permissionCodes.salesOrder.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
:sub="!!subView"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="filters glass">
<t-input
class="keyword"
:value="customerDisplayText"
readonly
borderless
placeholder="选择或扫码客户"
@click="customerSelectorVisible = true"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer" v-text="getCustomerText(item)" />
<t-tag
class="value"
size="small"
:theme="item.sourceType === 'LEGACY_EVENT' ? 'default' : 'primary'"
variant="light"
:content="getRecordTitle(item)"
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
:content="scannerVisible ? '关闭扫码' : '扫码'"
@click.stop="toggleScanner"
/>
</div>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'danger'"
variant="light-outline"
:content="getStatusText(item.status)"
</t-input>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-model="sourceType"
label="消费来源"
:options="sourceTypeOptions"
@change="reloadRecords"
/>
<t-dropdown-item
v-model="status"
label="消费状态"
:options="statusOptions"
@change="reloadRecords"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<div v-if="scannerVisible" class="scanner-wrap">
<code-scanner
visible
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框。"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="记录数" :note="`共 ${total} 条`" />
<t-cell title="消费金额合计" :note="`¥${formatPackageAmount(amountTotal)}`" />
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
:arrow="canOpenSource(item)"
v-entrance-transition="{ step: 30 }"
@click="openSource(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
<time-label class="time" :timestamp="item.effectiveAt" underline />
</div>
</template>
<template #note>
<strong class="red" v-text="`¥${formatPackageAmount(item.amount)}`" />
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="isLoading ? '正在加载消费记录' : '暂无消费记录'" />
<center-tips v-if="recordList.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
:enable-scan="false"
@change="handleCustomerChange"
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer" v-text="getCustomerText(item)" />
<t-tag
class="value"
size="small"
:theme="item.sourceType === 'LEGACY_EVENT' ? 'default' : 'primary'"
variant="light"
:content="getRecordTitle(item)"
/>
</div>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'danger'"
variant="light-outline"
:content="getStatusText(item.status)"
/>
<time-label class="time" :timestamp="item.effectiveAt" underline />
</div>
</template>
<template #note>
<strong class="red" v-text="`¥${formatPackageAmount(item.amount)}`" />
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="isLoading ? '正在加载消费记录' : '暂无消费记录'" />
<center-tips v-if="recordList.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
</template>
<!--
右栏:消费记录点开的是交易订单详情(另一个模块的整页),
直接占用详情槽,消费记录列表保持原位。
-->
<template #detail>
<sales-order-detail
ref="salesOrderDetailRef"
:key="`order-${selectedId}`"
:order-id="selectedId"
/>
</template>
<!--
第三层:订单详情跳到从属页面时,订单退到主栏、右栏换成这一层,
与交易订单列表里「订单详情 + 履约单」的走法一致。
-->
<template #sub>
<sales-order-sub-view
:key="subView"
:view="subView"
:order-id="selectedId"
@refresh="refreshRecycleDetail"
@saved="handleSubSaved"
/>
</template>
</master-detail-page>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
:enable-scan="false"
@change="handleCustomerChange"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="dateRange[0]"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</main>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="dateRange[1]"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</div>
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import type { DropdownValue } from "tdesign-mobile-vue";
import { TimeLabel, Time } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -189,6 +223,9 @@ import ConsumptionRecordAPI from "@/api/ConsumptionRecordAPI";
import CustomerAPI from "@/api/CustomerAPI";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerSelector from "@/components/CustomerSelector.vue";
import SalesOrderDetail from "@/pages/salesOrder/SalesOrderDetail.vue";
import SalesOrderSubView from "@/pages/salesOrder/component/SalesOrderSubView.vue";
import { getOrderPaneRoute } from "@/pages/salesOrder/component/orderPane";
import type {
ConsumptionRecord,
ConsumptionRecordPage,
@@ -210,6 +247,63 @@ defineOptions({ name: "ConsumptionRecordList" });
const pageSize = 20;
const route = useRoute();
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;右栏渲染订单详情,它自己的子页进第三层
const { selectedId, subView, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/product/consumption-records",
detail: detailRoute
});
const salesOrderDetailRef = ref<InstanceType<typeof SalesOrderDetail>>();
/** 转屏变窄时右栏不再渲染,按右栏当前那一层落到整页路由。 */
function detailRoute(id: string): string {
const view = subView.value;
return view ? getOrderPaneRoute({ orderId: id, view }) : `/product/sales-orders/${id}`;
}
/** 子页标识形如 `recycle-rule:698f`,冒号前是类型,后面是参数。 */
const subArg = computed(() => subView.value?.split(":")[1] || "");
// 子页之间是同层替换,反向同步给的是 none,回退到上一层时补成 back
watch(subView, (next, previous) => {
if (previous?.startsWith("fulfillment-detail:") && next === "fulfillments") {
paneDirection.value = "back";
}
if (previous?.startsWith("recycle-payment-detail:") && next?.startsWith("recycle-payments:")) {
paneDirection.value = "back";
}
if (previous?.startsWith("recycle-payment-revoke:") && next?.startsWith("recycle-payment-detail:")) {
paneDirection.value = "back";
}
});
async function refreshRecycleDetail(): Promise<void> {
await salesOrderDetailRef.value?.refreshAfterRecyclePayment();
}
async function handleRecyclePaymentSaved(paymentId?: string): Promise<void> {
const exchangeId = subArg.value;
if (paymentId && exchangeId) {
paneDirection.value = "forward";
subView.value = `recycle-payment-detail:${exchangeId}:${paymentId}`;
}
await refreshRecycleDetail();
}
/** 子页保存完成:新建了履约单或回收支付时,接着打开它刚建出来的详情。 */
async function handleSubSaved(kind: string, id: string): Promise<void> {
if (kind === "fulfillment-create") {
if (id) {
paneDirection.value = "forward";
subView.value = `fulfillment-detail:${id}`;
}
await salesOrderDetailRef.value?.refreshOrder();
return;
}
if (kind === "recycle-register") {
await handleRecyclePaymentSaved(id || undefined);
}
}
const userStore = useUserStore();
const sourceType = ref<ConsumptionRecordSourceType | "ALL">("ALL");
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
@@ -444,7 +538,7 @@ async function openSource(record: ConsumptionRecord): Promise<void> {
return;
}
if (record.sourceType === "SALES_ORDER" && record.salesOrderId) {
await router.push({ name: "SalesOrderDetail", params: { id: record.salesOrderId } });
openDetail(record.salesOrderId);
return;
}
if (record.sourceType === "LEGACY_EVENT" && record.sourceId) {
@@ -461,9 +555,28 @@ onMounted(async () => {
<style scoped lang="less">
.consumption-record-list {
min-height: 100vh;
padding: var(--tui-nav-height) 0 1rem;
// master 槽里没有 .tui-page-content,库与全局的列表规则不适用,这里补齐
.pull-refresh {
padding-top: 1rem;
:deep(.t-pull-down-refresh__track) {
gap: 1rem;
height: auto;
display: flex;
min-height: 100%;
flex-direction: column;
}
}
.filters {
top: -1rem;
z-index: 10;
margin: -1rem 0 0;
padding: 1rem 1rem 0;
position: sticky;
}
.list-wrap {
gap: 1rem;