Commit 99d3a13c by Lin

refactor(reception): 优化接待中心组件和样式变量

- 重构接待中心页面,移除冗余样式和逻辑,简化组件结构
- 更新样式变量以支持动态适配,确保在不同分辨率下的视觉一致性
- 统一样式配置,提升可维护性和用户体验
1 parent 163cdba7
<template> <template>
<card-container :root-style="outputCardRootStyle"> <card-container class="reception-dash-output-card">
<view class="tabs-box" :style="outputTabsBoxStyle"> <view class="tabs-box">
<un-segmented <un-segmented
shape="circle" shape="circle"
type="card" type="card"
:font-size="segmentedFontSize" :font-size="'var(--reception-dash-segmented-font-size)'"
:custom-style="{ height: 'var(--reception-dash-segmented-height)' }"
:model-value="tabIndex" :model-value="tabIndex"
active-color="#000000" active-color="#000000"
@update:model-value="onSegmentedTabIndex" @update:model-value="onSegmentedTabIndex"
...@@ -20,31 +21,24 @@ ...@@ -20,31 +21,24 @@
:key="idx" :key="idx"
class="compare-row" class="compare-row"
:class="{ 'compare-row-last': idx == compareRows.length - 1 }" :class="{ 'compare-row-last': idx == compareRows.length - 1 }"
:style="compareRowStyle(idx)"
> >
<text class="compare-label" :style="compareLabelTextStyle">{{ row.label }}</text> <text class="compare-label">{{ row.label }}</text>
<view class="compare-bar-bg" :style="compareBarBgStyle"> <view class="compare-bar-bg">
<view <view
class="compare-bar-fill" class="compare-bar-fill"
:class="row.barClass" :class="row.barClass"
:style="compareBarFillStyle(row)" :style="compareBarFillStyle(row)"
></view> ></view>
</view> </view>
<text class="compare-value" :style="compareValueTextStyle">{{ metricsVisible ? row.value : '****' }}</text> <text class="compare-value">{{ metricsVisible ? row.value : '****' }}</text>
</view> </view>
</view> </view>
</card-container> </card-container>
</template> </template>
<script setup lang="uts"> <script setup lang="uts">
import { computed } from 'vue'
import CardContainer from './CardContainer.uvue' import CardContainer from './CardContainer.uvue'
import type { CompareRow } from '../types/reception-output-types.uts' import type { CompareRow } from '../types/reception-output-types.uts'
import { cssClassRef } from '@/services/adapter'
import {
getReceptionPortraitDashboardConfig,
type ReceptionPortraitDashboardConfig
} from '../styles/portrait.uts'
const props = withDefaults( const props = withDefaults(
defineProps<{ defineProps<{
...@@ -70,102 +64,26 @@ const onSegmentedTabIndex = (v: number): void => { ...@@ -70,102 +64,26 @@ const onSegmentedTabIndex = (v: number): void => {
emit('update:tabIndex', v) emit('update:tabIndex', v)
} }
const portraitDash = computed((): ReceptionPortraitDashboardConfig | null => {
return getReceptionPortraitDashboardConfig(cssClassRef.value)
})
function outPick(mapper: (c: ReceptionPortraitDashboardConfig) => UTSJSONObject): UTSJSONObject {
const c = portraitDash.value
if (c == null) {
return {} as UTSJSONObject
}
return mapper(c)
}
const outputCardRootStyle = computed((): UTSJSONObject => {
return outPick((c) => {
return {
padding: c.dashCardPadding,
borderRadius: c.dashCardBorderRadius,
boxShadow: c.dashCardBoxShadow
} as UTSJSONObject
})
})
const outputTabsBoxStyle = computed((): UTSJSONObject => {
return outPick((c) => {
return { marginBottom: c.dashOutputTabsMarginBottom } as UTSJSONObject
})
})
const segmentedFontSize = computed((): number => {
const c = portraitDash.value
if (c != null) {
return c.dashSegmentedFontSize
}
return 14
})
const compareLabelTextStyle = computed((): UTSJSONObject => {
return outPick((c) => {
return {
fontSize: c.dashCompareLabelFontSize,
width: c.dashCompareLabelWidth
} as UTSJSONObject
})
})
const compareBarBgStyle = computed((): UTSJSONObject => {
return outPick((c) => {
return {
height: c.dashCompareBarHeight,
borderRadius: c.dashCompareBarBorderRadius,
marginRight: c.dashCompareBarBgMarginRight
} as UTSJSONObject
})
})
function compareBarFillStyle(row: CompareRow): UTSJSONObject { function compareBarFillStyle(row: CompareRow): UTSJSONObject {
const base = { width: row.barWidthPercent } as UTSJSONObject
const c = portraitDash.value
if (c == null) {
return base
}
return { return {
width: row.barWidthPercent, width: row.barWidthPercent,
height: c.dashCompareBarHeight, height: 'var(--reception-dash-compare-bar-height)',
borderRadius: c.dashCompareBarBorderRadius borderRadius: 'var(--reception-dash-compare-bar-border-radius)'
} as UTSJSONObject } as UTSJSONObject
} }
const compareValueTextStyle = computed((): UTSJSONObject => {
return outPick((c) => {
return {
fontSize: c.dashCompareValueFontSize,
width: c.dashCompareValueWidth,
fontWeight: '700'
} as UTSJSONObject
})
})
function compareRowStyle(idx: number): UTSJSONObject {
const c = portraitDash.value
if (c == null) {
return {} as UTSJSONObject
}
const last = idx == props.compareRows.length - 1
if (last) {
return {} as UTSJSONObject
}
return { marginBottom: c.dashCompareRowMarginBottom } as UTSJSONObject
}
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.reception-dash-output-card {
padding: var(--reception-dash-card-padding);
border-radius: var(--reception-dash-card-border-radius);
box-shadow: var(--reception-dash-card-box-shadow);
}
.tabs-box { .tabs-box {
flex-direction: row; flex-direction: row;
justify-content: space-between; justify-content: space-between;
margin-bottom: 24px; margin-bottom: var(--reception-dash-output-tabs-margin-bottom);
} }
.compare-section { .compare-section {
...@@ -175,7 +93,7 @@ function compareRowStyle(idx: number): UTSJSONObject { ...@@ -175,7 +93,7 @@ function compareRowStyle(idx: number): UTSJSONObject {
.compare-row { .compare-row {
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-bottom: 16px; margin-bottom: var(--reception-dash-compare-row-margin-bottom);
} }
.compare-row-last { .compare-row-last {
...@@ -183,24 +101,24 @@ function compareRowStyle(idx: number): UTSJSONObject { ...@@ -183,24 +101,24 @@ function compareRowStyle(idx: number): UTSJSONObject {
} }
.compare-label { .compare-label {
font-size: 13px; font-size: var(--reception-dash-compare-label-font-size);
color: #64748b; color: #64748b;
width: 90px; width: var(--reception-dash-compare-label-width);
} }
.compare-bar-bg { .compare-bar-bg {
flex: 1; flex: 1;
height: 6px; height: var(--reception-dash-compare-bar-height);
background-color: rgba(22, 119, 255, 0.08); background-color: rgba(22, 119, 255, 0.08);
border-radius: 4px; border-radius: var(--reception-dash-compare-bar-border-radius);
margin-right: 12px; margin-right: var(--reception-dash-compare-bar-bg-margin-right);
overflow: hidden; overflow: hidden;
flex-direction: row; flex-direction: row;
} }
.compare-bar-fill { .compare-bar-fill {
height: 100%; height: 100%;
border-radius: 4px; border-radius: var(--reception-dash-compare-bar-border-radius);
} }
.bg-blue-500 { .bg-blue-500 {
...@@ -212,10 +130,10 @@ function compareRowStyle(idx: number): UTSJSONObject { ...@@ -212,10 +130,10 @@ function compareRowStyle(idx: number): UTSJSONObject {
} }
.compare-value { .compare-value {
font-size: 13px; font-size: var(--reception-dash-compare-value-font-size);
font-weight: 600; font-weight: 700;
color: #1e293b; color: #1e293b;
width: 60px; width: var(--reception-dash-compare-value-width);
text-align: right; text-align: right;
} }
</style> </style>
...@@ -2,16 +2,15 @@ ...@@ -2,16 +2,15 @@
<!-- 接待中心 Tab 聚合页:与 pages/index、pages/person/myCenter 一致,SceneShell 负责 hideNativeTabBar + un-tabbar --> <!-- 接待中心 Tab 聚合页:与 pages/index、pages/person/myCenter 一致,SceneShell 负责 hideNativeTabBar + un-tabbar -->
<layout-root :page-vars="pageVars"> <layout-root :page-vars="pageVars">
<view class="reception-shell-page"> <view class="reception-shell-page">
<SceneShell ref="shellRef" <SceneShell
:active-tab-index="1"> ref="shellRef"
:active-tab-index="1"
>
<template #default> <template #default>
<!-- <view class="test test-view"> <!-- <view class="test test-view">
<text class="test-orientation-text">hooks:{{ hookOrientation }} {{ hookOrientation=='landscape'?'横屏':'竖屏'}} {{ isLandscape }}</text> <text class="test-orientation-text">hooks:{{ hookOrientation }} isLandscape:{{ isLandscape }} {{ hookOrientation=='landscape'?'横屏':'竖屏'}} {{ isLandscape }}</text>
</view> --> </view> -->
<view class="reception-center-page"> <view class="reception-center-page">
<!-- <un-navbar title="接待中心" left-icon="" /> -->
<!-- <view class="reception-navbar-spacer"></view> -->
<!-- Tab 切换 --> <!-- Tab 切换 -->
<view v-if="isLandscape != true" class="reception-tabs-container" :style="receptionTabsContainerStyle"> <view v-if="isLandscape != true" class="reception-tabs-container" :style="receptionTabsContainerStyle">
<un-tabs <un-tabs
...@@ -175,9 +174,10 @@ ...@@ -175,9 +174,10 @@
<script setup lang="uts"> <script setup lang="uts">
// 接待中心 Tab 聚合页 // 接待中心 Tab 聚合页
import { ref, computed, onMounted, onUnmounted, watch, onResize, type Ref, type ComponentPublicInstance } from 'vue' import { ref, computed, onMounted, onUnmounted, watch, onResize } from 'vue'
import type { Ref, ComponentPublicInstance } from 'vue'
import SceneShell from '@/components/HomeFrame/SceneShell.uvue' import SceneShell from '@/components/HomeFrame/SceneShell.uvue'
import { type UnPickerColumn, type UnPickerColumnItem, type UnPickerConfirmEvent, type UnTabItem } from '@/uni_modules/uview-unix' import type { UnPickerColumn, UnPickerColumnItem, UnPickerConfirmEvent, UnTabItem } from '@/uni_modules/uview-unix'
import FormDetail from './forms/FormDetail.uvue' import FormDetail from './forms/FormDetail.uvue'
import ReceptionDetail from './receptionDetail.uvue' import ReceptionDetail from './receptionDetail.uvue'
import ReceptionDashboardTab from './tabs/ReceptionDashboardTab.uvue' import ReceptionDashboardTab from './tabs/ReceptionDashboardTab.uvue'
...@@ -189,12 +189,6 @@ import { storage } from '@/utils/storage.uts' ...@@ -189,12 +189,6 @@ import { storage } from '@/utils/storage.uts'
import { resolutionState } from '@/services/adapter/index.uts' import { resolutionState } from '@/services/adapter/index.uts'
import { cssClassRef } from "@/services/adapter"; import { cssClassRef } from "@/services/adapter";
import { updateOrientation, useOrientation } from '@/services/adapter/hooks/index.uts' import { updateOrientation, useOrientation } from '@/services/adapter/hooks/index.uts'
// 导入样式变量
import {
getPortraitConfig,
getReceptionPortraitMainTabsConfig,
type ReceptionPortraitMainTabsConfig
} from "./styles/portrait.uts";
import pageVars from './styles/index.vars' import pageVars from './styles/index.vars'
const shellRef = ref(null) const shellRef = ref(null)
...@@ -205,11 +199,6 @@ onShow(() => { ...@@ -205,11 +199,6 @@ onShow(() => {
} }
}) })
const isPortrait768x1174 = computed((): boolean => {
// 仅在 768x1174 分辨率(竖屏适配类名)下展示顶部安全区占位
return cssClassRef.value.indexOf('layout-portrait-768x1174') >= 0
})
/** useOrientation 全局状态,配合 updateOrientation 在 onMounted / onResize 刷新后展示 */ /** useOrientation 全局状态,配合 updateOrientation 在 onMounted / onResize 刷新后展示 */
const receptionOrientationHook = useOrientation() const receptionOrientationHook = useOrientation()
const hookOrientation = computed((): string => { const hookOrientation = computed((): string => {
...@@ -222,110 +211,51 @@ const mainTabs: UnTabItem[] = [ ...@@ -222,110 +211,51 @@ const mainTabs: UnTabItem[] = [
{ name: '业绩看板' } as UnTabItem, { name: '业绩看板' } as UnTabItem,
{ name: '客户列表' } as UnTabItem { name: '客户列表' } as UnTabItem
] ]
// 动态样式 - 根据分辨率返回不同的样式
// 动态样式 - 根据分辨率返回不同的样式
const dynamicModuleBoxStyle = computed((): any => {
// 使用 cssClassRef.value 确保响应式
const adapterCls = cssClassRef.value;
if (adapterCls.indexOf('layout-portrait-768x1174') >= 0) {
const cfg = getPortraitConfig(adapterCls)
return cfg != null ? ({ ...cfg } as UTSJSONObject) : ({} as UTSJSONObject);
}
// computed 返回值不能为 null(UTS 中 Any? -> Any 会触发类型不匹配)
return {} as UTSJSONObject;
});
/** 仅 layout-portrait-768x1174 有值;其它分辨率为 null,主 Tab 保持模板 + scss 原样式 */
const receptionPortraitMainTabsOverride = computed((): null | ReceptionPortraitMainTabsConfig => {
return getReceptionPortraitMainTabsConfig(cssClassRef.value)
})
const receptionTabsContainerStyle = computed((): UTSJSONObject => { const receptionTabsContainerStyle = computed((): UTSJSONObject => {
const c = receptionPortraitMainTabsOverride.value
if (c == null) {
return {} as UTSJSONObject
}
return { return {
padding: c.containerPadding // 默认保持原 scss 的布局与间距
} as UTSJSONObject } as UTSJSONObject
}) })
const receptionMainTabsShellStyle = computed((): UTSJSONObject => { const receptionMainTabsShellStyle = computed((): UTSJSONObject => {
const c = receptionPortraitMainTabsOverride.value
if (c == null) {
return {} as UTSJSONObject
}
return { return {
padding: c.mainTabsPadding, // 默认保持原 scss 的布局与间距
borderRadius: c.mainTabsBorderRadius,
boxShadow: c.mainTabsBoxShadow
} as UTSJSONObject } as UTSJSONObject
}) })
const mainTabBarHeight = computed((): number => { const mainTabBarHeight = computed((): number => {
const c = receptionPortraitMainTabsOverride.value return 52
return c != null ? c.height : 52
}) })
const mainTabLineWidth = computed((): number => { const mainTabLineWidth = computed((): number => {
const c = receptionPortraitMainTabsOverride.value return 42
return c != null ? c.lineWidth : 42
}) })
const mainTabLineHeight = computed((): number => { const mainTabLineHeight = computed((): number => {
const c = receptionPortraitMainTabsOverride.value return 4
return c != null ? c.lineHeight : 4
}) })
const mainTabActiveStyle = computed((): UTSJSONObject => { const mainTabActiveStyle = computed((): UTSJSONObject => {
const c = receptionPortraitMainTabsOverride.value
if (c == null) {
return {
color: '#1677ff',
fontWeight: 700,
fontSize: '17px'
} as UTSJSONObject
}
return { return {
color: '#1677ff', color: '#1677ff',
fontWeight: 700, fontWeight: 700,
fontSize: c.activeFontSize fontSize: 'var(--reception-main-tabs-active-font-size)'
} as UTSJSONObject } as UTSJSONObject
}) })
const mainTabInactiveStyle = computed((): UTSJSONObject => { const mainTabInactiveStyle = computed((): UTSJSONObject => {
const c = receptionPortraitMainTabsOverride.value
if (c == null) {
return {
color: '#94a3b8',
fontWeight: 500,
fontSize: '15px'
} as UTSJSONObject
}
return { return {
color: '#94a3b8', color: '#94a3b8',
fontWeight: 400, fontWeight: 500,
fontSize: c.inactiveFontSize fontSize: 'var(--reception-main-tabs-inactive-font-size)'
} as UTSJSONObject } as UTSJSONObject
}) })
const mainTabItemStyle = computed((): UTSJSONObject => { const mainTabItemStyle = computed((): UTSJSONObject => {
const c = receptionPortraitMainTabsOverride.value
if (c == null) {
return {
paddingLeft: '18px',
paddingRight: '18px'
} as UTSJSONObject
}
return { return {
paddingLeft: c.itemPaddingLeft, paddingLeft: '18px',
paddingRight: c.itemPaddingRight, paddingRight: '18px'
paddingBottom: c.itemPaddingBottom
} as UTSJSONObject } as UTSJSONObject
}) })
...@@ -521,7 +451,6 @@ function syncReceptionDashboardLayout(): void { ...@@ -521,7 +451,6 @@ function syncReceptionDashboardLayout(): void {
`[ReceptionCenter] 屏幕方向变化:${isLandscape.value ? '横屏' : '竖屏'}(w=${w}, h=${h}, window=${ww}x${wh}, screen=${sw}x${sh})` `[ReceptionCenter] 屏幕方向变化:${isLandscape.value ? '横屏' : '竖屏'}(w=${w}, h=${h}, window=${ww}x${wh}, screen=${sw}x${sh})`
) )
} }
console.log('[ReceptionCenter] syncReceptionDashboardLayout');
// 横屏窄宽适配:避免右侧筛选区控件(如 segmented)在小于阈值时出现横向溢出 // 横屏窄宽适配:避免右侧筛选区控件(如 segmented)在小于阈值时出现横向溢出
const RECEPTION_FILTER_NARROW_WIDTH = 920 const RECEPTION_FILTER_NARROW_WIDTH = 920
...@@ -1241,7 +1170,6 @@ onUnmounted(() => { ...@@ -1241,7 +1170,6 @@ onUnmounted(() => {
<style scoped lang="scss"> <style scoped lang="scss">
@import "./styles/common.scss"; @import "./styles/common.scss";
<<<<<<< HEAD
// @import "./styles/landscape.scss"; // @import "./styles/landscape.scss";
// @import "./styles/portrait.scss"; // @import "./styles/portrait.scss";
...@@ -1260,8 +1188,6 @@ onUnmounted(() => { ...@@ -1260,8 +1188,6 @@ onUnmounted(() => {
height: 100%; height: 100%;
} }
=======
>>>>>>> e9b81af8 (refactor(reception): 移除不必要的样式和优化接待中心布局)
/* 接待中心页面包一层:供预录表单绝对定位覆盖 */ /* 接待中心页面包一层:供预录表单绝对定位覆盖 */
.reception-center-page { .reception-center-page {
flex: 1; flex: 1;
...@@ -1275,12 +1201,10 @@ onUnmounted(() => { ...@@ -1275,12 +1201,10 @@ onUnmounted(() => {
/* ========== Tab 容器 ========== */ /* ========== Tab 容器 ========== */
.reception-tabs-container { .reception-tabs-container {
background-color: #ffffff;
flex-shrink: 0; flex-shrink: 0;
border-bottom: 1px solid #eef2f7; border-bottom: 1px solid #eef2f7;
padding: 0px 12px 6px; padding: 0px 12px 6px;
box-sizing: border-box; box-sizing: border-box;
margin-top: 30px;
} }
.reception-main-tabs { .reception-main-tabs {
...@@ -1303,4 +1227,44 @@ onUnmounted(() => { ...@@ -1303,4 +1227,44 @@ onUnmounted(() => {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
} }
/* Tab 内容区域容器(竖屏/横屏共用) */
.reception-content-container {
flex: 1;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column;
}
/* 竖屏:保持原逻辑(单列) */
.reception-content-portrait {
flex: 1;
min-height: 0;
display: flex;
flex-direction: column;
}
/* 横屏:左右分栏同时展示(左 1/3,右 2/3) */
.reception-content-landscape {
flex: 1;
min-height: 0;
display: flex;
flex-direction: row;
}
.reception-landscape-left {
flex: 1;
min-height: 0;
min-width: 0;
overflow: hidden;
border-right: 1px solid #eef2f7;
}
.reception-landscape-right {
flex: 2;
min-height: 0;
min-width: 0;
overflow: hidden;
}
</style> </style>
...@@ -9,4 +9,8 @@ ...@@ -9,4 +9,8 @@
.reception-tabs-container{ .reception-tabs-container{
padding: var(--reception-tabs-container-padding); padding: var(--reception-tabs-container-padding);
margin-top: var(--reception-tabs-container-margin-top); margin-top: var(--reception-tabs-container-margin-top);
background-color: var(--reception-tabs-container-bgc);
}
.reception-main-tabs {
font-size: var(--reception-main-tabs-font-size);
} }
\ No newline at end of file \ No newline at end of file
...@@ -2,6 +2,27 @@ ...@@ -2,6 +2,27 @@
export default { export default {
common: { common: {
'--home-box-bg': '#FF4444', '--home-box-bg': '#FF4444',
// receptionCenter: tabs 默认字体(可被 resolutions 覆盖)
'--reception-main-tabs-active-font-size': '17px',
'--reception-main-tabs-inactive-font-size': '15px',
// 兼容旧变量(scss 里有引用)
'--reception-main-tabs-font-size': '17px',
// receptionCenter: dashboard(CardOutputValue) 默认样式变量(可被 resolutions 覆盖)
'--reception-dash-card-padding': '16px 20px',
'--reception-dash-card-border-radius': '22px',
'--reception-dash-card-box-shadow': '0 6px 22px rgba(15, 23, 42, 0.08)',
'--reception-dash-output-tabs-margin-bottom': '24px',
'--reception-dash-segmented-font-size': '14px',
'--reception-dash-segmented-height': '40px',
'--reception-dash-compare-row-margin-bottom': '16px',
'--reception-dash-compare-label-font-size': '13px',
'--reception-dash-compare-label-width': '90px',
'--reception-dash-compare-bar-height': '6px',
'--reception-dash-compare-bar-border-radius': '4px',
'--reception-dash-compare-bar-bg-margin-right': '12px',
'--reception-dash-compare-value-font-size': '13px',
'--reception-dash-compare-value-width': '60px',
}, },
portrait: { portrait: {
'--adapter-color': 'red', '--adapter-color': 'red',
...@@ -26,6 +47,25 @@ export default { ...@@ -26,6 +47,25 @@ export default {
// 'padding': '10px' // 'padding': '10px'
'--reception-tabs-container-padding': '8px 12px 60px' '--reception-tabs-container-padding': '8px 12px 60px'
'--reception-tabs-container-margin-top': '30px' '--reception-tabs-container-margin-top': '30px'
'--reception-tabs-container-bgc': '#ffffff',
// 针对 768x1174 竖屏:tabs 字体自适应增大
'--reception-main-tabs-active-font-size': '24px',
'--reception-main-tabs-inactive-font-size': '22px',
// 兼容旧变量(scss 里有引用)
'--reception-main-tabs-font-size': '24px',
// 针对 768x1174 竖屏:看板(CardOutputValue) 字体/宽高自适应增大
'--reception-dash-output-tabs-margin-bottom': '28px',
'--reception-dash-segmented-font-size': '19px',
'--reception-dash-segmented-height': '48px',
'--reception-dash-compare-row-margin-bottom': '18px',
'--reception-dash-compare-label-font-size': '17px',
'--reception-dash-compare-label-width': '104px',
'--reception-dash-compare-bar-height': '12px',
'--reception-dash-compare-bar-border-radius': '6px',
'--reception-dash-compare-bar-bg-margin-right': '14px',
'--reception-dash-compare-value-font-size': '17px',
'--reception-dash-compare-value-width': '72px',
}, },
'landscape-1174x768': { 'landscape-1174x768': {
'--adapter-color': '#FF4444', '--adapter-color': '#FF4444',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!