support tablet

This commit is contained in:
Timi
2026-11-02 23:12:05 +08:00
parent c48b19bed5
commit d3879c9c77
123 changed files with 4153 additions and 2673 deletions
+46 -7
View File
@@ -1,13 +1,13 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="积分账户详情"
left-arrow
@left-click="$router.back()"
@left-click="goBack"
/>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.point.accountRead" class="point-account-detail">
<card-container v-if="customer" v-entrance-transition>
<customer-profile-card :customer="customer" />
@@ -54,6 +54,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
@@ -69,10 +70,45 @@ defineOptions({
name: "PointAccountDetail"
});
const props = withDefaults(defineProps<{
/** 指定账户 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
accountId?: string;
/** 内联时由列表页带上的门店 ID,整页时读 query。 */
storeId?: string;
}>(), {
accountId: "",
storeId: ""
});
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
function resolveId(): string {
return props.accountId || String(route.params.id || "");
}
function resolveStoreId(): string {
return props.storeId || String(route.query.storeId || currentStoreStore.currentStoreId || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/points/account",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
// ---------- 门店 ----------
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
@@ -87,7 +123,6 @@ async function prepareStoreScope(): Promise<void> {
// ---------- 账户 ----------
const accountId = String(route.params.id || "");
const customer = ref<Customer>();
const account = ref<PointAccountData>();
const isLoading = ref(false);
@@ -95,6 +130,7 @@ const isLoading = ref(false);
const balanceText = computed(() => formatPoints(account.value?.balance));
async function loadAccount(): Promise<void> {
const accountId = resolveId();
if (!accountId) {
customer.value = undefined;
account.value = undefined;
@@ -105,7 +141,7 @@ async function loadAccount(): Promise<void> {
try {
account.value = await PointAPI.detail(
accountId,
String(route.query.storeId || currentStoreStore.currentStoreId || "")
resolveStoreId()
);
if (!account.value) {
customer.value = undefined;
@@ -180,14 +216,17 @@ function formatSignedPoints(value?: number): string {
return pointValue < 0 ? `扣除 ${formatWanInteger(Math.abs(pointValue))} 分` : `增加 ${formatWanInteger(pointValue)} 分`;
}
onMounted(async () => {
async function reload(): Promise<void> {
try {
await prepareStoreScope();
await loadAccount();
} catch {
Message.error("积分账户页面加载失败");
}
});
}
onMounted(reload);
watch(() => [props.accountId, route.params.id], reload);
</script>
<style scoped lang="less">
+82 -65
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar point-account-list">
<div class="tui-page-layout tui-navbar point-account-list">
<t-navbar
fixed
:z-index="20"
@@ -7,67 +7,85 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.point.accountRead" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="customer"
placeholder="搜索客户编码、姓名(拼音)"
borderless
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
</div>
<div class="list-wrap">
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:customer="item.customer"
class="item"
arrow
hover
@click="toDetail(item)"
<master-detail-page
v-can="permissionCodes.point.accountRead"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="customer"
placeholder="搜索客户编码、姓名(拼音)"
borderless
>
<template #description>
<span>余额:</span>
<span
class="balance"
:class="getBalanceTheme(item.balance)"
v-text="formatPoints(item.balance)" />
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</customer-cell>
</t-cell-group>
<center-tips :content="loadStateText" />
</div>
</t-pull-down-refresh>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
</main>
</t-input>
</div>
<div class="list-wrap">
<t-cell-group v-if="pageResult.list.length" class="list" theme="card">
<customer-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:customer="item.customer"
class="item"
arrow
hover
@click="toDetail(item)"
>
<template #description>
<span>余额:</span>
<span
class="balance"
:class="getBalanceTheme(item.balance)"
v-text="formatPoints(item.balance)" />
</template>
</customer-cell>
</t-cell-group>
<center-tips :content="loadStateText" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<point-account-detail
:key="`detail-${selectedId}`"
:account-id="selectedId"
:store-id="selectedStoreId"
/>
</template>
</master-detail-page>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
@change="handleCustomerChange"
/>
</div>
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { type PageResult, useUserStore } from "timi-web-api";
import PointAccountDetail from "@/pages/point/PointAccountDetail.vue";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
@@ -81,7 +99,12 @@ defineOptions({
name: "PointAccountList"
});
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;积分账户没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/points/account",
detail: id => `/management/points/account/${id}`
});
const selectedStoreId = ref("");
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -217,14 +240,8 @@ function getBalanceTheme(value?: number): string {
// ---------- 导航 ----------
async function toDetail(item: PointAccount): Promise<void> {
if (!item.id) {
return;
}
await router.push({
name: "PointAccountDetail",
params: { id: item.id },
query: item.storeId ? { storeId: item.storeId } : undefined
});
selectedStoreId.value = item.storeId || "";
openDetail(item.id || "");
}
// ---------- 生命周期 ----------
@@ -257,7 +274,7 @@ onMounted(async () => {
<style scoped lang="less">
.point-account-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
+1 -1
View File
@@ -244,7 +244,7 @@ onMounted(async () => {
<style scoped lang="less">
.point-adjust {
padding: calc(var(--app-nav-height)) 0 5rem;
padding: calc(var(--tui-nav-height)) 0 5rem;
.form {
margin: 1rem;
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-if="customer" v-can="permissionCodes.point.ledgerRead" class="point-ledger-detail">
<customer-profile-card
class="customer-profile"
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar point-ledger-list">
<div class="tui-page-layout tui-navbar point-ledger-list">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.point.ledgerRead" class="page-content scroll column list">
<main v-can="permissionCodes.point.ledgerRead" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
@@ -485,7 +485,7 @@ onUnmounted(() => {
<style scoped lang="less">
.point-ledger-list {
display: flex;
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
flex-direction: column;
+44 -4
View File
@@ -1,11 +1,11 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
@left-click="exit()"
>
<template #right>
<t-button
@@ -17,7 +17,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.pointRedeemSku.manage" class="redeem-sku-edit">
<t-form class="form card" v-entrance-transition>
<product-select-form-item
@@ -77,6 +77,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import PointAPI from "@/api/PointAPI";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
import type { ProductSelection } from "@/types/Product";
@@ -88,9 +89,22 @@ import { permissionCodes } from "@/utils/permission";
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
defineOptions({ name: "PointRedeemSkuEdit" });
const props = withDefaults(defineProps<{
/** 指定兑换配置 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
skuConfigId?: string;
}>(), {
skuConfigId: ""
});
const route = useRoute();
const currentId = computed(() => props.skuConfigId || String(route.params.id || ""));
const routeNavBarTitle = computed(() => {
// 内联时路由停在列表页,标题不能只看 route.name
if (props.skuConfigId) {
return "编辑兑换商品";
}
switch (route.name) {
case "PointRedeemSkuCreate":
return "新增兑换商品";
@@ -101,6 +115,24 @@ const routeNavBarTitle = computed(() => {
}
});
const router = useRouter();
// 竖屏整页编辑转横屏:回到分栏,右栏直接是编辑视图
useExpandToMaster({
path: "/management/points/redeem-skus",
id: () => (route.name === "PointRedeemSkuCreate" ? "" : currentId.value)
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
/** 取消/保存后回到上一层:分栏时通知列表页,否则走路由返回 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const selection = ref<{ skuId: string; skuUnitId: string }>();
const statusVisible = ref(false);
const statusDraft = ref<Array<string | number>>(["DRAFT"]);
@@ -148,7 +180,7 @@ function confirmStatus(value: Array<string | number>): void {
}
async function load(): Promise<void> {
const id = String(route.params.id || "");
const id = currentId.value;
if (!id) {
return;
}
@@ -194,6 +226,10 @@ async function save(): Promise<void> {
await PointAPI.redeemSkuCreate(data);
}
Message.success("兑换配置已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace({ name: "PointRedeemSkuList" });
} catch (error) {
Message.error(getErrorMessage(error, "兑换配置保存失败"));
@@ -210,6 +246,10 @@ async function remove(): Promise<void> {
try {
await PointAPI.redeemSkuRemove(form.id);
Message.success("兑换配置已标记删除");
if (pane) {
pane.close(true);
return;
}
await router.replace({ name: "PointRedeemSkuList" });
} catch (error) {
Message.error(getErrorMessage(error, "兑换配置删除失败"));
+89 -72
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar redeem-sku-list">
<div class="tui-page-layout tui-navbar redeem-sku-list">
<t-navbar
fixed
:z-index="20"
@@ -18,80 +18,92 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.pointRedeemSku.manage" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称、编码或 SKU"
/>
</div>
<t-cell-group v-if="result.list.length" theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toEdit(item)"
>
<template #left-icon>
<t-image
v-if="getProductPhoto(item)"
:src="getProductPhoto(item)"
:alt="item.product?.name || item.sku?.name || '产品图片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
/>
</template>
<template #title>
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
</template>
<template #note>
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'default'"
:content="statusText(item.status)"
<master-detail-page
v-can="permissionCodes.pointRedeemSku.manage"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索产品名称、编码或 SKU"
/>
</div>
<t-cell-group v-if="result.list.length" theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toEdit(item)"
>
<template #left-icon>
<t-image
v-if="getProductPhoto(item)"
:src="getProductPhoto(item)"
:alt="item.product?.name || item.sku?.name || '产品图片'"
fit="cover"
class="avatar"
/>
<product-sku-tags
:product-name="item.product?.name"
:fallback="item.sku?.specSummary || item.sku?.name || '默认 SKU'"
:unit="item.unit?.name"
<div
v-else
class="avatar fallback"
v-text="(item.product?.name || item.sku?.name || '产').slice(0, 1)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else :description="isLoading ? '正在加载兑换配置' : '暂无兑换配置'" />
<div class="tips" v-text="isNoMore ? `共 ${result.total} 条配置` : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</template>
<template #title>
<span class="clip-text" v-text="item.product?.name || item.sku?.name || '未命名产品'" />
</template>
<template #note>
<span class="orange keep-text" v-text="formatPoint(item.defaultPointCost)" />
</template>
<template #description>
<div class="description">
<t-tag
size="small"
:theme="item.status === 'ACTIVE' ? 'success' : 'default'"
:content="statusText(item.status)"
/>
<product-sku-tags
:product-name="item.product?.name"
:fallback="item.sku?.specSummary || item.sku?.name || '默认 SKU'"
:unit="item.unit?.name"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-empty v-else :description="isLoading ? '正在加载兑换配置' : '暂无兑换配置'" />
<div class="tips" v-text="isNoMore ? `共 ${result.total} 条配置` : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #detail>
<point-redeem-sku-edit :key="`edit-${selectedId}`" :sku-config-id="selectedId" />
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { Toolkit } from "timi-web";
import PointAPI from "@/api/PointAPI";
import PointRedeemSkuEdit from "@/pages/point/PointRedeemSkuEdit.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import { Message } from "@/utils/message";
import { formatWanInteger } from "@/utils/money";
@@ -101,6 +113,13 @@ import { permissionCodes } from "@/utils/permission";
import type { PointRedeemSku, PointRedeemSkuStatus } from "@/types/Point";
defineOptions({ name: "PointRedeemSkuList" });
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里;兑换商品没有独立的详情视图,选中即进编辑
const { selectedId, isWide, paneDirection, openDetail } = useMasterDetailPane({
path: "/management/points/redeem-skus",
detail: id => `/management/points/redeem-skus/${id}/edit`
});
const router = useRouter();
const result = reactive({ total: 0, list: [] as PointRedeemSku[] });
const keyword = shallowRef("");
@@ -180,10 +199,8 @@ async function toCreate(): Promise<void> {
await router.push({ name: "PointRedeemSkuCreate" });
}
async function toEdit(item: PointRedeemSku): Promise<void> {
if (item.id) {
await router.push({ name: "PointRedeemSkuEdit", params: { id: item.id } });
}
function toEdit(item: PointRedeemSku): void {
openDetail(item.id || "");
}
onMounted(async () => {
@@ -204,7 +221,7 @@ onUnmounted(() => {
.redeem-sku-list {
gap: 1rem;
display: flex;
padding: var(--app-nav-height) 0 5rem;
padding: var(--tui-nav-height) 0 5rem;
flex-direction: column;
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
@@ -17,7 +17,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.pointRedemption.create" class="redemption-create">
<t-form class="form card" label-width="7rem" v-entrance-transition>
<t-form-item label="客户" required-mark>
+36 -5
View File
@@ -1,13 +1,13 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="兑换详情"
left-arrow
@left-click="$router.back()"
@left-click="goBack"
/>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.pointRedemption.create" class="redemption-detail">
<customer-profile-card
v-if="customer"
@@ -80,7 +80,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
@@ -99,7 +99,37 @@ import { permissionCodes } from "@/utils/permission";
defineOptions({ name: "PointRedemptionDetail" });
const props = withDefaults(defineProps<{
/** 指定 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
redemptionId?: string;
}>(), {
redemptionId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.redemptionId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/points/redemptions",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const item = ref<PointRedemption>();
const customer = ref<Customer>();
@@ -132,7 +162,7 @@ function remaining(): string {
}
async function load(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -223,6 +253,7 @@ function timeText(value?: number): string {
}
onMounted(load);
watch(() => [props.redemptionId, route.params.id], load);
</script>
<style scoped lang="less">
+152 -132
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar redemption-list">
<div class="tui-page-layout tui-navbar redemption-list">
<t-navbar
fixed
:z-index="20"
@@ -18,136 +18,150 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.pointRedemption.create" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
clearable
borderless
placeholder="搜索客户、产品或 SKU"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</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
:label="skuLabel || '全部产品'"
:options="[]"
@open="openSkuSelector"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<t-cell-group v-if="skuId" theme="card">
<t-cell title="清除产品筛选" arrow @click="clearSku" />
</t-cell-group>
<t-cell-group v-if="skuId && canManageSku" theme="card">
<t-cell title="累计兑换基础数量" :note="stats ? quantityText(stats.redeemedBaseQuantityTotal) : '—'" />
<t-cell title="累计退货基础数量" :note="stats ? quantityText(stats.returnedBaseQuantityTotal) : '—'" />
<t-cell title="净兑换基础数量" :note="stats ? quantityText(stats.netRedeemedBaseQuantityTotal) : '—'" />
<t-cell description="统计按 SKU 基础单位计算,不受客户、时间及分页筛选影响" />
</t-cell-group>
<t-cell-group class="date-summary" theme="card" v-entrance-transition>
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<t-cell title="兑换次数" :note="`${Text.display(result.total)} 次`" />
</t-cell-group>
<div v-if="result.list.length" class="items">
<t-cell-group theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #left-icon>
<t-image
v-if="getCustomerPhoto(item)"
:src="getCustomerPhoto(item)"
:alt="item.customer?.name || '客户照片'"
fit="cover"
class="avatar"
<master-detail-page
v-can="permissionCodes.pointRedemption.create"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="load"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
clearable
borderless
placeholder="搜索客户、产品或 SKU"
>
<template #suffix-icon>
<div class="actions">
<t-button
v-if="customerId"
shape="circle"
theme="danger"
variant="text"
size="extra-small"
aria-label="清除客户选择"
@click.stop="clearCustomer"
>
<t-icon name="close" size="1rem" />
</t-button>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
<div
v-else
class="avatar fallback"
v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong v-text="item.productNameSnapshot || item.skuNameSnapshot || '未命名产品'" />
<t-tag
size="small"
:theme="item.status === 'FULLY_RETURNED' ? 'default' : 'success'"
:content="statusText(item.status)"
/>
</div>
</template>
<template #note>
<span class="orange" v-text="formatPoint(item.actualPointCost)" />
</template>
<template #description>
<span v-text="`${item.customer?.name || item.customerId || '未知客户'} · ${quantityText(item.quantity)} ${item.unitSnapshot || ''}`" />
</template>
</t-cell>
</t-cell-group>
</div>
</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
:label="skuLabel || '全部产品'"
:options="[]"
@open="openSkuSelector"
/>
</t-dropdown-menu>
</div>
<t-empty
v-else
:description="loading ? '正在加载兑换记录' : hasFilter ? '未找到匹配的兑换记录' : '暂无兑换记录'"
/>
</div>
</t-pull-down-refresh>
</main>
<div class="list-wrap">
<t-cell-group v-if="skuId" theme="card">
<t-cell title="清除产品筛选" arrow @click="clearSku" />
</t-cell-group>
<t-cell-group v-if="skuId && canManageSku" theme="card">
<t-cell title="累计兑换基础数量" :note="stats ? quantityText(stats.redeemedBaseQuantityTotal) : '—'" />
<t-cell title="累计退货基础数量" :note="stats ? quantityText(stats.returnedBaseQuantityTotal) : '—'" />
<t-cell title="净兑换基础数量" :note="stats ? quantityText(stats.netRedeemedBaseQuantityTotal) : '—'" />
<t-cell description="统计按 SKU 基础单位计算,不受客户、时间及分页筛选影响" />
</t-cell-group>
<t-cell-group class="date-summary" theme="card" v-entrance-transition>
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<t-cell title="兑换次数" :note="`${Text.display(result.total)} 次`" />
</t-cell-group>
<div v-if="result.list.length" class="items">
<t-cell-group theme="card">
<t-cell
v-for="item in result.list"
:key="item.id"
class="item"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #left-icon>
<t-image
v-if="getCustomerPhoto(item)"
:src="getCustomerPhoto(item)"
:alt="item.customer?.name || '客户照片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.customer?.name || item.customer?.code || '客').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong v-text="item.productNameSnapshot || item.skuNameSnapshot || '未命名产品'" />
<t-tag
size="small"
:theme="item.status === 'FULLY_RETURNED' ? 'default' : 'success'"
:content="statusText(item.status)"
/>
</div>
</template>
<template #note>
<span class="orange" v-text="formatPoint(item.actualPointCost)" />
</template>
<template #description>
<span v-text="`${item.customer?.name || item.customerId || '未知客户'} · ${quantityText(item.quantity)} ${item.unitSnapshot || ''}`" />
</template>
</t-cell>
</t-cell-group>
</div>
<t-empty
v-else
:description="loading ? '正在加载兑换记录' : hasFilter ? '未找到匹配的兑换记录' : '暂无兑换记录'"
/>
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<point-redemption-detail
:key="`detail-${selectedId}`"
:redemption-id="selectedId"
/>
</template>
</master-detail-page>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@@ -183,7 +197,9 @@
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { type DropdownValue } from "tdesign-mobile-vue";
import PointRedemptionDetail from "@/pages/point/PointRedemptionDetail.vue";
import { Text, Time, Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
@@ -206,6 +222,12 @@ defineOptions({ name: "PointRedemptionList" });
const route = useRoute();
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;兑换单没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/points/redemptions",
detail: id => `/management/points/redemptions/${id}`
});
const userStore = useUserStore();
const result = reactive({ total: 0, list: [] as PointRedemption[] });
const keyword = ref(getQueryText(route.query.keyword));
@@ -459,9 +481,7 @@ async function toCreate(): Promise<void> {
}
async function toDetail(item: PointRedemption): Promise<void> {
if (item.id) {
await router.push({ name: "PointRedemptionDetail", params: { id: item.id } });
}
openDetail(item.id || "");
}
onMounted(async () => {
+51 -7
View File
@@ -1,11 +1,11 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
title="积分规则详情"
left-arrow
@left-click="$router.back()"
@left-click="goBack"
>
<template #right>
<t-button
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.pointRule.read" class="point-rule-detail">
<section v-if="rule" class="rule-header" v-entrance-transition>
<div class="point-icon" :class="{ consume: isConsumeRule }">
@@ -112,7 +112,7 @@
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { CodeEditor } from "timi-tdesign-mobile";
import { CodeEditor, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { MarkdownView, Text, Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
@@ -134,8 +134,41 @@ defineOptions({
name: "PointRuleDetail"
});
const props = withDefaults(defineProps<{
/** 指定 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
ruleId?: string;
}>(), {
ruleId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.ruleId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/points/rules",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -181,7 +214,7 @@ async function loadOptionalEvent(eventId: string, message: string): Promise<Even
}
async function loadRule(): Promise<void> {
const ruleId = String(route.params.id || "");
const ruleId = resolveId();
if (!ruleId) {
rule.value = undefined;
event.value = undefined;
@@ -285,6 +318,10 @@ async function removeRule(): Promise<void> {
try {
await PointAPI.ruleRemove(ruleId);
Message.success("积分规则已删除");
if (pane) {
pane.close();
return;
}
await router.replace("/management/points/rules");
} catch (error) {
Message.error(getErrorMessage(error, "积分规则删除失败"));
@@ -297,10 +334,17 @@ async function removeRule(): Promise<void> {
async function toEdit(): Promise<void> {
const ruleId = String(route.params.id || "");
const ruleId = resolveId();
if (!canUpdate.value || !ruleId) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push({
name: "PointRuleEdit",
params: { id: ruleId },
@@ -319,7 +363,7 @@ async function toEventDetail(): Promise<void> {
});
}
watch(() => route.params.id, async () => {
watch(() => [props.ruleId, route.params.id], async () => {
await loadRule();
}, { immediate: true });
+42 -4
View File
@@ -1,11 +1,11 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
:title="routeNavBarTitle"
left-arrow
@left-click="$router.back()"
@left-click="exit()"
>
<template #right>
<t-button
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="pageAccess" class="point-rule-edit">
<t-form class="form card" label-width="7rem">
<card-container v-entrance-transition>
@@ -161,6 +161,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
@@ -187,9 +188,21 @@ defineOptions({
name: "PointRuleEdit"
});
const props = withDefaults(defineProps<{
/** 指定积分规则 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
ruleId?: string;
}>(), {
ruleId: ""
});
const route = useRoute();
const currentId = computed(() => props.ruleId || String(route.params.id || ""));
const routeNavBarTitle = computed(() => {
// 内联时路由停在列表页,标题不能只看 route.name
if (props.ruleId) {
return "编辑积分规则";
}
switch (route.name) {
case "PointRuleCreate":
return "新增积分规则";
@@ -200,9 +213,30 @@ const routeNavBarTitle = computed(() => {
}
});
const router = useRouter();
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项
useExpandToMaster({
path: "/management/points/rules",
id: () => (route.name === "PointRuleCreate" ? "" : currentId.value),
query: { view: "edit" }
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
/** 取消/保存后回到上一层:分栏时通知列表页,否则走路由返回 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
const routeId = currentId;
const isCreateMode = computed(() => !routeId.value);
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.pointRule.create : permissionCodes.pointRule.update);
@@ -529,6 +563,10 @@ async function saveRule(): Promise<void> {
await PointAPI.ruleUpdate(payload);
}
Message.success("积分规则已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace("/management/points/rules");
} catch (error) {
Message.error(getErrorMessage(error, "积分规则保存失败"));
+97 -70
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar point-rule-list">
<div class="tui-page-layout tui-navbar point-rule-list">
<t-navbar
fixed
:z-index="20"
@@ -11,83 +11,102 @@
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.pointRule.read" class="page-content scroll column list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<div class="filters">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索积分规则名称"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="statusFilter"
label="规则状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="pageResult.list.length"
class="list empty-cell-title-margin"
theme="card"
<master-detail-page
v-can="permissionCodes.pointRule.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="load"
>
<t-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
<div class="filters">
<t-input
v-model.trim="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索积分规则名称"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="statusFilter"
label="规则状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="pageResult.list.length"
class="list empty-cell-title-margin"
theme="card"
>
<template #left-icon>
<div class="point" :class="{ 'consume': item.pointValue && item.pointValue < 0 }">
<t-icon name="money" />
<span v-text="getPointText(item)" />
</div>
</template>
<template #title>
<div class="title">
<h4 class="text" v-text="item.name || '未命名规则'" />
<t-tag
:theme="getStatusTheme(item.status)"
variant="light-outline"
:content="getStatusText(item.status)"
/>
</div>
</template>
<template #description>
<div class="description">
<div v-text="`触发来源:${getTriggerSourceText(item)}`"></div>
<div v-text="`触发对象:${getTriggerRefText(item)}`"></div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
<t-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
:arrow="!!item.id"
:hover="!!item.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #left-icon>
<div class="point" :class="{ 'consume': item.pointValue && item.pointValue < 0 }">
<t-icon name="money" />
<span v-text="getPointText(item)" />
</div>
</template>
<template #title>
<div class="title">
<h4 class="text" v-text="item.name || '未命名规则'" />
<t-tag
:theme="getStatusTheme(item.status)"
variant="light-outline"
:content="getStatusText(item.status)"
/>
</div>
</template>
<template #description>
<div class="description">
<div v-text="`触发来源:${getTriggerSourceText(item)}`"></div>
<div v-text="`触发对象:${getTriggerRefText(item)}`"></div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<point-rule-edit v-if="editing" :key="`edit-${selectedId}`" :rule-id="selectedId" />
<point-rule-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:rule-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { type DropdownValue } from "tdesign-mobile-vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { Toolkit } from "timi-web";
import EventAPI from "@/api/EventAPI";
import PointAPI from "@/api/PointAPI";
import PointRuleDetail from "@/pages/point/PointRuleDetail.vue";
import PointRuleEdit from "@/pages/point/PointRuleEdit.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import type { PointRule, PointRuleStatus } from "@/types/Point";
import { formatWanInteger } from "@/utils/money";
@@ -102,6 +121,14 @@ defineOptions({
});
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/points/rules",
detail: id => `/management/points/rules/${id}`,
edit: id => `/management/points/rules/${id}/edit`
});
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -324,7 +351,7 @@ async function toDetail(rule: PointRule): Promise<void> {
if (!rule.id) {
return;
}
await router.push(`/management/points/rules/${rule.id}`);
openDetail(rule.id || "");
}
async function preparePage(): Promise<void> {
@@ -354,10 +381,10 @@ onUnmounted(() => {
<style scoped lang="less">
.point-rule-list {
padding: calc(var(--app-nav-height) + 4rem) 0 1rem;
padding: calc(var(--tui-nav-height) + 4rem) 0 1rem;
.filter-menu {
top: var(--app-nav-height);
top: var(--tui-nav-height);
left: 0;
right: 0;
z-index: 10;
+1 -1
View File
@@ -135,7 +135,7 @@ onMounted(async () => {
<style scoped lang="less">
.point-rule-sort {
padding: calc(var(--app-nav-height) + 1rem) 0 6rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 6rem;
.tip {
color: #52607a;