fix(product): better layout on tablet
This commit is contained in:
@@ -76,6 +76,17 @@ async function listLedger(page: PointLedgerPage, options?: ListOptions): Promise
|
|||||||
return await axios.post(`${BASE_URI}/ledger/list`, withCurrentStoreId(page));
|
return await axios.post(`${BASE_URI}/ledger/list`, withCurrentStoreId(page));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按流水 ID 查询积分流水。
|
||||||
|
*
|
||||||
|
* 不传 storeId:服务端按当前登录人的门店范围解析,非全局管理员天然只能查本店。
|
||||||
|
*/
|
||||||
|
async function ledgerDetail(id: string): Promise<PointLedger> {
|
||||||
|
return await axios.post(`${BASE_URI}/ledger/detail`, undefined, {
|
||||||
|
params: { id }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** 人工调整积分,后端使用 adjustRequestId 保证幂等。 */
|
/** 人工调整积分,后端使用 adjustRequestId 保证幂等。 */
|
||||||
async function adjust(request: PointAdjustRequest): Promise<void> {
|
async function adjust(request: PointAdjustRequest): Promise<void> {
|
||||||
await axios.post(`${BASE_URI}/adjust`, withCurrentStoreId(request));
|
await axios.post(`${BASE_URI}/adjust`, withCurrentStoreId(request));
|
||||||
@@ -177,6 +188,7 @@ export default {
|
|||||||
detailByCustomerId,
|
detailByCustomerId,
|
||||||
detail,
|
detail,
|
||||||
listLedger,
|
listLedger,
|
||||||
|
ledgerDetail,
|
||||||
adjust,
|
adjust,
|
||||||
ruleList,
|
ruleList,
|
||||||
ruleDetail,
|
ruleDetail,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
:z-index="20"
|
:z-index="20"
|
||||||
title="积分流水详情"
|
title="积分流水详情"
|
||||||
left-arrow
|
left-arrow
|
||||||
@left-click="$router.back()"
|
@left-click="goBack"
|
||||||
/>
|
/>
|
||||||
<main class="tui-page-content scroll column">
|
<main class="tui-page-content scroll column">
|
||||||
<div v-if="customer" v-can="permissionCodes.point.ledgerRead" class="point-ledger-detail">
|
<div v-if="customer" v-can="permissionCodes.point.ledgerRead" class="point-ledger-detail">
|
||||||
@@ -83,7 +83,7 @@
|
|||||||
<center-tips v-else :content="getRuleEmptyText()" />
|
<center-tips v-else :content="getRuleEmptyText()" />
|
||||||
</t-cell-group>
|
</t-cell-group>
|
||||||
</template>
|
</template>
|
||||||
<t-empty v-else :description="isLoading ? '正在加载积分流水' : '积分流水快照不存在,请从积分流水列表进入'" />
|
<t-empty v-else :description="isLoading ? '正在加载积分流水' : '积分流水不存在或无权查看'" />
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
@@ -92,11 +92,13 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { TimeLabel, Text } from "timi-web";
|
import { TimeLabel, Text } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
|
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import EventAPI from "@/api/EventAPI";
|
import EventAPI from "@/api/EventAPI";
|
||||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
|
||||||
|
import { buildLedgerSubPane } from "@/pages/point/component/ledgerPane";
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
import type { EventItem } from "@/types/EventItem";
|
import type { EventItem } from "@/types/EventItem";
|
||||||
import type { EventRecord } from "@/types/EventRecord";
|
import type { EventRecord } from "@/types/EventRecord";
|
||||||
@@ -109,10 +111,48 @@ defineOptions({
|
|||||||
name: "PointLedgerDetail"
|
name: "PointLedgerDetail"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
/** 指定流水 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
||||||
|
ledgerId?: string;
|
||||||
|
}>(), {
|
||||||
|
ledgerId: ""
|
||||||
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
|
||||||
|
function resolveId(): string {
|
||||||
|
return props.ledgerId || String(route.params.id || "");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
|
||||||
|
useExpandToMaster({
|
||||||
|
path: "/management/points/ledger",
|
||||||
|
id: () => resolveId()
|
||||||
|
});
|
||||||
|
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||||
|
const pane = usePane();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 尝试在右栏压入一层子页(分栏的第三层)。
|
||||||
|
*
|
||||||
|
* 接不住时有三种情况:整页打开详情、窄屏、宿主列表没声明子页槽,
|
||||||
|
* 此时返回 false,调用方退回整页跳转。
|
||||||
|
*/
|
||||||
|
function openSub(view: string): boolean {
|
||||||
|
return pane?.openSub(view) ?? false;
|
||||||
|
}
|
||||||
|
|
||||||
|
function goBack(): void {
|
||||||
|
if (pane) {
|
||||||
|
pane.close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
void router.back();
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- 权限 ----------
|
// ---------- 权限 ----------
|
||||||
|
|
||||||
const canReadCustomer = computed(() => userStore.hasPermissions(permissionCodes.customer.read));
|
const canReadCustomer = computed(() => userStore.hasPermissions(permissionCodes.customer.read));
|
||||||
@@ -139,32 +179,6 @@ function isDeletedEventRevokeLedger(value?: PointLedger): boolean {
|
|||||||
return value?.changeType === "REVOKE" && value?.triggerSourceType === "EVENT_RECORD" && !value.triggerSourceId;
|
return value?.changeType === "REVOKE" && value?.triggerSourceType === "EVENT_RECORD" && !value.triggerSourceId;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getQueryText(key: string): string {
|
|
||||||
const value = route.query[key];
|
|
||||||
return Array.isArray(value) ? String(value[0] || "") : String(value || "");
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseLedgerSnapshot(): PointLedger | undefined {
|
|
||||||
const snapshotText = getQueryText("snapshot");
|
|
||||||
if (!snapshotText) {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
const snapshot = JSON.parse(snapshotText) as PointLedger;
|
|
||||||
if (!snapshot || typeof snapshot !== "object") {
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
...snapshot,
|
|
||||||
id: String(route.params.id || snapshot.id || "")
|
|
||||||
};
|
|
||||||
} catch (error) {
|
|
||||||
console.warn("积分流水快照解析失败", error);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadOptional<T>(loader: () => Promise<T>, message: string): Promise<T | undefined> {
|
async function loadOptional<T>(loader: () => Promise<T>, message: string): Promise<T | undefined> {
|
||||||
try {
|
try {
|
||||||
return await loader();
|
return await loader();
|
||||||
@@ -175,17 +189,24 @@ async function loadOptional<T>(loader: () => Promise<T>, message: string): Promi
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function loadPageData(): Promise<void> {
|
async function loadPageData(): Promise<void> {
|
||||||
ledger.value = parseLedgerSnapshot();
|
ledger.value = undefined;
|
||||||
customer.value = undefined;
|
customer.value = undefined;
|
||||||
triggerEvent.value = undefined;
|
triggerEvent.value = undefined;
|
||||||
eventRecord.value = undefined;
|
eventRecord.value = undefined;
|
||||||
hitRule.value = undefined;
|
hitRule.value = undefined;
|
||||||
if (!ledger.value) {
|
const id = resolveId();
|
||||||
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
try {
|
try {
|
||||||
|
// 流水只追加不修改,缺字段的旧链接一律以服务端这条为准
|
||||||
|
ledger.value = await PointAPI.ledgerDetail(id);
|
||||||
|
if (!ledger.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (ledger.value.triggerSourceType === "EVENT_RECORD" && ledger.value.triggerSourceId && canReadEventRecord.value && !isDeletedEventRevoke.value) {
|
if (ledger.value.triggerSourceType === "EVENT_RECORD" && ledger.value.triggerSourceId && canReadEventRecord.value && !isDeletedEventRevoke.value) {
|
||||||
eventRecord.value = await loadOptional(() => EventRecordAPI.detail(ledger.value!.triggerSourceId!), "积分流水关联事件记录加载失败");
|
eventRecord.value = await loadOptional(() => EventRecordAPI.detail(ledger.value!.triggerSourceId!), "积分流水关联事件记录加载失败");
|
||||||
}
|
}
|
||||||
@@ -200,14 +221,20 @@ async function loadPageData(): Promise<void> {
|
|||||||
const ruleResult = ledger.value.ruleId && canReadRule.value
|
const ruleResult = ledger.value.ruleId && canReadRule.value
|
||||||
? loadOptional(() => PointAPI.ruleDetail(ledger.value!.ruleId!), "积分流水命中规则加载失败")
|
? loadOptional(() => PointAPI.ruleDetail(ledger.value!.ruleId!), "积分流水命中规则加载失败")
|
||||||
: Promise.resolve(undefined);
|
: Promise.resolve(undefined);
|
||||||
const customerResult = !eventRecord.value?.customer && ledger.value.customerId && canReadCustomer.value
|
// 详情接口已经把客户资料带回来了,只有缺失时才单独补一次
|
||||||
? loadOptional(() => CustomerAPI.detail(ledger.value!.customerId!), "积分流水客户加载失败")
|
const customerResult = ledger.value.customer
|
||||||
: Promise.resolve(undefined);
|
? Promise.resolve(ledger.value.customer)
|
||||||
|
: !eventRecord.value?.customer && ledger.value.customerId && canReadCustomer.value
|
||||||
|
? loadOptional(() => CustomerAPI.detail(ledger.value!.customerId!), "积分流水客户加载失败")
|
||||||
|
: Promise.resolve(undefined);
|
||||||
|
|
||||||
[triggerEvent.value, hitRule.value, customer.value] = await Promise.all([eventResult, ruleResult, customerResult]);
|
[triggerEvent.value, hitRule.value, customer.value] = await Promise.all([eventResult, ruleResult, customerResult]);
|
||||||
if (eventRecord.value?.customer) {
|
if (eventRecord.value?.customer) {
|
||||||
customer.value = eventRecord.value.customer;
|
customer.value = eventRecord.value.customer;
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn("积分流水加载失败", error);
|
||||||
|
ledger.value = undefined;
|
||||||
} finally {
|
} finally {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
}
|
}
|
||||||
@@ -312,43 +339,54 @@ function getRuleEmptyText(): string {
|
|||||||
// ---------- 导航 ----------
|
// ---------- 导航 ----------
|
||||||
|
|
||||||
async function toCustomerDetail(): Promise<void> {
|
async function toCustomerDetail(): Promise<void> {
|
||||||
if (customer.value?.id) {
|
const id = customer.value?.id;
|
||||||
await router.push(`/management/customers/${customer.value.id}`);
|
if (!id || openSub(buildLedgerSubPane("customer", id))) {
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
await router.push(`/management/customers/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toPointAccount(): Promise<void> {
|
async function toPointAccount(): Promise<void> {
|
||||||
if (!canReadPointAccount.value || !ledger.value?.accountId) {
|
const accountId = ledger.value?.accountId;
|
||||||
|
if (!canReadPointAccount.value || !accountId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (openSub(buildLedgerSubPane("account", accountId, ledger.value?.storeId || ""))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "PointAccountDetail",
|
name: "PointAccountDetail",
|
||||||
params: { id: ledger.value.accountId },
|
params: { id: accountId },
|
||||||
query: {
|
query: {
|
||||||
storeId: ledger.value.storeId || "",
|
storeId: ledger.value?.storeId || "",
|
||||||
transitionDepth: String(Number(route.meta.depth ?? 0) + 1)
|
transitionDepth: String(Number(route.meta.depth ?? 0) + 1)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toEventDetail(): Promise<void> {
|
async function toEventDetail(): Promise<void> {
|
||||||
if (!canReadEvent.value || !triggerEvent.value?.id) {
|
const id = triggerEvent.value?.id;
|
||||||
|
if (!canReadEvent.value || !id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (openSub(buildLedgerSubPane("event", id))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "EventDetail",
|
name: "EventDetail",
|
||||||
params: { id: triggerEvent.value.id },
|
params: { id },
|
||||||
query: { transitionDepth: String(Number(route.meta.depth ?? 0) + 1) }
|
query: { transitionDepth: String(Number(route.meta.depth ?? 0) + 1) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toEventRecordDetail(): Promise<void> {
|
async function toEventRecordDetail(): Promise<void> {
|
||||||
if (!eventRecord.value?.id) {
|
const id = eventRecord.value?.id;
|
||||||
|
if (!id || openSub(buildLedgerSubPane("event-record", id))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "EventRecordDetail",
|
name: "EventRecordDetail",
|
||||||
params: { id: eventRecord.value.id },
|
params: { id },
|
||||||
query: {
|
query: {
|
||||||
transitionDepth: String(Number(route.meta.depth ?? 0) + 1),
|
transitionDepth: String(Number(route.meta.depth ?? 0) + 1),
|
||||||
changeType: ledger.value?.changeType
|
changeType: ledger.value?.changeType
|
||||||
@@ -357,17 +395,30 @@ async function toEventRecordDetail(): Promise<void> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function toPointRuleDetail(): Promise<void> {
|
async function toPointRuleDetail(): Promise<void> {
|
||||||
if (!canReadRule.value || !hitRule.value?.id) {
|
const id = hitRule.value?.id;
|
||||||
|
if (!canReadRule.value || !id) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (openSub(buildLedgerSubPane("rule", id))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await router.push({
|
await router.push({
|
||||||
name: "PointRuleDetail",
|
name: "PointRuleDetail",
|
||||||
params: { id: hitRule.value.id },
|
params: { id },
|
||||||
query: { transitionDepth: String(Number(route.meta.depth ?? 0) + 1) }
|
query: { transitionDepth: String(Number(route.meta.depth ?? 0) + 1) }
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => [route.params.id, route.query.snapshot], async () => {
|
/**
|
||||||
|
* 重载判据:两个来源拼成一个字符串再 watch。
|
||||||
|
*
|
||||||
|
* 不能直接 watch `[props.ledgerId, route.params.id]`:读 `route.params.id` 会依赖
|
||||||
|
* 整个 `params` 对象,分栏里改个 query(进子页、返回)也会被连带触发,
|
||||||
|
* `loadPageData` 一进来就把 ledger 置空重拉,看起来就是详情页自己刷新了一遍。
|
||||||
|
*/
|
||||||
|
const reloadKey = computed(() => `${props.ledgerId}|${String(route.params.id || "")}`);
|
||||||
|
|
||||||
|
watch(reloadKey, async () => {
|
||||||
await loadPageData();
|
await loadPageData();
|
||||||
}, { immediate: true });
|
}, { immediate: true });
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
+149
-135
@@ -7,117 +7,136 @@
|
|||||||
left-arrow
|
left-arrow
|
||||||
@left-click="$router.back()"
|
@left-click="$router.back()"
|
||||||
/>
|
/>
|
||||||
<main v-can="permissionCodes.point.ledgerRead" class="tui-page-content scroll column list">
|
<master-detail-page
|
||||||
<t-pull-down-refresh
|
v-can="permissionCodes.point.ledgerRead"
|
||||||
class="pull-refresh"
|
class="list"
|
||||||
v-model="isRefreshing"
|
:split="isWide"
|
||||||
:refresh-timeout="30000"
|
:selected="!!selectedId"
|
||||||
@refresh="reload"
|
:direction="paneDirection"
|
||||||
@scrolltolower="load"
|
:sub="!!subView"
|
||||||
>
|
>
|
||||||
<div class="filters glass">
|
<template #master>
|
||||||
<t-input
|
<t-pull-down-refresh
|
||||||
v-model="customerKeyword"
|
class="pull-refresh"
|
||||||
class="customer"
|
v-model="isRefreshing"
|
||||||
type="search"
|
:refresh-timeout="30000"
|
||||||
borderless
|
@refresh="reload"
|
||||||
placeholder="输入客户编码或姓名"
|
@scrolltolower="load"
|
||||||
@clear="searchCustomer"
|
>
|
||||||
@enter="searchCustomer"
|
<div class="filters glass">
|
||||||
@input="searchCustomer"
|
<t-input
|
||||||
>
|
v-model="customerKeyword"
|
||||||
<template #suffix-icon>
|
class="customer"
|
||||||
<t-button
|
type="search"
|
||||||
size="extra-small"
|
borderless
|
||||||
theme="primary"
|
placeholder="输入客户编码或姓名"
|
||||||
variant="outline"
|
@clear="searchCustomer"
|
||||||
content="选择客户"
|
@enter="searchCustomer"
|
||||||
@click.stop="selectorVisible = true"
|
@input="searchCustomer"
|
||||||
/>
|
|
||||||
</template>
|
|
||||||
</t-input>
|
|
||||||
<t-dropdown-menu class="menus">
|
|
||||||
<t-dropdown-item
|
|
||||||
v-model="changeTypeFilter"
|
|
||||||
label="流水类型"
|
|
||||||
:options="changeTypeOptions"
|
|
||||||
@change="selectChangeType"
|
|
||||||
/>
|
|
||||||
<t-dropdown-item
|
|
||||||
v-model="dateFilter"
|
|
||||||
:label="dateFilterLabel"
|
|
||||||
:options="dateFilterOptions"
|
|
||||||
@change="selectDateFilter"
|
|
||||||
/>
|
|
||||||
</t-dropdown-menu>
|
|
||||||
</div>
|
|
||||||
<div class="list-wrap">
|
|
||||||
<card-container v-if="customer" class="customer">
|
|
||||||
<customer-profile-card :customer="customer" />
|
|
||||||
</card-container>
|
|
||||||
<t-cell-group class="summary" theme="card">
|
|
||||||
<t-cell
|
|
||||||
title="开始时间"
|
|
||||||
:note="dateRange[0] || '-'"
|
|
||||||
arrow
|
|
||||||
@click="openStartDate"
|
|
||||||
/>
|
|
||||||
<t-cell
|
|
||||||
title="结束时间"
|
|
||||||
:note="dateRange[1] || '-'"
|
|
||||||
arrow
|
|
||||||
@click="openEndDate"
|
|
||||||
/>
|
|
||||||
</t-cell-group>
|
|
||||||
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
|
|
||||||
<t-cell
|
|
||||||
v-entrance-transition="{ step: 30 }"
|
|
||||||
v-for="item in pageResult.list"
|
|
||||||
:key="item.id"
|
|
||||||
class="item"
|
|
||||||
:arrow="!!item.id"
|
|
||||||
:hover="!!item.id"
|
|
||||||
@click="toDetail(item)"
|
|
||||||
>
|
>
|
||||||
<template #leftIcon>
|
<template #suffix-icon>
|
||||||
<t-image
|
<t-button
|
||||||
v-if="getCustomerPhotoURL(item.customer!, 64)"
|
size="extra-small"
|
||||||
:src="getCustomerPhotoURL(item.customer!, 64)"
|
theme="primary"
|
||||||
fit="cover"
|
variant="outline"
|
||||||
class="avatar"
|
content="选择客户"
|
||||||
|
@click.stop="selectorVisible = true"
|
||||||
/>
|
/>
|
||||||
<div v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
|
|
||||||
</template>
|
</template>
|
||||||
<template #title>
|
</t-input>
|
||||||
<div class="title">
|
<t-dropdown-menu class="menus">
|
||||||
<t-tag
|
<t-dropdown-item
|
||||||
class="type-icon"
|
v-model="changeTypeFilter"
|
||||||
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
|
label="流水类型"
|
||||||
:content="getLedgerShortType(item)"
|
:options="changeTypeOptions"
|
||||||
variant="outline"
|
@change="selectChangeType"
|
||||||
|
/>
|
||||||
|
<t-dropdown-item
|
||||||
|
v-model="dateFilter"
|
||||||
|
:label="dateFilterLabel"
|
||||||
|
:options="dateFilterOptions"
|
||||||
|
@change="selectDateFilter"
|
||||||
|
/>
|
||||||
|
</t-dropdown-menu>
|
||||||
|
</div>
|
||||||
|
<div class="list-wrap">
|
||||||
|
<card-container v-if="customer" class="customer">
|
||||||
|
<customer-profile-card :customer="customer" />
|
||||||
|
</card-container>
|
||||||
|
<t-cell-group class="summary" theme="card">
|
||||||
|
<t-cell
|
||||||
|
title="开始时间"
|
||||||
|
:note="dateRange[0] || '-'"
|
||||||
|
arrow
|
||||||
|
@click="openStartDate"
|
||||||
|
/>
|
||||||
|
<t-cell
|
||||||
|
title="结束时间"
|
||||||
|
:note="dateRange[1] || '-'"
|
||||||
|
arrow
|
||||||
|
@click="openEndDate"
|
||||||
|
/>
|
||||||
|
</t-cell-group>
|
||||||
|
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
|
||||||
|
<t-cell
|
||||||
|
v-entrance-transition="{ step: 30 }"
|
||||||
|
v-for="item in pageResult.list"
|
||||||
|
:key="item.id"
|
||||||
|
class="item"
|
||||||
|
:arrow="!!item.id"
|
||||||
|
:hover="!!item.id"
|
||||||
|
@click="toDetail(item)"
|
||||||
|
>
|
||||||
|
<template #leftIcon>
|
||||||
|
<t-image
|
||||||
|
v-if="getCustomerPhotoURL(item.customer!, 64)"
|
||||||
|
:src="getCustomerPhotoURL(item.customer!, 64)"
|
||||||
|
fit="cover"
|
||||||
|
class="avatar"
|
||||||
/>
|
/>
|
||||||
<div class="name" v-text="item.customer?.name" />
|
<div v-else class="avatar fallback" v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)" />
|
||||||
</div>
|
</template>
|
||||||
</template>
|
<template #title>
|
||||||
<template #description>
|
<div class="title">
|
||||||
<div class="description">
|
<t-tag
|
||||||
<div>
|
class="type-icon"
|
||||||
<span>时间:</span>
|
:theme="item.pointDelta && 0 < item.pointDelta ? 'success' : 'danger'"
|
||||||
<time-label :timestamp="item.occurredAt" underline />
|
:content="getLedgerShortType(item)"
|
||||||
|
variant="outline"
|
||||||
|
/>
|
||||||
|
<div class="name" v-text="item.customer?.name" />
|
||||||
</div>
|
</div>
|
||||||
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
|
</template>
|
||||||
<div v-text="item.remark" />
|
<template #description>
|
||||||
</div>
|
<div class="description">
|
||||||
</template>
|
<div>
|
||||||
<template #note>
|
<span>时间:</span>
|
||||||
<div class="delta keep-text" :class="getLedgerTheme(item)" v-text="getLedgerDelta(item)" />
|
<time-label :timestamp="item.occurredAt" underline />
|
||||||
</template>
|
</div>
|
||||||
</t-cell>
|
<div v-text="`余额:${formatPointValue(item.balanceBefore)} → ${formatPointValue(item.balanceAfter)}`" />
|
||||||
</t-cell-group>
|
<div v-text="item.remark" />
|
||||||
<center-tips :content="loadStateText" />
|
</div>
|
||||||
</div>
|
</template>
|
||||||
</t-pull-down-refresh>
|
<template #note>
|
||||||
</main>
|
<div class="delta keep-text" :class="getLedgerTheme(item)" v-text="getLedgerDelta(item)" />
|
||||||
|
</template>
|
||||||
|
</t-cell>
|
||||||
|
</t-cell-group>
|
||||||
|
<center-tips :content="loadStateText" />
|
||||||
|
</div>
|
||||||
|
</t-pull-down-refresh>
|
||||||
|
</template>
|
||||||
|
<template #detail>
|
||||||
|
<point-ledger-detail :key="`detail-${selectedId}`" :ledger-id="selectedId" />
|
||||||
|
</template>
|
||||||
|
<!--
|
||||||
|
第三层:详情点进子页(客户 / 积分账户 / 事件 / 事件记录 / 积分规则)时,
|
||||||
|
列表整列滑出、详情退到主栏,右栏换成那个子页。
|
||||||
|
-->
|
||||||
|
<template #sub>
|
||||||
|
<ledger-sub-view :key="subView" :view="subView" />
|
||||||
|
</template>
|
||||||
|
</master-detail-page>
|
||||||
<customer-selector
|
<customer-selector
|
||||||
v-model="selectedCustomerId"
|
v-model="selectedCustomerId"
|
||||||
v-model:visible="selectorVisible"
|
v-model:visible="selectorVisible"
|
||||||
@@ -152,11 +171,15 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownValue } from "tdesign-mobile-vue";
|
||||||
|
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
import { TimeLabel, Toolkit } from "timi-web";
|
import { TimeLabel, Toolkit } from "timi-web";
|
||||||
import { type PageResult, useUserStore } from "timi-web-api";
|
import { type PageResult, useUserStore } from "timi-web-api";
|
||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import PointAPI from "@/api/PointAPI";
|
import PointAPI from "@/api/PointAPI";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||||
|
import PointLedgerDetail from "@/pages/point/PointLedgerDetail.vue";
|
||||||
|
import LedgerSubView from "@/pages/point/component/LedgerSubView.vue";
|
||||||
|
import { getLedgerSubRoute, parseLedgerSubPane } from "@/pages/point/component/ledgerPane";
|
||||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||||
import type { Customer } from "@/types/Customer";
|
import type { Customer } from "@/types/Customer";
|
||||||
import type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/types/Point";
|
import type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/types/Point";
|
||||||
@@ -172,10 +195,27 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
const currentStoreStore = useCurrentStoreStore();
|
const currentStoreStore = useCurrentStoreStore();
|
||||||
|
|
||||||
|
// ---------- 分栏导航 ----------
|
||||||
|
|
||||||
|
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;积分流水没有内联编辑视图
|
||||||
|
const { selectedId, subView, paneDirection, isWide, openDetail } = useMasterDetailPane({
|
||||||
|
path: "/management/points/ledger",
|
||||||
|
detail: detailRoute
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转屏变窄时右栏不再渲染,按右栏当前那一层落到整页路由。
|
||||||
|
*
|
||||||
|
* 子页落到各自模块的整页,详情落到流水自己的详情页。
|
||||||
|
*/
|
||||||
|
function detailRoute(id: string): string {
|
||||||
|
const sub = parseLedgerSubPane(subView.value || "");
|
||||||
|
return sub ? getLedgerSubRoute(sub) : `/management/points/ledger/${id}`;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------- 筛选 ----------
|
// ---------- 筛选 ----------
|
||||||
|
|
||||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||||
@@ -410,38 +450,12 @@ function getLedgerTheme(item: PointLedger): string {
|
|||||||
return item.pointDelta && 0 < item.pointDelta ? "increase" : "decrease";
|
return item.pointDelta && 0 < item.pointDelta ? "increase" : "decrease";
|
||||||
}
|
}
|
||||||
|
|
||||||
async function toDetail(item: PointLedger): Promise<void> {
|
function toDetail(item: PointLedger): void {
|
||||||
if (!item.id) {
|
if (!item.id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const snapshot: PointLedger = {
|
openDetail(item.id);
|
||||||
id: item.id,
|
|
||||||
accountId: item.accountId,
|
|
||||||
storeId: item.storeId,
|
|
||||||
customerId: item.customerId,
|
|
||||||
changeType: item.changeType,
|
|
||||||
direction: item.direction,
|
|
||||||
pointDelta: item.pointDelta,
|
|
||||||
balanceBefore: item.balanceBefore,
|
|
||||||
balanceAfter: item.balanceAfter,
|
|
||||||
ruleId: item.ruleId,
|
|
||||||
triggerSourceType: item.triggerSourceType,
|
|
||||||
triggerSourceId: item.triggerSourceId,
|
|
||||||
salesOrderId: item.salesOrderId,
|
|
||||||
groovyScriptVersionId: item.groovyScriptVersionId,
|
|
||||||
ruleSnapshot: item.ruleSnapshot,
|
|
||||||
sourcePayload: item.sourcePayload,
|
|
||||||
idempotencyKey: item.idempotencyKey,
|
|
||||||
remark: item.remark,
|
|
||||||
operatorUserId: item.operatorUserId,
|
|
||||||
occurredAt: item.occurredAt
|
|
||||||
};
|
|
||||||
await router.push({
|
|
||||||
name: "PointLedgerDetail",
|
|
||||||
params: { id: item.id },
|
|
||||||
query: { snapshot: JSON.stringify(snapshot) }
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildUnixRange(): [number, number] {
|
function buildUnixRange(): [number, number] {
|
||||||
|
|||||||
@@ -191,8 +191,11 @@ defineOptions({
|
|||||||
const props = withDefaults(defineProps<{
|
const props = withDefaults(defineProps<{
|
||||||
/** 指定积分规则 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
/** 指定积分规则 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
||||||
ruleId?: string;
|
ruleId?: string;
|
||||||
|
/** 在分栏中新增积分规则。 */
|
||||||
|
create?: boolean;
|
||||||
}>(), {
|
}>(), {
|
||||||
ruleId: ""
|
ruleId: "",
|
||||||
|
create: false
|
||||||
});
|
});
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
@@ -200,6 +203,9 @@ const currentId = computed(() => props.ruleId || String(route.params.id || ""));
|
|||||||
|
|
||||||
const routeNavBarTitle = computed(() => {
|
const routeNavBarTitle = computed(() => {
|
||||||
// 内联时路由停在列表页,标题不能只看 route.name
|
// 内联时路由停在列表页,标题不能只看 route.name
|
||||||
|
if (props.create) {
|
||||||
|
return "新增积分规则";
|
||||||
|
}
|
||||||
if (props.ruleId) {
|
if (props.ruleId) {
|
||||||
return "编辑积分规则";
|
return "编辑积分规则";
|
||||||
}
|
}
|
||||||
@@ -215,11 +221,10 @@ const routeNavBarTitle = computed(() => {
|
|||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
|
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
|
||||||
// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项
|
|
||||||
useExpandToMaster({
|
useExpandToMaster({
|
||||||
path: "/management/points/rules",
|
path: "/management/points/rules",
|
||||||
id: () => (route.name === "PointRuleCreate" ? "" : currentId.value),
|
id: () => (route.name === "PointRuleCreate" ? "__create__" : currentId.value),
|
||||||
query: { view: "edit" }
|
query: route.name === "PointRuleCreate" ? {} : { view: "edit" }
|
||||||
});
|
});
|
||||||
/** 非空说明当前被内联在主从分栏的右栏里 */
|
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||||
const pane = usePane();
|
const pane = usePane();
|
||||||
|
|||||||
@@ -86,7 +86,8 @@
|
|||||||
</t-pull-down-refresh>
|
</t-pull-down-refresh>
|
||||||
</template>
|
</template>
|
||||||
<template #detail>
|
<template #detail>
|
||||||
<point-rule-edit v-if="editing" :key="`edit-${selectedId}`" :rule-id="selectedId" />
|
<point-rule-edit v-if="selectedId === createPaneId" key="create" create />
|
||||||
|
<point-rule-edit v-else-if="editing" :key="`edit-${selectedId}`" :rule-id="selectedId" />
|
||||||
<point-rule-detail
|
<point-rule-detail
|
||||||
v-else
|
v-else
|
||||||
:key="`detail-${selectedId}-${detailVersion}`"
|
:key="`detail-${selectedId}-${detailVersion}`"
|
||||||
@@ -121,12 +122,13 @@ defineOptions({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const createPaneId = "__create__";
|
||||||
|
|
||||||
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里
|
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里
|
||||||
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
|
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
|
||||||
useMasterDetailPane({
|
useMasterDetailPane({
|
||||||
path: "/management/points/rules",
|
path: "/management/points/rules",
|
||||||
detail: id => `/management/points/rules/${id}`,
|
detail: id => id === createPaneId ? "/management/points/rules/create" : `/management/points/rules/${id}`,
|
||||||
edit: id => `/management/points/rules/${id}/edit`
|
edit: id => `/management/points/rules/${id}/edit`
|
||||||
});
|
});
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
@@ -279,6 +281,12 @@ watch(keyword, () => {
|
|||||||
reloadByKeyword();
|
reloadByKeyword();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(selectedId, async (id, previousId) => {
|
||||||
|
if (previousId === createPaneId && id !== createPaneId) {
|
||||||
|
await reload();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// ---------- 事件名称 ----------
|
// ---------- 事件名称 ----------
|
||||||
|
|
||||||
const eventList = ref<EventItem[]>([]);
|
const eventList = ref<EventItem[]>([]);
|
||||||
@@ -340,6 +348,10 @@ function getStatusTheme(status?: PointRuleStatus): "default" | "success" | "warn
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function toCreate(): Promise<void> {
|
async function toCreate(): Promise<void> {
|
||||||
|
if (isWide.value) {
|
||||||
|
openDetail(createPaneId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await router.push({ name: "PointRuleCreate" });
|
await router.push({ name: "PointRuleCreate" });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
<template>
|
||||||
|
<customer-detail
|
||||||
|
v-if="kind === 'customer'"
|
||||||
|
:customer-id="arg"
|
||||||
|
/>
|
||||||
|
<point-account-detail
|
||||||
|
v-else-if="kind === 'account'"
|
||||||
|
:account-id="arg"
|
||||||
|
:store-id="extra"
|
||||||
|
/>
|
||||||
|
<event-detail
|
||||||
|
v-else-if="kind === 'event'"
|
||||||
|
:event-id="arg"
|
||||||
|
/>
|
||||||
|
<event-record-detail
|
||||||
|
v-else-if="kind === 'event-record'"
|
||||||
|
:record-id="arg"
|
||||||
|
/>
|
||||||
|
<point-rule-detail
|
||||||
|
v-else-if="kind === 'rule'"
|
||||||
|
:rule-id="arg"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import CustomerDetail from "@/pages/customer/CustomerDetail.vue";
|
||||||
|
import EventDetail from "@/pages/event/EventDetail.vue";
|
||||||
|
import EventRecordDetail from "@/pages/event/EventRecordDetail.vue";
|
||||||
|
import PointAccountDetail from "@/pages/point/PointAccountDetail.vue";
|
||||||
|
import PointRuleDetail from "@/pages/point/PointRuleDetail.vue";
|
||||||
|
import { parseLedgerSubPane } from "@/pages/point/component/ledgerPane";
|
||||||
|
|
||||||
|
defineOptions({ name: "LedgerSubView" });
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
/** 子页标识,形如 `customer:698f`、`account:698f:12`。 */
|
||||||
|
view?: string;
|
||||||
|
}>(), {
|
||||||
|
view: ""
|
||||||
|
});
|
||||||
|
|
||||||
|
const pane = computed(() => parseLedgerSubPane(props.view));
|
||||||
|
const kind = computed(() => pane.value?.kind || "");
|
||||||
|
const arg = computed(() => pane.value?.arg || "");
|
||||||
|
const extra = computed(() => pane.value?.extra || "");
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/**
|
||||||
|
* 积分流水详情在右栏压入子页时的标识约定:`<kind>[:<arg>[:<extra>]]`。
|
||||||
|
*
|
||||||
|
* 这些子页都属于别的模块,宿主(积分流水列表页)按标识直接渲染对应页面,
|
||||||
|
* 与交易订单的 `orderPane` 是同一套思路,只是这里的上一级固定是当前流水。
|
||||||
|
*/
|
||||||
|
export type LedgerSubKind = "customer" | "account" | "event" | "event-record" | "rule";
|
||||||
|
|
||||||
|
export type LedgerSubPane = {
|
||||||
|
kind: LedgerSubKind;
|
||||||
|
/** 主参数:目标对象的 id。 */
|
||||||
|
arg: string;
|
||||||
|
/** 附加参数:目前只有积分账户详情需要带上门店 id。 */
|
||||||
|
extra: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
const LEDGER_SUB_KINDS: LedgerSubKind[] = ["customer", "account", "event", "event-record", "rule"];
|
||||||
|
|
||||||
|
function isLedgerSubKind(value: string): value is LedgerSubKind {
|
||||||
|
return LEDGER_SUB_KINDS.includes(value as LedgerSubKind);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 拼接子页标识,调用方通常是流水详情里的跳转函数。 */
|
||||||
|
export function buildLedgerSubPane(kind: LedgerSubKind, arg: string, extra = ""): string {
|
||||||
|
return extra ? `${kind}:${arg}:${extra}` : `${kind}:${arg}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析子页标识;不认识的标识返回 null,调用方应改走整页路由。 */
|
||||||
|
export function parseLedgerSubPane(value: string): LedgerSubPane | null {
|
||||||
|
if (!value) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const [kind, arg = "", extra = ""] = value.split(":");
|
||||||
|
if (!isLedgerSubKind(kind) || !arg) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return { kind, arg, extra };
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 子页对应的整页路由。
|
||||||
|
*
|
||||||
|
* 转屏变窄后右栏不再渲染,靠它把用户留在正在看的那一层;
|
||||||
|
* 也用于 `openSub()` 没接住时的兜底。
|
||||||
|
*/
|
||||||
|
export function getLedgerSubRoute(pane: LedgerSubPane): string {
|
||||||
|
const { kind, arg, extra } = pane;
|
||||||
|
switch (kind) {
|
||||||
|
case "customer": return `/management/customers/${arg}`;
|
||||||
|
case "account": return `/management/points/account/${arg}${extra ? `?storeId=${encodeURIComponent(extra)}` : ""}`;
|
||||||
|
case "event": return `/management/registration-events/${arg}`;
|
||||||
|
case "event-record": return `/management/registration-event-records/${arg}`;
|
||||||
|
case "rule": return `/management/points/rules/${arg}`;
|
||||||
|
default: return "/management/points/ledger";
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user