refactor layout

This commit is contained in:
Timi
2026-10-17 12:01:28 +08:00
parent fe467e8781
commit 469c595a7c
134 changed files with 11493 additions and 4437 deletions
+181 -78
View File
@@ -1,103 +1,166 @@
<template>
<t-pull-down-refresh
v-can="permissionCodes.storeDiary.read"
class="store-diary-list"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="content">
<section class="calendar" v-entrance-transition>
<t-calendar
:key="calendarRenderKey"
class="calendar-view"
:value="selectedCalendarDate"
:min-date="calendarMinDate"
:format="calendarFormat"
switch-mode="month"
:use-popup="false"
@panel-change="handleCalendarPanelChange"
@select="selectCalendarDate"
/>
</section>
<t-button
v-if="canCreate"
class="cell-button"
theme="primary"
@click="toCreateToday"
>
新增今天日记
</t-button>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
v-entrance-transition="{ step: 30 }"
<div class="page-layout navbar store-diary-list">
<t-navbar
fixed
:z-index="20"
title="门店日记"
left-arrow
@left-click="$router.back()"
>
<template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<store-diary-list-item :diary="item" @select="toDetail" />
<template v-if="canDelete" #right>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="swipe-cell-button"
theme="danger"
:loading="isDeleting && deletingId === item.id"
@click.stop="confirmDelete(item)"
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
删除
<template #icon>
<t-icon name="ellipsis" />
</template>
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<bottom-popup
v-model="diaryPopupVisible"
:title="`${selectedDateText} 门店日记`"
height="min(80vh, 40rem)"
left-button-text="关闭"
right-button-text=""
@left-button-click="closeDiaryPopup"
>
<div class="diary-popup">
<t-cell-group v-if="selectedDateDiaries.length">
<store-diary-list-item
v-for="(item, index) in selectedDateDiaries"
:key="item.id || index"
:diary="item"
hover
@select="toSelectedDiary"
/>
</t-cell-group>
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
</div>
</bottom-popup>
<template #content>
<div class="menu">
<t-button
v-for="action in pageNavBarActionList"
:key="action.key"
class="menu-item"
variant="text"
type="button"
:theme="action.theme"
:loading="action.loading"
:disabled="action.disabled || action.loading"
@click="handlePageNavBarAction(action)"
>
<template v-if="action.icon" #icon>
<t-icon :name="action.icon" />
</template>
<span v-text="action.text" />
</t-button>
</div>
</template>
</t-popover>
</div>
</template>
</t-navbar>
<main class="page-content scroll list">
<t-pull-down-refresh
v-can="permissionCodes.storeDiary.read"
class="store-diary-list pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="content">
<section class="calendar" v-entrance-transition>
<t-calendar
:key="calendarRenderKey"
class="calendar-view"
:value="selectedCalendarDate"
:min-date="calendarMinDate"
:format="calendarFormat"
switch-mode="month"
:use-popup="false"
@panel-change="handleCalendarPanelChange"
@select="selectCalendarDate"
/>
</section>
<t-button
v-if="canCreate"
class="cell-button"
theme="primary"
@click="toCreateToday"
>
新增今天日记
</t-button>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
v-entrance-transition="{ step: 30 }"
>
<store-diary-list-item :diary="item" @select="toDetail" />
<template v-if="canDelete" #right>
<t-button
class="swipe-cell-button"
theme="danger"
:loading="isDeleting && deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div class="center-tips" v-text="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<bottom-popup
v-model="diaryPopupVisible"
:title="`${selectedDateText} 门店日记`"
height="min(80vh, 40rem)"
left-button-text="关闭"
right-button-text=""
@left-button-click="closeDiaryPopup"
>
<div class="diary-popup">
<t-cell-group v-if="selectedDateDiaries.length">
<store-diary-list-item
v-for="(item, index) in selectedDateDiaries"
:key="item.id || index"
:diary="item"
hover
@select="toSelectedDiary"
/>
</t-cell-group>
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
</div>
</bottom-popup>
</div>
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { BottomPopup } from "timi-tdesign-mobile";
import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue";
import { type PageResult, useUserStore } from "timi-web-api";
import { Time } from "timi-web";
import StoreDiaryAPI, { type StoreDiaryListOptions } from "@/api/StoreDiaryAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import StoreDiaryListItem from "@/pages/store/component/StoreDiaryListItem.vue";
import type { NavBarAction } from "@/types/NavBarAction";
import type { StoreDiary } from "@/types/StoreDiary";
import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actionList) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import StoreDiaryListItem from "@/pages/store/component/StoreDiaryListItem.vue";
defineOptions({
name: "StoreDiaryList"
});
const router = useRouter();
const route = useRoute();
const navBarStore = useNavBarStore();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create));
@@ -418,8 +481,7 @@ async function preparePage(): Promise<void> {
}
onMounted(async () => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
try {
await preparePage();
} catch (error) {
@@ -427,7 +489,6 @@ onMounted(async () => {
}
});
onUnmounted(() => navBarStore.clearRight());
</script>
<style scoped lang="less">
@@ -506,4 +567,46 @@ onUnmounted(() => navBarStore.clearRight());
}
}
}
.nav-actions {
--td-popover-padding: 0 .5rem;
width: 6rem;
height: 100%;
display: flex;
align-items: center;
justify-content: flex-end;
:deep(.t-popover__content) { border-radius: .875rem; }
.trigger { padding: 0; }
.menu {
gap: .25rem;
display: grid;
padding: .5rem 0;
min-width: 9rem;
.menu-item {
--td-button-medium-height: 32px;
--td-button-medium-padding-horizontal: 10px;
gap: .25rem;
width: 100%;
font-weight: unset;
justify-content: flex-start;
}
}
}
:global(html.theme-dark) {
.nav-actions {
:deep(.t-popover__content) {
color: #e2e8f0;
background: rgba(30, 41, 59, .98);
}
.menu-item { color: #e2e8f0; }
}
}
</style>