support tablet
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div v-can="permissionCodes.eventRecord.read" class="page-layout navbar event-record-detail">
|
||||
<div v-can="permissionCodes.eventRecord.read" class="tui-page-layout tui-navbar event-record-detail">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
title="登记事件记录详情"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
@left-click="goBack"
|
||||
>
|
||||
<template #right>
|
||||
<t-button
|
||||
@@ -18,7 +18,7 @@
|
||||
/>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main class="page-content scroll column">
|
||||
<main class="tui-page-content scroll column">
|
||||
<customer-profile-card
|
||||
v-entrance-transition
|
||||
v-if="record?.customer"
|
||||
@@ -121,6 +121,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||
import { Text, TimeLabel } from "timi-web";
|
||||
import { type Attachment, useUserStore } from "timi-web-api";
|
||||
import EventRecordAPI from "@/api/EventRecordAPI";
|
||||
@@ -146,10 +147,34 @@ defineOptions({
|
||||
name: "EventRecordDetail"
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 指定记录 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
||||
recordId?: string;
|
||||
}>(), {
|
||||
recordId: ""
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 内联在右栏时请求切换到编辑视图 */
|
||||
edit: [];
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
|
||||
function resolveId(): string {
|
||||
return props.recordId || String(route.params.id || "");
|
||||
}
|
||||
|
||||
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
|
||||
useExpandToMaster({
|
||||
path: "/management/registration-event-records",
|
||||
id: () => resolveId()
|
||||
});
|
||||
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||
const pane = usePane();
|
||||
|
||||
// ---------- 记录数据 ----------
|
||||
|
||||
const record = ref<EventRecord>();
|
||||
@@ -286,7 +311,7 @@ function parsePointLedgerChangeType(value: unknown): PointLedgerChangeType | und
|
||||
// ---------- 页面数据 ----------
|
||||
|
||||
async function loadRecord(): Promise<void> {
|
||||
const recordId = String(route.params.id || "");
|
||||
const recordId = resolveId();
|
||||
if (!recordId) {
|
||||
record.value = undefined;
|
||||
return;
|
||||
@@ -375,6 +400,10 @@ async function removeRecord(id: string): Promise<void> {
|
||||
try {
|
||||
await EventRecordAPI.remove(id);
|
||||
Message.success("登记记录已删除");
|
||||
if (pane) {
|
||||
pane.close();
|
||||
return;
|
||||
}
|
||||
await router.replace({ name: "EventRecordList" });
|
||||
} catch (error) {
|
||||
const message = getErrorMessage(error, "登记记录删除失败");
|
||||
@@ -391,13 +420,29 @@ async function removeRecord(id: string): Promise<void> {
|
||||
// ---------- 导航 ----------
|
||||
|
||||
async function toEdit(): Promise<void> {
|
||||
const recordId = String(route.params.id || "");
|
||||
const recordId = resolveId();
|
||||
if (!recordId || !canUpdateRecord.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
|
||||
if (pane) {
|
||||
emit("edit");
|
||||
return;
|
||||
}
|
||||
|
||||
await router.push(`/management/registration-event-records/${recordId}/edit`);
|
||||
}
|
||||
|
||||
function goBack(): void {
|
||||
if (pane) {
|
||||
pane.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void router.back();
|
||||
}
|
||||
|
||||
async function toCustomerDetail(): Promise<void> {
|
||||
const customerId = record.value?.customer?.id;
|
||||
if (!customerId) {
|
||||
@@ -434,7 +479,7 @@ function getCurrentRouteDepth(): number {
|
||||
return Number(route.meta.depth ?? 0);
|
||||
}
|
||||
|
||||
watch(() => route.params.id, async () => {
|
||||
watch(() => [props.recordId, route.params.id], async () => {
|
||||
await loadRecord();
|
||||
}, { immediate: true });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user