fix filter and navbar style

This commit is contained in:
Timi
2026-10-22 01:06:31 +08:00
parent 3fc295acb2
commit 2ba4492579
10 changed files with 145 additions and 696 deletions
+33 -21
View File
@@ -79,16 +79,8 @@
/> />
</template> </template>
</t-input> </t-input>
<t-dropdown-menu class="date-filter">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
</t-dropdown-menu>
</div> </div>
<t-dropdown-menu class="filter-menu"> <t-dropdown-menu class="menus">
<t-dropdown-item <t-dropdown-item
v-model="actionFilter" v-model="actionFilter"
:label="eventFilterLabel" :label="eventFilterLabel"
@@ -114,12 +106,20 @@
<div class="list-wrapper"> <div class="list-wrapper">
<t-cell-group v-entrance-transition class="summary" theme="card"> <t-cell-group v-entrance-transition class="summary" theme="card">
<t-cell <t-cell
title="登记时间"
:note="dateFilterLabel"
arrow
@click="openDateFilterPicker"
/>
<t-cell
v-if="dateFilterType === 'custom'"
title="开始时间" title="开始时间"
:note="dateRange[0] || '-'" :note="dateRange[0] || '-'"
arrow arrow
@click="openStartTime" @click="openStartTime"
/> />
<t-cell <t-cell
v-if="dateFilterType === 'custom'"
title="结束时间" title="结束时间"
:note="dateRange[1] || '-'" :note="dateRange[1] || '-'"
arrow arrow
@@ -163,6 +163,15 @@
v-model:visible="customerSelectorVisible" v-model:visible="customerSelectorVisible"
@change="handleCustomerChange" @change="handleCustomerChange"
/> />
<t-popup v-model="dateFilterPickerVisible" placement="bottom">
<t-picker
v-model="dateFilterDraft"
:columns="dateOptions"
title="登记时间"
@cancel="dateFilterPickerVisible = false"
@confirm="confirmDateFilter"
/>
</t-popup>
<t-popup v-model="startVisible" placement="bottom"> <t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker <t-date-time-picker
v-if="startVisible" v-if="startVisible"
@@ -192,7 +201,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction"; import type { NavBarAction } from "@/types/NavBarAction";
import type { DropdownValue } from "tdesign-mobile-vue";
import { CenterTips, Time, Text, WebToolkit } from "timi-web"; import { CenterTips, Time, Text, WebToolkit } from "timi-web";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI"; import EventAPI from "@/api/EventAPI";
@@ -244,6 +252,8 @@ const customerId = ref(getQueryText("customerId"));
const customerSelectorVisible = ref(false); const customerSelectorVisible = ref(false);
const dateFilterType = ref<DateFilterType>(parseDateFilterType(route.query.dateType, dateOptions, "today")); const dateFilterType = ref<DateFilterType>(parseDateFilterType(route.query.dateType, dateOptions, "today"));
const dateRange = ref(parseDateRange(dateFilterType.value)); const dateRange = ref(parseDateRange(dateFilterType.value));
const dateFilterPickerVisible = ref(false);
const dateFilterDraft = ref<Array<string | number>>([]);
const startDraft = ref(""); const startDraft = ref("");
const endDraft = ref(""); const endDraft = ref("");
const actionFilter = ref<string[]>([]); const actionFilter = ref<string[]>([]);
@@ -265,7 +275,7 @@ let suppressOptionFilterReload = false;
const canCreateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.create)); const canCreateRecord = computed(() => userStore.hasPermissions(permissionCodes.eventRecord.create));
const canCreateEvent = computed(() => userStore.hasPermissions(permissionCodes.event.create)); const canCreateEvent = computed(() => userStore.hasPermissions(permissionCodes.event.create));
const dateFilterLabel = computed(() => dateOptions.find(item => item.value === dateFilterType.value)?.label || "今天"); const dateFilterLabel = computed(() => dateFilterType.value === "custom" ? "自定义" : dateOptions.find(item => item.value === dateFilterType.value)?.label || "今天");
const actionOptions = computed(() => eventList.value.map(item => ({ const actionOptions = computed(() => eventList.value.map(item => ({
label: getEventDisplayName(item), label: getEventDisplayName(item),
value: item.id || "" value: item.id || ""
@@ -530,12 +540,20 @@ function getEventStatusText(status?: EventStatus): string {
return ""; return "";
} }
async function selectDateFilter(type: DropdownValue): Promise<void> { function openDateFilterPicker(): void {
if (Array.isArray(type)) { dateFilterDraft.value = [dateFilterType.value];
dateFilterPickerVisible.value = true;
}
async function confirmDateFilter(value: Array<string | number>): Promise<void> {
dateFilterPickerVisible.value = false;
const selectedType = String(value[0] || "");
const selectedOption = dateOptions.find(item => item.value === selectedType);
if (!selectedOption) {
return; return;
} }
dateFilterType.value = String(type) as DateFilterType; dateFilterType.value = selectedOption.value;
if (dateFilterType.value !== "custom") { if (dateFilterType.value !== "custom") {
dateRange.value = buildPresetDateRange(dateFilterType.value); dateRange.value = buildPresetDateRange(dateFilterType.value);
await replaceFilterQuery(); await replaceFilterQuery();
@@ -544,7 +562,6 @@ async function selectDateFilter(type: DropdownValue): Promise<void> {
await replaceFilterQuery(); await replaceFilterQuery();
} }
} }
function openStartTime(): void { function openStartTime(): void {
startDraft.value = dateRange.value[0]; startDraft.value = dateRange.value[0];
startVisible.value = true; startVisible.value = true;
@@ -578,10 +595,6 @@ async function confirmEndTime(value?: string | number): Promise<void> {
} }
async function confirmCustomRange(): Promise<void> { async function confirmCustomRange(): Promise<void> {
if (dateFilterType.value === "custom") {
return;
}
dateFilterType.value = "custom"; dateFilterType.value = "custom";
await replaceFilterQuery(); await replaceFilterQuery();
await reloadRecords(); await reloadRecords();
@@ -790,8 +803,7 @@ onUnmounted(() => {
border-color: rgba(148, 163, 184, .16); border-color: rgba(148, 163, 184, .16);
} }
.date-filter, .menus {
.filter-menu {
background: #172033; background: #172033;
border-color: rgba(148, 163, 184, .16); border-color: rgba(148, 163, 184, .16);
} }
@@ -8,48 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div
class="nav-actions"
v-if="(canCreate) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button <t-button
class="trigger" v-if="canCreate"
theme="primary"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="新增"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main v-can="permissionCodes.customerFollowUpReminder.read" class="page-content scroll list"> <main v-can="permissionCodes.customerFollowUpReminder.read" class="page-content scroll list">
@@ -230,7 +196,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue"; import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
import { Time } from "timi-web"; import { Time } from "timi-web";
import { type PageResult, useUserStore } from "timi-web-api"; import { type PageResult, useUserStore } from "timi-web-api";
@@ -247,14 +212,6 @@ import { getCustomerPhotoURL } from "@/utils/customer";
import { parseDateTime } from "@/utils/date"; import { parseDateTime } from "@/utils/date";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission"; import { gaoRoleCodes, 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 type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
type DateFilterType = "all" | "today" | "next7" | "custom"; type DateFilterType = "all" | "today" | "next7" | "custom";
@@ -312,14 +269,6 @@ const endVisible = ref(false);
const startDraft = ref(""); const startDraft = ref("");
const endDraft = ref(""); const endDraft = ref("");
const actionList = computed(() => [{
action: toCreate,
icon: "add",
key: "create",
text: "新增跟进提醒",
theme: "primary" as const
}]);
async function handleStatusChange(value: DropdownValue): Promise<void> { async function handleStatusChange(value: DropdownValue): Promise<void> {
if (Array.isArray(value)) { if (Array.isArray(value)) {
return; return;
@@ -858,45 +807,4 @@ watch(() => route.query.customerId, async value => {
} }
} }
.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> </style>
+7 -98
View File
@@ -8,48 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div
class="nav-actions"
v-if="(canCreate) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button <t-button
class="trigger" v-if="canCreate"
theme="primary"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="新增"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll list"> <main v-can="permissionCodes.packageConfig.read" class="page-content scroll list">
@@ -68,7 +34,7 @@
clearable clearable
placeholder="搜索套餐名称或说明" placeholder="搜索套餐名称或说明"
/> />
<t-dropdown-menu class="status"> <t-dropdown-menu class="menus">
<t-dropdown-item <t-dropdown-item
v-model="status" v-model="status"
label="状态" label="状态"
@@ -134,7 +100,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue"; import { type DropdownValue } from "tdesign-mobile-vue";
import { Toolkit } from "timi-web"; import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
@@ -145,14 +110,6 @@ import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
import { getProductSkuSnapshotText } from "@/utils/product"; import { getProductSkuSnapshotText } from "@/utils/product";
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 { getErrorMessage } from "@/utils/error"; import { getErrorMessage } from "@/utils/error";
defineOptions({ name: "PackageConfigList" }); defineOptions({ name: "PackageConfigList" });
@@ -160,13 +117,6 @@ defineOptions({ name: "PackageConfigList" });
const router = useRouter(); const router = useRouter();
const userStore = useUserStore(); const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create)); const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
key: "create",
text: "新增套餐配置",
icon: "add",
theme: "primary",
action: toCreate
}] : []);
const keyword = ref(""); const keyword = ref("");
const status = ref("ALL"); const status = ref("ALL");
@@ -344,45 +294,4 @@ onUnmounted(() => {
} }
} }
.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> </style>
+1 -1
View File
@@ -23,7 +23,7 @@
clearable clearable
placeholder="搜索套餐名称或说明" placeholder="搜索套餐名称或说明"
/> />
<t-dropdown-menu class="status"> <t-dropdown-menu class="menus">
<t-dropdown-item <t-dropdown-item
v-model="status" v-model="status"
label="状态" label="状态"
+6 -91
View File
@@ -8,49 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <t-button
class="nav-actions"
v-if="pageNavBarActionList.length"
v-can="permissionCodes.pointRedeemSku.manage" v-can="permissionCodes.pointRedeemSku.manage"
> theme="primary"
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="新增"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main v-can="permissionCodes.pointRedeemSku.manage" class="page-content scroll list"> <main v-can="permissionCodes.pointRedeemSku.manage" class="page-content scroll list">
@@ -125,7 +90,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { Toolkit } from "timi-web"; import { Toolkit } from "timi-web";
import PointAPI from "@/api/PointAPI"; import PointAPI from "@/api/PointAPI";
import ProductSkuTags from "@/components/ProductSkuTags.vue"; import ProductSkuTags from "@/components/ProductSkuTags.vue";
@@ -134,14 +98,6 @@ import { formatWanInteger } from "@/utils/money";
import { getProductPhotoURL } from "@/utils/product"; import { getProductPhotoURL } from "@/utils/product";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref([{ key: "create", icon: "add", text: "新增兑换配置", theme: "primary", action: toCreate }]) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point"; import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
defineOptions({ name: "PointRedeemSkuList" }); defineOptions({ name: "PointRedeemSkuList" });
@@ -291,45 +247,4 @@ onUnmounted(() => {
} }
} }
.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> </style>
+6 -91
View File
@@ -8,49 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div <t-button
class="nav-actions"
v-if="pageNavBarActionList.length"
v-can="permissionCodes.pointRedemption.create" v-can="permissionCodes.pointRedemption.create"
> theme="primary"
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button
class="trigger"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="兑换"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main v-can="permissionCodes.pointRedemption.create" class="page-content scroll list"> <main v-can="permissionCodes.pointRedemption.create" class="page-content scroll list">
@@ -203,7 +168,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue"; import { type DropdownValue } from "tdesign-mobile-vue";
import { Text, Time, Toolkit } from "timi-web"; import { Text, Time, Toolkit } from "timi-web";
import CustomerAPI from "@/api/CustomerAPI"; import CustomerAPI from "@/api/CustomerAPI";
@@ -217,14 +181,6 @@ import { getPackageQuantityText } from "@/utils/package";
import { getCustomerPhotoURL } from "@/utils/customer"; import { getCustomerPhotoURL } from "@/utils/customer";
import { permissionCodes } from "@/utils/permission"; import { permissionCodes } from "@/utils/permission";
const pageNavBarActionVisible = ref(false);
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref([{ key: "create", icon: "add", text: "客户兑换", theme: "primary", action: toCreate }]) as NavBarAction[]).filter(action => action.visible !== false));
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
pageNavBarActionVisible.value = false;
await action.action();
}
import type { Customer } from "@/types/Customer"; import type { Customer } from "@/types/Customer";
defineOptions({ name: "PointRedemptionList" }); defineOptions({ name: "PointRedemptionList" });
@@ -516,45 +472,4 @@ onUnmounted(() => {
} }
} }
.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> </style>
+39 -3
View File
@@ -60,8 +60,16 @@
@refresh="reload" @refresh="reload"
@scrolltolower="load" @scrolltolower="load"
> >
<div class="filter-menu"> <div class="filters">
<t-dropdown-menu> <t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索积分规则名称"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item <t-dropdown-item
v-model="statusFilter" v-model="statusFilter"
label="规则状态" label="规则状态"
@@ -118,6 +126,7 @@
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction"; import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue"; import { type DropdownValue } from "tdesign-mobile-vue";
import { Toolkit } from "timi-web";
import EventAPI from "@/api/EventAPI"; import EventAPI from "@/api/EventAPI";
import PointAPI from "@/api/PointAPI"; import PointAPI from "@/api/PointAPI";
import { useCurrentStoreStore } from "@/store/currentStoreStore"; import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -175,6 +184,7 @@ const actionList = computed<NavBarAction[]>(() => {
}); });
const statusFilter = ref("ALL"); const statusFilter = ref("ALL");
const keyword = ref("");
const statusOptions = [ const statusOptions = [
{ label: "全部状态", value: "ALL" }, { label: "全部状态", value: "ALL" },
{ label: "草稿", value: "DRAFT" }, { label: "草稿", value: "DRAFT" },
@@ -205,19 +215,27 @@ const isLoading = ref(false);
const isRefreshing = ref(false); const isRefreshing = ref(false);
const isNoMore = ref(false); const isNoMore = ref(false);
let loadToken = 0; let loadToken = 0;
let reloadRequested = false;
const loadStateText = computed(() => { const loadStateText = computed(() => {
if (isLoading.value) { if (isLoading.value) {
return "正在加载更多"; return "正在加载更多";
} }
if (isNoMore.value) { if (isNoMore.value) {
return pageResult.list.length ? `共 ${pageResult.total} 条规则` : ""; if (pageResult.list.length) {
return `共 ${pageResult.total} 条规则`;
}
return keyword.value.trim() ? "未找到匹配积分规则" : "暂无积分规则";
} }
return "上拉加载更多"; return "上拉加载更多";
}); });
async function reload(): Promise<void> { async function reload(): Promise<void> {
isRefreshing.value = true; isRefreshing.value = true;
if (isLoading.value) {
reloadRequested = true;
return;
}
try { try {
page.index = 0; page.index = 0;
pageResult.total = 0; pageResult.total = 0;
@@ -251,14 +269,20 @@ async function load(): Promise<void> {
} finally { } finally {
if (token === loadToken) { if (token === loadToken) {
isLoading.value = false; isLoading.value = false;
if (reloadRequested) {
reloadRequested = false;
await reload();
}
} }
} }
} }
function buildRequest(): Page<PointRule> { function buildRequest(): Page<PointRule> {
const currentKeyword = keyword.value.trim();
return { return {
index: page.index, index: page.index,
size: page.size, size: page.size,
likesExample: currentKeyword ? { name: currentKeyword } : undefined,
equalsExample: statusFilter.value === "ALL" ? undefined : { equalsExample: statusFilter.value === "ALL" ? undefined : {
status: statusFilter.value as PointRuleStatus status: statusFilter.value as PointRuleStatus
} }
@@ -269,6 +293,14 @@ function buildListOptions(): { storeId: string } {
return { storeId: currentStoreStore.currentStoreId }; return { storeId: currentStoreStore.currentStoreId };
} }
const reloadByKeyword = Toolkit.debounce(async () => {
await reload();
}, false);
watch(keyword, () => {
reloadByKeyword();
});
// ---------- 事件名称 ---------- // ---------- 事件名称 ----------
const eventList = ref<EventItem[]>([]); const eventList = ref<EventItem[]>([]);
@@ -363,6 +395,10 @@ onMounted(async () => {
} }
}); });
onUnmounted(() => {
reloadByKeyword.cancel();
});
</script> </script>
<style scoped lang="less"> <style scoped lang="less">
+6 -98
View File
@@ -8,48 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div
class="nav-actions"
v-if="(route.name === 'ProductList' && canCreate) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button <t-button
class="trigger" v-if="route.name === 'ProductList' && canCreate"
theme="primary"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="新增"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main ref="productListRef" v-can="permissionCodes.product.read" class="page-content scroll list"> <main ref="productListRef" v-can="permissionCodes.product.read" class="page-content scroll list">
@@ -145,7 +111,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { type DropdownValue } from "tdesign-mobile-vue"; import { type DropdownValue } from "tdesign-mobile-vue";
import { useUserStore } from "timi-web-api"; import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router"; import { onBeforeRouteLeave } from "vue-router";
@@ -157,15 +122,6 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; 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();
}
defineOptions({ name: "ProductList" }); defineOptions({ name: "ProductList" });
const router = useRouter(); const router = useRouter();
@@ -173,13 +129,6 @@ const route = useRoute();
const productListRef = ref<HTMLElement | null>(null); const productListRef = ref<HTMLElement | null>(null);
const userStore = useUserStore(); const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create)); const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create));
const actionList = computed<NavBarAction[]>(() => canCreate.value ? [{
key: "create",
text: "新增产品",
icon: "add",
theme: "primary",
action: toCreate
}] : []);
const keyword = ref(""); const keyword = ref("");
const status = ref("ALL"); const status = ref("ALL");
@@ -506,45 +455,4 @@ onUnmounted(() => {
} }
} }
.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> </style>
@@ -1,7 +1,12 @@
<template> <template>
<t-cell-group class="filter-summary" theme="card"> <t-cell-group class="filter-summary" theme="card">
<t-cell title="开始时间" :note="filterBeginAtText" arrow @click="openStartTime" /> <t-cell
<t-cell title="结束时间" :note="filterEndAtText" arrow @click="openEndTime" /> title="下单时间"
:note="filterDateText"
arrow
@click="openFilterPopup('date')"
/>
<t-cell v-if="props.filter.dateFilterType === 'custom'" :note="filterDateRangeText" />
<t-cell title="状态" class="filter-cell" arrow @click="openFilterPopup('statusList')"> <t-cell title="状态" class="filter-cell" arrow @click="openFilterPopup('statusList')">
<template #note> <template #note>
<div class="filter-tags"> <div class="filter-tags">
@@ -63,38 +68,13 @@
:package-config-id="props.packageConfigId" :package-config-id="props.packageConfigId"
@confirm="confirmFilter" @confirm="confirmFilter"
/> />
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
v-model="startDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="开始时间"
:default-value="startDraft"
@cancel="cancelStartTime"
@confirm="confirmStartTime"
/>
</t-popup>
<t-popup v-model="endVisible" placement="bottom">
<t-date-time-picker
v-if="endVisible"
v-model="endDraft"
format="YYYY-MM-DD HH:mm"
:mode="['date', 'minute']"
title="结束时间"
:default-value="endDraft"
@cancel="cancelEndTime"
@confirm="confirmEndTime"
/>
</t-popup>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { Time } from "timi-web";
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue"; import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder"; import type { GaoSalesOrderStatus, GaoSalesOrderType, GaoSalesRefundStatus } from "@/types/SalesOrder";
import { import {
cloneSalesOrderFilter, type SalesOrderDateFilterType,
type SalesOrderFilterGroupKey, type SalesOrderFilterGroupKey,
type SalesOrderListFilter, type SalesOrderListFilter,
type SalesOrderPaymentFilter type SalesOrderPaymentFilter
@@ -132,72 +112,39 @@ const refundOptions: Array<{ label: string; value: GaoSalesRefundStatus }> = [
{ label: "待退款", value: "PENDING" }, { label: "待退款", value: "PENDING" },
{ label: "已退款", value: "REFUNDED" } { label: "已退款", value: "REFUNDED" }
]; ];
const filterBeginAtText = computed(() => props.filter.dateRange[0] || "不限"); const dateFilterLabels: Record<SalesOrderDateFilterType, string> = {
const filterEndAtText = computed(() => props.filter.dateRange[1] || "不限"); all: "全部",
today: "今天",
yesterday: "昨天",
thisWeek: "本周",
thisMonth: "本月",
last30: "最近 30 天",
custom: "自定义"
};
const filterDateText = computed(() => {
return dateFilterLabels[props.filter.dateFilterType];
});
const filterDateRangeText = computed(() => {
const [start, end] = props.filter.dateRange;
return `${start || "请选择"} 至 ${end || "请选择"}`;
});
const selectedStatusTags = computed(() => getSelectedOptionLabels(props.filter.statusList, statusOptions)); const selectedStatusTags = computed(() => getSelectedOptionLabels(props.filter.statusList, statusOptions));
const selectedOrderTypeTags = computed(() => getSelectedOptionLabels(props.filter.orderTypeList, orderTypeOptions)); const selectedOrderTypeTags = computed(() => getSelectedOptionLabels(props.filter.orderTypeList, orderTypeOptions));
const selectedPaymentTags = computed(() => getSelectedOptionLabels(props.filter.paymentStatusList, paymentOptions)); const selectedPaymentTags = computed(() => getSelectedOptionLabels(props.filter.paymentStatusList, paymentOptions));
const selectedRefundTags = computed(() => getSelectedOptionLabels(props.filter.refundStatusList, refundOptions)); const selectedRefundTags = computed(() => getSelectedOptionLabels(props.filter.refundStatusList, refundOptions));
const filterPopupVisible = ref(false); const filterPopupVisible = ref(false);
const activeFilterKey = ref<SalesOrderFilterGroupKey>(); const activeFilterKey = ref<SalesOrderFilterGroupKey>();
const startVisible = ref(false);
const endVisible = ref(false);
const startDraft = ref("");
const endDraft = ref("");
function getSelectedOptionLabels<T extends string>(valueList: T[], options: Array<{ label: string; value: T }>): string[] { function getSelectedOptionLabels<T extends string>(valueList: T[], options: Array<{ label: string; value: T }>): string[] {
const labels = options.filter(item => valueList.includes(item.value)).map(item => item.label); const labels = options.filter(item => valueList.includes(item.value)).map(item => item.label);
return labels.length ? labels : ["未选择"]; return labels.length ? labels : ["未选择"];
} }
function openFilterPopup(filterKey: Exclude<SalesOrderFilterGroupKey, "date">): void { function openFilterPopup(filterKey: SalesOrderFilterGroupKey): void {
activeFilterKey.value = filterKey; activeFilterKey.value = filterKey;
filterPopupVisible.value = true; filterPopupVisible.value = true;
} }
function openStartTime(): void {
startDraft.value = props.filter.dateRange[0] || `${Time.toDate(new Date())} 00:00`;
startVisible.value = true;
}
function openEndTime(): void {
endDraft.value = props.filter.dateRange[1] || `${Time.toDate(new Date())} 23:59`;
endVisible.value = true;
}
function cancelStartTime(): void {
startVisible.value = false;
startDraft.value = props.filter.dateRange[0];
}
function cancelEndTime(): void {
endVisible.value = false;
endDraft.value = props.filter.dateRange[1];
}
function confirmStartTime(value?: string | number): void {
startVisible.value = false;
confirmDateRange(0, String(value || startDraft.value));
}
function confirmEndTime(value?: string | number): void {
endVisible.value = false;
confirmDateRange(1, String(value || endDraft.value));
}
function confirmDateRange(index: 0 | 1, value: string): void {
const nextFilter = cloneSalesOrderFilter(props.filter);
const nextRange = [...nextFilter.dateRange] as [string, string];
nextRange[index] = value;
if (nextRange[0] && nextRange[1] && nextRange[1] < nextRange[0]) {
nextFilter.dateRange = [nextRange[1], nextRange[0]];
} else {
nextFilter.dateRange = nextRange;
}
nextFilter.dateFilterType = "custom";
emit("confirm", nextFilter);
}
function confirmFilter(value: SalesOrderListFilter): void { function confirmFilter(value: SalesOrderListFilter): void {
emit("confirm", value); emit("confirm", value);
} }
+6 -107
View File
@@ -8,48 +8,14 @@
@left-click="$router.back()" @left-click="$router.back()"
> >
<template #right> <template #right>
<div
class="nav-actions"
v-if="(canShowActionMenu) && pageNavBarActionList.length"
>
<t-popover
v-model:visible="pageNavBarActionVisible"
placement="bottom-right"
:show-arrow="false"
theme="light"
>
<t-button <t-button
class="trigger" v-if="canCreate"
theme="primary"
variant="text" variant="text"
:aria-label="'更多操作'" size="small"
type="button" content="新增"
> @click="toCreate"
<template #icon> />
<t-icon name="ellipsis" />
</template>
</t-button>
<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> </template>
</t-navbar> </t-navbar>
<main class="page-content scroll list"> <main class="page-content scroll list">
@@ -133,7 +99,6 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import { BottomPopup } from "timi-tdesign-mobile"; import { BottomPopup } from "timi-tdesign-mobile";
import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue"; import { type CalendarProps, DialogPlugin, type TDate } from "tdesign-mobile-vue";
import { type PageResult, useUserStore } from "timi-web-api"; import { type PageResult, useUserStore } from "timi-web-api";
@@ -145,14 +110,6 @@ import { getErrorMessage } from "@/utils/error";
import { Message } from "@/utils/message"; import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission"; 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"; import StoreDiaryListItem from "@/pages/store/component/StoreDiaryListItem.vue";
defineOptions({ defineOptions({
@@ -165,7 +122,6 @@ const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore(); const currentStoreStore = useCurrentStoreStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create)); const canCreate = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.create));
const canDelete = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.delete)); const canDelete = computed(() => userStore.hasPermissions(permissionCodes.storeDiary.delete));
const canShowActionMenu = computed(() => canCreate.value);
// ---------- 日历 ---------- // ---------- 日历 ----------
@@ -218,22 +174,6 @@ const calendarFormat = computed<NonNullable<CalendarProps["format"]>>(() => {
}; };
}); });
// ---------- 顶部操作 ----------
const actionList = computed<NavBarAction[]>(() => {
if (!canCreate.value) {
return [];
}
return [{
action: toCreate,
theme: "primary",
icon: "add",
key: "create",
text: "新增日记"
}];
});
// ---------- 列表数据 ---------- // ---------- 列表数据 ----------
const page = reactive({ const page = reactive({
@@ -561,45 +501,4 @@ onMounted(async () => {
} }
} }
.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> </style>