fix store diary style
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
:key="calendarRenderKey"
|
||||
class="calendar-view"
|
||||
:value="selectedCalendarDate"
|
||||
:min-date="calendarMinDate"
|
||||
:format="calendarFormat"
|
||||
switch-mode="month"
|
||||
:use-popup="false"
|
||||
@@ -26,17 +27,7 @@
|
||||
class="item"
|
||||
v-entrance-transition="index * 30"
|
||||
>
|
||||
<t-cell
|
||||
class="cell"
|
||||
:title="getTitle(item)"
|
||||
:description="getDescription(item)"
|
||||
arrow
|
||||
@click="toDetail(item)"
|
||||
>
|
||||
<template #note>
|
||||
<pass-time-label :timestamp="item.updatedAt || item.createdAt" underline />
|
||||
</template>
|
||||
</t-cell>
|
||||
<store-diary-list-item :diary="item" @select="toDetail" />
|
||||
<template v-if="canDelete" #right>
|
||||
<t-button
|
||||
class="swipe-cell-button"
|
||||
@@ -62,21 +53,14 @@
|
||||
@left-button-click="closeDiaryPopup"
|
||||
>
|
||||
<div class="diary-popup">
|
||||
<t-cell-group v-if="selectedDateDiaries.length" theme="card">
|
||||
<t-cell
|
||||
<t-cell-group v-if="selectedDateDiaries.length">
|
||||
<store-diary-list-item
|
||||
v-for="(item, index) in selectedDateDiaries"
|
||||
:key="item.id || index"
|
||||
class="cell"
|
||||
:title="getTitle(item)"
|
||||
:description="getDescription(item)"
|
||||
arrow
|
||||
:diary="item"
|
||||
hover
|
||||
@click="toSelectedDiary(item)"
|
||||
>
|
||||
<template #note>
|
||||
<pass-time-label :timestamp="item.updatedAt || item.createdAt" underline />
|
||||
</template>
|
||||
</t-cell>
|
||||
@select="toSelectedDiary"
|
||||
/>
|
||||
</t-cell-group>
|
||||
<div v-else class="popup-empty" v-text="'该日期暂无门店日记'" />
|
||||
</div>
|
||||
@@ -87,10 +71,11 @@
|
||||
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 { PassTimeLabel, Time } from "timi-web";
|
||||
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";
|
||||
@@ -102,6 +87,7 @@ defineOptions({
|
||||
});
|
||||
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
const navBarStore = useNavBarStore();
|
||||
const userStore = useUserStore();
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
@@ -112,10 +98,12 @@ const canShowActionMenu = computed(() => canCreate.value);
|
||||
// ---------- 日历 ----------
|
||||
|
||||
const today = new Date();
|
||||
const selectedCalendarDate = ref<Date>(today);
|
||||
const calendarMinDate = new Date(today.getFullYear() - 2, 0, 1);
|
||||
const initialCalendarDate = parseCalendarDate(route.query.calendarDate);
|
||||
const selectedCalendarDate = ref<Date>(initialCalendarDate);
|
||||
const calendarMonth = reactive({
|
||||
year: today.getFullYear(),
|
||||
month: today.getMonth() + 1
|
||||
year: initialCalendarDate.getFullYear(),
|
||||
month: initialCalendarDate.getMonth() + 1
|
||||
});
|
||||
const calendarRenderKey = ref(0);
|
||||
const calendarDiaryList = ref<StoreDiary[]>([]);
|
||||
@@ -290,12 +278,24 @@ function getDiaryDateText(item: StoreDiary): string {
|
||||
return date ? Time.formatDate(date) : "";
|
||||
}
|
||||
|
||||
function getTitle(item: StoreDiary): string {
|
||||
return item.title?.trim() || "未命名日记";
|
||||
}
|
||||
|
||||
function getDescription(item: StoreDiary): string {
|
||||
return item.description?.trim() || "暂无摘要";
|
||||
function parseCalendarDate(value: unknown): Date {
|
||||
const text = Array.isArray(value) ? String(value[0] || "") : String(value || "");
|
||||
const [year, month, day] = text.split("-").map(Number);
|
||||
const date = new Date(year, month - 1, day);
|
||||
if (
|
||||
!Number.isInteger(year)
|
||||
|| !Number.isInteger(month)
|
||||
|| !Number.isInteger(day)
|
||||
|| month < 1
|
||||
|| 12 < month
|
||||
|| day < 1
|
||||
|| date.getFullYear() !== year
|
||||
|| date.getMonth() + 1 !== month
|
||||
|| date.getDate() !== day
|
||||
) {
|
||||
return today;
|
||||
}
|
||||
return date;
|
||||
}
|
||||
|
||||
// ---------- 导航 ----------
|
||||
@@ -347,6 +347,13 @@ async function toDetail(item: StoreDiary): Promise<void> {
|
||||
if (!item.id) {
|
||||
return;
|
||||
}
|
||||
await router.replace({
|
||||
name: "StoreDiaryList",
|
||||
query: {
|
||||
...route.query,
|
||||
calendarDate: getDiaryDateText(item) || Time.formatDate(selectedCalendarDate.value)
|
||||
}
|
||||
});
|
||||
await router.push({
|
||||
name: "StoreDiaryDetail",
|
||||
params: { id: item.id }
|
||||
@@ -363,7 +370,7 @@ async function confirmDelete(item: StoreDiary): Promise<void> {
|
||||
const diaryId = item.id;
|
||||
const dialog = DialogPlugin.confirm({
|
||||
title: "删除门店日记",
|
||||
content: `确定删除“${getTitle(item)}”吗?删除后无法恢复。`,
|
||||
content: `确定删除“${item.title?.trim() || "未命名日记"}”吗?删除后无法恢复。`,
|
||||
cancelBtn: "取消",
|
||||
confirmBtn: "删除",
|
||||
onCancel() {
|
||||
@@ -463,28 +470,6 @@ onUnmounted(() => navBarStore.clearRight());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.cell {
|
||||
:deep(.t-cell__title) {
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.t-cell__title-text),
|
||||
:deep(.t-cell__description) {
|
||||
overflow: hidden;
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
:deep(.t-cell__note) {
|
||||
flex: 0 0 auto;
|
||||
min-width: 0;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.diary-popup {
|
||||
padding-bottom: .5rem;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user