support tablet
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<template>
|
||||
<div class="page-layout navbar">
|
||||
<div class="tui-page-layout tui-navbar">
|
||||
<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">
|
||||
<div v-can="permissionCodes.packageConfig.read" class="package-config-detail">
|
||||
<template v-if="config">
|
||||
<section class="hero" v-entrance-transition>
|
||||
@@ -109,6 +109,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { DialogPlugin } from "tdesign-mobile-vue";
|
||||
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||
import { Time } from "timi-web";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import PackageAPI from "@/api/PackageAPI";
|
||||
@@ -128,8 +129,33 @@ import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@
|
||||
|
||||
defineOptions({ name: "PackageConfigDetail" });
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 指定套餐配置 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
||||
configId?: string;
|
||||
}>(), {
|
||||
configId: ""
|
||||
});
|
||||
|
||||
const emit = defineEmits<{
|
||||
/** 内联在右栏时请求切换到编辑视图 */
|
||||
edit: [];
|
||||
}>();
|
||||
|
||||
const route = useRoute();
|
||||
const router = useRouter();
|
||||
|
||||
/** 内联渲染时 id 来自 prop,整页渲染时来自路由参数 */
|
||||
function resolveId(): string {
|
||||
return props.configId || String(route.params.id || "");
|
||||
}
|
||||
|
||||
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
|
||||
useExpandToMaster({
|
||||
path: "/management/package-configs",
|
||||
id: () => resolveId()
|
||||
});
|
||||
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||
const pane = usePane();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const config = ref<GaoPackageConfig>();
|
||||
@@ -152,7 +178,7 @@ function getItemPhotoURL(item: PackageConfigItem): string {
|
||||
}
|
||||
|
||||
async function loadData(): Promise<void> {
|
||||
const id = String(route.params.id || "");
|
||||
const id = resolveId();
|
||||
if (!id) {
|
||||
return;
|
||||
}
|
||||
@@ -171,10 +197,27 @@ async function loadData(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
async function toEdit(): Promise<void> {
|
||||
if (config.value?.id && canUpdate.value) {
|
||||
await router.push(`/management/package-configs/${config.value.id}/edit`);
|
||||
function goBack(): void {
|
||||
if (pane) {
|
||||
pane.close();
|
||||
return;
|
||||
}
|
||||
|
||||
void router.back();
|
||||
}
|
||||
|
||||
async function toEdit(): Promise<void> {
|
||||
if (!config.value?.id || !canUpdate.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
|
||||
if (pane) {
|
||||
emit("edit");
|
||||
return;
|
||||
}
|
||||
|
||||
await router.push(`/management/package-configs/${config.value.id}/edit`);
|
||||
}
|
||||
|
||||
async function toPurchase(): Promise<void> {
|
||||
@@ -214,6 +257,10 @@ function removeConfig(): void {
|
||||
try {
|
||||
await PackageAPI.configRemove(config.value!.id!);
|
||||
Message.success("套餐配置已删除");
|
||||
if (pane) {
|
||||
pane.close(true);
|
||||
return;
|
||||
}
|
||||
await router.replace("/management/package-configs");
|
||||
} catch (error) {
|
||||
Message.error(getErrorMessage(error, "套餐配置删除失败"));
|
||||
|
||||
Reference in New Issue
Block a user