refactor layout
This commit is contained in:
@@ -1,106 +1,161 @@
|
||||
<template>
|
||||
<div ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="sales-order-list">
|
||||
<div class="filters glass">
|
||||
<div class="search-row">
|
||||
<t-input
|
||||
v-model.trim="keyword"
|
||||
class="keyword"
|
||||
type="text"
|
||||
enterkeyhint="search"
|
||||
clearable
|
||||
borderless
|
||||
placeholder="订单号或客户"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<div class="actions">
|
||||
<t-button
|
||||
size="extra-small"
|
||||
theme="primary"
|
||||
variant="outline"
|
||||
content="选择客户"
|
||||
@click.stop="customerSelectorVisible = true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</t-input>
|
||||
<t-button
|
||||
class="filter-button"
|
||||
size="small"
|
||||
theme="light"
|
||||
variant="outline"
|
||||
@click="filterVisible = true"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="filter-1" />
|
||||
</template>
|
||||
<span>筛选</span>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<t-pull-down-refresh
|
||||
class="list-wrap"
|
||||
v-model="refreshing"
|
||||
:refresh-timeout="30000"
|
||||
@refresh="refresh"
|
||||
@scrolltolower="loadMore"
|
||||
<div class="page-layout navbar sales-order-list">
|
||||
<t-navbar
|
||||
fixed
|
||||
:z-index="20"
|
||||
title="销售订单"
|
||||
left-arrow
|
||||
@left-click="$router.back()"
|
||||
>
|
||||
<div class="items">
|
||||
<sales-order-summary
|
||||
v-if="customerId"
|
||||
ref="customerOrderSummaryRef"
|
||||
:customer="selectedCustomer"
|
||||
/>
|
||||
<t-cell-group v-if="packageConfigId" class="selected-package" theme="card">
|
||||
<t-cell title="套餐" :note="selectedPackageName">
|
||||
<template #left-icon>
|
||||
<t-icon name="layers" />
|
||||
<template #right>
|
||||
<div
|
||||
class="nav-actions"
|
||||
v-if="(route.name === 'SalesOrderList' && actions.length) && pageNavBarActionList.length"
|
||||
>
|
||||
<t-popover
|
||||
v-model:visible="pageNavBarActionVisible"
|
||||
placement="bottom-right"
|
||||
:show-arrow="false"
|
||||
theme="light"
|
||||
>
|
||||
<t-button
|
||||
class="trigger"
|
||||
variant="text"
|
||||
:aria-label="'更多操作'"
|
||||
type="button"
|
||||
>
|
||||
<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-cell>
|
||||
</t-cell-group>
|
||||
<sales-order-filter-summary
|
||||
:filter="appliedFilter"
|
||||
:total="total"
|
||||
:package-config-id="packageConfigId"
|
||||
@confirm="confirmFilter"
|
||||
/>
|
||||
<sales-order-list-cell
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:order="item"
|
||||
:can-receive="canReceive"
|
||||
:can-fulfill="canCreateFulfillment"
|
||||
:can-cancel="canCancel"
|
||||
:can-refund="canRefund"
|
||||
:can-store-manager="canStoreManager"
|
||||
v-entrance-transition="{ step: 30 }"
|
||||
@click="toDetail(item)"
|
||||
@cancel="toCancel(item)"
|
||||
@receive="toPayment(item)"
|
||||
@fulfill="toFulfillment(item)"
|
||||
@refund="toRefund(item)"
|
||||
@confirm-no-refund="toNoRefund(item)"
|
||||
/>
|
||||
<div v-if="!list.length" class="empty" v-text="loading ? '正在加载销售订单' : '暂无销售订单'" />
|
||||
</div>
|
||||
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
</t-popover>
|
||||
</div>
|
||||
</template>
|
||||
</t-navbar>
|
||||
<main ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="page-content scroll list">
|
||||
<t-pull-down-refresh
|
||||
class="list-wrap pull-refresh"
|
||||
v-model="refreshing"
|
||||
:refresh-timeout="30000"
|
||||
@refresh="refresh"
|
||||
@scrolltolower="loadMore"
|
||||
>
|
||||
<div class="filters glass">
|
||||
<div class="search-row">
|
||||
<t-input
|
||||
v-model.trim="keyword"
|
||||
class="keyword"
|
||||
type="text"
|
||||
enterkeyhint="search"
|
||||
clearable
|
||||
borderless
|
||||
placeholder="订单号或客户"
|
||||
>
|
||||
<template #suffix-icon>
|
||||
<div class="actions">
|
||||
<t-button
|
||||
size="extra-small"
|
||||
theme="primary"
|
||||
variant="outline"
|
||||
content="选择客户"
|
||||
@click.stop="customerSelectorVisible = true"
|
||||
/>
|
||||
</div>
|
||||
</template>
|
||||
</t-input>
|
||||
<t-button
|
||||
class="filter-button"
|
||||
size="small"
|
||||
theme="light"
|
||||
variant="outline"
|
||||
@click="filterVisible = true"
|
||||
>
|
||||
<template #icon>
|
||||
<t-icon name="filter-1" />
|
||||
</template>
|
||||
<span>筛选</span>
|
||||
</t-button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="items">
|
||||
<sales-order-summary
|
||||
v-if="customerId"
|
||||
ref="customerOrderSummaryRef"
|
||||
:customer="selectedCustomer"
|
||||
/>
|
||||
<t-cell-group v-if="packageConfigId" class="selected-package" theme="card">
|
||||
<t-cell title="套餐" :note="selectedPackageName">
|
||||
<template #left-icon>
|
||||
<t-icon name="layers" />
|
||||
</template>
|
||||
</t-cell>
|
||||
</t-cell-group>
|
||||
<sales-order-filter-summary
|
||||
:filter="appliedFilter"
|
||||
:total="total"
|
||||
:package-config-id="packageConfigId"
|
||||
@confirm="confirmFilter"
|
||||
/>
|
||||
<sales-order-list-cell
|
||||
v-for="item in list"
|
||||
:key="item.id"
|
||||
class="item"
|
||||
:order="item"
|
||||
:can-receive="canReceive"
|
||||
:can-fulfill="canCreateFulfillment"
|
||||
:can-cancel="canCancel"
|
||||
:can-refund="canRefund"
|
||||
:can-store-manager="canStoreManager"
|
||||
v-entrance-transition="{ step: 30 }"
|
||||
@click="toDetail(item)"
|
||||
@cancel="toCancel(item)"
|
||||
@receive="toPayment(item)"
|
||||
@fulfill="toFulfillment(item)"
|
||||
@refund="toRefund(item)"
|
||||
@confirm-no-refund="toNoRefund(item)"
|
||||
/>
|
||||
<div v-if="!list.length" class="empty" v-text="loading ? '正在加载销售订单' : '暂无销售订单'" />
|
||||
</div>
|
||||
<div class="center-tips" v-text="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
|
||||
</t-pull-down-refresh>
|
||||
</main>
|
||||
|
||||
<customer-selector
|
||||
v-model="customerId"
|
||||
v-model:visible="customerSelectorVisible"
|
||||
@change="handleCustomerChange"
|
||||
/>
|
||||
<sales-order-filter-popup
|
||||
v-model:visible="filterVisible"
|
||||
:model-value="appliedFilter"
|
||||
:package-config-id="packageConfigId"
|
||||
@confirm="confirmFilter"
|
||||
/>
|
||||
</div>
|
||||
<nav-bar-action-menu v-if="route.name === 'SalesOrderList' && actions.length" :actions="actions" />
|
||||
<customer-selector
|
||||
v-model="customerId"
|
||||
v-model:visible="customerSelectorVisible"
|
||||
@change="handleCustomerChange"
|
||||
/>
|
||||
<sales-order-filter-popup
|
||||
v-model:visible="filterVisible"
|
||||
:model-value="appliedFilter"
|
||||
:package-config-id="packageConfigId"
|
||||
@confirm="confirmFilter"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import type { NavBarAction } from "@/types/NavBarAction";
|
||||
import { Toolkit } from "timi-web";
|
||||
import { useUserStore } from "timi-web-api";
|
||||
import { onBeforeRouteLeave } from "vue-router";
|
||||
@@ -108,14 +163,10 @@ import CustomerAPI from "@/api/CustomerAPI";
|
||||
import PackageAPI from "@/api/PackageAPI";
|
||||
import SalesOrderAPI from "@/api/SalesOrderAPI";
|
||||
import CustomerSelector from "@/components/CustomerSelector.vue";
|
||||
import NavBarActionMenu from "@/components/NavBarActionMenu.vue";
|
||||
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
|
||||
import SalesOrderFilterSummary from "@/pages/salesOrder/components/SalesOrderFilterSummary.vue";
|
||||
import SalesOrderListCell from "@/pages/salesOrder/components/SalesOrderListCell.vue";
|
||||
import SalesOrderSummary from "@/pages/salesOrder/components/SalesOrderSummary.vue";
|
||||
import { useCurrentStoreStore } from "@/store/currentStoreStore";
|
||||
import { useNavBarStore } from "@/store/navBarStore";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
import type { GaoPackageConfig } from "@/types/Package";
|
||||
import type {
|
||||
GaoSalesOrderStatus,
|
||||
@@ -138,6 +189,17 @@ import { events, isCurrentStoreEvent, listDataEventKeys, type ListDataChangedPay
|
||||
import { Message } from "@/utils/message";
|
||||
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
|
||||
|
||||
const pageNavBarActionVisible = ref(false);
|
||||
const pageNavBarActionList = computed<NavBarAction[]>(() => (unref(actions) as NavBarAction[]).filter(action => action.visible !== false));
|
||||
|
||||
async function handlePageNavBarAction(action: NavBarAction): Promise<void> {
|
||||
pageNavBarActionVisible.value = false;
|
||||
await action.action();
|
||||
}
|
||||
|
||||
import SalesOrderFilterPopup from "@/pages/salesOrder/components/SalesOrderFilterPopup.vue";
|
||||
import type { Customer } from "@/types/Customer";
|
||||
|
||||
defineOptions({ name: "SalesOrderList" });
|
||||
|
||||
const SALES_ORDER_FILTER_STORAGE_KEY = "gao-customer-h5:sales-order-filter";
|
||||
@@ -145,7 +207,6 @@ const route = useRoute();
|
||||
const router = useRouter();
|
||||
const salesOrderListRef = ref<HTMLElement | null>(null);
|
||||
const currentStoreStore = useCurrentStoreStore();
|
||||
const navBarStore = useNavBarStore();
|
||||
const userStore = useUserStore();
|
||||
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.create));
|
||||
const canCreatePackageOrder = computed(() => userStore.hasPermissions(permissionCodes.customerPackage.create));
|
||||
@@ -701,8 +762,7 @@ watch(() => currentStoreStore.currentStoreId, async (value, oldValue) => {
|
||||
onMounted(async () => {
|
||||
unregisterSalesOrderListEvent = events.register(listDataEventKeys.salesOrderChanged, (payload: ListDataChangedPayload) => requestEventRefresh(payload));
|
||||
syncCachedRouteContext();
|
||||
navBarStore.clearRight();
|
||||
navBarStore.setCustomRightVisible(!!actions.value.length);
|
||||
|
||||
applyRouteFilters();
|
||||
lastAppliedRouteFilterKey = routeFilterKey.value;
|
||||
try {
|
||||
@@ -731,8 +791,7 @@ onActivated(async () => {
|
||||
} else {
|
||||
restorePageScrollPosition();
|
||||
}
|
||||
navBarStore.clearRight();
|
||||
navBarStore.setCustomRightVisible(!!actions.value.length);
|
||||
|
||||
});
|
||||
|
||||
onDeactivated(() => {
|
||||
@@ -740,7 +799,6 @@ onDeactivated(() => {
|
||||
savePageScrollPosition();
|
||||
}
|
||||
filterVisible.value = false;
|
||||
navBarStore.clearRight();
|
||||
});
|
||||
|
||||
onBeforeRouteLeave(to => {
|
||||
@@ -756,7 +814,6 @@ onUnmounted(() => {
|
||||
isDisposed = true;
|
||||
unregisterSalesOrderListEvent?.();
|
||||
unregisterSalesOrderListEvent = undefined;
|
||||
navBarStore.clearRight();
|
||||
search.cancel();
|
||||
});
|
||||
</script>
|
||||
@@ -831,4 +888,46 @@ onUnmounted(() => {
|
||||
text-align: center;
|
||||
}
|
||||
}
|
||||
|
||||
.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>
|
||||
|
||||
Reference in New Issue
Block a user