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
+3
View File
@@ -142,3 +142,6 @@ components.d.ts
# 需要团队共享的结论请写入 AGENTS.md 或 .serena/memories/,不要放这里。
/.workbuddy/
# ---> 本地调试产物(CDP 截图、登录态、一次性脚本)
/.debug-tmp/
+2 -7
View File
@@ -15,11 +15,6 @@
"type-check": "vue-tsc -p tsconfig.app.json --noEmit",
"type-check:publish": "vue-tsc -p tsconfig.publish.json --noEmit"
},
"pnpm": {
"patchedDependencies": {
"tdesign-mobile-vue@1.16.0": "patches/tdesign-mobile-vue@1.16.0.patch"
}
},
"dependencies": {
"@zxing/browser": "^0.1.5",
"@zxing/library": "^0.21.3",
@@ -28,9 +23,9 @@
"echarts-wordcloud": "^2.1.0",
"less": "^4.3.0",
"pinia": "^3.0.2",
"tdesign-mobile-vue": "^1.16.2",
"timi-ts": "link:E:/WebProject/timi-ts",
"tdesign-mobile-vue": "^1.17.1",
"timi-tdesign-mobile": "link:E:/WebProject/timi-tdesign-mobile",
"timi-ts": "link:E:/WebProject/timi-ts",
"timi-web": "link:E:/WebProject/timi-web",
"timi-web-api": "link:E:/WebProject/timi-web-api",
"ts-node": "^10.9.2",
-153
View File
@@ -1,153 +0,0 @@
diff --git a/cjs/swiper/props.js b/cjs/swiper/props.js
index 5615922a8c3410f703f768e363d39afa3138e7b1..b9a192a32dba34970287d0521e7e2077ac5b034c 100644
--- a/cjs/swiper/props.js
+++ b/cjs/swiper/props.js
@@ -57,7 +57,7 @@ var props = {
default: true
},
navigation: {
- type: [Object, Function]
+ type: [Boolean, Object, Function]
},
nextMargin: {
type: [String, Number],
diff --git a/cjs/swiper/type.d.ts b/cjs/swiper/type.d.ts
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
--- a/cjs/swiper/type.d.ts
+++ b/cjs/swiper/type.d.ts
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
height?: string | number;
interval?: number;
loop?: boolean;
- navigation?: SwiperNavigation | TNode;
+ navigation?: boolean | SwiperNavigation | TNode;
nextMargin?: string | number;
previousMargin?: string | number;
onChange?: (current: number, context: {
diff --git a/es/shared/hover.mjs b/es/shared/hover.mjs
index 634ba6d66891d1c98d62c48d2069a0519a6633ed..20c84d3176f194afe1fa530d8db3a87b0faf2979 100644
--- a/es/shared/hover.mjs
+++ b/es/shared/hover.mjs
@@ -48,13 +48,15 @@ var Hover = {
current: state,
timers: [],
add: function add() {
- if (ctx.current.disabledHover || !ctx.current.className) return;
- if (!el.classList.contains(ctx.current.className)) {
- el.classList.add(ctx.current.className);
+ var current = ctx.current;
+ if (!current || current.disabledHover || !current.className) return;
+ if (!el.classList.contains(current.className)) {
+ el.classList.add(current.className);
}
},
remove: function remove() {
- if (ctx.current.className) el.classList.remove(ctx.current.className);
+ var current = ctx.current;
+ if (current && current.className) el.classList.remove(current.className);
},
clearTimers: function clearTimers() {
ctx.timers.forEach(function (t) {
@@ -63,18 +65,20 @@ var Hover = {
ctx.timers = [];
},
downHandler: function downHandler() {
- if (ctx.current.disabledHover) return;
+ var current = ctx.current;
+ if (!current || current.disabledHover) return;
ctx.clearTimers();
ctx.timers.push(window.setTimeout(function () {
ctx.add();
- }, ctx.current.startTime));
+ }, current.startTime));
},
upHandler: function upHandler() {
- if (ctx.current.disabledHover) return;
+ var current = ctx.current;
+ if (!current || current.disabledHover) return;
ctx.clearTimers();
ctx.timers.push(window.setTimeout(function () {
ctx.remove();
- }, ctx.current.stayTime));
+ }, current.stayTime));
},
cancelHandler: function cancelHandler() {
ctx.clearTimers();
diff --git a/es/swiper/props.mjs b/es/swiper/props.mjs
index a48cee3e0abe71c2ef1f3e83303ec061cb098f8d..27511b26df36116f59a27b584120ea71451d7bf0 100644
--- a/es/swiper/props.mjs
+++ b/es/swiper/props.mjs
@@ -53,7 +53,7 @@ var props = {
default: true
},
navigation: {
- type: [Object, Function]
+ type: [Boolean, Object, Function]
},
nextMargin: {
type: [String, Number],
diff --git a/es/swiper/type.d.ts b/es/swiper/type.d.ts
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
--- a/es/swiper/type.d.ts
+++ b/es/swiper/type.d.ts
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
height?: string | number;
interval?: number;
loop?: boolean;
- navigation?: SwiperNavigation | TNode;
+ navigation?: boolean | SwiperNavigation | TNode;
nextMargin?: string | number;
previousMargin?: string | number;
onChange?: (current: number, context: {
diff --git a/esm/swiper/props.js b/esm/swiper/props.js
index 1b4ac31d550b0cb1aac6cc0f4bca7590d6df16cb..c959b7eaa05bd34704bf724f77fe5be230dbb0ad 100644
--- a/esm/swiper/props.js
+++ b/esm/swiper/props.js
@@ -53,7 +53,7 @@ var props = {
default: true
},
navigation: {
- type: [Object, Function]
+ type: [Boolean, Object, Function]
},
nextMargin: {
type: [String, Number],
diff --git a/esm/swiper/type.d.ts b/esm/swiper/type.d.ts
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
--- a/esm/swiper/type.d.ts
+++ b/esm/swiper/type.d.ts
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
height?: string | number;
interval?: number;
loop?: boolean;
- navigation?: SwiperNavigation | TNode;
+ navigation?: boolean | SwiperNavigation | TNode;
nextMargin?: string | number;
previousMargin?: string | number;
onChange?: (current: number, context: {
diff --git a/lib/swiper/props.js b/lib/swiper/props.js
index 1b4ac31d550b0cb1aac6cc0f4bca7590d6df16cb..c959b7eaa05bd34704bf724f77fe5be230dbb0ad 100644
--- a/lib/swiper/props.js
+++ b/lib/swiper/props.js
@@ -53,7 +53,7 @@ var props = {
default: true
},
navigation: {
- type: [Object, Function]
+ type: [Boolean, Object, Function]
},
nextMargin: {
type: [String, Number],
diff --git a/lib/swiper/type.d.ts b/lib/swiper/type.d.ts
index f72d82f2902ebd0636c091450a0d77ae00964917..75b7920cb3e94fac6fc7c1ef909c6972128d06f3 100644
--- a/lib/swiper/type.d.ts
+++ b/lib/swiper/type.d.ts
@@ -10,7 +10,7 @@ export interface TdSwiperProps {
height?: string | number;
interval?: number;
loop?: boolean;
- navigation?: SwiperNavigation | TNode;
+ navigation?: boolean | SwiperNavigation | TNode;
nextMargin?: string | number;
previousMargin?: string | number;
onChange?: (current: number, context: {
+52
View File
@@ -0,0 +1,52 @@
diff --git a/es/shared/hover.mjs b/es/shared/hover.mjs
index 67b24bad56..c40589c034 100644
--- a/es/shared/hover.mjs
+++ b/es/shared/hover.mjs
@@ -49,13 +49,15 @@
hovered: false,
timers: [],
add: function add() {
- if (ctx.current.disabledHover || !ctx.current.className) return;
- if (!el.classList.contains(ctx.current.className)) {
- el.classList.add(ctx.current.className);
+ var current = ctx.current;
+ if (!current || current.disabledHover || !current.className) return;
+ if (!el.classList.contains(current.className)) {
+ el.classList.add(current.className);
}
},
remove: function remove() {
- if (ctx.current.className) el.classList.remove(ctx.current.className);
+ var current = ctx.current;
+ if (current && current.className) el.classList.remove(current.className);
},
clearTimers: function clearTimers() {
ctx.timers.forEach(function (t) {
@@ -64,21 +66,23 @@
ctx.timers = [];
},
downHandler: function downHandler() {
- if (ctx.current.disabledHover || ctx.hovered) return;
+ var current = ctx.current;
+ if (!current || current.disabledHover || ctx.hovered) return;
ctx.hovered = true;
ctx.clearTimers();
ctx.timers.push(window.setTimeout(function () {
ctx.add();
- }, ctx.current.startTime));
+ }, current.startTime));
},
upHandler: function upHandler() {
- if (ctx.current.disabledHover || !ctx.hovered) return;
+ var current = ctx.current;
+ if (!current || current.disabledHover || !ctx.hovered) return;
ctx.hovered = false;
ctx.clearTimers();
ctx.add();
ctx.timers.push(window.setTimeout(function () {
ctx.remove();
- }, ctx.current.stayTime));
+ }, current.stayTime));
},
cancelHandler: function cancelHandler() {
if (!ctx.hovered) return;
+11 -6
View File
@@ -4,6 +4,11 @@ settings:
autoInstallPeers: true
excludeLinksFromLockfile: false
patchedDependencies:
tdesign-mobile-vue@1.17.1:
hash: c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3
path: patches/tdesign-mobile-vue@1.17.1.patch
importers:
.:
@@ -30,8 +35,8 @@ importers:
specifier: ^3.0.2
version: 3.0.4(typescript@5.8.3)(vue@3.5.40(typescript@5.8.3))
tdesign-mobile-vue:
specifier: ^1.16.2
version: 1.16.2(vue@3.5.40(typescript@5.8.3))
specifier: ^1.17.1
version: 1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3))
timi-tdesign-mobile:
specifier: link:E:/WebProject/timi-tdesign-mobile
version: link:../timi-tdesign-mobile
@@ -1743,9 +1748,9 @@ packages:
peerDependencies:
vue: ^3.0.0
tdesign-mobile-vue@1.16.2:
resolution: {integrity: sha512-05lOApsyGeIFzlOuJvvm+P0o3h7FeHM9HsPcslRFPwOQXIZW1AvJhnvP7aon3mdFtUEFdeja6yq7uJB8Os4haQ==}
engines: {node: '>=12.0.0'}
tdesign-mobile-vue@1.17.1:
resolution: {integrity: sha512-gCmhaNCc2xhSkbITHiXnE/UGs6GHLe9LTE7T26ELOENC5Cqpa+j4KYU9wz6uqFV+Ro10RkG3DFikYHnq0gNN0A==}
engines: {node: '>=18.0.0'}
peerDependencies:
vue: ^3.2.6
@@ -3681,7 +3686,7 @@ snapshots:
'@babel/runtime': 7.29.7
vue: 3.5.40(typescript@5.8.3)
tdesign-mobile-vue@1.16.2(vue@3.5.40(typescript@5.8.3)):
tdesign-mobile-vue@1.17.1(patch_hash=c98db305008fbfd00046666ca890e1c6cb88257c0619418694689cddf8cd78c3)(vue@3.5.40(typescript@5.8.3)):
dependencies:
'@babel/runtime': 7.29.7
'@use-gesture/vanilla': 10.3.1
+2
View File
@@ -0,0 +1,2 @@
patchedDependencies:
tdesign-mobile-vue@1.17.1: patches/tdesign-mobile-vue@1.17.1.patch
+36 -62
View File
@@ -17,6 +17,20 @@ html {
}
html.theme-dark {
// TDesign 的深色变量挂在 :root[theme-mode='dark'] 上,项目用的是 html.theme-dark,
// 两者不匹配会让组件和页面骨架一直停在浅色,这里补齐基础色做桥接
--td-bg-color-page: #10161f;
--td-bg-color-container: #1a2230;
--td-bg-color-container-hover: #222c3c;
--td-component-border: rgba(255, 255, 255, .12);
--td-text-color-primary: rgba(255, 255, 255, .9);
--td-text-color-secondary: rgba(255, 255, 255, .55);
--td-text-color-placeholder: rgba(255, 255, 255, .35);
// 导航激活项在深色下需要压深,否则浅色胶囊压在深底上太刺眼
--tui-rail-active-background: rgba(15, 118, 110, .22);
--tui-tabbar-active-background: rgba(15, 118, 110, .22);
color-scheme: dark;
background: #10161f;
}
@@ -38,40 +52,14 @@ html.theme-dark body {
box-sizing: border-box;
}
.page-layout,
/**
* 页面骨架(tui-page-layout / tui-page-content / tui-navbar / tui-tabbar)由
* timi-tdesign-mobile 的 page-layout.less 提供,这里只保留业务侧约定。
*/
.tui-page-layout,
.main-layout {
color: var(--td-text-color-primary);
background: var(--td-bg-color-page);
min-height: 100vh;
box-sizing: border-box;
.page-content {
flex: 1;
inset: 0;
width: 100%;
display: flex;
overflow: hidden;
position: absolute;
min-height: 0;
padding-top: calc(env(safe-area-inset-top, 0px) + 48px + 1rem);
box-sizing: border-box;
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
flex-direction: column;
&.scroll {
overflow: auto;
-webkit-overflow-scrolling: touch;
}
&.column {
gap: 1rem;
display: flex;
flex-direction: column;
&.scroll > * {
flex-shrink: 0;
}
}
.tui-page-content {
.filters {
--td-search-bg-color: var(--tui-white);
@@ -113,6 +101,7 @@ html.theme-dark body {
}
}
// 列表页的滚动容器:外层分栏只管宽度,滚动交给它
.pull-refresh {
flex: 1;
min-height: 0;
@@ -136,40 +125,25 @@ html.theme-dark body {
}
}
&.navbar {
--app-nav-height: calc(env(safe-area-inset-top, 0px) + 48px);
/**
* 列表页的顶部间距必须落在真正的滚动容器上,内容才能穿进导航栏的毛玻璃层。
* 这类"业务语义"的约定放在项目侧,库只提供骨架和变量。
*
* 不要求 .scroll:分栏形态下内容区不滚动,滚动的是主栏里的列表容器,
* 但间距的落点一样,所以两种形态共用这一条。
*/
&.tui-navbar .tui-page-content {
.t-navbar__content {
color: var(--tui-black, #000);
overflow: visible;
box-shadow: 0 3px 8px rgba(0, 0, 0, .1);
background: rgba(250, 250, 250, .8);
backdrop-filter: blur(10px);
-webkit-backdrop-filter: blur(10px);
&.notice {
padding-top: var(--tui-nav-height);
}
&.tabbar {
&.list {
padding-top: 0;
padding-bottom: 0;
.page-content.scroll,
.page-content.column {
padding-bottom: 6rem;
}
}
.page-content.scroll {
&.notice {
padding-top: var(--app-nav-height);
}
&.list {
padding-top: 0;
padding-bottom: 0;
.pull-refresh {
padding-top: calc(var(--app-nav-height) + 1rem);
padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 1rem);
}
.pull-refresh {
padding-top: calc(var(--tui-nav-height) + 1rem);
}
}
}
+2 -1
View File
@@ -26,6 +26,7 @@
</template>
<script setup lang="ts">
import type { BaseTableCol, TableRowData } from "tdesign-mobile-vue";
import type { ProductStockPreviewItem } from "@/utils/productStock";
defineOptions({
@@ -36,7 +37,7 @@ defineProps<{
items: ProductStockPreviewItem[];
}>();
const columns = [
const columns: BaseTableCol<TableRowData>[] = [
{ colKey: "product", title: "产品", width: "40%", ellipsis: true },
{ colKey: "required", title: "需求", width: "20%", align: "right", cell: "required" },
{ colKey: "available", title: "可用", width: "20%", align: "right", cell: "available" },
+33 -73
View File
@@ -1,45 +1,26 @@
<template>
<div class="main-layout diselect">
<div class="content">
<page-transition
:keep-alive="shouldKeepAlive"
:page-background="globalUIStore.bodyBackground"
:page-class="pageClass"
:respect-reduced-motion="false"
/>
</div>
<t-tab-bar
v-model="tabVal"
:class="{ 'is-hidden': !tabBarStore.isShowing }"
class="tab-bar glass-white"
shape="round"
theme="tag"
:split="false"
:z-index="999"
:bordered="false"
:disabled="!tabBarStore.isShowing"
@change="onChangeTab"
>
<t-tab-bar-item
v-for="item in list"
:key="item.value"
class="item bg-transparent"
:value="item.value"
>
<span v-text="item.text"></span>
<template #icon>
<t-icon :name="item.icon" />
</template>
</t-tab-bar-item>
</t-tab-bar>
</div>
<app-shell
v-model="tabVal"
class="diselect"
:items="navList"
logo-text="糕"
tab-bar-float
:hide-nav="!tabBarStore.isShowing"
@change="onChangeTab"
>
<page-transition
:keep-alive="shouldKeepAlive"
:page-background="globalUIStore.bodyBackground"
:page-class="pageClass"
/>
</app-shell>
</template>
<script setup lang="ts">
import { AppShell, PageTransition, useLayout } from "timi-tdesign-mobile";
import { useGlobalUIStore } from "@/store/globalUI";
import { useTabBarStore } from "@/store/tabBarStore";
import { permissionCodes } from "@/utils/permission";
import { PageTransition } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api/store";
import type { RouteLocationNormalizedLoaded } from "vue-router";
@@ -49,6 +30,9 @@ const globalUIStore = useGlobalUIStore();
const tabBarStore = useTabBarStore();
const userStore = useUserStore();
/** 与 AppShell 内部的断点参数保持一致,用于判断页面是否需要底部留白。 */
const { railVisible } = useLayout({ tablet: true });
const cachedRouteNames = new Set(["EventRecordRank", "SalesOrderList", "ProductList", "ProductStockList", "ProductStockBatchSelect", "ProductStockBatchConfigure"]);
function shouldKeepAlive(sourceRoute: RouteLocationNormalizedLoaded): boolean {
@@ -99,6 +83,12 @@ const list = computed(() => tabList.filter(item => (
&& (!item.role || userStore.hasRoles(item.role, item.roleMode))
)));
const navList = computed(() => list.value.map(item => ({
value: item.value,
text: item.text,
icon: item.icon
})));
watch(() => route.path, (newPath: string) => {
tabVal.value = resolveTabValue(newPath);
}, { immediate: true });
@@ -161,48 +151,18 @@ const isTabBarPaddingNeeded = computed(() => {
return false;
}
// 左侧导航栏出现后底部不再有标签栏,页面不需要为它留白
if (railVisible.value) {
return false;
}
return route.meta.tabBarPadding !== false;
});
const pageClass = computed(() => ({
"page-layout": true,
navbar: true,
tabbar: isTabBarPaddingNeeded.value
"tui-page-layout": true,
"tui-navbar": true,
"tui-tabbar": isTabBarPaddingNeeded.value
}));
</script>
<style scoped lang="less">
.main-layout {
height: 100vh;
overflow: hidden;
position: relative;
.content {
height: 100%;
}
.tab-bar {
--td-tab-bar-height: 52px;
--td-tab-bar-active-bg: var(--td-brand-color-2);
bottom: 1rem;
opacity: 1;
transform: translateY(0);
transition: opacity 520ms, transform 520ms var(--tui-bezier);
pointer-events: auto;
backdrop-filter: blur(10px);
&.is-hidden {
opacity: 0;
pointer-events: none;
transform: translateY(calc(100% + 1rem));
}
.item {
margin: 4px 0;
padding: 0 4px;
}
}
}
</style>
+2 -1
View File
@@ -13,6 +13,7 @@ import { initializeTwaBridge } from "@/utils/twaBridge";
import { VEntranceTransition } from "timi-tdesign-mobile";
import timiWebStyle from "../../timi-web/src/assets/style/timi-web.less?inline";
import tdesignCustomStyle from "../../timi-tdesign-mobile/src/assets/style/tdesign-custom.less?inline";
import tuiLayoutStyle from "../../timi-tdesign-mobile/src/assets/style/page-layout.less?inline";
import "vue-virtual-scroller/dist/vue-virtual-scroller.css";
import "tdesign-mobile-vue/es/style/index.css";
@@ -33,7 +34,7 @@ function mountLibraryOverrideStyle(): void {
const style = document.createElement("style");
style.id = libraryOverrideStyleId;
style.textContent = `${timiWebStyle}\n${tdesignCustomStyle}`;
style.textContent = `${timiWebStyle}\n${tdesignCustomStyle}\n${tuiLayoutStyle}`;
document.head.append(style);
}
+1 -1
View File
@@ -341,7 +341,7 @@ onMounted(async () => {
<style scoped lang="less">
.shared-panel {
--ai-msg-padding-top: calc(var(--app-nav-height) + 1rem);
--ai-msg-padding-top: calc(var(--tui-nav-height) + 1rem);
:deep(.welcome) {
margin: auto 0;
@@ -272,7 +272,7 @@ watch(() => props.sessionKey, async () => {
.ai-conversation-list {
width: min(70vw, 24rem);
height: 100vh;
padding: calc(var(--app-nav-height) + .5rem) 0 calc(1rem + env(safe-area-inset-bottom, 0px));
padding: calc(var(--tui-nav-height) + .5rem) 0 calc(1rem + env(safe-area-inset-bottom, 0px));
display: flex;
overflow: auto;
position: relative;
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar customer-data-charts-page">
<div class="tui-page-layout tui-navbar customer-data-charts-page">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.stat.read" class="page-content scroll column">
<main v-can="permissionCodes.stat.read" class="tui-page-content scroll column">
<div class="filters glass">
<t-input
v-model="customerCode"
+44 -13
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-if="customer"
v-can="permissionCodes.customer.read"
@@ -166,10 +166,10 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Message } from "@/utils/message";
import { TimeLabel, Text } from "timi-web";
import { useUserStore, type Attachment } from "timi-web-api";
import { Text, TimeLabel } from "timi-web";
import { type Attachment, useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
import PointAPI from "@/api/PointAPI";
import TagAPI from "@/api/TagAPI";
@@ -189,19 +189,34 @@ import { getAttachmentReadURL, getAttachmentTypeText } from "@/utils/attachment"
import { normalizeBodyAreaValue } from "@/utils/customer";
import { corePermissionCodes, permissionCodes } from "@/utils/permission";
import { LunarCalendar } from "@/utils/LunarCalendar";
import type { BodyAreaValue, Customer } from "@/types/Customer";
defineOptions({
name: "CustomerDetail"
});
const props = withDefaults(defineProps<{
/** 指定客户 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
customerId?: string;
}>(), {
customerId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/customers",
id: () => String(route.params.id || "")
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
const userStore = useUserStore();
const isRemoving = ref(false);
@@ -346,7 +361,7 @@ function toggleBirthdateText(): void {
}
async function loadCustomer(): Promise<void> {
const id = String(route.params.id || "");
const id = props.customerId || String(route.params.id || "");
if (!id) {
customer.value = undefined;
customerTagList.value = [];
@@ -504,10 +519,26 @@ async function toPackageOrderList(): Promise<void> {
await toSalesOrderList("PACKAGE");
}
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
async function toEdit(): Promise<void> {
if (!customer.value?.id) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
const queryDepth = Array.isArray(route.query.transitionDepth) ? route.query.transitionDepth[0] : route.query.transitionDepth;
const depth = Number(queryDepth);
await router.push({
@@ -573,7 +604,7 @@ async function toCustomerDataCharts(): Promise<void> {
onMounted(async () => {
await loadCustomer();
});
watch(() => route.params.id, loadCustomer);
watch(() => [props.customerId, route.params.id], loadCustomer);
</script>
<style scoped lang="less">
+44 -14
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
@@ -19,7 +19,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="savePermissionCode" class="customer-edit">
<t-form class="form card" label-width="5rem" :disabled="isCustomerBound" v-entrance-transition>
<t-form-item label="客户编码">
@@ -232,7 +232,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { type Attachment, AttachmentAPI, useUserStore } from "timi-web-api";
import { Message } from "@/utils/message";
import CustomerAPI from "@/api/CustomerAPI";
@@ -262,21 +262,47 @@ defineOptions({
const route = useRoute();
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerCreate":
return "新增客户";
case "CustomerEdit":
return "编辑客户";
default:
return "";
}
const props = withDefaults(defineProps<{
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
customerId?: string;
}>(), {
customerId: ""
});
const router = useRouter();
const userStore = useUserStore();
const settingStore = useSettingStore();
const currentStoreStore = useCurrentStoreStore();
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
const pane = usePane();
const currentId = computed(() => props.customerId || String(route.params.id || ""));
const isCreateMode = computed(() => route.name === "CustomerCreate");
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项
useExpandToMaster({
path: "/management/customers",
id: () => (isCreateMode.value ? "" : currentId.value),
query: { view: "edit" }
});
/** 内联时路由仍是列表页,标题不能只看 route.name */
const routeNavBarTitle = computed(() => {
if (isCreateMode.value) {
return "新增客户";
}
return pane || route.name === "CustomerEdit" ? "编辑客户" : "";
});
/** 退出编辑:分栏时交回列表页,整页时回路由 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.customer.create : permissionCodes.customer.update);
const hasCustomerDeletePermission = computed(() => userStore.hasPermissions(permissionCodes.customer.delete));
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
@@ -515,7 +541,7 @@ async function prepareStoreScope(): Promise<void> {
async function loadDetail() {
await prepareStoreScope();
const id = String(route.params.id || "");
const id = currentId.value;
if (!id) {
customerTagList.value = [];
selectedTagIdList.value = [];
@@ -672,6 +698,10 @@ async function doSubmit(): Promise<void> {
}
await CustomerAPI.update(payload);
Message.success("保存成功");
if (pane) {
pane.close(true);
return;
}
const redirect = String(route.query.redirect || "");
if (redirect) {
await router.replace(redirect);
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar customer-invite-rank">
<div class="tui-page-layout tui-navbar customer-invite-rank">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.customer.read" class="page-content scroll column list">
<main v-can="permissionCodes.customer.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
@@ -180,7 +180,7 @@ onMounted(async () => {
<style scoped lang="less">
.customer-invite-rank {
gap: 1rem;
padding: calc(var(--app-nav-height) + 1rem) 0 2rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 2rem;
display: flex;
flex-direction: column;
@@ -240,7 +240,7 @@ onBeforeUnmount(() => {
.state {
gap: .75rem;
inset: var(--app-nav-height) 0 0;
inset: var(--tui-nav-height) 0 0;
display: flex;
position: absolute;
align-items: center;
@@ -252,7 +252,7 @@ onBeforeUnmount(() => {
gap: .25rem;
left: .75rem;
right: .75rem;
top: calc(var(--app-nav-height) + .75rem);
top: calc(var(--tui-nav-height) + .75rem);
padding: .5rem .75rem;
color: #52607a;
display: flex;
+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 list">
<main class="tui-page-content scroll column list">
<div class="pull-refresh">
<div v-can="permissionCodes.customer.read" class="customer-invitee-list">
<customer-profile-card
+148 -123
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar customer-list">
<div class="tui-page-layout tui-navbar customer-list">
<t-navbar
fixed
:z-index="20"
@@ -11,120 +11,127 @@
<navbar-actions :actions="actionList" :visible="canCreateCustomer" />
</template>
</t-navbar>
<main v-can="permissionCodes.customer.read" class="page-content scroll column 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
size="extra-small"
<master-detail-page
v-can="permissionCodes.customer.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<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
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="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>
<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)"
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"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<center-tips v-if="!pageResult.list.length" :content="isLoading ? '正在加载客户' : '暂无客户数据'" />
<center-tips v-if="pageResult.list.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
<customer-cell
class="cell"
:customer="item"
arrow
@click="openDetail(item.id || '')"
>
<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>
<center-tips v-if="!pageResult.list.length" :content="isLoading ? '正在加载客户' : '暂无客户数据'" />
<center-tips v-if="pageResult.list.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
<tag-selector
v-model="selectedTagIdList"
@@ -137,7 +144,21 @@
:loading="isRemoving"
@confirm="removeCustomer"
/>
</main>
</template>
<template #detail>
<customer-edit
v-if="editing"
:key="`edit-${selectedId}`"
:customer-id="selectedId"
/>
<customer-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:customer-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
</div>
<t-popup v-model="startVisible" placement="bottom">
@@ -174,6 +195,9 @@ import { Time, Toolkit } from "timi-web";
import { type Page, type PageResult, useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
import CodeScanner from "@/components/CodeScanner.vue";
import CustomerDetail from "@/pages/customer/CustomerDetail.vue";
import CustomerEdit from "@/pages/customer/CustomerEdit.vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import CustomerRemoveDialog from "@/pages/customer/component/CustomerRemoveDialog.vue";
import TagSelector from "@/components/TagSelector.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -193,6 +217,15 @@ const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const settingStore = useSettingStore();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/customers",
detail: id => `/management/customers/${id}`,
edit: id => `/management/customers/${id}/edit`
});
const isRefreshing = ref(false);
const isRemoving = ref(false);
const removeDialogVisible = ref(false);
@@ -423,13 +456,6 @@ async function toCreate(): Promise<void> {
});
}
async function toDetail(customer: Customer): Promise<void> {
if (!customer.id) {
return;
}
await router.push(`/management/customers/${customer.id}`);
}
// ---------- 删除客户 ----------
function openRemoveDialog(customer: Customer): void {
@@ -477,7 +503,6 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
<style scoped lang="less">
.customer-list {
.scanner-wrapper {
padding: .5rem 1rem 0;
}
@@ -489,7 +514,7 @@ function buildCreatedAtRange(): [number | undefined, number | undefined] {
padding: .5rem 1rem;
overflow: auto;
position: sticky;
top: calc(var(--app-nav-height) + 3.5rem);
top: calc(var(--tui-nav-height) + 3.5rem);
box-shadow: var(--td-shadow-1);
:deep(.t-tag) {
+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-can="permissionCodes.qrCode.create" class="qr-page">
<t-form class="form card" v-entrance-transition>
<t-form-item label="编码前缀">
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar data-export-page">
<div class="tui-page-layout tui-navbar data-export-page">
<t-navbar fixed :z-index="20" title="数据导出" left-arrow @left-click="$router.back()">
<template #right>
<t-button
@@ -13,7 +13,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<t-cell-group title="导出范围" theme="card" v-entrance-transition>
<t-cell title="时间范围" :note="dateFilterLabel" arrow @click="openDateFilterPicker" />
<t-cell title="导出附件">
+5 -4
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar data-export-stat-page">
<div class="tui-page-layout tui-navbar data-export-stat-page">
<t-navbar fixed :z-index="20" title="导出统计" left-arrow @left-click="router.back()">
<template #right>
<t-button
@@ -12,7 +12,7 @@
/>
</template>
</t-navbar>
<main v-if="request && stat" class="page-content scroll column content">
<main v-if="request && stat" class="tui-page-content scroll column content">
<t-cell-group title="统计范围" theme="card" v-entrance-transition>
<t-cell v-if="request.allTime" title="时间范围" note="全部时间" />
<template v-else>
@@ -47,6 +47,7 @@
</template>
<script setup lang="ts">
import type { BaseTableCol, TableRowData } from "tdesign-mobile-vue";
import DataExportAPI from "@/api/DataExportAPI";
import {
formatDataExportCount,
@@ -65,7 +66,7 @@ const dataExportStore = useDataExportStore();
const request = computed(() => dataExportStore.request);
const stat = computed(() => dataExportStore.stat);
const isTaskCreating = ref(false);
const moduleStatColumns = computed(() => [
const moduleStatColumns = computed<BaseTableCol<TableRowData>[]>(() => [
{ colKey: "module", title: "模块", fixed: "left" },
...(request.value?.includeAttachment
? [{ colKey: "recordAndAttachmentCount", title: "数据/附件" }]
@@ -73,7 +74,7 @@ const moduleStatColumns = computed(() => [
{ colKey: "businessEstimateSize", title: "业务大小", align: "right" },
...(request.value?.includeAttachment ? [{ colKey: "attachmentSize", title: "附件大小", align: "right" }] : []),
{ colKey: "estimateSize", title: "合计", align: "right" }
]);
] as BaseTableCol<TableRowData>[]);
const moduleStatTableData = computed(() => (stat.value?.moduleStatList || []).map(item => ({
module: getDataExportModuleLabel(item.module),
recordCount: formatDataExportCount(item.recordCount),
+2 -2
View File
@@ -1,7 +1,7 @@
<template>
<div class="page-layout navbar data-export-task-page">
<div class="tui-page-layout tui-navbar data-export-task-page">
<t-navbar fixed :z-index="20" title="导出任务" left-arrow @left-click="router.back()" />
<main v-if="task" class="page-content scroll column">
<main v-if="task" class="tui-page-content scroll column">
<t-cell-group
class="task-card"
title="导出任务"
+47 -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.event.read"
class="registration-event-detail"
@@ -143,7 +143,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Time, Text } from "timi-web";
import { type ModuleCode, type Role, RoleAPI, useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
@@ -165,6 +165,18 @@ defineOptions({
name: "EventDetail"
});
const props = withDefaults(defineProps<{
/** 指定事件 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
eventId?: string;
}>(), {
eventId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
@@ -172,6 +184,18 @@ const currentStoreStore = useCurrentStoreStore();
const moduleCode: ModuleCode = "GAO";
const defaultColor = "#2f88ff";
function resolveId(): string {
return props.eventId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/registration-events",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
// ---------- 权限与门店 ----------
const isDeletedEvent = computed(() => event.value?.status === "DELETED");
@@ -224,7 +248,7 @@ async function loadRoleOptions(): Promise<void> {
}
async function loadEvent(): Promise<void> {
const eventId = String(route.params.id || "");
const eventId = resolveId();
if (!eventId) {
event.value = undefined;
return;
@@ -374,10 +398,17 @@ function getCurrentRouteDepth(): number {
}
async function toEdit(): Promise<void> {
const eventId = String(route.params.id || "");
const eventId = resolveId();
if (!canUpdate.value || !eventId) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push({
name: "EventEdit",
params: { id: eventId },
@@ -385,7 +416,16 @@ async function toEdit(): Promise<void> {
});
}
watch(() => route.params.id, async () => {
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
watch(() => [props.eventId, route.params.id], async () => {
await loadEvent();
}, { immediate: true });
+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="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="event-edit">
<t-form class="form card" label-width="7rem" v-entrance-transition>
<t-form-item label="颜色">
@@ -252,6 +252,7 @@ import { Time } from "timi-web";
import { type ModuleCode, type Role, RoleAPI, useUserStore } from "timi-web-api";
import type { ColorObject } from "tdesign-mobile-vue";
import EventAPI from "@/api/EventAPI";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import EventOptionEditor from "@/pages/event/component/EventOptionEditor.vue";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
import { getErrorMessage } from "@/utils/error";
@@ -275,6 +276,45 @@ defineOptions({
const route = useRoute();
const props = withDefaults(defineProps<{
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
eventId?: string;
}>(), {
eventId: ""
});
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
const pane = usePane();
const routeId = computed(() => props.eventId || String(route.params.id || ""));
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
// 新增(EventCreate)没有可依附的选中项,不触发
useExpandToMaster({
path: "/management/registration-events",
id: () => routeId.value,
query: { view: "edit" }
});
/** 不可编辑时退回详情:分栏时只是把右栏切回详情,整页时才跳路由 */
async function exitToDetail(): Promise<void> {
if (pane) {
pane.close();
return;
}
await router.replace({ name: "EventDetail", params: { id: routeId.value } });
}
/** 退出编辑:分栏时交回列表页,整页时回路由 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "EventCreate":
@@ -282,13 +322,13 @@ const routeNavBarTitle = computed(() => {
case "EventEdit":
return "编辑登记事件";
default:
return "";
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
return pane ? "编辑登记事件" : "";
}
});
const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
const moduleCode: ModuleCode = "GAO";
const isCreateMode = computed(() => !routeId.value);
@@ -696,6 +736,10 @@ async function saveEventItem(): Promise<void> {
await EventAPI.updateOptionGroupList(formModel.id || routeId.value, prepareEventOptionGroupList(optionGroupList.value));
}
Message.success("登记事件已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace("/management/registration-events");
} catch (error) {
Message.error(getErrorMessage(error, "登记事件保存失败"));
@@ -724,12 +768,12 @@ async function fillForm(): Promise<void> {
const current = await EventAPI.detail(routeId.value);
if (current.status === "DELETED") {
Message.error("已删除登记事件不可编辑");
await router.replace({ name: "EventDetail", params: { id: routeId.value } });
await exitToDetail();
return;
}
if (current.bizType === "PACKAGE_PURCHASE" || current.bizType === "LEGACY_CONSUMPTION") {
Message.warning("退役事件仅支持历史查看,不能编辑");
await router.replace({ name: "EventDetail", params: { id: routeId.value } });
await exitToDetail();
return;
}
Object.assign(formModel, {
+103 -77
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar registration-event-list">
<div class="tui-page-layout tui-navbar registration-event-list">
<t-navbar
fixed
:z-index="20"
@@ -11,81 +11,99 @@
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main
<master-detail-page
v-can="{ value: [permissionCodes.event.read, permissionCodes.user.read], mode: 'and' }"
class="page-content scroll column list"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<t-cell-group class="fix-last-cell-line" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in visibleEventList"
:key="item.id"
class="item"
>
<t-cell
class="cell"
:arrow="!!item.id"
:hover="!!item.id"
@click="toEventItem(item)"
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<t-cell-group class="fix-last-cell-line" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in visibleEventList"
:key="item.id"
class="item"
>
<template #title>
<div class="header">
<div class="color" :style="{ background: item.color || defaultColor }" />
<div class="title" v-text="item.name || '未命名事件'" />
<t-tag
class="status"
:theme="getStatusTag(item).theme"
variant="outline"
:content="getStatusTag(item).text"
/>
<t-tag v-if="item.requirePhoto" theme="warning" variant="outline">需拍照</t-tag>
<t-tag v-if="item.requireVerification" theme="warning" variant="outline">需核销</t-tag>
<t-tag v-if="item.bizType === 'PACKAGE_PURCHASE'" theme="primary" variant="outline">套餐购买</t-tag>
<t-tag v-if="item.bizType === 'LEGACY_CONSUMPTION'" theme="default" variant="outline">历史消费</t-tag>
</div>
</template>
<template #description>
<div class="description">
<div class="line">
<span>可登记角色</span>
<t-tag
v-for="roleCode in item.roleCodeList"
:key="roleCode"
theme="primary"
variant="light-outline"
:content="getRoleName(roleCode)"
/>
<span v-if="!(item.roleCodeList || []).length" class="muted" v-text="'未配置'" />
</div>
<div class="line" v-text="getLimitText(item)" />
<div class="line" v-text="`${getEventBizTypeText(item.bizType)}|${getValueDefinitionText(item)}`" />
<div v-if="item.bizType === 'PACKAGE_PURCHASE'" class="line" v-text="`绑定套餐:${item.packageConfig?.name || '未配置'}`" />
</div>
</template>
</t-cell>
<template v-if="canDeleteEvent && item.status !== 'DELETED'" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingEventId === item.id"
@click.stop="openRemoveDialog(item)"
<t-cell
class="cell"
:arrow="!!item.id"
:hover="!!item.id"
@click="toEventItem(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<center-tips v-if="!visibleEventList.length" :content="emptyText" />
<center-tips v-if="visibleEventList.length" :content="isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<template #title>
<div class="header">
<div class="color" :style="{ background: item.color || defaultColor }" />
<div class="title" v-text="item.name || '未命名事件'" />
<t-tag
class="status"
:theme="getStatusTag(item).theme"
variant="outline"
:content="getStatusTag(item).text"
/>
<t-tag v-if="item.requirePhoto" theme="warning" variant="outline">需拍照</t-tag>
<t-tag v-if="item.requireVerification" theme="warning" variant="outline">需核销</t-tag>
<t-tag v-if="item.bizType === 'PACKAGE_PURCHASE'" theme="primary" variant="outline">套餐购买</t-tag>
<t-tag v-if="item.bizType === 'LEGACY_CONSUMPTION'" theme="default" variant="outline">历史消费</t-tag>
</div>
</template>
<template #description>
<div class="description">
<div class="line">
<span>可登记角色</span>
<t-tag
v-for="roleCode in item.roleCodeList"
:key="roleCode"
theme="primary"
variant="light-outline"
:content="getRoleName(roleCode)"
/>
<span v-if="!(item.roleCodeList || []).length" class="muted" v-text="'未配置'" />
</div>
<div class="line" v-text="getLimitText(item)" />
<div class="line" v-text="`${getEventBizTypeText(item.bizType)}|${getValueDefinitionText(item)}`" />
<div v-if="item.bizType === 'PACKAGE_PURCHASE'" class="line" v-text="`绑定套餐:${item.packageConfig?.name || '未配置'}`" />
</div>
</template>
</t-cell>
<template v-if="canDeleteEvent && item.status !== 'DELETED'" #right>
<t-button
class="delete"
theme="danger"
:loading="isRemoving && removingEventId === item.id"
@click.stop="openRemoveDialog(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<center-tips v-if="!visibleEventList.length" :content="emptyText" />
<center-tips v-if="visibleEventList.length" :content="isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #detail>
<event-edit
v-if="editing"
:key="`edit-${selectedId}`"
:event-id="selectedId"
/>
<event-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:event-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
<event-remove-dialog
v-model:visible="removeDialogVisible"
@@ -100,6 +118,9 @@
import type { NavbarAction } from "@/types/NavbarAction.ts";
import { Message } from "@/utils/message";
import { type Page, type PageResult, type Role, useUserStore } from "timi-web-api";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import EventDetail from "@/pages/event/EventDetail.vue";
import EventEdit from "@/pages/event/EventEdit.vue";
import EventAPI from "@/api/EventAPI";
import EventRemoveDialog from "@/pages/event/component/EventRemoveDialog.vue";
import ManagedUserAPI from "@/api/ManagedUserAPI";
@@ -119,6 +140,14 @@ const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/registration-events",
detail: id => `/management/registration-events/${id}`,
edit: id => `/management/registration-events/${id}/edit`
});
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
const eventListOptions = computed(() => ({ storeId: currentStoreStore.currentStoreId }));
const canCreateEvent = computed(() => userStore.hasPermissions(permissionCodes.event.create));
@@ -194,10 +223,7 @@ const notEffectiveStatusTag: StatusTag = { text: "未生效", theme: "default" }
const expiredStatusTag: StatusTag = { text: "已过期", theme: "danger" };
async function toEventItem(item: EventItem): Promise<void> {
if (!item.id) {
return;
}
await router.push(`/management/registration-events/${item.id}`);
openDetail(item.id || "");
}
// ---------- 删除 ----------
@@ -364,7 +390,7 @@ onUnmounted(() => {
<style scoped lang="less">
.registration-event-list {
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem 0;
.item {
+51 -6
View File
@@ -1,11 +1,11 @@
<template>
<div v-can="permissionCodes.eventRecord.read" class="page-layout navbar event-record-detail">
<div v-can="permissionCodes.eventRecord.read" class="tui-page-layout tui-navbar event-record-detail">
<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">
<customer-profile-card
v-entrance-transition
v-if="record?.customer"
@@ -121,6 +121,7 @@
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Text, TimeLabel } from "timi-web";
import { type Attachment, useUserStore } from "timi-web-api";
import EventRecordAPI from "@/api/EventRecordAPI";
@@ -146,10 +147,34 @@ defineOptions({
name: "EventRecordDetail"
});
const props = withDefaults(defineProps<{
/** 指定记录 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
recordId?: string;
}>(), {
recordId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
function resolveId(): string {
return props.recordId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/registration-event-records",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
// ---------- 记录数据 ----------
const record = ref<EventRecord>();
@@ -286,7 +311,7 @@ function parsePointLedgerChangeType(value: unknown): PointLedgerChangeType | und
// ---------- 页面数据 ----------
async function loadRecord(): Promise<void> {
const recordId = String(route.params.id || "");
const recordId = resolveId();
if (!recordId) {
record.value = undefined;
return;
@@ -375,6 +400,10 @@ async function removeRecord(id: string): Promise<void> {
try {
await EventRecordAPI.remove(id);
Message.success("登记记录已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "EventRecordList" });
} catch (error) {
const message = getErrorMessage(error, "登记记录删除失败");
@@ -391,13 +420,29 @@ async function removeRecord(id: string): Promise<void> {
// ---------- 导航 ----------
async function toEdit(): Promise<void> {
const recordId = String(route.params.id || "");
const recordId = resolveId();
if (!recordId || !canUpdateRecord.value) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push(`/management/registration-event-records/${recordId}/edit`);
}
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
async function toCustomerDetail(): Promise<void> {
const customerId = record.value?.customer?.id;
if (!customerId) {
@@ -434,7 +479,7 @@ function getCurrentRouteDepth(): number {
return Number(route.meta.depth ?? 0);
}
watch(() => route.params.id, async () => {
watch(() => [props.recordId, route.params.id], async () => {
await loadRecord();
}, { immediate: true });
+49 -6
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="registration-record-edit">
<t-form class="form card" v-entrance-transition>
<t-form-item label="客户" required-mark>
@@ -175,6 +175,7 @@
<script setup lang="ts">
import DateTimeNowPicker from "@/components/DateTimeNowPicker.vue";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import { Message } from "@/utils/message";
@@ -211,6 +212,44 @@ defineOptions({
const router = useRouter();
const route = useRoute();
const props = withDefaults(defineProps<{
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
recordId?: string;
}>(), {
recordId: ""
});
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
const pane = usePane();
const routeId = computed(() => props.recordId || String(route.params.id || ""));
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑
useExpandToMaster({
path: "/management/registration-event-records",
id: () => routeId.value,
query: { view: "edit" }
});
/** 退出编辑:分栏时交回列表页,整页时回路由 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
/** 不可编辑时退回详情:分栏时只是把右栏切回详情,整页时才跳路由 */
async function exitToDetail(): Promise<void> {
if (pane) {
pane.close();
return;
}
await router.replace({ name: "EventRecordDetail", params: { id: routeId.value } });
}
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerEventRecordCreate":
@@ -220,7 +259,8 @@ const routeNavBarTitle = computed(() => {
case "EventRecordEdit":
return "编辑登记事件记录";
default:
return "";
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
return pane ? "编辑登记事件记录" : "";
}
});
const settingStore = useSettingStore();
@@ -228,7 +268,6 @@ const userStore = useUserStore();
// ---------- 路由权限 ----------
const routeId = computed(() => String(route.params.id || ""));
const isEditMode = computed(() => !!routeId.value);
const pageAccess = computed(() => isEditMode.value ? permissionCodes.eventRecord.update : permissionCodes.eventRecord.create);
const saveButtonText = computed(() => isEditMode.value ? "保存" : "提交");
@@ -627,6 +666,10 @@ async function updateRecord(): Promise<void> {
attachmentList: buildPhotoAttachmentList()
});
Message.success("记录已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace(`/management/registration-event-records/${editingRecord.value.id}`);
}
// ---------- 页面数据 ----------
@@ -647,7 +690,7 @@ async function loadRecordForEdit(): Promise<void> {
const record = await EventRecordAPI.detail(routeId.value);
if (isRetiredEvent(record.event)) {
Message.warning("退役事件记录仅支持历史查看,不能编辑");
await router.replace({ name: "EventRecordDetail", params: { id: routeId.value } });
await exitToDetail();
return;
}
editingRecord.value = record;
+140 -106
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar registration-record-list">
<div class="tui-page-layout tui-navbar registration-record-list">
<t-navbar
fixed
:z-index="20"
@@ -11,111 +11,134 @@
<navbar-actions :actions="actionList" :visible="canCreateRecord" />
</template>
</t-navbar>
<main v-can="permissionCodes.eventRecord.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="filters glass">
<div class="search-date">
<t-input
v-model.trim="keyword"
class="search-input"
type="search"
borderless
placeholder="搜索客户、姓名拼音、编码、事件、备注、登记人"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<master-detail-page
v-can="permissionCodes.eventRecord.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reloadRecords"
@scrolltolower="loadRecords"
>
<div class="filters glass">
<div class="search-date">
<t-input
v-model.trim="keyword"
class="search-input"
type="search"
borderless
placeholder="搜索客户、姓名拼音、编码、事件、备注、登记人"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
</div>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="actionFilter"
:label="eventFilterLabel"
options-columns="2"
:options="actionOptions"
multiple
/>
<t-dropdown-item
v-model="verificationFilter"
:label="verificationFilterLabel"
:options="verificationOptions"
/>
<t-dropdown-item
v-model="optionFilter"
:label="optionFilterLabel"
:footer="!optionFilterOptions.length ? optionFilterUnavailableFooter : undefined"
options-columns="2"
:options="optionFilterOptions"
multiple
/>
</t-dropdown-menu>
</div>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="actionFilter"
:label="eventFilterLabel"
options-columns="2"
:options="actionOptions"
multiple
/>
<t-dropdown-item
v-model="verificationFilter"
:label="verificationFilterLabel"
:options="verificationOptions"
/>
<t-dropdown-item
v-model="optionFilter"
:label="optionFilterLabel"
:footer="!optionFilterOptions.length ? optionFilterUnavailableFooter : undefined"
options-columns="2"
:options="optionFilterOptions"
multiple
/>
</t-dropdown-menu>
</div>
<div class="list-wrapper">
<t-cell-group v-entrance-transition class="summary" theme="card">
<t-cell
title="登记时间"
:note="dateFilterLabel"
arrow
@click="openDateFilterPicker"
/>
<t-cell
v-if="dateFilterType === 'custom'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType === 'custom'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="事件" :note="eventFilterLabel" />
<t-cell v-if="optionFilterLabel !== '全部选项'" title="选项" :note="optionFilterLabel" />
<t-cell title="记录数" :note="Text.display(pageResult.total)" />
<t-cell title="客户数" :note="Text.display(pageResult.customerCount)" />
<t-cell v-if="summaryNumberValueText" title="数值合计" :note="summaryNumberValueText" />
</t-cell-group>
<t-cell-group v-if="hasSelectedOption && optionStatList.length" title="选项统计" class="option-stat" theme="card">
<t-cell
v-for="item in optionStatList"
:key="`${item.groupId}-${item.optionId}`"
:title="`${item.groupName || '选项组'}:${item.optionLabel || '未命名选项'}`"
:note="`${item.recordCount || 0} 条`"
/>
</t-cell-group>
<t-cell-group
v-if="pageResult.list.length"
class="record-list"
theme="card"
>
<event-record-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:record="item"
@updated="reloadRecords"
/>
</t-cell-group>
<center-tips v-else :content="isLoading ? '正在加载登记事件记录' : '暂无登记事件记录'" />
<center-tips v-if="pageResult.list.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<div class="list-wrapper">
<t-cell-group v-entrance-transition class="summary" theme="card">
<t-cell
title="登记时间"
:note="dateFilterLabel"
arrow
@click="openDateFilterPicker"
/>
<t-cell
v-if="dateFilterType === 'custom'"
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
v-if="dateFilterType === 'custom'"
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
<t-cell title="事件" :note="eventFilterLabel" />
<t-cell v-if="optionFilterLabel !== '全部选项'" title="选项" :note="optionFilterLabel" />
<t-cell title="记录数" :note="Text.display(pageResult.total)" />
<t-cell title="客户数" :note="Text.display(pageResult.customerCount)" />
<t-cell v-if="summaryNumberValueText" title="数值合计" :note="summaryNumberValueText" />
</t-cell-group>
<t-cell-group v-if="hasSelectedOption && optionStatList.length" title="选项统计" class="option-stat" theme="card">
<t-cell
v-for="item in optionStatList"
:key="`${item.groupId}-${item.optionId}`"
:title="`${item.groupName || '选项组'}:${item.optionLabel || '未命名选项'}`"
:note="`${item.recordCount || 0} 条`"
/>
</t-cell-group>
<t-cell-group
v-if="pageResult.list.length"
class="record-list"
theme="card"
>
<event-record-cell
v-entrance-transition="{ step: 30 }"
v-for="item in pageResult.list"
:key="item.id"
:record="item"
:inline="isWide"
@open="openDetail"
@updated="reloadRecords"
/>
</t-cell-group>
<center-tips v-else :content="isLoading ? '正在加载登记事件记录' : '暂无登记事件记录'" />
<center-tips v-if="pageResult.list.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<event-record-edit
v-if="editing"
:key="`edit-${selectedId}`"
:record-id="selectedId"
/>
<event-record-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:record-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
<customer-selector
v-model="customerId"
@@ -165,6 +188,9 @@ import { useUserStore } from "timi-web-api";
import EventAPI from "@/api/EventAPI";
import EventRecordAPI from "@/api/EventRecordAPI";
import CustomerSelector from "@/components/CustomerSelector.vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import EventRecordDetail from "@/pages/event/EventRecordDetail.vue";
import EventRecordEdit from "@/pages/event/EventRecordEdit.vue";
import EventRecordCell from "@/pages/event/component/EventRecordCell.vue";
import type { EventOptionStat, EventRecordPage, EventRecordPageResult, VerificationStatus } from "@/types/EventRecord";
import { isRetiredEvent } from "@/utils/event";
@@ -183,6 +209,14 @@ defineOptions({
const pageSize = 20;
const route = useRoute();
const router = useRouter();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/registration-event-records",
detail: id => `/management/registration-event-records/${id}`,
edit: id => `/management/registration-event-records/${id}/edit`
});
const userStore = useUserStore();
// ---------- 筛选 ----------
@@ -666,7 +700,7 @@ onUnmounted(() => {
<style scoped lang="less">
.registration-record-list {
display: flex;
padding: var(--app-nav-height) 0 6rem 0;
padding: var(--tui-nav-height) 0 6rem 0;
flex-direction: column;
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar event-record-rank">
<div class="tui-page-layout tui-navbar event-record-rank">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main ref="rankPageRef" v-can="permissionCodes.stat.read" class="page-content scroll column list">
<main ref="rankPageRef" v-can="permissionCodes.stat.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
+1 -1
View File
@@ -171,7 +171,7 @@ onMounted(async () => {
<style scoped lang="less">
.registration-event-sort {
padding: calc(var(--app-nav-height) + 1rem) 0 6rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 6rem;
.tip {
color: #52607a;
+11 -1
View File
@@ -85,6 +85,8 @@ defineOptions({
interface Props {
record: EventRecordListItemView;
/** 内联在主从分栏里:点击只通知父级切换右栏,不跳路由 */
inline?: boolean;
}
type RecordTag = {
@@ -93,9 +95,13 @@ type RecordTag = {
theme: "primary" | "warning" | "success";
};
const props = defineProps<Props>();
const props = withDefaults(defineProps<Props>(), {
inline: false
});
const emit = defineEmits<{
updated: [];
/** 内联模式下请求打开记录详情 */
open: [id: string];
}>();
const route = useRoute();
const router = useRouter();
@@ -141,6 +147,10 @@ async function toDetail(): Promise<void> {
if (!id) {
return;
}
if (props.inline) {
emit("open", id);
return;
}
await router.push({
path: `/management/registration-event-records/${id}`,
query: {
@@ -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.customerFollowUpReminder.read" class="follow-up-reminder-detail">
<t-empty v-if="!detail" :description="isLoading ? '正在加载跟进提醒' : '跟进提醒不存在'" />
<template v-else>
@@ -95,6 +95,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { DialogPlugin } from "tdesign-mobile-vue";
import { NotifyAPI, type NotifyDetail, useUserStore } from "timi-web-api";
import { TimeLabel, Time } from "timi-web";
@@ -119,8 +120,41 @@ defineOptions({
name: "FollowUpReminderDetail"
});
const props = withDefaults(defineProps<{
/** 指定提醒 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
reminderId?: string;
}>(), {
reminderId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.reminderId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/customer-follow-up-reminders",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const detail = ref<FollowUpReminder>();
@@ -197,7 +231,7 @@ async function loadDetail(): Promise<void> {
loadToken = token;
detail.value = undefined;
internalNotifyStatus.value = undefined;
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -256,9 +290,17 @@ function getCurrentRouteDepth(): number {
}
async function toEdit(): Promise<void> {
if (detail.value?.id && canUpdate.value) {
await router.push({ name: "CustomerFollowUpReminderEdit", params: { id: detail.value.id } });
if (!detail.value?.id || !canUpdate.value) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push({ name: "CustomerFollowUpReminderEdit", params: { id: detail.value.id } });
}
function confirmComplete(): void {
@@ -317,6 +359,10 @@ async function remove(id: string): Promise<void> {
try {
await FollowUpReminderAPI.remove(id);
Message.success("跟进提醒已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "CustomerFollowUpReminderList" });
} catch (error) {
Message.error(getErrorMessage(error, "跟进提醒删除失败"));
@@ -325,7 +371,7 @@ async function remove(id: string): Promise<void> {
}
}
watch(() => route.params.id, async () => {
watch(() => [props.reminderId, route.params.id], async () => {
await loadDetail();
}, { immediate: true });
@@ -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="pageAccess" class="follow-up-reminder-edit">
<t-form class="form card" label-width="6rem">
<t-form-item label="客户" content-align="right" required-mark>
@@ -127,6 +127,7 @@
<script setup lang="ts">
import { Time } from "timi-web";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { AttachmentAPI, type User, useUserStore } from "timi-web-api";
import CustomerProfileCard from "@/components/CustomerProfileCard.vue";
import { Message } from "@/utils/message";
@@ -162,6 +163,34 @@ defineOptions({
const route = useRoute();
const props = withDefaults(defineProps<{
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
reminderId?: string;
}>(), {
reminderId: ""
});
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
const pane = usePane();
const routeId = computed(() => props.reminderId || String(route.params.id || ""));
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑
useExpandToMaster({
path: "/management/customer-follow-up-reminders",
id: () => routeId.value,
query: { view: "edit" }
});
/** 退出编辑:分栏时交回列表页,整页时回路由 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "CustomerFollowUpReminderCreate":
@@ -169,14 +198,13 @@ const routeNavBarTitle = computed(() => {
case "CustomerFollowUpReminderEdit":
return "编辑跟进提醒";
default:
return "";
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
return pane ? "编辑跟进提醒" : "";
}
});
const router = useRouter();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const routeId = computed(() => String(route.params.id || ""));
const isEditMode = computed(() => !!routeId.value);
const pageAccess = computed(() => isEditMode.value
? permissionCodes.customerFollowUpReminder.update
@@ -495,6 +523,10 @@ async function loadForm(): Promise<void> {
const current = await FollowUpReminderAPI.detail(routeId.value);
if (current.status !== "PENDING") {
Message.warning("已完成的跟进提醒不能修改");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "CustomerFollowUpReminderDetail", params: { id: routeId.value } });
return;
}
@@ -588,6 +620,10 @@ async function save(): Promise<void> {
id = await FollowUpReminderAPI.create(payload);
}
Message.success("跟进提醒已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace({ name: "CustomerFollowUpReminderDetail", params: { id } });
} catch (error) {
Message.error(getErrorMessage(error, "跟进提醒保存失败"));
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar follow-up-reminder-list">
<div class="tui-page-layout tui-navbar follow-up-reminder-list">
<t-navbar
fixed
:z-index="20"
@@ -18,142 +18,165 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.customerFollowUpReminder.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<div class="filters glass">
<t-input
v-model="customerSearchKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码、姓名或拼音"
@enter="applyCustomerSearch"
@clear="clearCustomer"
>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-input>
<t-dropdown-menu ref="dropdownMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="handleDateFilterChange"
/>
<t-dropdown-item
v-model="statusFilter"
:label="statusFilterLabel"
:options="statusOptions"
@change="handleStatusChange"
/>
<t-dropdown-item
:label="selectedResponsibleName"
:options="[]"
@open="openResponsibleSelector"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<customer-profile-card class="customer" :customer="selectedCustomer" />
<t-cell-group class="summary" theme="card">
<t-cell title="提醒数量" :note="`共 ${pageResult.total} 条`" />
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
<master-detail-page
v-can="permissionCodes.customerFollowUpReminder.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="fetch"
>
<div class="filters glass">
<t-input
v-model="customerSearchKeyword"
class="customer"
type="search"
borderless
placeholder="输入客户编码、姓名或拼音"
@enter="applyCustomerSearch"
@clear="clearCustomer"
>
<t-cell
v-entrance-transition="{ step: 30 }"
class="cell"
arrow
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerName(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerName(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<div class="name-channel">
<span class="text-bold" v-text="getCustomerName(item)" />
<t-tag
v-if="item.notifyChannelList?.includes('INTERNAL')"
size="small"
theme="primary"
variant="outline"
content="站内信"
/>
<t-tag
v-if="item.notifyChannelList?.includes('SMS')"
size="small"
theme="warning"
variant="outline"
content="短信"
/>
</div>
<t-tag size="small" :theme="getStatusTheme(item.status)" :content="getStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="content clip-text" v-text="getContentSummary(item.content)" />
<div class="time-responsible">
<span
class="remind-time"
:class="getReminderTimeClass(item)"
v-text="getReminderTimeText(item.remindAt)"
/>
<span v-text="`负责人:${getResponsibleName(item)}`" />
</div>
</div>
</template>
</t-cell>
<template #right>
<div class="swipe-actions">
<t-button
v-if="canComplete && item.status === 'PENDING'"
class="complete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'complete'"
@click.stop="confirmComplete(item)"
>完成</t-button>
<t-button
v-if="canDelete"
class="delete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'delete'"
@click.stop="confirmDelete(item)"
>删除</t-button>
</div>
<template #suffix-icon>
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</template>
</t-swipe-cell>
</t-cell-group>
<center-tips :content="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
</div>
</t-pull-down-refresh>
</t-input>
<t-dropdown-menu ref="dropdownMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="handleDateFilterChange"
/>
<t-dropdown-item
v-model="statusFilter"
:label="statusFilterLabel"
:options="statusOptions"
@change="handleStatusChange"
/>
<t-dropdown-item
:label="selectedResponsibleName"
:options="[]"
@open="openResponsibleSelector"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<customer-profile-card class="customer" :customer="selectedCustomer" />
<t-cell-group class="summary" theme="card">
<t-cell title="提醒数量" :note="`共 ${pageResult.total} 条`" />
<t-cell v-if="dateFilterType !== 'all'" title="提醒时间" :note="dateFilterLabel" />
<t-cell v-if="selectedResponsibleId" title="负责人" :note="selectedResponsibleName" />
</t-cell-group>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line empty-cell-title-margin" theme="card">
<t-swipe-cell
v-for="(item, index) in pageResult.list"
:key="item.id || index"
class="item"
>
<t-cell
v-entrance-transition="{ step: 30 }"
class="cell"
arrow
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerName(item)"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="getCustomerName(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<div class="name-channel">
<span class="text-bold" v-text="getCustomerName(item)" />
<t-tag
v-if="item.notifyChannelList?.includes('INTERNAL')"
size="small"
theme="primary"
variant="outline"
content="站内信"
/>
<t-tag
v-if="item.notifyChannelList?.includes('SMS')"
size="small"
theme="warning"
variant="outline"
content="短信"
/>
</div>
<t-tag size="small" :theme="getStatusTheme(item.status)" :content="getStatusText(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="content clip-text" v-text="getContentSummary(item.content)" />
<div class="time-responsible">
<span
class="remind-time"
:class="getReminderTimeClass(item)"
v-text="getReminderTimeText(item.remindAt)"
/>
<span v-text="`负责人:${getResponsibleName(item)}`" />
</div>
</div>
</template>
</t-cell>
<template #right>
<div class="swipe-actions">
<t-button
v-if="canComplete && item.status === 'PENDING'"
class="complete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'complete'"
@click.stop="confirmComplete(item)"
>完成</t-button>
<t-button
v-if="canDelete"
class="delete swipe-cell-button"
variant="text"
:loading="operatingId === item.id && operatingType === 'delete'"
@click.stop="confirmDelete(item)"
>删除</t-button>
</div>
</template>
</t-swipe-cell>
</t-cell-group>
<center-tips :content="isLoading ? '正在加载提醒' : pageResult.list.length ? (isNoMore ? '已经到底了' : '上拉加载更多') : '暂无跟进提醒'" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<follow-up-reminder-edit
v-if="editing"
:key="`edit-${selectedId}`"
:reminder-id="selectedId"
/>
<follow-up-reminder-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:reminder-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
<customer-selector
v-model="selectedCustomerId"
v-model:visible="customerSelectorVisible"
@@ -190,13 +213,15 @@
@confirm="confirmEnd"
/>
</t-popup>
</main>
</div>
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { DialogPlugin, type DropdownValue } from "tdesign-mobile-vue";
import FollowUpReminderDetail from "@/pages/followUpReminder/FollowUpReminderDetail.vue";
import FollowUpReminderEdit from "@/pages/followUpReminder/FollowUpReminderEdit.vue";
import { Time } from "timi-web";
import { type PageResult, useUserStore } from "timi-web-api";
import { Message } from "@/utils/message";
@@ -222,6 +247,14 @@ defineOptions({
const router = useRouter();
const route = useRoute();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/customer-follow-up-reminders",
detail: id => `/management/customer-follow-up-reminders/${id}`,
edit: id => `/management/customer-follow-up-reminders/${id}/edit`
});
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
@@ -617,9 +650,7 @@ async function toCreate(): Promise<void> {
}
async function toDetail(item: FollowUpReminder): Promise<void> {
if (item.id) {
await router.push({ name: "CustomerFollowUpReminderDetail", params: { id: item.id } });
}
openDetail(item.id || "");
}
onMounted(async () => {
@@ -653,7 +684,7 @@ watch(() => route.query.customerId, async value => {
<style scoped lang="less">
.follow-up-reminder-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.selected-filter {
@@ -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.orderFulfillment.create" class="fulfillment-create">
<t-cell-group title="履约来源" theme="card">
<t-cell title="销售订单" :note="order?.orderNo || order?.id || '未找到来源订单'" />
@@ -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.orderFulfillment.read" class="fulfillment-detail">
<template v-if="fulfillment">
<t-cell-group title="履约单信息" theme="card" v-entrance-transition>
@@ -176,6 +176,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { TimeLabel } from "timi-web";
import { useUserStore } from "timi-web-api";
import FulfillmentAPI from "@/api/FulfillmentAPI";
@@ -203,8 +204,36 @@ import type { OrderFulfillment, OrderFulfillmentItem } from "@/types/Fulfillment
type ReasonAction = "reject" | "cancel";
defineOptions({ name: "OrderFulfillmentDetail" });
const props = withDefaults(defineProps<{
/** 指定履约单 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
fulfillmentId?: string;
}>(), {
fulfillmentId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.fulfillmentId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/order-fulfillments",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const fulfillment = ref<OrderFulfillment>();
const order = ref<SalesOrder>();
@@ -344,7 +373,7 @@ async function loadStockPreview(target: OrderFulfillment): Promise<void> {
}
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) return;
loading.value = true;
try {
@@ -439,6 +468,7 @@ async function submitReason(): Promise<void> {
finally { operating.value = false; }
}
onMounted(loadData);
watch(() => [props.fulfillmentId, route.params.id], loadData);
</script>
<style scoped lang="less">
+138 -121
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar fulfillment-list">
<div class="tui-page-layout tui-navbar fulfillment-list">
<t-navbar
fixed
:z-index="20"
@@ -11,125 +11,139 @@
<navbar-actions :actions="actions" :visible="canCreate" />
</template>
</t-navbar>
<main v-can="permissionCodes.orderFulfillment.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
class="customer"
:value="customerDisplayText"
readonly
borderless
placeholder="选择客户"
@click="customerSelectorVisible = true"
>
<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="filterMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
:label="skuFilterLabel"
:options="[]"
@open="openSkuFilter"
/>
<t-dropdown-item
v-model="status"
label="履约状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<div class="list-wrap">
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
<template v-if="salesOrder">
<t-cell title="订单号" :note="salesOrder.orderNo || salesOrder.id || '未知订单'" />
<t-cell title="订单类型" :note="getSalesOrderTypeText(salesOrder.orderType)" />
<t-cell title="订单状态">
<template #note>
<t-tag
:content="getSalesOrderStatusText(salesOrder.status)"
:theme="getStatusTheme(salesOrder.status)"
variant="light-outline"
/>
</template>
</t-cell>
</template>
<t-cell v-if="selectedSkuOptionList.length" class="sku-filter-cell" title="已筛选 SKU">
<template #note>
<div class="selected-sku-list">
<t-tag
v-for="sku in selectedSkuOptionList"
:key="sku.skuId"
size="small"
<master-detail-page
v-can="permissionCodes.orderFulfillment.read"
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="loadMore"
>
<div class="filters glass">
<t-input
class="customer"
:value="customerDisplayText"
readonly
borderless
placeholder="选择客户"
@click="customerSelectorVisible = true"
>
<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="formatSelectedSkuName(sku.productName, sku.skuName)"
content="选择客户"
@click.stop="customerSelectorVisible = true"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<div v-if="list.length" class="items">
<order-fulfillment-list-cell
v-for="item in list"
:key="item.id"
class="item"
:fulfillment="item"
v-entrance-transition="{ step: 30 }"
@detail="toDetail(item)"
/>
</t-input>
<t-dropdown-menu ref="filterMenuRef" class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
:label="skuFilterLabel"
:options="[]"
@open="openSkuFilter"
/>
<t-dropdown-item
v-model="status"
label="履约状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<center-tips v-else :content="loading ? '正在加载履约单' : '暂无履约单'" />
<center-tips :content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</main>
<div class="list-wrap">
<t-cell-group v-if="salesOrder || selectedSkuOptionList.length" class="filter-info" theme="card">
<template v-if="salesOrder">
<t-cell title="订单号" :note="salesOrder.orderNo || salesOrder.id || '未知订单'" />
<t-cell title="订单类型" :note="getSalesOrderTypeText(salesOrder.orderType)" />
<t-cell title="订单状态">
<template #note>
<t-tag
:content="getSalesOrderStatusText(salesOrder.status)"
:theme="getStatusTheme(salesOrder.status)"
variant="light-outline"
/>
</template>
</t-cell>
</template>
<t-cell v-if="selectedSkuOptionList.length" class="sku-filter-cell" title="已筛选 SKU">
<template #note>
<div class="selected-sku-list">
<t-tag
v-for="sku in selectedSkuOptionList"
:key="sku.skuId"
size="small"
theme="primary"
variant="outline"
:content="formatSelectedSkuName(sku.productName, sku.skuName)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<div v-if="list.length" class="items">
<order-fulfillment-list-cell
v-for="item in list"
:key="item.id"
class="item"
:fulfillment="item"
v-entrance-transition="{ step: 30 }"
@detail="toDetail(item)"
/>
</div>
<center-tips v-else :content="loading ? '正在加载履约单' : '暂无履约单'" />
<center-tips :content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<order-fulfillment-detail
:key="`detail-${selectedId}`"
:fulfillment-id="selectedId"
/>
</template>
</master-detail-page>
<sku-filter-popup
v-model="skuFilterVisible"
@@ -170,7 +184,9 @@
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import type { NavbarAction } from "@/types/NavbarAction.ts";
import OrderFulfillmentDetail from "@/pages/fulfillment/OrderFulfillmentDetail.vue";
import { type DropdownValue } from "tdesign-mobile-vue";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -195,6 +211,12 @@ defineOptions({ name: "OrderFulfillmentList" });
const route = useRoute();
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;履约单没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/order-fulfillments",
detail: id => `/management/order-fulfillments/${id}`
});
const filterMenuRef = ref<{ collapseMenu: () => void }>();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.orderFulfillment.create));
@@ -505,12 +527,7 @@ function buildUnixRange(): [number | undefined, number | undefined] {
}
async function toDetail(item: OrderFulfillment): Promise<void> {
if (item.id) {
await router.push({
path: `/management/order-fulfillments/${item.id}`,
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
});
}
openDetail(item.id || "");
}
async function toSalesOrderList(): Promise<void> {
@@ -565,7 +582,7 @@ onMounted(async () => {
<style scoped lang="less">
.fulfillment-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar quick-fulfillment">
<div class="tui-page-layout tui-navbar quick-fulfillment">
<t-navbar
fixed
:z-index="20"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.orderFulfillment.create" class="page-content scroll column content">
<main v-can="permissionCodes.orderFulfillment.create" class="tui-page-content scroll column content">
<customer-profile-card
v-if="selectedCustomer"
class="customer-profile"
@@ -413,7 +413,7 @@ onUnmounted(() => {
<style scoped lang="less">
.quick-fulfillment {
.content {
padding: calc(var(--app-nav-height) + .75rem) 0 2rem;
padding: calc(var(--tui-nav-height) + .75rem) 0 2rem;
}
@@ -136,6 +136,7 @@
</template>
<script setup lang="ts">
import type { BaseTableCol, TableRowData } from "tdesign-mobile-vue";
import { TimeLabel } from "timi-web";
import FulfillmentAPI from "@/api/FulfillmentAPI";
import type { QuickFulfillmentSku, QuickFulfillmentSourceOrder, QuickFulfillmentSourceOrderItem } from "@/types/Fulfillment";
@@ -162,7 +163,7 @@ const sourceSkuIdKey = computed(() => JSON.stringify(sourceSkuIdList.value));
const sourceOrderList = ref<QuickFulfillmentSourceOrder[]>([]);
const selectedSourceOrderIdList = ref<string[]>([]);
const loadingSourceOrders = ref(false);
const coverageColumns = [
const coverageColumns: BaseTableCol<TableRowData>[] = [
{ colKey: "product", title: "产品名", width: "40%", ellipsis: true },
{ colKey: "source", title: "来源", width: "20%", align: "right" },
{ colKey: "required", title: "需要", width: "20%", align: "right" },
+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-can="permissionCodes.eventRecord.create" class="quick-sign-in-page">
<t-cell-group v-if="!isEventLoading && !eventLoadFailed" theme="card">
<t-cell title="登记事件" arrow @click="eventPopupVisible = true">
+2 -2
View File
@@ -389,7 +389,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-management-create {
min-height: 100%;
padding-top: var(--app-nav-height);
padding-top: var(--tui-nav-height);
.form {
margin: 0;
@@ -448,7 +448,7 @@ onMounted(async () => {
width: 100%;
min-width: 0;
max-width: 100%;
top: var(--app-nav-height);
top: var(--tui-nav-height);
z-index: 10;
position: sticky;
}
+38 -5
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="corePermissionCodes.notify.read" class="notify-detail">
<t-empty
v-if="!detail"
@@ -73,6 +73,7 @@ import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
import { corePermissionCodes } from "@/utils/permission";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
type RecipientFilter = "all" | "unread" | "read";
@@ -81,8 +82,36 @@ defineOptions({
name: "NotifyDetail"
});
const props = withDefaults(defineProps<{
/** 指定通知 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
notifyId?: string;
}>(), {
notifyId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.notifyId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/notifications",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const canDeleteNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.delete));
const canCancelNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.cancel));
@@ -133,7 +162,7 @@ async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
detail.value = undefined;
const notifyId = String(route.params.id || "");
const notifyId = resolveId();
if (!notifyId) {
return;
}
@@ -209,6 +238,10 @@ async function confirmDelete(): Promise<void> {
try {
await NotifyAPI.managementDelete(notifyId);
Message.success("通知已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "NotifyList" });
} catch (error) {
Message.error(getErrorMessage(error, "通知删除失败"));
@@ -269,7 +302,7 @@ async function openRecipientListByFilter(filter: RecipientFilter): Promise<void>
// ---------- 生命周期 ----------
watch(() => route.params.id, async () => {
watch(() => [props.notifyId, route.params.id], async () => {
await loadDetail();
}, { immediate: true });
+80 -64
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar notify-management">
<div class="tui-page-layout tui-navbar notify-management">
<t-navbar
fixed
:z-index="20"
@@ -18,64 +18,78 @@
/>
</template>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
<master-detail-page
v-can="corePermissionCodes.notify.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
<t-cell-group
v-if="pageResult.list.length"
class="items fix-last-cell-line"
theme="card"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ scheduled: isScheduled(item) }">
<t-icon :name="isScheduled(item) ? 'time' : 'notification'" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<span v-if="isScheduled(item)" v-text="`定时 ${Time.toDateTime(item.sendAt)}`" />
<time-label v-else :timestamp="item.sendAt || item.createdAt" underline />
</template>
<template #note>
<t-tag size="small" :theme="getStatusTheme(item)" :content="getStatusText(item)" />
</template>
</t-cell>
<template #right>
<t-button
v-if="canCancel(item)"
class="cancel"
theme="primary"
@click.stop="confirmCancel(item)"
>取消</t-button>
<t-button
v-if="canDeleteNotify"
class="delete"
theme="danger"
@click.stop="confirmDelete(item)"
>删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!isLoading" description="暂无已发送通知" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<notify-detail
:key="`detail-${selectedId}`"
:notify-id="selectedId"
/>
</template>
</master-detail-page>
</div>
</template>
@@ -91,6 +105,8 @@ import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes } from "@/utils/permission";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import NotifyDetail from "@/pages/notify/NotifyDetail.vue";
type NotifyTagTheme = "default" | "success" | "warning" | "primary" | "danger";
@@ -99,6 +115,12 @@ defineOptions({
});
const pageSize = 20;
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;通知没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/notifications",
detail: id => `/management/notifications/${id}`
});
const router = useRouter();
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
@@ -211,13 +233,7 @@ async function refresh(): Promise<void> {
}
async function toDetail(item: NotifyManagementItem): Promise<void> {
if (!item.id) {
return;
}
await router.push({
name: "NotifyDetail",
params: { id: item.id }
});
openDetail(item.id || "");
}
async function toCreate(): Promise<void> {
@@ -292,7 +308,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-management {
min-height: 100%;
padding: calc(var(--app-nav-height) + 1rem) 0 1rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem;
.items {
overflow: hidden;
+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 list">
<main class="tui-page-content scroll column list">
<div class="pull-refresh">
<div v-can="corePermissionCodes.notify.read" class="notify-recipient-list">
<template v-if="detail">
+38 -5
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 bg-white">
<main class="tui-page-content scroll column bg-white">
<div v-can="corePermissionCodes.notify.read" class="notify-detail">
<notify-content
v-if="detail"
@@ -42,6 +42,7 @@ import { DialogPlugin } from "tdesign-mobile-vue";
import { getAttachmentReadURL } from "@/utils/attachment";
import { corePermissionCodes } from "@/utils/permission";
import { Message } from "@/utils/message.ts";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
@@ -50,9 +51,37 @@ import NotifyContent from "@/pages/notify/component/NotifyContent.vue";
import { getErrorMessage } from "@/utils/error";
const props = withDefaults(defineProps<{
/** 指定通知 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
notifyId?: string;
}>(), {
notifyId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.notifyId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/notify",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
defineOptions({
name: "UserNotifyDetail"
});
@@ -67,7 +96,7 @@ let loadToken = 0;
async function loadDetail(): Promise<void> {
const requestToken = loadToken + 1;
loadToken = requestToken;
const detailId = String(route.params.id || "");
const detailId = resolveId();
if (!detailId) {
detail.value = undefined;
return;
@@ -124,6 +153,10 @@ async function deleteDetail(detailId: string): Promise<void> {
try {
await NotifyAPI.deleteInternal(detailId);
Message.success("通知已删除");
if (pane) {
pane.close();
return;
}
await router.replace({ name: "UserNotifyList" });
} catch (error) {
Message.error(getErrorMessage(error, "通知删除失败"));
@@ -161,7 +194,7 @@ function resolveAttachmentUrl(attachmentId: string): string {
// ---------- 生命周期 ----------
watch(() => route.params.id, async () => {
watch(() => [props.notifyId, route.params.id], async () => {
await loadDetail();
}, { immediate: true });
+87 -72
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar notify-list">
<div class="tui-page-layout tui-navbar notify-list">
<t-navbar
fixed
:z-index="20"
@@ -18,71 +18,85 @@
/>
</template>
</t-navbar>
<main v-can="corePermissionCodes.notify.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
<master-detail-page
v-can="corePermissionCodes.notify.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-segmented
v-model="filterMode"
class="filter"
block
:options="filterOptions"
@change="switchFilter"
v-entrance-transition
/>
<t-cell-group v-if="pageResult.list.length" class="items fix-last-cell-line" theme="card">
<t-swipe-cell
v-for="item in pageResult.list"
:key="item.id"
class="item"
v-entrance-transition="{ step: 30 }"
>
<t-cell arrow hover @click="toDetail(item)">
<template #leftIcon>
<div class="icon" :class="{ unread: isUnread(item) }">
<t-icon name="notification" size="1.25rem" />
</div>
</template>
<template #title>
<div class="title">
<span v-text="getSubject(item)" />
</div>
</template>
<template #description>
<time-label :timestamp="item.sendAt" underline />
</template>
<template #note>
<t-tag
v-if="filterMode === 'all' && isUnread(item)"
class="unread-label"
theme="danger"
size="small"
>未读</t-tag>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
size="small"
>未读</t-tag>
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-cell>
<template #right>
<t-button
class="delete"
theme="danger"
:loading="deletingId === item.id"
@click.stop="confirmDelete(item)"
>
删除
</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
</t-swipe-cell>
</t-cell-group>
<t-empty
v-else-if="!isLoading"
description="暂无站内通知"
/>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<user-notify-detail
:key="`detail-${selectedId}`"
:notify-id="selectedId"
/>
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</template>
</master-detail-page>
</div>
</template>
@@ -92,6 +106,8 @@ import { NotifyAPI, type NotifyDetail, type Page, type PageResult, useUserStore
import { DialogPlugin } from "tdesign-mobile-vue";
import { Message } from "@/utils/message";
import { corePermissionCodes } from "@/utils/permission";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import UserNotifyDetail from "@/pages/notify/UserNotifyDetail.vue";
@@ -106,7 +122,12 @@ defineOptions({
});
const pageSize = 20;
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;站内通知没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/notify",
detail: id => `/notify/${id}`
});
const userStore = useUserStore();
const canReadNotify = computed(() => userStore.hasPermissions(corePermissionCodes.notify.read));
@@ -305,13 +326,7 @@ function getSubject(item: NotifyDetail): string {
}
async function toDetail(item: NotifyDetail): Promise<void> {
if (!item.id) {
return;
}
await router.push({
name: "UserNotifyDetail",
params: { id: item.id }
});
openDetail(item.id || "");
}
// ---------- 生命周期 ----------
@@ -334,7 +349,7 @@ onMounted(async () => {
<style scoped lang="less">
.notify-list {
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem 0;
min-height: 100%;
flex-direction: column;
+54 -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.packageConfig.read" class="package-config-detail">
<template v-if="config">
<section class="hero" v-entrance-transition>
@@ -109,6 +109,7 @@
<script setup lang="ts">
import { DialogPlugin } from "tdesign-mobile-vue";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
@@ -128,8 +129,33 @@ import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@
defineOptions({ name: "PackageConfigDetail" });
const props = withDefaults(defineProps<{
/** 指定套餐配置 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
configId?: string;
}>(), {
configId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
const route = useRoute();
const router = useRouter();
/** 内联渲染时 id 来自 prop,整页渲染时来自路由参数 */
function resolveId(): string {
return props.configId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/package-configs",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
const userStore = useUserStore();
const currentStoreStore = useCurrentStoreStore();
const config = ref<GaoPackageConfig>();
@@ -152,7 +178,7 @@ function getItemPhotoURL(item: PackageConfigItem): string {
}
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -171,10 +197,27 @@ async function loadData(): Promise<void> {
}
}
async function toEdit(): Promise<void> {
if (config.value?.id && canUpdate.value) {
await router.push(`/management/package-configs/${config.value.id}/edit`);
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
async function toEdit(): Promise<void> {
if (!config.value?.id || !canUpdate.value) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push(`/management/package-configs/${config.value.id}/edit`);
}
async function toPurchase(): Promise<void> {
@@ -214,6 +257,10 @@ function removeConfig(): void {
try {
await PackageAPI.configRemove(config.value!.id!);
Message.success("套餐配置已删除");
if (pane) {
pane.close(true);
return;
}
await router.replace("/management/package-configs");
} catch (error) {
Message.error(getErrorMessage(error, "套餐配置删除失败"));
+52 -5
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="savePermissionCode" class="package-config-edit">
<t-form class="form card" label-width="6rem" v-entrance-transition>
<t-form-item label="套餐名称" required-mark>
@@ -84,7 +84,11 @@
/>
</t-form-item>
<t-form-item label="备注">
<t-input v-model.trim="item.remark" borderless placeholder="选填" />
<t-input
:model-value="item.remark ?? ''"
@update:model-value="value => item.remark = String(value).trim()"
borderless placeholder="选填"
/>
</t-form-item>
<div class="price">
<span>预估价(原价)</span>
@@ -135,6 +139,7 @@
<script setup lang="ts">
import { AnimatedAmount, Time } from "timi-web";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import ProductSelectFormItem from "@/components/productSelector/ProductSelectFormItem.vue";
@@ -157,9 +162,22 @@ type PackageConfigFormItem = Partial<PackageConfigItem> & { clientKey: string };
defineOptions({ name: "PackageConfigEdit" });
const props = withDefaults(defineProps<{
/** 指定套餐配置 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
configId?: string;
}>(), {
configId: ""
});
const route = useRoute();
/** 内联渲染时 id 来自 prop,整页渲染时来自路由参数 */
const currentId = computed(() => props.configId || String(route.params.id || ""));
const routeNavBarTitle = computed(() => {
// 内联时路由停在列表页,标题只能看当前是新增还是编辑
if (props.configId) {
return "编辑套餐配置";
}
switch (route.name) {
case "PackageConfigCreate":
return "新增套餐配置";
@@ -170,9 +188,30 @@ const routeNavBarTitle = computed(() => {
}
});
const router = useRouter();
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑。
// 新增(Create)返回空 id,不触发——右栏没有可依附的选中项
useExpandToMaster({
path: "/management/package-configs",
id: () => (route.name === "PackageConfigCreate" ? "" : 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 savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.packageConfig.create : permissionCodes.packageConfig.update);
const isGlobalManager = computed(() => userStore.hasRoles(gaoRoleCodes.globalManager));
@@ -412,11 +451,19 @@ async function save(): Promise<void> {
if (isCreateMode.value) {
const id = await PackageAPI.configCreate(payload);
Message.success("套餐配置已创建");
if (pane) {
pane.close(true);
return;
}
await router.replace(`/management/package-configs/${id}`);
return;
}
await PackageAPI.configUpdate(payload);
Message.success("套餐配置已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace(`/management/package-configs/${routeId.value}`);
} catch (error) {
Message.error(getErrorMessage(error, "套餐配置保存失败"));
+103 -77
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar package-config-list">
<div class="tui-page-layout tui-navbar package-config-list">
<t-navbar
fixed
:z-index="20"
@@ -18,92 +18,111 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
<master-detail-page
v-can="permissionCodes.packageConfig.read"
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="loadMore"
>
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
<div class="filters glass">
<t-input
v-model.trim="keyword"
class="keyword"
borderless
clearable
placeholder="搜索套餐名称或说明"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="configList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
<t-cell
class="item"
v-for="item in configList"
:key="item.id"
v-entrance-transition="{ step: 30 }"
>
<template #title>
<div class="title">
<strong v-text="item.name || '未命名套餐'" />
<t-tag :content="getPackageConfigStatusText(item.status)" variant="light-outline" :theme="getStatusTheme(item.status)" />
</div>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
</template>
<template #description>
<div class="description">
<div class="products">
<t-tag
v-for="productItem in item.itemList || []"
:key="productItem.id || `${productItem.skuId}-${productItem.skuUnitId}`"
:content="getProductRightText(productItem)"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
variant="light"
/>
<t-tag v-if="!item.itemList?.length" content="暂无产品权益" />
</div>
<div class="price-actions">
<div class="price">
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.standardAmount)" />
</div>
<div v-if="item.id" class="actions" @click.stop>
<t-button
class="detail"
theme="primary"
size="extra-small"
content="详情"
@click.stop="toDetail(item)"
/>
</div>
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载套餐配置' : '暂无套餐配置'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<package-config-edit v-if="editing" :key="`edit-${selectedId}`" :config-id="selectedId" />
<package-config-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:config-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { type DropdownValue } from "tdesign-mobile-vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { Toolkit } from "timi-web";
import { useUserStore } from "timi-web-api";
import PackageAPI from "@/api/PackageAPI";
import PackageConfigDetail from "@/pages/package/PackageConfigDetail.vue";
import PackageConfigEdit from "@/pages/package/PackageConfigEdit.vue";
import type { GaoPackageConfig, PackageConfigItem, PackageConfigStatus } from "@/types/Package";
import { formatPackageAmount, getPackageConfigStatusText, getPackageQuantityText } from "@/utils/package";
import { Message } from "@/utils/message";
@@ -116,6 +135,15 @@ defineOptions({ name: "PackageConfigList" });
const router = useRouter();
const userStore = useUserStore();
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/package-configs",
detail: id => `/management/package-configs/${id}`,
edit: id => `/management/package-configs/${id}/edit`
});
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.packageConfig.create));
const keyword = ref("");
@@ -191,10 +219,8 @@ async function toCreate(): Promise<void> {
await router.push("/management/package-configs/create");
}
async function toDetail(item: GaoPackageConfig): Promise<void> {
if (item.id) {
await router.push(`/management/package-configs/${item.id}`);
}
function toDetail(item: GaoPackageConfig): void {
openDetail(item.id || "");
}
function getStatusTheme(statusValue?: PackageConfigStatus): "success" | "warning" | "default" {
@@ -223,7 +249,7 @@ onUnmounted(() => {
<style scoped lang="less">
.package-config-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list {
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar package-order-config-list">
<div class="tui-page-layout tui-navbar package-order-config-list">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.packageConfig.read" class="page-content scroll column list">
<main v-can="permissionCodes.packageConfig.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="refreshing"
@@ -207,7 +207,7 @@ onUnmounted(() => {
<style scoped lang="less">
.package-order-config-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list {
+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"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.customerPackage.create" class="package-purchase">
<t-form class="form card" v-entrance-transition>
<t-form-item label="客户" required-mark>
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar permission-list">
<div class="tui-page-layout tui-navbar permission-list">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll column list">
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
@@ -151,7 +151,7 @@ async function loadSourceRoles(): Promise<void> {
<style scoped lang="less">
.permission-list {
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem 0;
.list-wrapper {
+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-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }"
class="permission-settings"
@@ -209,11 +209,11 @@ onMounted(async () => {
.role-delegation-permission-assign {
gap: 1rem;
display: flex;
padding: calc(var(--app-nav-height) + 3.5rem) 0 6rem 0;
padding: calc(var(--tui-nav-height) + 3.5rem) 0 6rem 0;
flex-direction: column;
.header {
top: var(--app-nav-height);
top: var(--tui-nav-height);
left: 0;
right: 0;
z-index: 20;
+39 -5
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
@@ -19,7 +19,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="pageAccess" class="role-edit">
<t-form v-entrance-transition class="form card">
<t-form-item label="名称">
@@ -121,7 +121,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Message } from "@/utils/message";
import { useUserStore } from "timi-web-api";
import { useCurrentStoreStore } from "@/store/currentStoreStore";
@@ -142,9 +142,21 @@ defineOptions({
name: "RoleEdit"
});
const props = withDefaults(defineProps<{
/** 指定角色 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
roleId?: string;
}>(), {
roleId: ""
});
const route = useRoute();
const currentId = computed(() => props.roleId || String(route.params.id || ""));
const routeNavBarTitle = computed(() => {
// 内联时路由停在列表页,标题不能只看 route.name
if (props.roleId) {
return "编辑角色";
}
switch (route.name) {
case "RoleCreate":
return "新增角色";
@@ -155,13 +167,31 @@ const routeNavBarTitle = computed(() => {
}
});
const router = useRouter();
// 竖屏整页编辑转横屏:回到分栏,右栏直接是编辑视图
useExpandToMaster({
path: "/management/permissions/roles",
id: () => (route.name === "RoleCreate" ? "" : currentId.value)
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
/** 取消/保存后回到上一层:分栏时通知列表页,否则走路由返回 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const permissionStore = usePermissionSettingsStore();
const currentStoreStore = useCurrentStoreStore();
const userStore = useUserStore();
// ---------- 路由权限 ----------
const routeId = computed(() => String(route.params.id || ""));
const routeId = currentId;
const isCreateMode = computed(() => !routeId.value);
const savePermissionCode = computed(() => isCreateMode.value ? corePermissionCodes.role.create : corePermissionCodes.role.update);
const pageAccess = computed(() => ({
@@ -452,6 +482,10 @@ async function saveBaseInfo(): Promise<void> {
await permissionStore.setRoleParentRole(formModel.id, formModel.parentRoleId);
}
Message.success(isCreateMode.value ? "角色已创建" : "基础信息已保存");
if (pane) {
pane.close(true);
return;
}
await router.push(`/management/permissions/roles/${role?.id || formModel.id}`);
} catch (error) {
await reloadAfterError();
+53 -34
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar role-list">
<div class="tui-page-layout tui-navbar role-list">
<t-navbar
fixed
:z-index="20"
@@ -18,45 +18,58 @@
/>
</template>
</t-navbar>
<main v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }" class="page-content scroll column list">
<t-pull-down-refresh
class="list-wrapper pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
>
<t-cell-group v-if="sortedRoles.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedRoles"
:key="item.id"
class="item"
>
<t-cell
:title="item.name"
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
arrow
hover
@click="router.push(`/management/permissions/roles/${item.id}`)"
<master-detail-page
v-can="{ value: [corePermissionCodes.role.read, corePermissionCodes.permission.read], mode: 'and' }"
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="refresh"
>
<t-cell-group v-if="sortedRoles.length" theme="card">
<t-swipe-cell
v-entrance-transition="{ step: 30 }"
v-for="item in sortedRoles"
:key="item.id"
class="item"
>
<template #title>
<div class="title" v-text="item.name" :style="{ paddingLeft: `${item.level * 1.25}rem` }" />
</template>
</t-cell>
<template #right>
<t-button v-if="canDeleteRole(item)" v-can="corePermissionCodes.role.delete" class="delete" theme="danger" @click="removeRole(item.id)">删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
</t-pull-down-refresh>
</main>
<t-cell
:title="item.name"
:note="`${item.code} · ${getRoleScopeLabel(item)}`"
arrow
hover
@click="openDetail(item.id || '')"
>
<template #title>
<div class="title" v-text="item.name" :style="{ paddingLeft: `${item.level * 1.25}rem` }" />
</template>
</t-cell>
<template #right>
<t-button v-if="canDeleteRole(item)" v-can="corePermissionCodes.role.delete" class="delete" theme="danger" @click="removeRole(item.id)">删除</t-button>
</template>
</t-swipe-cell>
</t-cell-group>
<t-empty v-else-if="!permissionStore.loading" description="暂无角色" />
</t-pull-down-refresh>
</template>
<template #detail>
<role-edit :key="`edit-${selectedId}`" :role-id="selectedId" />
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { Message } from "@/utils/message";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import RoleEdit from "@/pages/permission/RoleEdit.vue";
import type { Role } from "@/store/permissionSettingsStore";
import { getErrorMessage } from "@/utils/error";
import { corePermissionCodes, coreRoleCodes } from "@/utils/permission";
@@ -71,6 +84,12 @@ defineOptions({
name: "RoleList"
});
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;角色没有独立详情视图,选中即进编辑
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/permissions/roles",
detail: id => `/management/permissions/roles/${id}`
});
const router = useRouter();
const permissionStore = usePermissionSettingsStore();
const userStore = useUserStore();
@@ -183,7 +202,7 @@ async function refreshAuthorizationScope(): Promise<void> {
<style scoped lang="less">
.role-list {
padding: calc(var(--app-nav-height) + 1rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 1rem) 0 1rem 0;
.list-wrapper {
padding-bottom: 6rem;
@@ -237,11 +237,11 @@ onMounted(async () => {
.role-permission-assign {
gap: 1rem;
display: flex;
padding: calc(var(--app-nav-height) + 4rem) 0 1rem 0;
padding: calc(var(--tui-nav-height) + 4rem) 0 1rem 0;
flex-direction: column;
.header {
top: var(--app-nav-height);
top: var(--tui-nav-height);
left: 0;
right: 0;
z-index: 20;
+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;
+1 -1
View File
@@ -243,7 +243,7 @@ function pad(value: number): string {
<style scoped lang="less">
.gao-chart-page {
gap: 1rem;
padding: calc(var(--app-nav-height) + 1rem) 1rem 1rem;
padding: calc(var(--tui-nav-height) + 1rem) 1rem 1rem;
display: flex;
flex-direction: column;
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-category-list">
<div class="tui-page-layout tui-navbar product-category-list">
<t-navbar
fixed
:z-index="20"
@@ -11,7 +11,7 @@
<navbar-actions :actions="actionList" :visible="canShowActionMenu" />
</template>
</t-navbar>
<main v-can="permissionCodes.productCategory.read" class="page-content scroll column list">
<main v-can="permissionCodes.productCategory.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
@@ -372,7 +372,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-category-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list {
+1 -1
View File
@@ -134,7 +134,7 @@ onMounted(async () => {
<style scoped lang="less">
.product-category-rank {
padding: calc(var(--app-nav-height) + 1rem) 0 6rem;
padding: calc(var(--tui-nav-height) + 1rem) 0 6rem;
.tip {
color: #52607a;
+1 -1
View File
@@ -261,7 +261,7 @@ function pad(value: number): string {
<style scoped lang="less">
.gao-chart-page {
gap: 1rem;
padding: calc(var(--app-nav-height) + 1rem) 1rem 1rem;
padding: calc(var(--tui-nav-height) + 1rem) 1rem 1rem;
display: flex;
flex-direction: column;
+56 -6
View File
@@ -1,17 +1,17 @@
<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>
<navbar-actions :actions="actionList" />
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.product.read" class="product-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-if="product">
@@ -148,12 +148,37 @@ import {
} from "@/utils/product";
import { Message } from "@/utils/message";
import { permissionCodes } from "@/utils/permission";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { Text } from "timi-web";
import AttachmentSelector from "@/components/attachmentSelector/AttachmentSelector.vue";
defineOptions({ name: "ProductDetail" });
const props = withDefaults(defineProps<{
/** 指定产品 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
productId?: string;
}>(), {
productId: ""
});
const emit = defineEmits<{
/** 内联在右栏时请求切换到编辑视图 */
edit: [];
}>();
function resolveId(): string {
return props.productId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/products",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
const route = useRoute();
const router = useRouter();
const userStore = useUserStore();
@@ -191,7 +216,7 @@ const actionList = computed<NavbarAction[]>(() => {
});
async function load(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -204,9 +229,26 @@ async function load(): Promise<void> {
}
async function edit(): Promise<void> {
if (product.value?.id) {
await router.push(`/management/products/${product.value.id}/edit`);
if (!product.value?.id) {
return;
}
// 分栏时右栏直接切到编辑视图,不跳路由,列表上下文保留
if (pane) {
emit("edit");
return;
}
await router.push(`/management/products/${product.value.id}/edit`);
}
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
async function viewStock(): Promise<void> {
@@ -289,6 +331,10 @@ function remove(): void {
emitListDataChanged(listDataEventKeys.productChanged, id);
emitListDataChanged(listDataEventKeys.productStockChanged, id);
Message.success("产品已移除");
if (pane) {
pane.close();
return;
}
await router.replace("/management/products");
} catch (error) {
Message.error(getErrorMessage(error, "产品移除失败"));
@@ -299,6 +345,10 @@ function remove(): void {
});
}
watch(() => [props.productId, route.params.id], async () => {
await load();
});
onMounted(async () => {
try {
+43 -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="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="savePermissionCode" class="product-edit">
<t-form class="form card" label-width="6rem" v-entrance-transition>
<t-form-item label="产品编码" required-mark help="使用英语、拼音或唯一数字">
@@ -40,7 +40,11 @@
<span class="picker-text" v-text="getProductStatusText(form.status)" />
</t-form-item>
<t-form-item label="备注">
<t-textarea v-model="form.remark" borderless maxlength="255" autosize placeholder="可填写产品说明" />
<t-textarea
:model-value="form.remark ?? ''"
@update:model-value="value => form.remark = String(value)"
borderless maxlength="255" autosize placeholder="可填写产品说明"
/>
</t-form-item>
<t-form-item label-width="0">
<attachment-selector
@@ -219,7 +223,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { DialogPlugin, type ColorObject } from "tdesign-mobile-vue";
import { type Attachment, AttachmentAPI, useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
@@ -248,6 +252,34 @@ defineOptions({ name: "ProductEdit" });
const route = useRoute();
const props = withDefaults(defineProps<{
/** 内联到主从分栏时由列表页传入,优先于路由参数 */
productId?: string;
}>(), {
productId: ""
});
/** 非空说明当前被内联在右栏里,退出走 close 而不是路由 */
const pane = usePane();
const routeId = computed(() => props.productId || String(route.params.id || ""));
// 竖屏整页编辑转横屏:回到分栏,并用 view=edit 让列表页把右栏还原成编辑
useExpandToMaster({
path: "/management/products",
id: () => routeId.value,
query: { view: "edit" }
});
/** 退出编辑:分栏时交回列表页,整页时回路由 */
function exit(saved = false): void {
if (pane) {
pane.close(saved);
return;
}
void router.back();
}
const routeNavBarTitle = computed(() => {
switch (route.name) {
case "ProductCreate":
@@ -255,12 +287,12 @@ const routeNavBarTitle = computed(() => {
case "ProductEdit":
return "编辑产品";
default:
return "";
// 内联在右栏时路由仍是列表页,标题不能只看 route.name
return pane ? "编辑产品" : "";
}
});
const router = useRouter();
const userStore = useUserStore();
const routeId = computed(() => String(route.params.id || ""));
const isCreateMode = computed(() => !routeId.value);
const savePermissionCode = computed(() => isCreateMode.value ? permissionCodes.product.create : permissionCodes.product.update);
const isSaving = ref(false);
@@ -1073,6 +1105,10 @@ async function save(): Promise<void> {
emitListDataChanged(listDataEventKeys.productChanged, productId);
emitListDataChanged(listDataEventKeys.productStockChanged, productId);
Message.success(isCreateMode.value ? "产品已创建" : "产品已保存");
if (pane) {
pane.close(true);
return;
}
await router.replace(`/management/products/${productId}`);
} catch (error) {
Message.error(getErrorMessage(error, "产品保存失败,请检查 SKU 编码、规格组合和单位配置"));
+119 -87
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-list">
<div class="tui-page-layout tui-navbar product-list">
<t-navbar
fixed
:z-index="20"
@@ -18,100 +18,125 @@
/>
</template>
</t-navbar>
<main ref="productListRef" v-can="permissionCodes.product.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索产品名称(拼音)或编码"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
<t-dropdown-item
v-model="productType"
label="类型"
:options="productTypeOptions"
@change="selectProductType"
/>
<t-dropdown-item
:model-value="categoryIdList"
label="分类"
:options="categoryOptions"
multiple
:options-columns="2"
@change="selectCategory"
@confirm="confirmCategory"
@reset="resetCategory"
@update:model-value="updateCategory"
/>
</t-dropdown-menu>
</div>
<t-cell-group
v-if="productList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
<master-detail-page
ref="productListRef"
v-can="permissionCodes.product.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<t-cell v-for="item in productList" :key="item.id" class="item" arrow hover v-entrance-transition="{ step: 30 }" @click="toDetail(item)">
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.name || '产品图片'"
fit="cover"
class="avatar"
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
placeholder="搜索产品名称(拼音)或编码"
/>
<t-dropdown-menu class="menus">
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
<div
v-else
class="avatar fallback"
v-text="(item.name || '产').slice(0, 1)"
<t-dropdown-item
v-model="productType"
label="类型"
:options="productTypeOptions"
@change="selectProductType"
/>
</template>
<template #title>
<div class="text-bold" v-text="item.name || '未命名产品'" />
</template>
<template #note>
<t-tag
size="small"
variant="outline"
:theme="getProductStatusTheme(item.status)"
:content="getProductStatusText(item.status)"
<t-dropdown-item
:model-value="categoryIdList"
label="分类"
:options="categoryOptions"
multiple
:options-columns="2"
@change="selectCategory"
@confirm="confirmCategory"
@reset="resetCategory"
@update:model-value="updateCategory"
/>
</template>
<template #description>
<div class="description">
</t-dropdown-menu>
</div>
<t-cell-group
v-if="productList.length"
class="list fix-last-cell-line empty-cell-title-margin"
theme="card"
>
<t-cell v-for="item in productList" :key="item.id" class="item" arrow hover v-entrance-transition="{ step: 30 }" @click="toDetail(item)">
<template #leftIcon>
<t-image
v-if="getProductPhotoURL(item)"
:src="getProductPhotoURL(item)"
:alt="item.name || '产品图片'"
fit="cover"
class="avatar"
/>
<div
v-else
class="avatar fallback"
v-text="(item.name || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="text-bold" v-text="item.name || '未命名产品'" />
</template>
<template #note>
<t-tag
size="small"
variant="outline"
:content="getProductTypeText(item.productType)"
:theme="getProductStatusTheme(item.status)"
:content="getProductStatusText(item.status)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="productList.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
</template>
<template #description>
<div class="description">
<t-tag
size="small"
variant="outline"
:content="getProductTypeText(item.productType)"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="productList.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #detail>
<product-edit
v-if="editing"
:key="`edit-${selectedId}`"
:product-id="selectedId"
/>
<product-detail
v-else
:key="`detail-${selectedId}-${detailVersion}`"
:product-id="selectedId"
@edit="openEdit"
/>
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { type DropdownValue } from "tdesign-mobile-vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import ProductDetail from "@/pages/product/ProductDetail.vue";
import ProductEdit from "@/pages/product/ProductEdit.vue";
import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import ProductAPI from "@/api/ProductAPI";
@@ -124,9 +149,18 @@ import { permissionCodes } from "@/utils/permission";
defineOptions({ name: "ProductList" });
const router = useRouter();
const route = useRoute();
const productListRef = ref<HTMLElement | null>(null);
// 选中项、编辑态、切换方向、关闭逻辑、转屏、query 同步都在这里
const { selectedId, editing, detailVersion, paneDirection, isWide, openDetail, openEdit } =
useMasterDetailPane({
path: "/management/products",
detail: id => `/management/products/${id}`,
edit: id => `/management/products/${id}/edit`
});
const productListRef = ref<ComponentPublicInstance | null>(null);
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.product.create));
@@ -150,7 +184,7 @@ let unregisterProductListEvent: (() => void) | undefined;
let isDisposed = false;
function getProductListPage(): HTMLElement | null {
return productListRef.value?.querySelector<HTMLElement>(".pull-refresh") || null;
return (productListRef.value?.$el as HTMLElement | undefined)?.querySelector<HTMLElement>(".pull-refresh") || null;
}
function savePageScrollPosition(): void {
@@ -383,9 +417,7 @@ async function toCreate(): Promise<void> {
}
async function toDetail(item: Product): Promise<void> {
if (item.id) {
await router.push(`/management/products/${item.id}`);
}
openDetail(item.id || "");
}
onMounted(async () => {
@@ -435,7 +467,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list {
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar">
<div class="tui-page-layout tui-navbar">
<t-navbar
fixed
:z-index="20"
@@ -19,7 +19,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.productStock.create" class="product-stock-batch-configure">
<t-form class="form card" label-width="5rem" v-entrance-transition>
<t-form-item label="入库备注" required-mark>
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-stock-batch-select">
<div class="tui-page-layout tui-navbar product-stock-batch-select">
<t-navbar
fixed
:z-index="20"
@@ -19,7 +19,7 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.productStock.create" class="page-content scroll column list">
<main v-can="permissionCodes.productStock.create" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
@@ -385,7 +385,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-stock-batch-select {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
+40 -4
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.productStock.read" class="product-stock-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-else-if="product && sku && stock">
@@ -109,6 +109,7 @@
<script setup lang="ts">
import { shallowRef } from "vue";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import ProductProfile from "@/pages/product/component/ProductProfile.vue";
@@ -125,8 +126,43 @@ type ManualStockOperation = Extract<StockOperationType, "MANUAL_IN" | "MANUAL_OU
defineOptions({ name: "ProductStockDetail" });
const props = withDefaults(defineProps<{
/** 指定 SKU ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
skuId?: string;
/** 所属产品 ID,整页详情转回分栏时用来定位 SKU 列表。 */
productId?: string;
}>(), {
skuId: "",
productId: ""
});
const route = useRoute();
const router = useRouter();
/** 内联渲染时 id 来自 prop,整页渲染时来自路由参数。 */
function resolveId(): string {
return props.skuId || String(route.params.skuId || "");
}
// 竖屏整页详情转横屏:回到 SKU 列表并把选中项还原到右栏。
// 没带 productId(从别处跳进来)时不动,避免落到无效的列表路径
const masterProductId = props.productId || String(route.query.productId || "");
useExpandToMaster({
path: `/management/product-stocks/${masterProductId}/skus`,
id: () => (masterProductId ? resolveId() : "")
});
/** 非空说明当前被内联在主从分栏的右栏里。 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const product = ref<Product>();
const sku = ref<ProductSku>();
@@ -190,7 +226,7 @@ function selectUnit(unitId: string): void {
}
async function loadAll(): Promise<void> {
const skuId = String(route.params.skuId || "");
const skuId = resolveId();
if (!skuId) {
return;
}
+3 -3
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-stock-list">
<div class="tui-page-layout tui-navbar product-stock-list">
<t-navbar
fixed
:z-index="20"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main ref="productStockListRef" v-can="permissionCodes.productStock.read" class="page-content scroll column list">
<main ref="productStockListRef" v-can="permissionCodes.productStock.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
@@ -364,7 +364,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-stock-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
+36 -6
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.productStock.read" class="product-stock-record-detail">
<t-loading v-if="isLoading" class="loading" size="32px" />
<template v-else-if="record">
@@ -135,7 +135,7 @@
</template>
<script setup lang="ts">
import { BottomPopup } from "timi-tdesign-mobile";
import { BottomPopup, useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { TimeLabel } from "timi-web";
import { useUserStore, type Attachment } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
@@ -154,8 +154,38 @@ import type { PhotoItem } from "@/types/Photo";
defineOptions({ name: "ProductStockRecordDetail" });
const props = withDefaults(defineProps<{
/** 指定库存流水 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
recordId?: string;
}>(), {
recordId: ""
});
const route = useRoute();
const router = useRouter();
/** 内联渲染时 id 来自 prop,整页渲染时来自路由参数 */
function resolveId(): string {
return props.recordId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/product-stock-records",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const record = ref<StockRecord>();
const baseUnitName = ref("");
@@ -291,7 +321,7 @@ async function submitManualRevoke(): Promise<void> {
}
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -319,7 +349,7 @@ onMounted(async () => {
await loadData();
});
watch(() => String(route.params.id || ""), async (id, previousId) => {
watch(resolveId, async (id, previousId) => {
if (id && id !== previousId) {
await loadData();
}
+175 -169
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-stock-record-list">
<div class="tui-page-layout tui-navbar product-stock-record-list">
<t-navbar
fixed
:z-index="20"
@@ -7,161 +7,175 @@
left-arrow
@left-click="handleNavBarBack"
/>
<main v-can="permissionCodes.productStock.read" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh has-dropdown-menu-navbar"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<dropdown-menu-navbar
v-model="keyword"
:filters="dropdownFilters"
placeholder="搜索产品名称(拼音)或编码"
@filter-change="handleFilterChange"
<master-detail-page
v-can="permissionCodes.productStock.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="pull-refresh has-dropdown-menu-navbar"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
variant="outline"
content="选择产品"
@click.stop="productSelectorVisible = true"
/>
</div>
</template>
</dropdown-menu-navbar>
<div class="list-wrap">
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</template>
<template v-if="filteredSku">
<t-cell title="累计入库" :note="getStockSummaryText(inBaseQuantityTotal)" />
<t-cell title="累计出库" :note="getStockSummaryText(outBaseQuantityTotal)" />
</template>
</t-cell-group>
<t-cell-group v-if="filteredProduct && filteredSku" theme="card">
<t-cell class="sku">
<template #leftIcon>
<t-image
v-if="filteredSkuPhotoURL"
class="avatar"
:src="filteredSkuPhotoURL"
:alt="filteredProduct.name || '产品图片'"
fit="cover"
/>
<div
v-else
class="fallback"
v-text="(filteredProduct.name || filteredProduct.code || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong class="text-bold clip-text" v-text="filteredProduct.name || '未命名产品'" />
<product-sku-tags
v-if="filteredSku.specValueIdList?.length"
:product-name="filteredProduct.name"
:snapshot="filteredSkuSnapshot"
:fallback="filteredSku.specSummary || filteredSku.name"
/>
</div>
</template>
<template #note>
<t-tag
variant="light-outline"
<dropdown-menu-navbar
v-model="keyword"
:filters="dropdownFilters"
placeholder="搜索产品名称(拼音)或编码"
@filter-change="handleFilterChange"
>
<template #suffix-icon>
<div class="actions">
<t-button
size="extra-small"
theme="primary"
:content="getProductTypeText(filteredProduct.productType)"
variant="outline"
content="选择产品"
@click.stop="productSelectorVisible = true"
/>
</div>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="list empty-cell-title-margin" theme="card">
<t-cell
v-for="(record, index) in recordList"
:key="record.id || `${record.occurredAt}-${record.requestNo}-${index}`"
class="item"
:arrow="!!record.id"
:hover="!!record.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(record)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(record.customer, 64)"
:src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)"
fit="cover"
class="avatar"
/>
<div
v-else-if="record.customer"
class="avatar fallback"
v-text="getCustomerText(record).slice(0, 1)"
/>
<t-image
v-else-if="record.operator"
:src="getOperatorAvatar(record)"
:alt="getOperatorText(record)"
fit="cover"
class="avatar"
/>
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)">
<t-icon :name="getOperationIcon(record.operationType)" size="1.25rem" />
</span>
</template>
<template #title>
<div class="title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
<strong class="product-name clip-text" v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag
v-if="record.productNameSnapshot !== record.skuNameSnapshot"
size="small"
:content="record.skuNameSnapshot"
</dropdown-menu-navbar>
<div class="list-wrap">
<t-cell-group v-if="isCustomDate || filteredSku" class="summary" theme="card">
<template v-if="isCustomDate">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<span
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="quantity"
v-text="getStockQuantityText(record)"
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</div>
</template>
<template #description>
<div class="description">
<time-label :timestamp="record.occurredAt" underline />
<div class="delta">
<span>库存:</span>
<span
class="value"
:class="getDeltaClass(record.onHandDelta)"
v-text="getDeltaText(record.onHandDelta)"
</template>
<template v-if="filteredSku">
<t-cell title="累计入库" :note="getStockSummaryText(inBaseQuantityTotal)" />
<t-cell title="累计出库" :note="getStockSummaryText(outBaseQuantityTotal)" />
</template>
</t-cell-group>
<t-cell-group v-if="filteredProduct && filteredSku" theme="card">
<t-cell class="sku">
<template #leftIcon>
<t-image
v-if="filteredSkuPhotoURL"
class="avatar"
:src="filteredSkuPhotoURL"
:alt="filteredProduct.name || '产品图片'"
fit="cover"
/>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="recordList.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
</main>
<div
v-else
class="fallback"
v-text="(filteredProduct.name || filteredProduct.code || '产').slice(0, 1)"
/>
</template>
<template #title>
<div class="title">
<strong class="text-bold clip-text" v-text="filteredProduct.name || '未命名产品'" />
<product-sku-tags
v-if="filteredSku.specValueIdList?.length"
:product-name="filteredProduct.name"
:snapshot="filteredSkuSnapshot"
:fallback="filteredSku.specSummary || filteredSku.name"
/>
</div>
</template>
<template #note>
<t-tag
variant="light-outline"
theme="primary"
:content="getProductTypeText(filteredProduct.productType)"
/>
</template>
</t-cell>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="list empty-cell-title-margin" theme="card">
<t-cell
v-for="(record, index) in recordList"
:key="record.id || `${record.occurredAt}-${record.requestNo}-${index}`"
class="item"
:arrow="!!record.id"
:hover="!!record.id"
v-entrance-transition="{ step: 30 }"
@click="toDetail(record)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(record.customer, 64)"
:src="getCustomerPhotoURL(record.customer, 64)"
:alt="getCustomerText(record)"
fit="cover"
class="avatar"
/>
<div
v-else-if="record.customer"
class="avatar fallback"
v-text="getCustomerText(record).slice(0, 1)"
/>
<t-image
v-else-if="record.operator"
:src="getOperatorAvatar(record)"
:alt="getOperatorText(record)"
fit="cover"
class="avatar"
/>
<span v-else class="icon" :class="getDeltaClass(record.onHandDelta)">
<t-icon :name="getOperationIcon(record.operationType)" size="1.25rem" />
</span>
</template>
<template #title>
<div class="title">
<span v-if="record.customer" class="actor" v-text="getCustomerText(record)" />
<span v-else-if="record.operator" class="actor" v-text="getOperatorText(record)" />
<strong class="operation" :class="getOperationClass(record.operationType)" v-text="getStockOperationText(record.operationType)" />
<strong class="product-name clip-text" v-text="record.productNameSnapshot || '未命名产品'" />
<t-tag
v-if="record.productNameSnapshot !== record.skuNameSnapshot"
size="small"
:content="record.skuNameSnapshot"
/>
<span
v-if="record.quantity !== undefined && record.quantity !== null && record.quantity !== ''"
class="quantity"
v-text="getStockQuantityText(record)"
/>
</div>
</template>
<template #description>
<div class="description">
<time-label :timestamp="record.occurredAt" underline />
<div class="delta">
<span>库存:</span>
<span
class="value"
:class="getDeltaClass(record.onHandDelta)"
v-text="getDeltaText(record.onHandDelta)"
/>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="recordList.length" :content="loadStateText" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<product-stock-record-detail
:key="`detail-${selectedId}-${detailVersion}`"
:record-id="selectedId"
/>
</template>
</master-detail-page>
<product-select-popup
v-model="selectedProductSku"
v-model:visible="productSelectorVisible"
@@ -196,10 +210,12 @@
<script setup lang="ts">
import { type DropdownValue } from "tdesign-mobile-vue";
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { TimeLabel, Time } from "timi-web";
import { UserAPI } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import ProductAPI from "@/api/ProductAPI";
import ProductStockRecordDetail from "@/pages/product/ProductStockRecordDetail.vue";
import ProductSelectPopup from "@/components/productSelector/ProductSelectPopup.vue";
import ProductSkuTags from "@/components/ProductSkuTags.vue";
import type { ProductSkuSelectionValue } from "@/types/ProductSkuSelection";
@@ -221,6 +237,13 @@ type DirectionFilter = "ALL" | StockRecordDirection;
const pageSize = 15;
const route = useRoute();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;库存流水没有内联编辑视图
const { selectedId, detailVersion, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/product-stock-records",
detail: id => `/management/product-stock-records/${id}`
});
const pageNavBarBackTo = ref<string>();
const router = useRouter();
const recordList = ref<StockRecord[]>([]);
@@ -389,25 +412,8 @@ function getDeltaClass(value?: number | string): string {
return 0 < amount ? "positive" : amount < 0 ? "negative" : "gray";
}
async function toDetail(record: StockRecord): Promise<void> {
if (record.id) {
await router.push({
name: "ProductStockRecordDetail",
params: { id: record.id },
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
});
}
}
function getCurrentRouteDepth(): number {
const transitionDepth = Array.isArray(route.query.transitionDepth)
? route.query.transitionDepth[0]
: route.query.transitionDepth;
const depth = Number(transitionDepth);
if (transitionDepth && Number.isInteger(depth) && 0 <= depth && depth <= 20) {
return depth;
}
return Number(route.meta.depth ?? 0);
function toDetail(record: StockRecord): void {
openDetail(record.id || "");
}
async function loadMore(force = false): Promise<void> {
@@ -671,7 +677,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-stock-record-list {
display: flex;
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
flex-direction: column;
.list-wrap {
+119 -111
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar product-stock-sku-list">
<div class="tui-page-layout tui-navbar product-stock-sku-list">
<t-navbar
fixed
:z-index="20"
@@ -7,104 +7,121 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.productStock.read" class="page-content scroll column list">
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索 SKU 名称、编码或规格"
/>
</div>
<div class="content">
<t-cell-group theme="card">
<t-cell title="产品" :note="product?.name" />
</t-cell-group>
<t-cell-group
v-if="skuStockList.length"
theme="card"
class="list fix-last-cell-line empty-cell-title-margin"
>
<t-cell
class="item"
v-for="item in skuStockList"
:key="item.skuId || item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
<master-detail-page
v-can="permissionCodes.productStock.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<t-pull-down-refresh
class="list-wrap empty-cell-title-margin pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="refresh"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
v-model="keyword"
class="keyword"
type="search"
borderless
clearable
placeholder="搜索 SKU 名称、编码或规格"
/>
</div>
<div class="content">
<t-cell-group theme="card">
<t-cell title="产品" :note="product?.name" />
</t-cell-group>
<t-cell-group
v-if="skuStockList.length"
theme="card"
class="list fix-last-cell-line empty-cell-title-margin"
>
<template #title>
<div class="title">
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
<div
v-if="getUnitList(item).length"
class="unit-options"
role="group"
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
>
<t-button
v-for="unit in getUnitList(item)"
:key="unit.id"
size="extra-small"
:theme="getSelectedUnit(item)?.id === unit.id ? 'primary' : 'default'"
:variant="getSelectedUnit(item)?.id === unit.id ? 'base' : 'outline'"
:aria-label="`切换到${unit.name || '未命名单位'}`"
:aria-pressed="getSelectedUnit(item)?.id === unit.id"
@click.stop="selectUnit(item, unit.id || '')"
<t-cell
class="item"
v-for="item in skuStockList"
:key="item.skuId || item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #title>
<div class="title">
<strong v-text="item.sku?.name || '未命名 SKU 明细'" />
<div
v-if="getUnitList(item).length"
class="unit-options"
role="group"
:aria-label="`切换${item.sku?.name || 'SKU'}库存单位`"
>
<span v-text="unit.name || '未命名单位'" />
</t-button>
<t-button
v-for="unit in getUnitList(item)"
:key="unit.id"
size="extra-small"
:theme="getSelectedUnit(item)?.id === unit.id ? 'primary' : 'default'"
:variant="getSelectedUnit(item)?.id === unit.id ? 'base' : 'outline'"
:aria-label="`切换到${unit.name || '未命名单位'}`"
:aria-pressed="getSelectedUnit(item)?.id === unit.id"
@click.stop="selectUnit(item, unit.id || '')"
>
<span v-text="unit.name || '未命名单位'" />
</t-button>
</div>
</div>
</div>
</template>
<template #leftIcon>
<t-image
v-if="getSkuPhotoURL(item)"
:src="getSkuPhotoURL(item)"
:alt="item.sku?.name || 'SKU 图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="skuStockList.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</main>
</template>
<template #leftIcon>
<t-image
v-if="getSkuPhotoURL(item)"
:src="getSkuPhotoURL(item)"
:alt="item.sku?.name || 'SKU 图片'"
fit="cover"
class="avatar"
/>
<div v-else class="avatar fallback" v-text="(item.sku?.name || 'S').slice(0, 1)" />
</template>
<template #description>
<div class="stock">
<span class="on-hand">
<span>库存</span>
<strong v-text="getStockQuantityText(item, item.onHandQuantity)" />
</span>
<span class="available">
<span>可用</span>
<strong v-text="getStockQuantityText(item, item.availableQuantity)" />
</span>
<span class="reserved">
<span>预占</span>
<strong v-text="getStockQuantityText(item, item.reservedQuantity)" />
</span>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="emptyText" />
<center-tips v-if="skuStockList.length" :content="isLoading ? '正在加载更多' : isNoMore ? '已经到底了' : '上拉加载更多'" />
</div>
</t-pull-down-refresh>
</template>
<template #detail>
<product-stock-detail
:key="`detail-${selectedId}-${detailVersion}`"
:sku-id="selectedId"
:product-id="productId"
/>
</template>
</master-detail-page>
</div>
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { useUserStore } from "timi-web-api";
import ProductAPI from "@/api/ProductAPI";
import ProductStockDetail from "@/pages/product/ProductStockDetail.vue";
import { getErrorMessage } from "@/utils/error";
import { convertBaseQuantityToPackageQuantity } from "@/utils/package";
import { getProductPhotoURL, getProductQuantityText } from "@/utils/product";
@@ -115,7 +132,6 @@ import type { Product, ProductSkuUnit, ProductStock } from "@/types/Product";
defineOptions({ name: "ProductStockSkuList" });
const router = useRouter();
const route = useRoute();
const userStore = useUserStore();
const keyword = ref("");
@@ -141,6 +157,14 @@ const emptyText = computed(() => {
return "该产品暂无启用库存管理的 SKU";
});
// ---------- 主从分栏 ----------
const { selectedId, detailVersion, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: `/management/product-stocks/${productId.value}/skus`,
// 整页详情带上 productId,转回分栏时才知道该回到哪个产品的 SKU 列表
detail: id => `/management/product-stocks/${id}?productId=${encodeURIComponent(productId.value)}`
});
function getSkuPhotoURL(item: ProductStock): string {
return item.sku ? getProductPhotoURL(item.sku) : "";
}
@@ -191,17 +215,6 @@ let keywordTimer: number | undefined;
let requestToken = 0;
let suppressKeywordFetch = false;
function getCurrentRouteDepth(): number {
const transitionDepth = Array.isArray(route.query.transitionDepth)
? route.query.transitionDepth[0]
: route.query.transitionDepth;
const depth = Number(transitionDepth);
if (transitionDepth && Number.isInteger(depth) && 0 <= depth && depth <= 20) {
return depth;
}
return Number(route.meta.depth ?? 0);
}
async function fetch(reset = false): Promise<void> {
if (!reset && (isLoading.value || isNoMore.value)) {
return;
@@ -274,15 +287,10 @@ async function loadMore(): Promise<void> {
}
}
async function toDetail(item: ProductStock): Promise<void> {
if (!item.skuId) {
return;
function toDetail(item: ProductStock): void {
if (item.skuId) {
openDetail(item.skuId);
}
await router.push({
name: "ProductStockDetail",
params: { skuId: item.skuId },
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
});
}
onMounted(async () => {
@@ -322,7 +330,7 @@ onUnmounted(() => {
<style scoped lang="less">
.product-stock-sku-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
@@ -59,7 +59,11 @@
<t-input v-model.trim="sku.name" borderless maxlength="128" placeholder="如 黑色运动鞋;男;36" />
</t-form-item>
<t-form-item label="SKU 条码">
<t-input v-model.trim="sku.barcode" borderless maxlength="64" placeholder="选填" />
<t-input
:model-value="sku.barcode ?? ''"
@update:model-value="value => sku.barcode = String(value).trim()"
borderless maxlength="64" placeholder="选填"
/>
</t-form-item>
<t-form-item label="库存管理" content-align="right">
<t-switch v-model="sku.stockEnabled" size="small" :disabled="props.productType === 'SERVICE'" />
@@ -74,7 +78,11 @@
<t-switch :model-value="sku.status === 'ACTIVE'" size="small" @change="setSkuStatus" />
</t-form-item>
<t-form-item label="备注">
<t-input v-model.trim="sku.remark" borderless maxlength="255" placeholder="选填" />
<t-input
:model-value="sku.remark ?? ''"
@update:model-value="value => sku.remark = String(value).trim()"
borderless maxlength="255" placeholder="选填"
/>
</t-form-item>
<div class="photo-wrap">
<attachment-selector
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar consumption-record-list">
<div class="tui-page-layout tui-navbar consumption-record-list">
<t-navbar
fixed
:z-index="20"
@@ -7,7 +7,7 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="permissionCodes.salesOrder.read" class="page-content scroll column list">
<main v-can="permissionCodes.salesOrder.read" class="tui-page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
@@ -462,7 +462,7 @@ onMounted(async () => {
<style scoped lang="less">
.consumption-record-list {
min-height: 100vh;
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.list-wrap {
+34 -4
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="pageAccess" class="package-record-detail">
<template v-if="record">
<section class="hero" v-entrance-transition>
@@ -124,6 +124,7 @@
</template>
<script setup lang="ts">
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { DialogPlugin } from "tdesign-mobile-vue";
import { TimeLabel, Text } from "timi-web";
import { useUserStore } from "timi-web-api";
@@ -145,8 +146,36 @@ type ReasonAction = "reject" | "cancel";
defineOptions({ name: "FundRecordDetail" });
// 公共变量
const props = withDefaults(defineProps<{
/** 指定流水 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
recordId?: string;
}>(), {
recordId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.recordId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/fund-records",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const isOperating = ref(false);
@@ -178,7 +207,7 @@ function getRecordStatusTheme(recordValue: FundRecord): "success" | "warning" |
}
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
if (!id) {
return;
}
@@ -331,6 +360,7 @@ async function toRevoke(): Promise<void> {
// ---------- 生命周期 ----------
onMounted(loadData);
watch(() => [props.recordId, route.params.id], loadData);
</script>
<style scoped lang="less">
+163 -157
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar sales-order-record-list">
<div class="tui-page-layout tui-navbar sales-order-record-list">
<t-navbar
fixed
:z-index="20"
@@ -7,150 +7,164 @@
left-arrow
@left-click="$router.back()"
/>
<main v-can="pageAccess" class="page-content scroll column list">
<t-pull-down-refresh
class="pull-refresh"
v-model="isRefreshing"
:refresh-timeout="30000"
@refresh="reload"
@scrolltolower="loadMore"
>
<div class="filters glass">
<t-input
class="customer"
v-model.trim="customerSearchKeyword"
borderless
placeholder="输入客户编码或姓名"
@enter="applyCustomerSearch"
>
<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 class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<t-dropdown-item
v-if="!isSelfReceiveOnly"
v-model="operationType"
:label="operationFilterLabel"
:options="operationOptions"
@change="selectOperation"
/>
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
<master-detail-page
v-can="pageAccess"
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="loadMore"
>
<div class="filters glass">
<t-input
class="customer"
v-model.trim="customerSearchKeyword"
borderless
placeholder="输入客户编码或姓名"
@enter="applyCustomerSearch"
>
<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 class="menus">
<t-dropdown-item
v-model="dateFilterType"
:label="dateFilterLabel"
:options="dateOptions"
@change="selectDateFilter"
/>
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer clip-text" v-text="getCustomerText(item)" />
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
<t-tag
size="small"
:content="getRecordStatusText(item)"
variant="light-outline"
:theme="getRecordStatusTheme(item)"
<t-dropdown-item
v-if="!isSelfReceiveOnly"
v-model="operationType"
:label="operationFilterLabel"
:options="operationOptions"
@change="selectOperation"
/>
<t-dropdown-item
v-model="status"
label="状态"
:options="statusOptions"
@change="selectStatus"
/>
</t-dropdown-menu>
</div>
<t-cell-group v-if="isCustomDate" class="date-summary" theme="card">
<t-cell
title="开始时间"
:note="dateRange[0] || '-'"
arrow
@click="openStartTime"
/>
<t-cell
title="结束时间"
:note="dateRange[1] || '-'"
arrow
@click="openEndTime"
/>
</t-cell-group>
<t-cell-group v-if="recordList.length" class="empty-cell-title-margin" theme="card">
<t-cell
class="item"
v-for="item in recordList"
:key="item.id"
arrow
v-entrance-transition="{ step: 30 }"
@click="toDetail(item)"
>
<template #leftIcon>
<t-image
v-if="getCustomerPhotoURL(item.customer, 64)"
:src="getCustomerPhotoURL(item.customer, 64)"
:alt="getCustomerText(item)"
fit="cover"
class="avatar"
/>
</div>
</template>
<template #description>
<div class="description">
<div class="operator">
<div class="field">
<span class="label">发起人</span>
<span class="text-bold" v-text="getOperatorText(item)" />
</div>
<div v-if="item.verifier" class="field">
<span class="label">核销人</span>
<span class="text-bold" v-text="getVerifierText(item)" />
</div>
<time-label :timestamp="item.occurredAt" underline />
<div v-else class="avatar fallback" v-text="getCustomerText(item).slice(0, 1)" />
</template>
<template #title>
<div class="title">
<span class="customer clip-text" v-text="getCustomerText(item)" />
<span class="type" :class="getOperationClass(item.operationType)" v-text="getFundOperationText(item.operationType)" />
<t-tag
size="small"
:content="getRecordStatusText(item)"
variant="light-outline"
:theme="getRecordStatusTheme(item)"
/>
</div>
<div class="amounts">
<div class="order-amount">
<span class="label">订单总价</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
</template>
<template #description>
<div class="description">
<div class="operator">
<div class="field">
<span class="label">发起人</span>
<span class="text-bold" v-text="getOperatorText(item)" />
</div>
<div v-if="item.verifier" class="field">
<span class="label">核销人</span>
<span class="text-bold" v-text="getVerifierText(item)" />
</div>
<time-label :timestamp="item.occurredAt" underline />
</div>
<div class="unpaid-amount">
<span class="label">剩余待收</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderUnpaidAmountSnapshot)" />
</div>
<div class="record-amount">
<span class="label">流水金额</span>
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.amount)" />
<div class="amounts">
<div class="order-amount">
<span class="label">订单总价</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderAmount)" />
</div>
<div class="unpaid-amount">
<span class="label">剩余待收</span>
<span>¥</span>
<span v-text="formatPackageAmount(item.salesOrderUnpaidAmountSnapshot)" />
</div>
<div class="record-amount">
<span class="label">流水金额</span>
<span class="red">¥</span>
<span class="value red" v-text="formatPackageAmount(item.amount)" />
</div>
</div>
</div>
</div>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载资金流水' : '暂无资金流水'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</main>
</template>
</t-cell>
</t-cell-group>
<center-tips v-else :content="loading ? '正在加载资金流水' : '暂无资金流水'" />
<center-tips :content="loadStateText" />
</t-pull-down-refresh>
</template>
<template #detail>
<fund-record-detail
:key="`detail-${selectedId}`"
:record-id="selectedId"
/>
</template>
</master-detail-page>
<customer-selector
v-model="customerId"
v-model:visible="customerSelectorVisible"
@@ -184,7 +198,9 @@
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { type DropdownValue } from "tdesign-mobile-vue";
import FundRecordDetail from "@/pages/salesOrder/FundRecordDetail.vue";
import { TimeLabel, Time } from "timi-web";
import { useUserStore } from "timi-web-api";
import CustomerAPI from "@/api/CustomerAPI";
@@ -206,6 +222,12 @@ defineOptions({ name: "FundRecordList" });
const route = useRoute();
const router = useRouter();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;资金流水没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/fund-records",
detail: id => `/management/fund-records/${id}`
});
const userStore = useUserStore();
const recordList = ref<FundRecord[]>([]);
const operationType = ref(route.query.operationType === "RECEIVE" ? "RECEIVE" : "ALL");
@@ -487,23 +509,7 @@ function getRecordStatusTheme(item: FundRecord): "success" | "warning" | "danger
}
async function toDetail(item: FundRecord): Promise<void> {
if (item.id) {
await router.push({
path: `/management/fund-records/${item.id}`,
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
});
}
}
function getCurrentRouteDepth(): number {
const transitionDepth = Array.isArray(route.query.transitionDepth)
? route.query.transitionDepth[0]
: route.query.transitionDepth;
const depth = Number(transitionDepth);
if (transitionDepth && Number.isInteger(depth) && 0 <= depth && depth <= 20) {
return depth;
}
return Number(route.meta.depth ?? 0);
openDetail(item.id || "");
}
onMounted(async () => {
@@ -522,7 +528,7 @@ onMounted(async () => {
<style scoped lang="less">
.sales-order-record-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.item {
+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"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.fund.revoke" class="package-operation-edit">
<t-cell-group v-if="record" title="原资金记录" theme="card" v-entrance-transition>
<t-cell title="操作类型" :note="getFundOperationText(record.operationType)" />
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-layout navbar sales-order-cancel">
<div class="tui-page-layout tui-navbar sales-order-cancel">
<t-navbar fixed :z-index="20" title="取消销售订单" left-arrow @left-click="$router.back()">
<template #right>
<t-button
@@ -14,7 +14,7 @@
/>
</template>
</t-navbar>
<main v-can="permissionCodes.salesOrder.cancel" class="page-content scroll column notice">
<main v-can="permissionCodes.salesOrder.cancel" class="tui-page-content scroll column notice">
<t-notice-bar
theme="warning"
visible
+6 -2
View File
@@ -97,7 +97,11 @@
/>
</t-form-item>
<t-form-item label="产品备注">
<t-input v-model="item.remark" borderless placeholder="选填" />
<t-input
:model-value="item.remark ?? ''"
@update:model-value="value => item.remark = String(value).trim()"
borderless placeholder="选填"
/>
</t-form-item>
<div class="price">
<animated-amount
@@ -599,7 +603,7 @@ onMounted(() => {
.sales-order-create {
gap: 1rem;
display: flex;
padding: calc(var(--app-nav-height) + 1rem) 0 calc(6.5rem + env(safe-area-inset-bottom, 0));
padding: calc(var(--tui-nav-height) + 1rem) 0 calc(6.5rem + env(safe-area-inset-bottom, 0));
flex-direction: column;
.form {
+34 -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.salesOrder.read" class="sales-order-detail">
<template v-if="order">
<customer-profile-card
@@ -252,13 +252,42 @@ import {
} from "@/utils/salesOrder";
import { Message } from "@/utils/message";
import { gaoRoleCodes, permissionCodes } from "@/utils/permission";
import { useExpandToMaster, usePane } from "timi-tdesign-mobile";
import { uploadPhotoList } from "@/utils/photo";
import type { GaoSalesOrderItem, GaoSalesPaymentStatus, SalesOrder } from "@/types/SalesOrder";
defineOptions({ name: "SalesOrderDetail" });
const props = withDefaults(defineProps<{
/** 指定订单 ID 时忽略路由参数,用于平板主从分栏的内联渲染。 */
orderId?: string;
}>(), {
orderId: ""
});
const route = useRoute();
const router = useRouter();
function resolveId(): string {
return props.orderId || String(route.params.id || "");
}
// 竖屏整页进来后转成横屏:回到列表页并恢复右栏选中,而不是继续停在整页详情
useExpandToMaster({
path: "/management/sales-orders",
id: () => resolveId()
});
/** 非空说明当前被内联在主从分栏的右栏里 */
const pane = usePane();
function goBack(): void {
if (pane) {
pane.close();
return;
}
void router.back();
}
const userStore = useUserStore();
const order = ref<SalesOrder>();
const loading = ref(false);
@@ -372,7 +401,7 @@ function getItemFulfillmentStatus(item: GaoSalesOrderItem): { text: string; them
}
async function loadData(): Promise<void> {
const id = String(route.params.id || "");
const id = resolveId();
isEditing.value = false;
if (!id) {
order.value = undefined;
@@ -499,7 +528,7 @@ function getCurrentRouteDepth(): number {
}
onMounted(loadData);
watch(() => route.params.id, loadData);
watch(() => [props.orderId, route.params.id], loadData);
</script>
<style scoped lang="less">
+115 -105
View File
@@ -1,97 +1,112 @@
<template>
<div class="page-layout navbar sales-order-list">
<div class="tui-page-layout tui-navbar sales-order-list">
<t-navbar fixed :z-index="20" title="销售订单" left-arrow @left-click="$router.back()">
<template #right>
<navbar-actions :actions="actions" :visible="route.name === 'SalesOrderList'" />
</template>
</t-navbar>
<main ref="salesOrderListRef" v-can="permissionCodes.salesOrder.read" class="page-content scroll column 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>
<master-detail-page
ref="salesOrderListRef"
v-can="permissionCodes.salesOrder.read"
class="list"
:split="isWide"
:selected="!!selectedId"
:direction="paneDirection"
>
<template #master>
<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>
<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)"
/>
<center-tips v-if="!list.length" :content="loading ? '正在加载销售订单' : '暂无销售订单'" />
</div>
<center-tips :content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</main>
<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)"
/>
<center-tips v-if="!list.length" :content="loading ? '正在加载销售订单' : '暂无销售订单'" />
</div>
<center-tips :content="loading ? '正在加载' : noMore ? '已经到底了' : '上拉加载更多'" />
</t-pull-down-refresh>
</template>
<template #detail>
<sales-order-detail
:key="`detail-${selectedId}`"
:order-id="selectedId"
/>
</template>
</master-detail-page>
<customer-selector
v-model="customerId"
@@ -108,7 +123,9 @@
</template>
<script setup lang="ts">
import { MasterDetailPage, useMasterDetailPane } from "timi-tdesign-mobile";
import { Toolkit } from "timi-web";
import SalesOrderDetail from "@/pages/salesOrder/SalesOrderDetail.vue";
import { useUserStore } from "timi-web-api";
import { onBeforeRouteLeave } from "vue-router";
import CustomerAPI from "@/api/CustomerAPI";
@@ -146,10 +163,17 @@ import type { Customer } from "@/types/Customer";
defineOptions({ name: "SalesOrderList" });
const SALES_ORDER_FILTER_STORAGE_KEY = "gao-customer-h5:sales-order-filter";
const route = useRoute();
// 选中项、切换方向、关闭逻辑、转屏、query 同步都在这里;订单没有内联编辑视图
const { selectedId, paneDirection, isWide, openDetail } = useMasterDetailPane({
path: "/management/sales-orders",
detail: id => `/management/sales-orders/${id}`
});
const router = useRouter();
const salesOrderListRef = ref<HTMLElement | null>(null);
const salesOrderListRef = ref<ComponentPublicInstance | null>(null);
const currentStoreStore = useCurrentStoreStore();
const userStore = useUserStore();
const canCreate = computed(() => userStore.hasPermissions(permissionCodes.salesOrder.create));
@@ -167,7 +191,7 @@ let unregisterSalesOrderListEvent: (() => void) | undefined;
let isDisposed = false;
function getSalesOrderPage(): HTMLElement | null {
return salesOrderListRef.value?.querySelector<HTMLElement>(".pull-refresh") || null;
return (salesOrderListRef.value?.$el as HTMLElement | undefined)?.querySelector<HTMLElement>(".pull-refresh") || null;
}
function savePageScrollPosition(): void {
@@ -600,21 +624,7 @@ async function handleCustomerChange(): Promise<void> {
}
async function toDetail(item: SalesOrder): Promise<void> {
if (item.id) await router.push({
path: `/management/sales-orders/${item.id}`,
query: { transitionDepth: String(getCurrentRouteDepth() + 1) }
});
}
function getCurrentRouteDepth(): number {
const transitionDepth = Array.isArray(route.query.transitionDepth)
? route.query.transitionDepth[0]
: route.query.transitionDepth;
const depth = Number(transitionDepth);
if (transitionDepth && Number.isInteger(depth) && 0 <= depth && depth <= 20) {
return depth;
}
return Number(route.meta.depth ?? 0);
openDetail(item.id || "");
}
async function toPayment(item: SalesOrder): Promise<void> {
@@ -764,7 +774,7 @@ onUnmounted(() => {
<style scoped lang="less">
.sales-order-list {
padding: var(--app-nav-height) 0 1rem;
padding: var(--tui-nav-height) 0 1rem;
.filters {
+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"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.fund.refund" class="sales-order-operation">
<t-cell-group v-if="order" title="销售订单" theme="card" v-entrance-transition>
<t-cell title="订单号" :note="order.orderNo || order.id" />
+2 -2
View File
@@ -1,5 +1,5 @@
<template>
<div v-can="permissionCodes.fundReceive.create" class="page-layout navbar sales-order-payment">
<div v-can="permissionCodes.fundReceive.create" class="tui-page-layout tui-navbar sales-order-payment">
<t-navbar
fixed
:z-index="20"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<t-cell-group
v-if="order"
title="销售订单"
+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"
@@ -18,7 +18,7 @@
/>
</template>
</t-navbar>
<main class="page-content scroll column">
<main class="tui-page-content scroll column">
<div v-can="permissionCodes.fund.refund" class="sales-order-operation">
<t-cell-group
v-if="order"
+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 class="about-page">
<section class="brand" v-entrance-transition>
<logo @click="handleLogoClick" />
+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 class="agreement-page">
<template v-if="article">
<header class="header" v-entrance-transition>

Some files were not shown because too many files have changed in this diff Show More