chore(consumption): master-detail-page on tablet
This commit is contained in:
@@ -7,7 +7,15 @@
|
|||||||
left-arrow
|
left-arrow
|
||||||
@left-click="$router.back()"
|
@left-click="$router.back()"
|
||||||
/>
|
/>
|
||||||
<main v-can="permissionCodes.salesOrder.read" class="tui-page-content scroll column list">
|
<master-detail-page
|
||||||
|
v-can="permissionCodes.salesOrder.read"
|
||||||
|
class="list"
|
||||||
|
:split="isWide"
|
||||||
|
:selected="!!selectedId"
|
||||||
|
:direction="paneDirection"
|
||||||
|
:sub="!!subView"
|
||||||
|
>
|
||||||
|
<template #master>
|
||||||
<t-pull-down-refresh
|
<t-pull-down-refresh
|
||||||
class="pull-refresh"
|
class="pull-refresh"
|
||||||
v-model="isRefreshing"
|
v-model="isRefreshing"
|
||||||
@@ -147,6 +155,32 @@
|
|||||||
<center-tips v-if="recordList.length" :content="loadStateText" />
|
<center-tips v-if="recordList.length" :content="loadStateText" />
|
||||||
</div>
|
</div>
|
||||||
</t-pull-down-refresh>
|
</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
|
<customer-selector
|
||||||
v-model="customerId"
|
v-model="customerId"
|
||||||
v-model:visible="customerSelectorVisible"
|
v-model:visible="customerSelectorVisible"
|
||||||
@@ -177,11 +211,11 @@
|
|||||||
@confirm="confirmEndTime"
|
@confirm="confirmEndTime"
|
||||||
/>
|
/>
|
||||||
</t-popup>
|
</t-popup>
|
||||||
</main>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
|
||||||
import type { DropdownValue } from "tdesign-mobile-vue";
|
import type { DropdownValue } from "tdesign-mobile-vue";
|
||||||
import { TimeLabel, Time } from "timi-web";
|
import { TimeLabel, Time } from "timi-web";
|
||||||
import { useUserStore } from "timi-web-api";
|
import { useUserStore } from "timi-web-api";
|
||||||
@@ -189,6 +223,9 @@ import ConsumptionRecordAPI from "@/api/ConsumptionRecordAPI";
|
|||||||
import CustomerAPI from "@/api/CustomerAPI";
|
import CustomerAPI from "@/api/CustomerAPI";
|
||||||
import CodeScanner from "@/components/CodeScanner.vue";
|
import CodeScanner from "@/components/CodeScanner.vue";
|
||||||
import CustomerSelector from "@/components/CustomerSelector.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 {
|
import type {
|
||||||
ConsumptionRecord,
|
ConsumptionRecord,
|
||||||
ConsumptionRecordPage,
|
ConsumptionRecordPage,
|
||||||
@@ -210,6 +247,63 @@ defineOptions({ name: "ConsumptionRecordList" });
|
|||||||
const pageSize = 20;
|
const pageSize = 20;
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
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 userStore = useUserStore();
|
||||||
const sourceType = ref<ConsumptionRecordSourceType | "ALL">("ALL");
|
const sourceType = ref<ConsumptionRecordSourceType | "ALL">("ALL");
|
||||||
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
|
const status = ref<ConsumptionRecordStatus | "ALL">("ALL");
|
||||||
@@ -444,7 +538,7 @@ async function openSource(record: ConsumptionRecord): Promise<void> {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (record.sourceType === "SALES_ORDER" && record.salesOrderId) {
|
if (record.sourceType === "SALES_ORDER" && record.salesOrderId) {
|
||||||
await router.push({ name: "SalesOrderDetail", params: { id: record.salesOrderId } });
|
openDetail(record.salesOrderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (record.sourceType === "LEGACY_EVENT" && record.sourceId) {
|
if (record.sourceType === "LEGACY_EVENT" && record.sourceId) {
|
||||||
@@ -461,9 +555,28 @@ onMounted(async () => {
|
|||||||
|
|
||||||
<style scoped lang="less">
|
<style scoped lang="less">
|
||||||
.consumption-record-list {
|
.consumption-record-list {
|
||||||
min-height: 100vh;
|
|
||||||
padding: var(--tui-nav-height) 0 1rem;
|
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 {
|
.list-wrap {
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user