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
+227 -127
View File
@@ -1,132 +1,186 @@
<template>
<div v-can="permissionCodes.customer.read" class="customer-list">
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
placeholder="搜索编码、姓名(拼音)、电话"
borderless
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
@click.stop="toggleScanner"
>
<template #icon>
<t-icon name="scan" />
</template>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</template>
</t-input>
<t-dropdown-menu ref="filterMenu" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="canReadTag"
:label="tagFilterText"
@open="handleTagFilterOpen"
/>
</t-dropdown-menu>
</div>
<div v-if="scannerVisible" class="scanner-wrapper">
<code-scanner
:visible="scannerVisible"
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<div v-if="canReadTag && selectedTagList.length" class="selected-tags bg-white">
<t-tag
v-for="item in selectedTagList"
:key="item.id"
theme="primary"
variant="light-outline"
:content="getTagName(item)"
/>
<t-button size="extra-small" variant="text" @click="clearTagFilter">清空</t-button>
</div>
<t-pull-down-refresh
class="fix-last-cell-line"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
<div class="page-layout navbar customer-list">
<t-navbar
fixed
:z-index="20"
title="客户管理"
left-arrow
@left-click="$router.back()"
>
<div class="list-wrap">
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell v-if="keyword" title="关键词" :note="keyword" />
<t-cell v-if="selectedTagList.length" title="标签" :note="tagFilterText" />
<t-cell title="客户总数" :note="`${pageResult.total} 位`" />
</t-cell-group>
<t-cell-group class="items" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.id || item.code || index"
class="item"
<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"
>
<customer-cell
class="cell"
:customer="item"
arrow
@click="toDetail(item)"
<t-button
class="trigger"
variant="text"
:aria-label="'更多操作'"
type="button"
>
<template #description>
<telephone-link :value="item.telephone" />
<template #icon>
<t-icon name="ellipsis" />
</template>
</customer-cell>
<template v-if="canDeleteCustomer" #right>
</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>
</t-navbar>
<main v-can="permissionCodes.customer.read" class="page-content scroll list">
<t-pull-down-refresh
class="pull-refresh fix-last-cell-line"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="search"
placeholder="搜索编码、姓名(拼音)、电话"
borderless
>
<template #suffix-icon>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingCustomerId === item.id"
@click.stop="openRemoveDialog(item)"
size="extra-small"
theme="primary"
variant="outline"
@click.stop="toggleScanner"
>
删除
<template #icon>
<t-icon name="scan" />
</template>
<span v-text="scannerVisible ? '关闭扫码' : '扫码'" />
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载客户' : '暂无客户数据'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<tag-selector
v-model="selectedTagIdList"
v-model:visible="tagSelectorVisible"
@change="handleTagFilterChanged"
/>
<customer-remove-dialog
v-model:visible="removeDialogVisible"
:customer="removeTarget"
:loading="isRemoving"
@confirm="removeCustomer"
/>
</t-input>
<t-dropdown-menu ref="filterMenu" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="canReadTag"
:label="tagFilterText"
@open="handleTagFilterOpen"
/>
</t-dropdown-menu>
</div>
<div v-if="scannerVisible" class="scanner-wrapper">
<code-scanner
:visible="scannerVisible"
:status-text="scanStatus"
active-text="正在识别客户编码,请将条码或二维码移入取景框"
@decode="handleDecodedText"
@status-change="handleScanStatusChange"
/>
</div>
<div v-if="canReadTag && selectedTagList.length" class="selected-tags bg-white">
<t-tag
v-for="item in selectedTagList"
:key="item.id"
theme="primary"
variant="light-outline"
:content="getTagName(item)"
/>
<t-button size="extra-small" variant="text" @click="clearTagFilter">清空</t-button>
</div>
<div class="list-wrap">
<t-cell-group class="summary" theme="card">
<t-cell
v-if="dateFilterType !== 'all'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType !== 'all'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell v-if="keyword" title="关键词" :note="keyword" />
<t-cell v-if="selectedTagList.length" title="标签" :note="tagFilterText" />
<t-cell title="客户总数" :note="`${pageResult.total} 位`" />
</t-cell-group>
<t-cell-group class="items" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="(item, index) in pageResult.list"
:key="item.id || item.code || index"
class="item"
>
<customer-cell
class="cell"
:customer="item"
arrow
@click="toDetail(item)"
>
<template #description>
<telephone-link :value="item.telephone" />
</template>
</customer-cell>
<template v-if="canDeleteCustomer" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingCustomerId === item.id"
@click.stop="openRemoveDialog(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<div v-if="!pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载客户' : '暂无客户数据'" />
<div v-if="pageResult.list.length" class="center-tips" v-text="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<tag-selector
v-model="selectedTagIdList"
v-model:visible="tagSelectorVisible"
@change="handleTagFilterChanged"
/>
<customer-remove-dialog
v-model:visible="removeDialogVisible"
:customer="removeTarget"
:loading="isRemoving"
@confirm="removeCustomer"
/>
</main>
</div>
<nav-bar-action-menu v-if="canShowActionMenu" :actions="actionList" />
<t-popup v-model="startVisible" placement="bottom">
<t-date-time-picker
v-if="startVisible"
@@ -154,6 +208,7 @@
</template>
<script setup lang="ts">
import type { NavBarAction } from "@/types/NavBarAction";
import type { DropdownValue } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { Time, Toolkit, WebToolkit } from "timi-web";
@@ -163,14 +218,21 @@ import CodeScanner from "@/components/CodeScanner.vue";
import CustomerRemoveDialog from "@/pages/customer/component/CustomerRemoveDialog.vue";
import TagSelector from "@/components/TagSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { useNavBarStore } from "@/store/navBarStore";
import { useSettingStore } from "@/store/settingStore";
import type { Customer } from "@/types/Customer";
import type { NavBarAction } from "@/types/NavBarAction";
import type { Tag } from "@/types/Tag";
import { buildPresetDateRange, parseDateTime } from "@/utils/date";
import { corePermissionCodes, 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 { useSettingStore } from "@/store/settingStore";
defineOptions({
name: "CustomerList"
});
@@ -181,7 +243,6 @@ const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const settingStore = useSettingStore();
const navBarStore = useNavBarStore();
const isRefreshing = ref(false);
const isExporting = ref(false);
const isRemoving = ref(false);
@@ -409,8 +470,7 @@ async function loadData(): Promise<void> {
onMounted(loadData);
onMounted(() => {
navBarStore.clearRight();
navBarStore.setCustomRightVisible(canShowActionMenu.value);
});
watch(keyword, async () => {
@@ -421,7 +481,6 @@ watch(keyword, async () => {
});
onUnmounted(() => {
navBarStore.clearRight();
window.clearTimeout(keywordTimer);
scannerVisible.value = false;
});
@@ -504,7 +563,6 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
<style scoped lang="less">
.customer-list {
padding: var(--app-nav-height) 0 1rem 0;
.filters {
top: var(--app-nav-height);
@@ -641,4 +699,46 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
}
}
.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>