diff --git a/src/api/PointAPI.ts b/src/api/PointAPI.ts index f73c81b..bb93c60 100644 --- a/src/api/PointAPI.ts +++ b/src/api/PointAPI.ts @@ -76,6 +76,17 @@ async function listLedger(page: PointLedgerPage, options?: ListOptions): Promise return await axios.post(`${BASE_URI}/ledger/list`, withCurrentStoreId(page)); } +/** + * 按流水 ID 查询积分流水。 + * + * 不传 storeId:服务端按当前登录人的门店范围解析,非全局管理员天然只能查本店。 + */ +async function ledgerDetail(id: string): Promise { + return await axios.post(`${BASE_URI}/ledger/detail`, undefined, { + params: { id } + }); +} + /** 人工调整积分,后端使用 adjustRequestId 保证幂等。 */ async function adjust(request: PointAdjustRequest): Promise { await axios.post(`${BASE_URI}/adjust`, withCurrentStoreId(request)); @@ -177,6 +188,7 @@ export default { detailByCustomerId, detail, listLedger, + ledgerDetail, adjust, ruleList, ruleDetail, diff --git a/src/pages/point/PointLedgerDetail.vue b/src/pages/point/PointLedgerDetail.vue index 8163510..75fee86 100644 --- a/src/pages/point/PointLedgerDetail.vue +++ b/src/pages/point/PointLedgerDetail.vue @@ -5,7 +5,7 @@ :z-index="20" title="积分流水详情" left-arrow - @left-click="$router.back()" + @left-click="goBack" />
@@ -83,7 +83,7 @@ - +
@@ -92,11 +92,13 @@ diff --git a/src/pages/point/PointLedgerList.vue b/src/pages/point/PointLedgerList.vue index 98c200f..c1b5088 100644 --- a/src/pages/point/PointLedgerList.vue +++ b/src/pages/point/PointLedgerList.vue @@ -7,117 +7,136 @@ left-arrow @left-click="$router.back()" /> -
- -
- - - - - - - -
-
- - - - - - - - - + + + + + import type { DropdownValue } from "tdesign-mobile-vue"; +import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile"; import { TimeLabel, Toolkit } from "timi-web"; import { type PageResult, useUserStore } from "timi-web-api"; import CustomerAPI from "@/api/CustomerAPI"; import PointAPI from "@/api/PointAPI"; 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 type { Customer } from "@/types/Customer"; import type { PointLedger, PointLedgerChangeType, PointLedgerPage } from "@/types/Point"; @@ -172,10 +195,27 @@ defineOptions({ }); const route = useRoute(); -const router = useRouter(); const userStore = useUserStore(); 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)); @@ -410,38 +450,12 @@ function getLedgerTheme(item: PointLedger): string { return item.pointDelta && 0 < item.pointDelta ? "increase" : "decrease"; } -async function toDetail(item: PointLedger): Promise { +function toDetail(item: PointLedger): void { if (!item.id) { return; } - const snapshot: PointLedger = { - 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) } - }); + openDetail(item.id); } function buildUnixRange(): [number, number] { diff --git a/src/pages/point/PointRuleEdit.vue b/src/pages/point/PointRuleEdit.vue index 87d983a..caa3ea3 100644 --- a/src/pages/point/PointRuleEdit.vue +++ b/src/pages/point/PointRuleEdit.vue @@ -191,8 +191,11 @@ defineOptions({ const props = withDefaults(defineProps<{ /** 指定积分规则 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */ ruleId?: string; + /** 在分栏中新增积分规则。 */ + create?: boolean; }>(), { - ruleId: "" + ruleId: "", + create: false }); const route = useRoute(); @@ -200,6 +203,9 @@ const currentId = computed(() => props.ruleId || String(route.params.id || "")); const routeNavBarTitle = computed(() => { // 内联时路由停在列表页,标题不能只看 route.name + if (props.create) { + return "新增积分规则"; + } if (props.ruleId) { return "编辑积分规则"; } @@ -215,11 +221,10 @@ const routeNavBarTitle = computed(() => { const router = useRouter(); // 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。 -// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项 useExpandToMaster({ path: "/management/points/rules", - id: () => (route.name === "PointRuleCreate" ? "" : currentId.value), - query: { view: "edit" } + id: () => (route.name === "PointRuleCreate" ? "__create__" : currentId.value), + query: route.name === "PointRuleCreate" ? {} : { view: "edit" } }); /** 非空说明当前被内联在主从分栏的右栏里 */ const pane = usePane(); diff --git a/src/pages/point/PointRuleList.vue b/src/pages/point/PointRuleList.vue index be80671..4e8db54 100644 --- a/src/pages/point/PointRuleList.vue +++ b/src/pages/point/PointRuleList.vue @@ -86,7 +86,8 @@