Commit edc402f8 by Lin

refactor(components): 优化接待中心组件的弹层和列表展示

- 将多个 scroll-view 组件替换为 list-view 以提升性能和用户体验
- 统一底部弹层高度设置,确保与其他组件一致
- 调整样式以支持更灵活的布局,改善标签和场景选择的展示效果
- 增强代码可读性,简化属性绑定和样式管理
1 parent ca7ad30a
...@@ -6,21 +6,31 @@ ...@@ -6,21 +6,31 @@
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="选择品牌" title="选择品牌"
:popupH="sheetPanelHeightPx"
:maxHeight="sheetPanelHeightPx"
@close="onBrandSheetClose" @close="onBrandSheetClose"
> >
<scroll-view class="tag-scroll" scroll-y="true"> <list-view
<view class="tag-box"> class="tag-list-view"
<template v-for="(item, index) in brandList" :key="index"> direction="vertical"
<view :bounces="false"
class="tag-item" :show-scrollbar="true"
:class="{ checked: isBrandRowChecked(item as UTSJSONObject) }" :style="tagScrollStyle"
@click="onTapBrandRow(item as UTSJSONObject)" >
> <list-item class="tag-list-item" :type="0">
<text class="tag-text">{{ formatBrandTagLabel(item as UTSJSONObject) }}</text> <view class="tag-box">
</view> <template v-for="(item, index) in brandList" :key="index">
</template> <view
</view> class="tag-item"
</scroll-view> :class="{ checked: isBrandRowChecked(item as UTSJSONObject) }"
@click="onTapBrandRow(item as UTSJSONObject)"
>
<text class="tag-text">{{ formatBrandTagLabel(item as UTSJSONObject) }}</text>
</view>
</template>
</view>
</list-item>
</list-view>
</MessageBox> </MessageBox>
<!-- 第二步:底部弹框 — 根据所选品牌筛选的车型 tag --> <!-- 第二步:底部弹框 — 根据所选品牌筛选的车型 tag -->
<MessageBox <MessageBox
...@@ -28,23 +38,32 @@ ...@@ -28,23 +38,32 @@
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="选择车型" title="选择车型"
:maxHeight="1000" :popupH="sheetPanelHeightPx"
:maxHeight="sheetPanelHeightPx"
back back
@close="onModelSheetClose" @close="onModelSheetClose"
> >
<scroll-view class="tag-scroll" scroll-y="true"> <list-view
<view class="tag-box"> class="tag-list-view"
<template v-for="(item, index) in modelList" :key="index"> direction="vertical"
<view :bounces="false"
class="tag-item" :show-scrollbar="true"
:class="{ checked: isModelRowChecked(item as UTSJSONObject) }" :style="tagScrollStyle"
@click="onTapModelRow(item as UTSJSONObject)" >
> <list-item class="tag-list-item" :type="0">
<text class="tag-text">{{ (item as UTSJSONObject).name }}</text> <view class="tag-box">
</view> <template v-for="(item, index) in modelList" :key="index">
</template> <view
</view> class="tag-item"
</scroll-view> :class="{ checked: isModelRowChecked(item as UTSJSONObject) }"
@click="onTapModelRow(item as UTSJSONObject)"
>
<text class="tag-text">{{ (item as UTSJSONObject).name }}</text>
</view>
</template>
</view>
</list-item>
</list-view>
</MessageBox> </MessageBox>
</view> </view>
</template> </template>
...@@ -55,7 +74,7 @@ ...@@ -55,7 +74,7 @@
import { getMerchantCarBrandList, getCarBrandsListApi } from '@/api/common-api.uts' import { getMerchantCarBrandList, getCarBrandsListApi } from '@/api/common-api.uts'
import { dispatch } from '@/store/index.uts' import { dispatch } from '@/store/index.uts'
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from 'vue'
import { nextTick } from 'vue' import { nextTick, computed } from 'vue'
import { import {
getMockFlatCarBrandRows, getMockFlatCarBrandRows,
getMockCarModelsList getMockCarModelsList
...@@ -85,6 +104,39 @@ ...@@ -85,6 +104,39 @@
const brandSheetRef = ref<ComponentPublicInstance | null>(null) const brandSheetRef = ref<ComponentPublicInstance | null>(null)
const modelSheetRef = ref<ComponentPublicInstance | null>(null) const modelSheetRef = ref<ComponentPublicInstance | null>(null)
/** 底部弹层高度:半屏 px,与 MessageBox popupH/maxHeight 一致以固定面板高度(同 CustomerTags) */
const sheetPanelHeightPx = ref(400)
/** list-view 需明确 px 高度;扣除 tips-content padding、标题区、列表区 margin(同 CustomerTags) */
const TAG_SCROLL_VERTICAL_RESERVE_PX = 120
const tagScrollStyle = computed((): UTSJSONObject => {
const panel = sheetPanelHeightPx.value
const h = panel - TAG_SCROLL_VERTICAL_RESERVE_PX
const finalH = h > 160 ? h : 160
const out = {} as UTSJSONObject
out['height'] = `${finalH}px`
out['width'] = '100%'
return out
})
function updateSheetPanelHeight(): void {
try {
const info = uni.getSystemInfoSync()
const wh = info.windowHeight
if (wh != null) {
const h = wh as number
if (h > 0) {
sheetPanelHeightPx.value = Math.floor(h / 2)
return
}
}
} catch (_e) {
// ignore
}
sheetPanelHeightPx.value = 400
}
const brandList = ref<Array<any>>([]) const brandList = ref<Array<any>>([])
const modelList = ref<Array<any>>([]) const modelList = ref<Array<any>>([])
/** 第一步选中的行(含 brandId、brandName、name、id 等,与 CarBrands selectCar 一致) */ /** 第一步选中的行(含 brandId、brandName、name、id 等,与 CarBrands selectCar 一致) */
...@@ -128,6 +180,7 @@ ...@@ -128,6 +180,7 @@
} }
function openModelSheet(): void { function openModelSheet(): void {
updateSheetPanelHeight()
const r = modelSheetRef.value const r = modelSheetRef.value
const inst = r != null ? (r as ComponentPublicInstance) : null const inst = r != null ? (r as ComponentPublicInstance) : null
if (inst != null) { if (inst != null) {
...@@ -381,6 +434,7 @@ ...@@ -381,6 +434,7 @@
/** 打开:mock 模式仅填充标签数据并弹出底部框,无请求/store/dispatch,避免异常进 catch */ /** 打开:mock 模式仅填充标签数据并弹出底部框,无请求/store/dispatch,避免异常进 catch */
function open(): void { function open(): void {
updateSheetPanelHeight()
if (USE_MOCK_CAR_BRAND_LIST) { if (USE_MOCK_CAR_BRAND_LIST) {
brandList.value = getMockFlatCarBrandRows() brandList.value = getMockFlatCarBrandRows()
nextTick(() => { nextTick(() => {
...@@ -455,15 +509,34 @@ ...@@ -455,15 +509,34 @@
<style scoped lang="scss"> <style scoped lang="scss">
.car-brand-select-root { .car-brand-select-root {
width: 100%;
display: flex;
flex-direction: column; flex-direction: column;
/* Android:避免父级 overflow:hidden 影响子 list-view 手势(同 CustomerTags / FormDetail) */
overflow: visible;
} }
.tag-scroll { .tag-list-view {
max-height: 400px; width: 100%;
max-width: 100%;
align-self: stretch;
box-sizing: border-box;
flex-shrink: 0;
margin-top: 8px; margin-top: 8px;
margin-bottom: 16px; margin-bottom: 16px;
} }
.tag-list-item {
width: 100%;
margin: 0;
box-sizing: border-box;
height: auto;
min-height: 0;
align-self: flex-start;
flex-grow: 0;
flex-shrink: 0;
}
.tag-box { .tag-box {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
......
...@@ -5,34 +5,44 @@ ...@@ -5,34 +5,44 @@
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="选择客户标签" title="选择客户标签"
:popupH="sheetPanelHeightPx"
:maxHeight="sheetPanelHeightPx"
@close="onSheetClose" @close="onSheetClose"
> >
<scroll-view class="tag-scroll" scroll-y="true" enable-flex> <list-view
<view class="tag-groups"> class="tag-list-view"
<template v-for="(group, gi) in tagGroups" :key="gi"> direction="vertical"
<view class="tag-section"> :bounces="false"
<text :show-scrollbar="true"
v-if="hasSectionTitle(group as UTSJSONObject)" :style="tagScrollStyle"
class="section-title" >
>{{ getCategoryTitle(group as UTSJSONObject) }}</text> <list-item class="tag-list-item" :type="0">
<view class="tag-box"> <view class="tag-groups">
<template <template v-for="(group, gi) in tagGroups" :key="gi">
v-for="(item, ti) in getGroupTags(group as UTSJSONObject)" <view class="tag-section">
:key="ti" <text
> v-if="hasSectionTitle(group as UTSJSONObject)"
<view class="section-title"
class="tag-item" >{{ getCategoryTitle(group as UTSJSONObject) }}</text>
:class="{ checked: isRowChecked(item as UTSJSONObject) }" <view class="tag-box">
@click="onTapRow(item as UTSJSONObject)" <template
v-for="(item, ti) in getGroupTags(group as UTSJSONObject)"
:key="ti"
> >
<text class="tag-text">{{ (item as UTSJSONObject)['label'] }}</text> <view
</view> class="tag-item"
</template> :class="{ checked: isRowChecked(item as UTSJSONObject) }"
@click="onTapRow(item as UTSJSONObject)"
>
<text class="tag-text">{{ (item as UTSJSONObject)['label'] }}</text>
</view>
</template>
</view>
</view> </view>
</view> </template>
</template> </view>
</view> </list-item>
</scroll-view> </list-view>
</MessageBox> </MessageBox>
</view> </view>
</template> </template>
...@@ -40,7 +50,7 @@ ...@@ -40,7 +50,7 @@
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from '@/components/MessageBox.uvue' import MessageBox from '@/components/MessageBox.uvue'
import { findSenceTag } from '@/api/receiption.uts' import { findSenceTag } from '@/api/receiption.uts'
import { ref, nextTick } from 'vue' import { ref, nextTick, computed } from 'vue'
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from 'vue'
/** 无接口或解析失败时的两级示例数据 */ /** 无接口或解析失败时的两级示例数据 */
...@@ -282,6 +292,41 @@ ...@@ -282,6 +292,41 @@
const sheetRef = ref<ComponentPublicInstance | null>(null) const sheetRef = ref<ComponentPublicInstance | null>(null)
const tagGroups = ref<Array<UTSJSONObject>>(buildMockTagGroups()) const tagGroups = ref<Array<UTSJSONObject>>(buildMockTagGroups())
/** 底部弹出层高度:屏幕高度的 50%(App 端不用 vh,用 windowHeight 换算为 px) */
const sheetPanelHeightPx = ref(400)
/**
* 弹层内用 list-view + 明确 px 高度纵向滚动(同 FormDetail);scroll-view 在 MessageBox/un-popup 内部分端仍不生效。
* 从面板高度扣除:MessageBox .tips-content 上下 padding 48、标题区约 36、本区 margin 8+16。
*/
const TAG_SCROLL_VERTICAL_RESERVE_PX = 120
const tagScrollStyle = computed((): UTSJSONObject => {
const panel = sheetPanelHeightPx.value
const h = panel - TAG_SCROLL_VERTICAL_RESERVE_PX
const finalH = h > 160 ? h : 160
const out = {} as UTSJSONObject
out['height'] = `${finalH}px`
out['width'] = '100%'
return out
})
function updateSheetPanelHeight(): void {
try {
const info = uni.getSystemInfoSync()
const wh = info.windowHeight
if (wh != null) {
const h = wh as number
if (h > 0) {
sheetPanelHeightPx.value = Math.floor(h / 2)
return
}
}
} catch (e) {
console.error('getSystemInfoSync 失败:', e)
}
sheetPanelHeightPx.value = 400
}
function getGroupTags(group: UTSJSONObject): Array<UTSJSONObject> { function getGroupTags(group: UTSJSONObject): Array<UTSJSONObject> {
const t = group['tags'] const t = group['tags']
...@@ -371,6 +416,7 @@ ...@@ -371,6 +416,7 @@
} }
async function open(): Promise<void> { async function open(): Promise<void> {
updateSheetPanelHeight()
await loadTagListFromApi() await loadTagListFromApi()
nextTick(() => { nextTick(() => {
nextTick(() => { nextTick(() => {
...@@ -394,18 +440,32 @@ ...@@ -394,18 +440,32 @@
width: 100%; width: 100%;
flex: 1; flex: 1;
min-height: 0; min-height: 0;
display: flex;
flex-direction: column; flex-direction: column;
overflow: hidden; /* Android:滚动父级勿用 overflow:hidden,易导致子 list-view 手势异常(FormDetail 同注) */
overflow: visible;
} }
/* 与 FormAdd 一致:scroll-view 需落在有界高度内;仅 max-height 在 App 端常无法触发纵向滚动 */ /* 高度由 tagScrollStyle 内联 px 指定 */
.tag-scroll { .tag-list-view {
flex: 1;
min-height: 0;
width: 100%; width: 100%;
max-width: 100%;
align-self: stretch;
box-sizing: border-box;
flex-shrink: 0;
margin-top: 8px; margin-top: 8px;
margin-bottom: 16px; margin-bottom: 16px;
overflow: hidden; }
.tag-list-item {
width: 100%;
margin: 0;
box-sizing: border-box;
height: auto;
min-height: 0;
align-self: flex-start;
flex-grow: 0;
flex-shrink: 0;
} }
.tag-groups { .tag-groups {
......
...@@ -5,21 +5,31 @@ ...@@ -5,21 +5,31 @@
position="bottom" position="bottom"
:isFooter="false" :isFooter="false"
title="选择接待场景" title="选择接待场景"
:popupH="sheetPanelHeightPx"
:maxHeight="sheetPanelHeightPx"
@close="onSheetClose" @close="onSheetClose"
> >
<scroll-view class="tag-scroll" scroll-y="true"> <list-view
<view class="tag-box"> class="tag-list-view"
<template v-for="(item, index) in sceneList" :key="index"> direction="vertical"
<view :bounces="false"
class="tag-item" :show-scrollbar="true"
:class="{ checked: isRowChecked(item as UTSJSONObject) }" :style="tagScrollStyle"
@click="onTapRow(item as UTSJSONObject)" >
> <list-item class="tag-list-item" :type="0">
<text class="tag-text">{{ (item as UTSJSONObject)['label'] }}</text> <view class="tag-box">
</view> <template v-for="(item, index) in sceneList" :key="index">
</template> <view
</view> class="tag-item"
</scroll-view> :class="{ checked: isRowChecked(item as UTSJSONObject) }"
@click="onTapRow(item as UTSJSONObject)"
>
<text class="tag-text">{{ (item as UTSJSONObject)['label'] }}</text>
</view>
</template>
</view>
</list-item>
</list-view>
</MessageBox> </MessageBox>
</view> </view>
</template> </template>
...@@ -27,7 +37,7 @@ ...@@ -27,7 +37,7 @@
<script setup lang="uts"> <script setup lang="uts">
import MessageBox from '@/components/MessageBox.uvue' import MessageBox from '@/components/MessageBox.uvue'
import { findAllSence } from '@/api/receiption.uts' import { findAllSence } from '@/api/receiption.uts'
import { ref, nextTick } from 'vue' import { ref, nextTick, computed } from 'vue'
import { ComponentPublicInstance } from 'vue' import { ComponentPublicInstance } from 'vue'
/** 接口失败或空列表时的兜底数据 */ /** 接口失败或空列表时的兜底数据 */
...@@ -116,6 +126,38 @@ ...@@ -116,6 +126,38 @@
const sheetRef = ref<ComponentPublicInstance | null>(null) const sheetRef = ref<ComponentPublicInstance | null>(null)
const sceneList = ref<Array<UTSJSONObject>>(buildMockSceneList()) const sceneList = ref<Array<UTSJSONObject>>(buildMockSceneList())
/** 底部弹层半屏高度,与 MessageBox popupH/maxHeight 一致(同 CustomerTags) */
const sheetPanelHeightPx = ref(400)
const TAG_SCROLL_VERTICAL_RESERVE_PX = 120
const tagScrollStyle = computed((): UTSJSONObject => {
const panel = sheetPanelHeightPx.value
const h = panel - TAG_SCROLL_VERTICAL_RESERVE_PX
const finalH = h > 160 ? h : 160
const out = {} as UTSJSONObject
out['height'] = `${finalH}px`
out['width'] = '100%'
return out
})
function updateSheetPanelHeight(): void {
try {
const info = uni.getSystemInfoSync()
const wh = info.windowHeight
if (wh != null) {
const h = wh as number
if (h > 0) {
sheetPanelHeightPx.value = Math.floor(h / 2)
return
}
}
} catch (_e) {
// ignore
}
sheetPanelHeightPx.value = 400
}
async function loadSceneListFromApi(): Promise<void> { async function loadSceneListFromApi(): Promise<void> {
try { try {
const params = { scene: 1 } as UTSJSONObject const params = { scene: 1 } as UTSJSONObject
...@@ -177,6 +219,7 @@ ...@@ -177,6 +219,7 @@
} }
async function open(): Promise<void> { async function open(): Promise<void> {
updateSheetPanelHeight()
await loadSceneListFromApi() await loadSceneListFromApi()
nextTick(() => { nextTick(() => {
nextTick(() => { nextTick(() => {
...@@ -197,15 +240,33 @@ ...@@ -197,15 +240,33 @@
<style scoped lang="scss"> <style scoped lang="scss">
.scene-select-root { .scene-select-root {
width: 100%;
display: flex;
flex-direction: column; flex-direction: column;
overflow: visible;
} }
.tag-scroll { .tag-list-view {
max-height: 400px; width: 100%;
max-width: 100%;
align-self: stretch;
box-sizing: border-box;
flex-shrink: 0;
margin-top: 8px; margin-top: 8px;
margin-bottom: 16px; margin-bottom: 16px;
} }
.tag-list-item {
width: 100%;
margin: 0;
box-sizing: border-box;
height: auto;
min-height: 0;
align-self: flex-start;
flex-grow: 0;
flex-shrink: 0;
}
.tag-box { .tag-box {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
......
...@@ -112,11 +112,21 @@ ...@@ -112,11 +112,21 @@
const visible = ref<boolean>(false) const visible = ref<boolean>(false)
const popupRef= ref(null) const popupRef= ref(null)
const popupStyle = computed(() => { const popupStyle = computed(() => {
return { const w = props.popupW != null && props.popupW > 0 ? (props.popupW ?? 0) + 'px' : '100%'
width: props.popupW != null && props.popupW > 0 ? (props.popupW ?? 0) + 'px' : '100%', const minH = props.popupH != null && props.popupH > 0 ? (props.popupH ?? 0) + 'px' : '100%'
minHeight: props.popupH != null && props.popupH > 0 ? (props.popupH ?? 0) + 'px' : '100%', const maxH = props.maxHeight != null && props.maxHeight > 0 ? (props.maxHeight ?? 0) + 'px' : '100%'
maxHeight: props.maxHeight != null && props.maxHeight > 0 ? (props.maxHeight ?? 0) + 'px' : '100%' const style = {
width: w,
minHeight: minH,
maxHeight: maxH
} as UTSJSONObject
// 底部弹层且 min/max 为同一像素值时(如半屏高),固定 height,避免 App 端仅靠 max-height 时外层随内容增高、scroll-view 无法滚动
const ph = props.popupH != null ? props.popupH as number : 0
const mh = props.maxHeight != null ? props.maxHeight as number : 0
if (props.position === 'bottom' && ph > 0 && mh > 0 && ph === mh) {
style['height'] = mh + 'px'
} }
return style
}) })
function onClose(): void { function onClose(): void {
emit('close') emit('close')
...@@ -161,14 +171,18 @@ ...@@ -161,14 +171,18 @@
background: #ffffff; background: #ffffff;
border-radius: 10px; border-radius: 10px;
height: 100%; height: 100%;
min-height: 0;
overflow: hidden;
display: flex;
flex-direction: column; flex-direction: column;
.tips-content { .tips-content {
width: 100%; width: 100%;
padding: 24px; padding: 24px;
box-sizing: border-box; box-sizing: border-box;
height: calc(100% - 50px); flex: 1;
min-height: 0;
position: relative; position: relative;
display: flex;
flex-direction: column; flex-direction: column;
.icon-close-box { .icon-close-box {
position: absolute; position: absolute;
...@@ -184,6 +198,7 @@ ...@@ -184,6 +198,7 @@
.tips-title { .tips-title {
position: relative; position: relative;
width: 100%; width: 100%;
flex-shrink: 0;
font-weight: 500; font-weight: 500;
font-size: 18px; font-size: 18px;
color: #292d33; color: #292d33;
...@@ -200,6 +215,7 @@ ...@@ -200,6 +215,7 @@
.tips-text { .tips-text {
display: block; display: block;
flex-shrink: 0;
font-size: 15px; font-size: 15px;
color: #5a5e66; color: #5a5e66;
letter-spacing: 0.5px; letter-spacing: 0.5px;
...@@ -213,6 +229,7 @@ ...@@ -213,6 +229,7 @@
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 50px; height: 50px;
flex-shrink: 0;
border-top: 1px solid #e8e8e8; border-top: 1px solid #e8e8e8;
flex-direction: row; flex-direction: row;
.close { .close {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!