Commit 802c492e by liimin

refactor(reception): 重构接待中心筛选器组件

- 创建统一的 ReceptionFilters 组件替代原有的主次筛选组件
- 在客户列表标签页中集成新的筛选器组件
- 移除废弃的筛选器相关组件导入和使用
- 优化仪表板时间进度计算,添加数值范围限制
- 移除未使用的产值卡片相关代码和样式
- 简化组件
1 parent 731e68d7
<template>
<view class="reception-filters" :class="{ 'filter-section--wrap': receptionFilterNarrowMode }">
<!-- Primary Filter: 主筛选(已提交/未提交) -->
<view v-if="listSubTabIndex == 0" class="rcf-half">
<view class="filter-tabs-row entry-filter-segmented-wrap">
<un-segmented
type="card"
:font-size="'var(--reception-list-filters-segmented-font-size, 14px)'"
:custom-style="{ height: 'var(--reception-list-filters-segmented-height, 40px)' }"
bg-color="#f1f5f9"
active-color="#000000"
:model-value="filterTabIndex"
@update:model-value="emit('switchFilterTab', $event)"
>
<un-segmented-item text="已提交"></un-segmented-item>
<un-segmented-item text="未提交"></un-segmented-item>
</un-segmented>
</view>
</view>
<!-- Secondary Filter: 次级筛选(战败/成交、待上传/待提交) -->
<view class="filter-actions filter-actions--review" v-if="listSubTabIndex == 0">
<!-- 已提交 Tab: 显示战败/成交 -->
<view v-if="filterTabIndex == 0" class="rcf-review-half review-tabs-wrap-wide">
<view class="filter-tabs-row entry-filter-segmented-wrap">
<un-segmented
type="card"
:font-size="'var(--reception-list-filters-segmented-font-size, 14px)'"
:custom-style="{ height: 'var(--reception-list-filters-segmented-height, 40px)' }"
bg-color="#f1f5f9"
active-color="#000000"
:model-value="submittedResultTabIndex"
@update:model-value="onSwitchSubmittedResult($event)"
>
<un-segmented-item text="战败"></un-segmented-item>
<un-segmented-item text="成交"></un-segmented-item>
</un-segmented>
</view>
</view>
<!-- 未提交 Tab: 显示待上传/待提交 -->
<view v-if="filterTabIndex == 1" class="rcf-review-half review-tabs-wrap-wide">
<view class="filter-tabs-row entry-filter-segmented-wrap">
<un-segmented
type="card"
:font-size="'var(--reception-list-filters-segmented-font-size, 14px)'"
:custom-style="{ height: 'var(--reception-list-filters-segmented-height, 40px)' }"
bg-color="#f1f5f9"
active-color="#000000"
:model-value="unsubmittedPendingTabIndex"
@update:model-value="emit('switchUnsubmittedPendingTab', $event)"
>
<un-segmented-item text="待上传"></un-segmented-item>
<un-segmented-item text="待提交"></un-segmented-item>
</un-segmented>
</view>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from 'vue'
const props = withDefaults(defineProps<{
listSubTabIndex: number
filterTabIndex: number
submittedResultTabIndex: number
unsubmittedPendingTabIndex: number
receptionFilterNarrowMode?: boolean
}>(), {
listSubTabIndex: 0,
filterTabIndex: 0,
submittedResultTabIndex: 0,
unsubmittedPendingTabIndex: 0,
receptionFilterNarrowMode: false
})
const emit = defineEmits<{
switchFilterTab: [number]
switchSubmittedResultTab: [number]
switchUnsubmittedPendingTab: [number]
}>()
const onSwitchSubmittedResult = (event: any) => {
const tabIndex: number = event as number
emit('switchSubmittedResultTab', tabIndex)
}
</script>
<style scoped lang="scss">
@import "../styles/reception-filter-shared.scss";
.reception-filters {
display: flex;
flex-direction: row;
gap: 8px;
width: 100%;
}
.rcf-half {
flex: 1;
min-width: 0;
}
.filter-actions.filter-actions--review {
flex: 2 1 0;
min-width: 0;
}
.rcf-review-half {
width: 100%;
}
.review-tabs-wrap-wide {
width: 100%;
}
.filter-tabs-row.entry-filter-segmented-wrap {
height: var(--reception-list-filters-tabs-row-height, 40px);
min-height: var(--reception-list-filters-tabs-row-height, 40px);
}
/* ✅ 响应式布局:窄屏时垂直排列 */
.filter-section--wrap {
flex-direction: column;
gap: 8px;
}
.filter-section--wrap .rcf-half,
.filter-section--wrap .filter-actions--review {
width: 100%;
}
</style>
...@@ -25,22 +25,14 @@ ...@@ -25,22 +25,14 @@
</view> </view>
<view class="filter-section" :class="{ 'filter-section--wrap': receptionFilterNarrowMode }"> <view class="filter-section" :class="{ 'filter-section--wrap': receptionFilterNarrowMode }">
<ReceptionListPrimaryFilter <ReceptionFilters
:list-sub-tab-index="listSubTabIndex"
:entry-filter-index="entryFilterIndex"
:filter-tab-index="filterTabIndex"
@switch-entry-filter-tab="(idx: number) => { entryFilterIndex = idx }"
@switch-filter-tab="onFilterTabChange"
@customer-entry-click="onCustomerEntryClick"
/>
<ReceptionListSecondaryFilter
:list-sub-tab-index="listSubTabIndex" :list-sub-tab-index="listSubTabIndex"
:filter-tab-index="filterTabIndex" :filter-tab-index="filterTabIndex"
:submitted-result-tab-index="submittedResultTabIndex" :submitted-result-tab-index="submittedResultTabIndex"
:review-tab-index="reviewTabIndex"
:unsubmitted-pending-tab-index="unsubmittedPendingTabIndex" :unsubmitted-pending-tab-index="unsubmittedPendingTabIndex"
:reception-filter-narrow-mode="receptionFilterNarrowMode"
@switch-filter-tab="onFilterTabChange"
@switch-submitted-result-tab="onSwitchSubmittedResultTab" @switch-submitted-result-tab="onSwitchSubmittedResultTab"
@open-review-picker="showReviewPicker = true"
@switch-unsubmitted-pending-tab="onUnsubmittedPendingChange" @switch-unsubmitted-pending-tab="onUnsubmittedPendingChange"
/> />
</view> </view>
...@@ -83,22 +75,14 @@ ...@@ -83,22 +75,14 @@
</view> </view>
<view class="filter-section" :class="{ 'filter-section--wrap': receptionFilterNarrowMode }"> <view class="filter-section" :class="{ 'filter-section--wrap': receptionFilterNarrowMode }">
<ReceptionListPrimaryFilter <ReceptionFilters
:list-sub-tab-index="listSubTabIndex"
:entry-filter-index="entryFilterIndex"
:filter-tab-index="filterTabIndex"
@switch-entry-filter-tab="(idx: number) => { entryFilterIndex = idx }"
@switch-filter-tab="onFilterTabChange"
@customer-entry-click="onCustomerEntryClick"
/>
<ReceptionListSecondaryFilter
:list-sub-tab-index="listSubTabIndex" :list-sub-tab-index="listSubTabIndex"
:filter-tab-index="filterTabIndex" :filter-tab-index="filterTabIndex"
:submitted-result-tab-index="submittedResultTabIndex" :submitted-result-tab-index="submittedResultTabIndex"
:review-tab-index="reviewTabIndex"
:unsubmitted-pending-tab-index="unsubmittedPendingTabIndex" :unsubmitted-pending-tab-index="unsubmittedPendingTabIndex"
:reception-filter-narrow-mode="receptionFilterNarrowMode"
@switch-filter-tab="onFilterTabChange"
@switch-submitted-result-tab="onSwitchSubmittedResultTab" @switch-submitted-result-tab="onSwitchSubmittedResultTab"
@open-review-picker="showReviewPicker = true"
@switch-unsubmitted-pending-tab="onUnsubmittedPendingChange" @switch-unsubmitted-pending-tab="onUnsubmittedPendingChange"
/> />
</view> </view>
...@@ -178,8 +162,7 @@ import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent ...@@ -178,8 +162,7 @@ import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent
import ListCustomer from '../lists/ListCustomer.uvue' import ListCustomer from '../lists/ListCustomer.uvue'
import ListReception from '../lists/ListReception.uvue' import ListReception from '../lists/ListReception.uvue'
import CustomEmpty from '@/components/CustomEmpty/index.uvue' import CustomEmpty from '@/components/CustomEmpty/index.uvue'
import ReceptionListPrimaryFilter from '../filters/ReceptionListPrimaryFilter.uvue' import ReceptionFilters from '../filters/ReceptionFilters.uvue'
import ReceptionListSecondaryFilter from '../filters/ReceptionListSecondaryFilter.uvue'
import { useIsPortrait } from '@/services/adapter/hooks/index.uts' import { useIsPortrait } from '@/services/adapter/hooks/index.uts'
type ReceptionListSubTabItem = { type ReceptionListSubTabItem = {
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
</view> </view>
<view class="progress-meta-row"> <view class="progress-meta-row">
<text class="progress-label-text">时间进度</text> <text class="progress-label-text">时间进度</text>
<text class="progress-value-text">{{ performanceMetricsVisible ? (timeProgressPercent + '%') : '**' }}</text> <text class="progress-value-text">{{ performanceMetricsVisible ? (Math.min(100, Math.max(0, timeProgress)) + '%') : '**' }}</text>
</view> </view>
<view class="progress-bar-bg"> <view class="progress-bar-bg">
<view class="progress-bar-fill" :style="{ width: progressWidth }"></view> <view class="progress-bar-fill" :style="{ width: progressWidth }"></view>
...@@ -32,22 +32,6 @@ ...@@ -32,22 +32,6 @@
<!-- ✅ 性能优化:使用 v-if 延迟渲染重型组件,避免同时初始化 --> <!-- ✅ 性能优化:使用 v-if 延迟渲染重型组件,避免同时初始化 -->
<CardFlow v-if="shouldRenderCardFlow" :performance-data="flowPerformanceDataRef" :metrics-visible="performanceMetricsVisible" /> <CardFlow v-if="shouldRenderCardFlow" :performance-data="flowPerformanceDataRef" :metrics-visible="performanceMetricsVisible" />
<CardOutputValue
:tab-index="outputTabIndex"
:compare-rows="currentOutputTab.compareRows"
:metrics-visible="performanceMetricsVisible"
@update:tab-index="onUpdateOutputTabIndex"
v-if="false"
/>
<view class="card-month-value-wrap">
<CardMonthValue
:summary="currentOutputTab.summary"
:target-value-text="targetValueText"
:achievement-value-text="achievementValueText"
:metrics-visible="performanceMetricsVisible"
v-if="false"
/>
</view>
<view class="card-time-value-wrap"> <view class="card-time-value-wrap">
<CardTimeBoard v-if="shouldRenderCardTimeBoard" :data="timeBoardDataRef" :metrics-visible="performanceMetricsVisible" /> <CardTimeBoard v-if="shouldRenderCardTimeBoard" :data="timeBoardDataRef" :metrics-visible="performanceMetricsVisible" />
...@@ -59,12 +43,8 @@ ...@@ -59,12 +43,8 @@
<script setup lang="uts"> <script setup lang="uts">
import { computed, nextTick, ref } from 'vue' import { computed, nextTick, ref } from 'vue'
import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent } from '@/types/uview-unix-types.uts'
import CardFlow from '../cards/CardFlow.uvue' import CardFlow from '../cards/CardFlow.uvue'
import CardOutputValue from '../cards/CardOutputValue.uvue'
import CardMonthValue from '../cards/CardMonthValue.uvue'
import CardTimeBoard from '../cards/CardTimeBoard.uvue' import CardTimeBoard from '../cards/CardTimeBoard.uvue'
import type { CompareRow, OutputSummary, OutputTabData } from '../types/reception-output-types.uts'
import { useOrientation } from '@/services/adapter/hooks/index.uts' import { useOrientation } from '@/services/adapter/hooks/index.uts'
/** ✅ 工具函数:格式化日期为 YYYY-MM-DD */ /** ✅ 工具函数:格式化日期为 YYYY-MM-DD */
...@@ -111,8 +91,6 @@ function getNum(obj: UTSJSONObject, key: string): number { ...@@ -111,8 +91,6 @@ function getNum(obj: UTSJSONObject, key: string): number {
return isNaN(n) ? 0 : n return isNaN(n) ? 0 : n
} }
const emit = defineEmits<{}>()
// ✅ 性能优化:复用 adapter 的 useOrientation Hook,避免直接调用 getSystemInfoSync // ✅ 性能优化:复用 adapter 的 useOrientation Hook,避免直接调用 getSystemInfoSync
const orientation = useOrientation() const orientation = useOrientation()
...@@ -120,28 +98,8 @@ const orientation = useOrientation() ...@@ -120,28 +98,8 @@ const orientation = useOrientation()
const shouldRenderCardFlow = ref(false) const shouldRenderCardFlow = ref(false)
const shouldRenderCardTimeBoard = ref(false) const shouldRenderCardTimeBoard = ref(false)
// ✅ 内部管理产值卡片 Tab 索引(0=转化率,1=客单价)
const outputTabIndex = ref(0)
// ✅ 内部管理业绩指标可见性(睁眼/闭眼) // ✅ 内部管理业绩指标可见性(睁眼/闭眼)
const performanceMetricsVisible = ref(true) const performanceMetricsVisible = ref(true)
type PerformanceTypeItem = { label: string; value: number }
function performanceTypeList(): UnPickerColumn {
let list: PerformanceTypeItem[] = []
// TODO: 需要从父组件获取 isHarmonyValue,暂时使用默认值
list = [
{ label: "延保", value: 1 },
{ label: "权益", value: 3 },
]
const items: UnPickerColumn = []
let i = 0
while (i < list.length) {
items.push({ text: list[i].label, value: list[i].value } as UnPickerColumnItem)
i++
}
return items
}
// ✅ 内部数据计算逻辑(从父组件迁移) // ✅ 内部数据计算逻辑(从父组件迁移)
/** ✅ 计算漏斗性能数据 */ /** ✅ 计算漏斗性能数据 */
...@@ -273,40 +231,13 @@ function setTimeProgress(): void { ...@@ -273,40 +231,13 @@ function setTimeProgress(): void {
// e.g. 2026-03-30 => 30 / 31 => 97% // e.g. 2026-03-30 => 30 / 31 => 97%
const now = new Date() const now = new Date()
const nowNum = now.getDate() const nowNum = now.getDate()
// 通过“下个月第 0 天”拿到“本月最后一天”,从而得到当月天数 // 通过"下个月第 0 天"拿到"本月最后一天",从而得到当月天数
const monthDayNum = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate() const monthDayNum = new Date(now.getFullYear(), now.getMonth() + 1, 0).getDate()
timeProgress.value = monthDayNum > 0 ? Math.round(nowNum / monthDayNum * 100) : 0 timeProgress.value = monthDayNum > 0 ? Math.round(nowNum / monthDayNum * 100) : 0
} }
// 页面首次渲染也要有值(避免首帧出现 0% 闪烁) // 页面首次渲染也要有值(避免首帧出现 0% 闪烁)
setTimeProgress() setTimeProgress()
const timeProgressPercent = computed((): number => {
// 防御性 clamp:确保 width 与文本不会出现异常值
if (timeProgress.value < 0) { return 0 }
if (timeProgress.value > 100) { return 100 }
return timeProgress.value
})
/** ✅ 本月产值卡片底部:目标产值展示 */
const monthValueTargetText = computed((): string => {
const d = props.performanceData
const v = getNum(d, "targetProduction")
if (v > 0) {
return `${v.toFixed(0) }万`
}
return "-"
})
/** ✅ 本月产值卡片底部:达成比例 */
const monthValueAchievementText = computed((): string => {
const d = props.performanceData
const v = getNum(d, "productionContribution")
if (v > 0) {
return `${v.toFixed(0) }%`
}
return "-"
})
/** ✅ 漏斗性能数据:优先使用传入的,否则内部计算 */ /** ✅ 漏斗性能数据:优先使用传入的,否则内部计算 */
const flowPerformanceDataRef = computed((): UTSJSONObject => { const flowPerformanceDataRef = computed((): UTSJSONObject => {
const v = props.flowPerformanceData const v = props.flowPerformanceData
...@@ -327,67 +258,10 @@ const timeBoardDataRef = computed((): UTSJSONObject => { ...@@ -327,67 +258,10 @@ const timeBoardDataRef = computed((): UTSJSONObject => {
return calcTimeBoardData(props.allReceptionRecords != null ? props.allReceptionRecords : null) return calcTimeBoardData(props.allReceptionRecords != null ? props.allReceptionRecords : null)
}) })
/** ✅ 当前输出 Tab 数据(转化率/客单价) */
const currentOutputTab = computed((): OutputTabData => {
const d = props.performanceData
const idx = outputTabIndex.value
// 转化率:当前值即百分比(0-100),宽度 = 当前值/100 换算为百分比展示,即 value%
const toRatePct = (x: number): string => `${Math.min(100, x).toFixed(1) }%`
const compareRows0: CompareRow[] = [
{ label: "优秀门店均值", barWidthPercent: toRatePct(getNum(d, "excellentStoreAvgDealRate")), barClass: "bg-blue-500", value: `${getNum(d, "excellentStoreAvgDealRate").toFixed(1) }%` } as any,
{ label: "本门店", barWidthPercent: toRatePct(getNum(d, "thisStoreDealRate")), barClass: "bg-blue-400", value: `${getNum(d, "thisStoreDealRate").toFixed(1) }%` } as any,
{ label: "个人", barWidthPercent: toRatePct(getNum(d, "personalDealRate")), barClass: "bg-blue-400", value: `${getNum(d, "personalDealRate").toFixed(1) }%` } as any
]
const summary0: OutputSummary = {
summaryLabel: "实际产值",
summaryValueNum: getNum(d, "actualProduction").toFixed(1),
summaryValueUnit: "万",
personalLabel: "个人产值",
personalValue: `${getNum(d, "personalProduction").toFixed(1) }万`,
ringPercent: `${getNum(d, "achievementRatio").toFixed(1) }%`,
ringLabel: "达成率",
ringPercentNum: Math.min(100, getNum(d, "achievementRatio")),
ringComparePercent: 100
}
const tab0: OutputTabData = {
compareRows: compareRows0,
summary: summary0
}
const eAvg = getNum(d, "excellentStoreAvgDeal")
const thisVal = getNum(d, "thisStoreKdj")
const perVal = getNum(d, "personalKdj")
// 客单价:以最大值为100%基准,当前值/最大值*100 换算展示
const maxDeal = eAvg > thisVal ? (Math.max(eAvg, perVal)) : (Math.max(thisVal, perVal))
const toDealPct = (x: number): string => `${(maxDeal > 0 ? (x / maxDeal * 100) : 0).toFixed(1) }%`
const compareRows1: CompareRow[] = [
{ label: "优秀门店均值", barWidthPercent: toDealPct(eAvg), barClass: "bg-blue-500", value: `¥${ Math.round(eAvg)}` } as any,
{ label: "本门店", barWidthPercent: toDealPct(thisVal), barClass: "bg-blue-400", value: `¥${ Math.round(thisVal)}` } as any,
{ label: "个人", barWidthPercent: toDealPct(perVal), barClass: "bg-blue-400", value: `¥${ Math.round(perVal)}` } as any
]
const summary1: OutputSummary = {
summaryLabel: "实际产值",
summaryValueNum: getNum(d, "actualProduction").toFixed(1),
summaryValueUnit: "万",
personalLabel: "个人产值",
personalValue: `${getNum(d, "personalProduction").toFixed(1) }万`,
ringPercent: `${getNum(d, "achievementRatio").toFixed(1) }%`,
ringLabel: "达成率",
ringPercentNum: Math.min(100, getNum(d, "achievementRatio")),
ringComparePercent: 100
}
const tab1: OutputTabData = {
compareRows: compareRows1,
summary: summary1
}
if (idx == 1) { return tab1 }
return tab0
})
function onUpdateOutputTabIndex(index: number): void {
outputTabIndex.value = index
}
const progressWidth = computed((): string => { const progressWidth = computed((): string => {
const raw = timeProgressPercent.value // ✅ 直接在这里做 clamp,避免额外的计算属性
const raw = timeProgress.value
const pct = (typeof raw == 'number' && isNaN(raw) != true) ? raw : 0 const pct = (typeof raw == 'number' && isNaN(raw) != true) ? raw : 0
const w = pct < 0 ? 0 : (pct > 100 ? 100 : pct) const w = pct < 0 ? 0 : (pct > 100 ? 100 : pct)
const displayW = w > 0 && w < 4 ? 4 : w const displayW = w > 0 && w < 4 ? 4 : w
...@@ -408,21 +282,10 @@ const headerEyeIconSize = computed((): number => { ...@@ -408,21 +282,10 @@ const headerEyeIconSize = computed((): number => {
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.card-month-value-wrap { .card-time-value-wrap {
margin: 0; margin: 0;
} flex: 1; /* ✅ 640x1024 竖屏:让时效统计卡片占据剩余空间 */
.card-time-value-wrap {
margin: 0;
flex: 1; /* ✅ 640x1024 竖屏:让时效统计卡片占据剩余空间 */
min-height: 0;
}
// @import "../styles/common.scss";
.dashboard-scroll-view {
flex: 1;
min-height: 0; min-height: 0;
width: 100%;
height: auto;
background-color: #f8f9fa;
} }
.dashboard-content { .dashboard-content {
...@@ -488,52 +351,6 @@ const headerEyeIconSize = computed((): number => { ...@@ -488,52 +351,6 @@ const headerEyeIconSize = computed((): number => {
color: #1E293B; color: #1E293B;
} }
.tag-box {
height: var(--reception-dash-header-tag-height, 36px);
min-width: var(--reception-dash-header-tag-min-width, 148px);
background-color: #f5f9ff;
padding: 0 var(--reception-dash-header-tag-padding-x, 10px);
border-radius: var(--reception-dash-header-tag-border-radius, 10px);
border: 1px solid #cfe0f4;
flex-direction: row;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
// ✅ 性能优化:移除 box-shadow
// box-shadow: 0 2px 8px rgba(59, 130, 246, 0.10);
}
.module-badge {
height: var(--reception-dash-header-badge-height, 22px);
padding: 0 var(--reception-dash-header-badge-padding-x, 8px);
border-radius: 999px;
background-color: #e5effd;
border: 1px solid #c9ddf7;
flex-direction: row;
align-items: center;
justify-content: center;
margin-right: var(--reception-dash-header-badge-margin-right, 8px);
}
.module-badge-text {
font-size: var(--reception-dash-header-badge-font-size, 10px);
font-weight: 600;
color: #4f6b95;
}
.tag-text {
font-size: var(--reception-dash-header-tag-font-size, 13px);
font-weight: 700;
color: #1f3a5a;
}
.tag-arrow-icon {
width: var(--reception-dash-header-arrow-icon-size, 14px);
height: var(--reception-dash-header-arrow-icon-size, 14px);
margin-left: var(--reception-dash-header-arrow-icon-margin-left, 6px);
opacity: 0.75;
}
.progress-meta-row { .progress-meta-row {
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!