refactor layout
This commit is contained in:
+129
-12
@@ -1,5 +1,48 @@
|
||||
<template>
|
||||
<div class="home-tab">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
title="客户"
|
||||
>
|
||||
<template #right>
|
||||
<div
|
||||
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||
class="nav-right-slot"
|
||||
>
|
||||
<t-badge
|
||||
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||
class="badge"
|
||||
:count="pageNavBarRight.badge"
|
||||
:max-count="99"
|
||||
:show-zero="false"
|
||||
>
|
||||
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||
</button>
|
||||
</t-badge>
|
||||
<button
|
||||
v-else-if="pageNavBarRight.icon"
|
||||
class="button"
|
||||
type="button"
|
||||
:disabled="pageNavBarRight.disabled"
|
||||
@click="handlePageNavBarRightAction"
|
||||
>
|
||||
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="nav-text"
|
||||
type="button"
|
||||
:disabled="pageNavBarRight.disabled"
|
||||
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
|
||||
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
|
||||
@click="handlePageNavBarRightAction"
|
||||
v-text="pageNavBarRight.text"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main class="page-content scroll column home-tab">
|
||||
<section
|
||||
v-for="group in visibleEntryGroupList"
|
||||
:key="group.title"
|
||||
@@ -52,12 +95,47 @@
|
||||
</template>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { NotifyAPI, useUserStore } from "timi-web-api";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
|
||||
const pageNavBarRight = reactive({
|
||||
icon: "",
|
||||
badge: undefined as number | undefined,
|
||||
text: "",
|
||||
textColor: "",
|
||||
disabled: false,
|
||||
action: undefined as (() => void | Promise<void>) | undefined
|
||||
});
|
||||
|
||||
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
|
||||
pageNavBarRight.icon = value || "";
|
||||
pageNavBarRight.badge = undefined;
|
||||
pageNavBarRight.disabled = false;
|
||||
pageNavBarRight.action = action;
|
||||
if (value) {
|
||||
pageNavBarRight.text = "";
|
||||
pageNavBarRight.textColor = "";
|
||||
}
|
||||
}
|
||||
|
||||
function setPageNavBarRightBadge(value?: number): void {
|
||||
pageNavBarRight.badge = value === undefined ? undefined : Math.max(0, value);
|
||||
}
|
||||
|
||||
function clearPageNavBarRight(): void {
|
||||
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
|
||||
}
|
||||
|
||||
async function handlePageNavBarRightAction(): Promise<void> {
|
||||
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
|
||||
return;
|
||||
}
|
||||
await pageNavBarRight.action();
|
||||
}
|
||||
|
||||
import { corePermissionCodes, gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
defineOptions({
|
||||
@@ -65,7 +143,6 @@ defineOptions({
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const navBarStore = useNavBarStore();
|
||||
const userStore = useUserStore();
|
||||
const unreadNotifyCount = ref(0);
|
||||
let isPageActive = true;
|
||||
@@ -160,33 +237,32 @@ async function loadUnreadNotifyCount(): Promise<void> {
|
||||
console.warn("未读通知数量加载失败", error);
|
||||
}
|
||||
if (isPageActive) {
|
||||
navBarStore.setRightBadge(unreadNotifyCount.value);
|
||||
setPageNavBarRightBadge(unreadNotifyCount.value);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
navBarStore.clearRight();
|
||||
clearPageNavBarRight();
|
||||
if (canReadNotify.value) {
|
||||
navBarStore.setRightIcon("notification", async () => {
|
||||
setPageNavBarRightIcon("notification", async () => {
|
||||
await router.push("/notify");
|
||||
});
|
||||
navBarStore.setRightBadge(0);
|
||||
setPageNavBarRightBadge(0);
|
||||
await loadUnreadNotifyCount();
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
isPageActive = false;
|
||||
navBarStore.clearRight();
|
||||
clearPageNavBarRight();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.home-tab {
|
||||
gap: 1rem;
|
||||
display: flex;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 1rem 6rem 1rem;
|
||||
flex-direction: column;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
|
||||
.entry-group {
|
||||
|
||||
@@ -285,4 +361,45 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nav-right-slot {
|
||||
width: 6rem;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
.badge {
|
||||
:deep(.t-badge__content) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.button,
|
||||
.nav-text {
|
||||
color: var(--td-text-color-primary, #333);
|
||||
border: none;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
background: transparent;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
&:disabled {
|
||||
color: var(--td-text-color-disabled);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-text {
|
||||
font: inherit;
|
||||
cursor: default;
|
||||
|
||||
&.clickable { cursor: pointer; }
|
||||
&.disabled { cursor: not-allowed; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
<template>
|
||||
<div class="product-tab">
|
||||
<t-navbar fixed :z-index="20" title="产品" />
|
||||
<main class="page-content scroll column product-tab">
|
||||
<t-cell-group
|
||||
v-for="(group, index) in visibleMenuGroupList"
|
||||
:key="group.title"
|
||||
class="menu-group"
|
||||
:title="group.title"
|
||||
theme="card"
|
||||
v-entrance-transition="{ step: 30 }"
|
||||
v-entrance-transition
|
||||
>
|
||||
<t-cell
|
||||
v-for="item in group.items"
|
||||
@@ -23,7 +24,7 @@
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<div v-if="!visibleMenuGroupList.length" class="empty" v-text="'当前账号暂无产品管理权限'" />
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
@@ -177,8 +178,5 @@ async function go(path: string): Promise<void> {
|
||||
<style scoped lang="less">
|
||||
.product-tab {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
padding: calc(var(--app-nav-height)) 0 6rem;
|
||||
flex-direction: column;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<template>
|
||||
<div class="management-tab">
|
||||
<t-navbar fixed :z-index="20" title="管理" />
|
||||
<main class="page-content scroll column management-tab">
|
||||
<t-cell-group class="user-card" theme="card" v-entrance-transition>
|
||||
<t-cell
|
||||
v-if="currentUser"
|
||||
@@ -63,7 +64,7 @@
|
||||
<p>技术支持:夜雨</p>
|
||||
<p>Copyright © 2026 imyeyu.com</p>
|
||||
</footer>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
@@ -323,9 +324,6 @@ onBeforeRouteLeave(() => {
|
||||
<style scoped lang="less">
|
||||
.management-tab {
|
||||
gap: .5rem;
|
||||
display: flex;
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 5rem 0;
|
||||
flex-direction: column;
|
||||
|
||||
.user-card {
|
||||
|
||||
|
||||
+168
-62
@@ -1,54 +1,95 @@
|
||||
<template>
|
||||
<div class="store-tab">
|
||||
<section v-entrance-transition v-if="canViewStore || canManageStore" class="store-header">
|
||||
<t-cell-group class="store-card" theme="card">
|
||||
<t-cell
|
||||
v-if="canViewStore"
|
||||
class="info"
|
||||
:title="currentStoreStore.currentStoreName"
|
||||
:description="currentStore?.address"
|
||||
<t-navbar fixed :z-index="20" title="门店">
|
||||
<template #right>
|
||||
<div
|
||||
v-if="pageNavBarRight.icon || pageNavBarRight.text"
|
||||
class="nav-right-slot"
|
||||
>
|
||||
<t-badge
|
||||
v-if="pageNavBarRight.icon && pageNavBarRight.badge !== undefined"
|
||||
class="badge"
|
||||
:count="pageNavBarRight.badge"
|
||||
:max-count="99"
|
||||
:show-zero="false"
|
||||
>
|
||||
<button class="button" type="button" :disabled="pageNavBarRight.disabled" @click="handlePageNavBarRightAction">
|
||||
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||
</button>
|
||||
</t-badge>
|
||||
<button
|
||||
v-else-if="pageNavBarRight.icon"
|
||||
class="button"
|
||||
type="button"
|
||||
:disabled="pageNavBarRight.disabled"
|
||||
@click="handlePageNavBarRightAction"
|
||||
>
|
||||
<t-icon :name="pageNavBarRight.icon" size="1.25rem" />
|
||||
</button>
|
||||
<button
|
||||
v-else
|
||||
class="nav-text"
|
||||
type="button"
|
||||
:disabled="pageNavBarRight.disabled"
|
||||
:style="{ color: pageNavBarRight.disabled ? 'var(--td-text-color-disabled)' : pageNavBarRight.textColor || 'var(--td-text-color-primary, #333)' }"
|
||||
:class="{ clickable: !!pageNavBarRight.action, disabled: pageNavBarRight.disabled }"
|
||||
@click="handlePageNavBarRightAction"
|
||||
v-text="pageNavBarRight.text"
|
||||
/>
|
||||
<t-cell
|
||||
v-if="canSelectStore"
|
||||
class="action"
|
||||
title="切换门店"
|
||||
note="选择使用门店"
|
||||
arrow
|
||||
hover
|
||||
@click="openStorePicker"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="swap" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
v-if="canManageStore"
|
||||
class="action"
|
||||
title="门店管理"
|
||||
note="管理门店资料和营业日"
|
||||
arrow
|
||||
hover
|
||||
@click="goStoreManagement"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="shop-3" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
v-if="canManageStoreDiary"
|
||||
class="action"
|
||||
title="门店日记"
|
||||
note="记录门店经营日常"
|
||||
arrow
|
||||
hover
|
||||
@click="goStoreDiaryManagement"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="file" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
</section>
|
||||
</div>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main class="page-content scroll column store-tab">
|
||||
<t-cell-group
|
||||
v-if="canViewStore || canManageStore"
|
||||
theme="card"
|
||||
v-entrance-transition
|
||||
>
|
||||
<t-cell
|
||||
v-if="canViewStore"
|
||||
class="info"
|
||||
:title="currentStoreStore.currentStoreName"
|
||||
:description="currentStore?.address"
|
||||
/>
|
||||
<t-cell
|
||||
v-if="canSelectStore"
|
||||
class="action"
|
||||
title="切换门店"
|
||||
note="选择使用门店"
|
||||
arrow
|
||||
hover
|
||||
@click="openStorePicker"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="swap" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
v-if="canManageStore"
|
||||
class="action"
|
||||
title="门店管理"
|
||||
note="管理门店资料和营业日"
|
||||
arrow
|
||||
hover
|
||||
@click="goStoreManagement"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="shop-3" />
|
||||
</template>
|
||||
</t-cell>
|
||||
<t-cell
|
||||
v-if="canManageStoreDiary"
|
||||
class="action"
|
||||
title="门店日记"
|
||||
note="记录门店经营日常"
|
||||
arrow
|
||||
hover
|
||||
@click="goStoreDiaryManagement"
|
||||
>
|
||||
<template #leftIcon>
|
||||
<t-icon name="file" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<store-data-charts :key="`${currentStoreStore.currentStoreId}-${chartRefreshKey}`" />
|
||||
<t-popup v-model="storePickerVisible" placement="bottom">
|
||||
<t-picker
|
||||
@@ -59,20 +100,51 @@
|
||||
@confirm="confirmStorePicker"
|
||||
/>
|
||||
</t-popup>
|
||||
</div>
|
||||
</main>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { Message } from "@/utils/message";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||
import { clearStoreChartCache } from "@/utils/storeChartCache";
|
||||
|
||||
const pageNavBarRight = reactive({
|
||||
icon: "",
|
||||
badge: undefined as number | undefined,
|
||||
text: "",
|
||||
textColor: "",
|
||||
disabled: false,
|
||||
action: undefined as (() => void | Promise<void>) | undefined
|
||||
});
|
||||
|
||||
function setPageNavBarRightIcon(value?: string, action?: () => void | Promise<void>): void {
|
||||
pageNavBarRight.icon = value || "";
|
||||
pageNavBarRight.badge = undefined;
|
||||
pageNavBarRight.disabled = false;
|
||||
pageNavBarRight.action = action;
|
||||
if (value) {
|
||||
pageNavBarRight.text = "";
|
||||
pageNavBarRight.textColor = "";
|
||||
}
|
||||
}
|
||||
|
||||
function clearPageNavBarRight(): void {
|
||||
Object.assign(pageNavBarRight, { icon: "", badge: undefined, text: "", textColor: "", disabled: false, action: undefined });
|
||||
}
|
||||
|
||||
async function handlePageNavBarRightAction(): Promise<void> {
|
||||
if (pageNavBarRight.disabled || !pageNavBarRight.action) {
|
||||
return;
|
||||
}
|
||||
await pageNavBarRight.action();
|
||||
}
|
||||
|
||||
import { gaoRoleCodes, gaoStoreScopePermissionCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
type PickerValue = string | number;
|
||||
|
||||
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/StoreDataCharts.vue"));
|
||||
const StoreDataCharts = defineAsyncComponent(() => import("@/pages/store/component/StoreDataCharts.vue"));
|
||||
|
||||
defineOptions({
|
||||
name: "StoreTab"
|
||||
@@ -81,7 +153,6 @@ defineOptions({
|
||||
const router = useRouter();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
const chartRefreshKey = ref(0);
|
||||
|
||||
const currentStore = computed(() => currentStoreStore.currentStore);
|
||||
@@ -168,7 +239,7 @@ async function goStoreDiaryManagement(): Promise<void> {
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
navBarStore.setRightIcon("refresh", refreshCharts);
|
||||
setPageNavBarRightIcon("refresh", refreshCharts);
|
||||
if (canSelectStore.value) {
|
||||
await currentStoreStore.loadStoreList();
|
||||
} else if (canLoadLoginStore.value) {
|
||||
@@ -177,14 +248,12 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
navBarStore.clearRight();
|
||||
clearPageNavBarRight();
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped lang="less">
|
||||
.store-tab {
|
||||
padding: calc(var(--app-nav-height) + 1rem) 0 6rem 0;
|
||||
|
||||
.store-header {
|
||||
|
||||
.store-card {
|
||||
@@ -196,10 +265,6 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.data-charts-page) {
|
||||
padding-top: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
:global(html.theme-dark) {
|
||||
@@ -213,4 +278,45 @@ onUnmounted(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.nav-right-slot {
|
||||
width: 6rem;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
|
||||
.badge {
|
||||
:deep(.t-badge__content) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
}
|
||||
}
|
||||
|
||||
.button,
|
||||
.nav-text {
|
||||
color: var(--td-text-color-primary, #333);
|
||||
border: none;
|
||||
padding: 0;
|
||||
display: inline-flex;
|
||||
background: transparent;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
&:disabled {
|
||||
color: var(--td-text-color-disabled);
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.nav-text {
|
||||
font: inherit;
|
||||
cursor: default;
|
||||
|
||||
&.clickable { cursor: pointer; }
|
||||
&.disabled { cursor: not-allowed; }
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user