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="routeNavBarTitle"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
@left-click="exit()"
|
||||
>
|
||||
<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="pageAccess" class="point-rule-edit">
|
||||
<t-form class="form card" label-width="7rem">
|
||||
<card-container v-entrance-transition>
|
||||
@@ -161,6 +161,7 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
|
||||
import { Time } from "timi-web";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import EventAPI from "@/api/EventAPI";
|
||||
@@ -187,9 +188,21 @@ defineOptions({
|
||||
name: "PointRuleEdit"
|
||||
});
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
/** 指定积分规则 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
|
||||
ruleId?: string;
|
||||
}>(), {
|
||||
ruleId: ""
|
||||
});
|
||||
|
||||
const route = useRoute();
|
||||
const currentId = computed(() => props.ruleId || String(route.params.id || ""));
|
||||
|
||||
const routeNavBarTitle = computed(() => {
|
||||
// 内联时路由停在列表页,标题不能只看 route.name
|
||||
if (props.ruleId) {
|
||||
return "编辑积分规则";
|
||||
}
|
||||
switch (route.name) {
|
||||
case "PointRuleCreate":
|
||||
return "新增积分规则";
|
||||
@@ -200,9 +213,30 @@ const routeNavBarTitle = computed(() => {
|
||||
}
|
||||
});
|
||||
const router = useRouter();
|
||||
|
||||
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
|
||||
// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项
|
||||
useExpandToMaster({
|
||||
path: "/management/points/rules",
|
||||
id: () => (route.name === "PointRuleCreate" ? "" : currentId.value),
|
||||
query: { view: "edit" }
|
||||
});
|
||||
/** 非空说明当前被内联在主从分栏的右栏里 */
|
||||
const pane = usePane();
|
||||
|
||||
/** 取消/保存后回到上一层:分栏时通知列表页,否则走路由返回 */
|
||||
function exit(saved = false): void {
|
||||
if (pane) {
|
||||
pane.close(saved);
|
||||
return;
|
||||
}
|
||||
|
||||
void router.back();
|
||||
}
|
||||
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const routeId = computed(() => String(route.params.id || ""));
|
||||
const routeId = currentId;
|
||||
const isCreateMode = computed(() => !routeId.value);
|
||||
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
|
||||
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.pointRule.create : permissionCodes.pointRule.update);
|
||||
@@ -529,6 +563,10 @@ async function saveRule(): Promise<void> {
|
||||
await PointAPI.ruleUpdate(payload);
|
||||
}
|
||||
Message.success("积分规则已保存");
|
||||
if (pane) {
|
||||
pane.close(true);
|
||||
return;
|
||||
}
|
||||
await router.replace("/management/points/rules");
|
||||
} catch (error) {
|
||||
Message.error(getErrorMessage(error, "积分规则保存失败"));
|
||||
|
||||
Reference in New Issue
Block a user