Commit 177e1a0e by Lin

refactor(reception): 重构接待中心组件以优化布局和样式

- 更新 launch.json 中的 playground 类型为 standard
- 修改 ReceptionCenter 组件,调整预录表单和客户档案详情的展示方式,采用全屏覆盖层
- 移除 FormAdd 和 FormDetail 组件中的 un-popup,改为使用自定义样式的视图结构
- 添加新的样式类以支持绝对定位和灵活布局,提升用户体验
1 parent 3a141ba8
......@@ -8,7 +8,7 @@
},
{
"customPlaygroundType" : "device",
"playground" : "custom",
"playground" : "standard",
"type" : "uni-app:app-ios"
}
]
......
<template>
<un-popup
:show="props.show"
mode="right"
:width="popupSize.w"
:height="popupSize.h"
closeable
closeOnClickOverlay
safeAreaInsetBottom
safeAreaInsetTop
:customStyle="{ overflow: 'hidden', boxSizing: 'border-box' }"
@close="handleClose"
@open="onPopupOpen"
>
<view class="form-add-root">
<view class="form-add-wrap">
<view class="form-add-header">
<text class="form-add-title">客户档案</text>
......@@ -132,11 +120,11 @@
@cancel="datePickerShow = false"
@close="datePickerShow = false"
/>
</un-popup>
</view>
</template>
<script setup lang="uts">
import { ref, onMounted, watch, nextTick, computed } from 'vue'
import { ref, watch, nextTick, computed } from 'vue'
import { ComponentPublicInstance } from 'vue'
import CarBrands from '@/components/CarBrands.uvue'
import SenceSelect from './SenceSelect.uvue'
......@@ -145,14 +133,6 @@ import { saveVisitsInfo, updateVisitsInfo, findVisitsInfo } from '@/api/receipti
import { storage } from '@/utils/storage.uts'
const phoneRex = /^1[3-9]\d{9}$/
// 使用窗口实际尺寸,避免 100% 导致溢出
type PopupSize = { w: string; h: string }
function getPopupSize(): PopupSize {
const info = uni.getWindowInfo()
const w = info.windowWidth > 0 ? info.windowWidth : info.screenWidth
const h = info.windowHeight > 0 ? info.windowHeight : info.screenHeight
return { w: w + 'px', h: h + 'px' }
}
const props = withDefaults(
defineProps<{
......@@ -163,16 +143,6 @@ const props = withDefaults(
{ show: false, initialRecord: null }
)
const popupSize = ref<PopupSize>({ w: '375px', h: '667px' })
onMounted(() => {
popupSize.value = getPopupSize()
})
function onPopupOpen(): void {
popupSize.value = getPopupSize()
}
const emit = defineEmits<{
'close': []
/** 保存或重复归类处理完成后通知父级刷新列表 */
......@@ -238,7 +208,7 @@ const brandCascaderShow = ref(false)
const carBrandSelectRef = ref<ComponentPublicInstance | null>(null)
watch(brandCascaderShow, (show: boolean) => {
// 双 nextTick:CarBrands 在 un-popup 内,确保弹层渲染后再取 ref 调用 open
// 双 nextTick:确保子面板挂载后再取 ref 调用 open
nextTick(() => {
nextTick(() => {
const r = carBrandSelectRef.value
......@@ -523,7 +493,8 @@ watch(
return
}
void loadEditDetailIfNeeded()
}
},
{ immediate: true }
)
function handleClose(): void {
......@@ -683,6 +654,17 @@ async function handleSubmit(): Promise<void> {
</script>
<style lang="scss" scoped>
.form-add-root {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 0;
overflow: hidden;
box-sizing: border-box;
background-color: #ffffff;
}
.form-add-wrap {
display: flex;
flex-direction: column;
......
<template>
<un-popup
:show="props.show"
mode="right"
:width="popupSize.w"
:height="popupSize.h"
closeable
closeOnClickOverlay
safeAreaInsetBottom
safeAreaInsetTop
:content-draggable="false"
:customStyle="{ boxSizing: 'border-box' }"
@close="handleClose"
@open="onPopupOpen"
>
<view class="form-detail-root">
<view class="form-detail-top-bar">
<view class="form-detail-back-btn" @click="handleClose">
<un-icon name="arrow-left"></un-icon>
</view>
</view>
<view class="form-detail-wrap" :style="formDetailWrapStyle">
<view class="form-detail-header">
<text class="form-detail-title">客户档案</text>
......@@ -74,7 +66,7 @@
</list-item>
</list-view>
</view>
</un-popup>
</view>
</template>
<script setup lang="uts">
......@@ -94,13 +86,8 @@ type GoodsCardItem = {
customerTag: string
}
type PopupSize = { w: string; h: string }
function getPopupSize(): PopupSize {
const info = uni.getWindowInfo()
const w = info.windowWidth > 0 ? info.windowWidth : info.screenWidth
const h = info.windowHeight > 0 ? info.windowHeight : info.screenHeight
return { w: w + 'px', h: h + 'px' }
}
/** 顶部返回栏占位(与 updateLayoutHeights 内扣减一致) */
const FORM_DETAIL_TOP_BAR_PX = 48
const props = withDefaults(
defineProps<{
......@@ -119,8 +106,6 @@ const materialGoodsCards = ref<GoodsCardItem[]>([])
/** 仅在接口成功返回业务 data 后为 true,失败或未请求时回退 parseGoodsListFromDetail */
const materialGoodsFromApi = ref(false)
const popupSize = ref<PopupSize>({ w: '375px', h: '667px' })
/** 弹层内父级常无法把 height:100% 传到子节点;list-view 需明确 px 高度才能纵向滚动 */
const wrapHeightPx = ref(667)
const scrollAreaHeightPx = ref(400)
......@@ -131,7 +116,10 @@ const FORM_DETAIL_VERTICAL_RESERVE = 120
function updateLayoutHeights(): void {
const info = uni.getWindowInfo()
const wh = info.windowHeight > 0 ? info.windowHeight : info.screenHeight
wrapHeightPx.value = wh > 0 ? wh : 667
const fullH = wh > 0 ? wh : 667
// 全屏覆盖层内:内容区 = 窗口高度 − 顶部返回栏
const contentH = fullH - FORM_DETAIL_TOP_BAR_PX
wrapHeightPx.value = contentH > 200 ? contentH : 200
const scrollH = wrapHeightPx.value - FORM_DETAIL_VERTICAL_RESERVE
scrollAreaHeightPx.value = scrollH > 160 ? scrollH : 160
}
......@@ -149,7 +137,6 @@ const scrollViewStyle = computed((): UTSJSONObject => {
})
onMounted(() => {
popupSize.value = getPopupSize()
updateLayoutHeights()
})
......@@ -278,6 +265,10 @@ watch(
materialGoodsFromApi.value = false
return
}
updateLayoutHeights()
nextTick(() => {
updateLayoutHeights()
})
const r = props.detail
if (r == null) {
resolvedDetail.value = null
......@@ -285,17 +276,10 @@ watch(
}
resolvedDetail.value = r
void loadDetailFromApiIfNeeded(r)
}
},
{ immediate: true }
)
function onPopupOpen(): void {
popupSize.value = getPopupSize()
updateLayoutHeights()
nextTick(() => {
updateLayoutHeights()
})
}
const emit = defineEmits<{
'close': []
}>()
......@@ -693,6 +677,37 @@ function handleClose(): void {
</script>
<style lang="scss" scoped>
.form-detail-root {
display: flex;
flex-direction: column;
width: 100%;
height: 100%;
min-height: 0;
overflow: hidden;
box-sizing: border-box;
background-color: #ffffff;
}
.form-detail-top-bar {
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
width: 100%;
flex-shrink: 0;
box-sizing: border-box;
padding-left: 8px;
padding-top: 5px;
}
.form-detail-back-btn {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 8px;
}
.form-detail-wrap {
display: flex;
flex-direction: column;
......
<template>
<!-- 与 HomeFrame 接待详情一致:预录表单用绝对定位层 + v-show,不再使用 FormAdd 内 un-popup -->
<view class="reception-center-page">
<!-- 根节点包一层:保证 scroll-view 在 flex 父级内获得确定高度,否则 4.0+ 默认高度=内容高,无法内部滚动、scrolltolower 不触发 -->
<view class="reception-dashboard-root">
<scroll-view
......@@ -211,14 +213,24 @@
</scroll-view>
</view>
<un-picker :show="show" :columns="columns" @close="onClose" @cancel="onClose" @confirm="onConfirm" />
<!-- 预录信息:由 FormAdd 组件统一维护 -->
<FormAdd
:show="preEntryPopupVisible"
:initial-record="formAddInitialRecord"
@close="onPreEntryClose"
@saved="onFormAddSaved"
/>
<FormDetail :show="showReceptionDetail" :detail="receptionDetailItem" @close="onReceptionDetailClose" />
<!-- 预录信息:全屏覆盖层展示,与 index 中 ReceptionDetail 同模式 -->
<view v-show="preEntryPopupVisible" class="form-add-inner">
<FormAdd
:show="preEntryPopupVisible"
:initial-record="formAddInitialRecord"
@close="onPreEntryClose"
@saved="onFormAddSaved"
/>
</view>
<!-- 客户档案详情:全屏覆盖层,与预录 FormAdd 同模式 -->
<view v-show="showReceptionDetail" class="form-detail-inner">
<FormDetail
:show="showReceptionDetail"
:detail="receptionDetailItem"
@close="onReceptionDetailClose"
/>
</view>
</view>
</template>
<script setup lang="uts">
......@@ -1211,6 +1223,31 @@ onUnmounted(() => {
</script>
<style>
/* 接待中心页面包一层:供预录表单绝对定位覆盖 */
.reception-center-page {
flex: 1;
width: 100%;
height: 100%;
min-height: 0;
position: relative;
display: flex;
flex-direction: column;
}
/* 预录信息 / 客户档案详情 全屏层:对齐 HomeFrame .reception-detail-inner */
.form-add-inner,
.form-detail-inner {
position: absolute;
left: 0;
top: 0;
right: 0;
bottom: 0;
display: flex;
flex-direction: column;
z-index: 10;
background-color: #ffffff;
}
/* 接待中心外层:占满 HomeFrame 内 reception-center-inner,给 scroll-view 明确高度上限 */
.reception-dashboard-root {
flex: 1;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!