Commit 9f8dd65c by Lin

refactor(components): 重构接待中心组件,优化布局和数据处理

- 移除不再使用的 CustomerFile, CustomerFlow, CustomerInfo, CustomerProfileForm, RecordList 组件
- 在 ReceptionCenter 组件中调整进度条显示逻辑,优化样式以支持水平布局
- 引入新的数据获取方法 getPerformanceData 和 getCustomerList,替代原有的注释代码
- 更新 FormDetail 组件,重构数据展示逻辑,增强用户体验
- 调整样式,统一使用 px 单位,提升跨平台兼容性
1 parent 74bc5c9d
<template>
<view class="customer-flow-box">
<text class="customer-flow-title">门店客流情况</text>
<!-- uni-app x 不支持 background-image,用 image+overflow 模拟雪碧图;App 端不支持 calc/vmin 故用固定 px -->
<view class="sprite-icon icon-customer-flow">
<!-- <image class="sprite-img" src="/static/images/reception/bg-reception-flow.png" mode="scaleToFill" /> -->
</view>
<view class="deliveries flex flex-col">
<text class="label-text">累计交付数</text>
<view class="num-wrap">
<text class="num-text">{{ formattedNumber('cumulativeDeliveryCount') }}</text>
</view>
</view>
<view class="touchpoints flex flex-col">
<text class="label-text">实际触客数</text>
<view class="num-wrap">
<text class="num-text">{{ formattedNumber('actualContactCount') }}</text>
</view>
</view>
<view class="touchpoint-rate flex flex-col">
<text class="label-text">实际触客率</text>
<view class="num-wrap">
<text :class="['num-text rate-num', { 'rate-color': showRateColor }]">{{ formattedNumber('contactRate', '%') }}</text>
</view>
</view>
</view>
</template>
<script setup lang="uts">
import { computed } from "vue";
/** 页面数据:cumulativeDeliveryCount、actualContactCount、contactRate */
const props = withDefaults(
defineProps<{
pageData?: UTSJSONObject | null
dataShow?: boolean
}>(),
{
pageData: (): UTSJSONObject => ({}),
dataShow: true
}
);
/** 是否显示触客率高亮色(蓝色) */
const showRateColor = computed((): boolean => {
if (!props.dataShow) {
return false;
}
const pd = props.pageData;
if (pd == null) {
return false;
}
const val = pd["contactRate"];
if (val == null) {
return false;
}
const n = val as number;
return n > 0;
});
/** 格式化数字,无数据时返回 --(与原文一致:0 视为无数据) */
function formattedNumber(key: string, unit: string | null = null): string {
const pd = props.pageData;
const ds = props.dataShow;
if (pd == null || !ds) {
return "--";
}
const val = pd[key];
if (val == null || val == 0 || val == "") {
return "--";
}
let str = "" + val;
if (unit != null && unit != "") {
str = str + unit;
}
return str;
}
</script>
<style scoped lang="scss">
/* 门店客流 - 基准 211px,随父级 flex 比例自适应 */
.customer-flow-box {
position: relative;
width: 100%;
height: 100%;
min-height: 0;
color: #333333;
background-color: #ffffff;
border-radius: 16px;
}
.customer-flow-title {
position: relative;
z-index: 1;
font-size: 14px;
font-weight: 400;
padding: 12px 16px 0;
}
/* 雪碧图布局:宽高 100% 填满父级 */
.sprite-icon {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 16px;
overflow: hidden;
}
.icon-customer-flow .sprite-img {
width: 100%;
height: 100%;
}
.deliveries,
.touchpoints,
.touchpoint-rate {
position: absolute;
font-size: 10px;
box-sizing: border-box;
display: flex;
flex-direction: column;
}
.label-text {
font-size: 10px;
color: inherit;
}
.deliveries,
.touchpoints {
color: #ffffff;
width: 200px;
height: 64px;
left: 16px;
justify-content: center;
align-items: center;
}
.deliveries .num-text,
.touchpoints .num-text {
font-size: 12px;
font-weight: 400;
color: #ffffff;
text-align: center;
}
.deliveries .label-text,
.touchpoints .label-text {
color: #ffffff;
text-align: center;
}
/* 基准 211px 下 54/118/104px,用百分比适配高度变化 */
.deliveries {
top: 25.6%;
padding-top: 0;
}
.touchpoints {
top: 55.9%;
padding-top: 0;
}
.touchpoint-rate {
top: 49.3%;
left: 64.6%;
}
.touchpoint-rate .num-text {
font-size: 14px;
font-weight: bold;
color: #333333;
transition: all 0.15s;
}
.touchpoint-rate .rate-color {
color: #4673ff;
}
</style>
...@@ -18,13 +18,11 @@ ...@@ -18,13 +18,11 @@
</view> </view>
<!-- 下:进度条区域(时间进度暂无接口字段,暂用 achievementRatio 或固定值) --> <!-- 下:进度条区域(时间进度暂无接口字段,暂用 achievementRatio 或固定值) -->
<view class="progress-section"> <view class="progress-section">
<view class="progress-labels"> <view class="progress-label">时间进度</view>
<text class="progress-label">时间进度</text>
<text class="progress-label">{{ timeProgressPercent }}%</text>
</view>
<view class="progress-bar-bg"> <view class="progress-bar-bg">
<view class="progress-bar-fill" :style="{ width: timeProgressPercent + '%' }"></view> <view class="progress-bar-fill" :style="{ width: timeProgressPercent + '%' }"></view>
</view> </view>
<view class="progress-label">{{ timeProgressPercent }}%</view>
</view> </view>
</view> </view>
<!-- Funnel Card --> <!-- Funnel Card -->
...@@ -354,7 +352,7 @@ import { ref, computed, onMounted } from 'vue' ...@@ -354,7 +352,7 @@ import { ref, computed, onMounted } from 'vue'
import type { UnPickerColumn, UnPickerColumnItem, UnPickerConfirmEvent } from '@/uni_modules/uview-unix' import type { UnPickerColumn, UnPickerColumnItem, UnPickerConfirmEvent } from '@/uni_modules/uview-unix'
import FormAdd from './FormAdd.uvue' import FormAdd from './FormAdd.uvue'
import FormDetail from './FormDetail.uvue' import FormDetail from './FormDetail.uvue'
import { getMerchantPerformance } from '@/api/receiption.uts' import { getMerchantPerformance, getCustomerFileList } from '@/api/receiption.uts'
// 产值卡片 tabs:0=本月交付转化率,1=本月交付客单价 // 产值卡片 tabs:0=本月交付转化率,1=本月交付客单价
const outputTabIndex = ref(1); const outputTabIndex = ref(1);
...@@ -794,16 +792,45 @@ function getDefaultCustomerFileParams(): UTSJSONObject { ...@@ -794,16 +792,45 @@ function getDefaultCustomerFileParams(): UTSJSONObject {
"bussinessScene": 2, "bussinessScene": 2,
} }
} }
const getPerformanceData = async () => {
await getMerchantPerformance(defaultMerchantParams).then((res) => {
// TODO: 根据接口返回结构解析并更新业绩看板数据
// UTS:any 对象不能用 . 访问属性,需转成 UTSJSONObject 后用下标访问
const resObj = res as UTSJSONObject
const bizData = resObj['data'] as UTSJSONObject | null
performanceData.value = bizData != null ? bizData : ({} as UTSJSONObject)
console.error("获取业绩数据成功:", performanceData.value)
}).catch((err) => {
console.error("获取业绩数据失败:", err)
})
}
const getCustomerList = async () => {
await getCustomerFileList(getDefaultCustomerFileParams()).then((res) => {
console.log("获取客户档案列表成功:", res);
// customerList.value = res.data.list as UTSJSONObject[]
const resObj = res as UTSJSONObject
const bizData = resObj['data'] as UTSJSONObject | null
if (bizData != null) {
const list = bizData['list']
if (list != null && list instanceof Array) {
const arr: UTSJSONObject[] = []
let i = 0
while (i < list.length) {
const item = list[i] as UTSJSONObject
arr.push(item)
i++
}
customerList.value = arr
}
}
console.log("customerList:", customerList.value);
}).catch((err) => {
console.error("获取客户档案列表失败:", err)
})
}
onMounted(() => { onMounted(() => {
// getMerchantPerformance(defaultMerchantParams).then((res) => { // getPerformanceData()
// // TODO: 根据接口返回结构解析并更新业绩看板数据 // getCustomerList()
// // UTS:any 对象不能用 . 访问属性,需转成 UTSJSONObject 后用下标访问
// const resObj = res as UTSJSONObject
// const bizData = resObj['data'] as UTSJSONObject | null
// performanceData.value = bizData != null ? bizData : ({} as UTSJSONObject)
// }).catch((err) => {
// console.error("获取业绩数据失败:", err)
// })
// 硬编码模拟数据展示 // 硬编码模拟数据展示
performanceData.value = { performanceData.value = {
cumulativeDeliveryCount: 128, cumulativeDeliveryCount: 128,
...@@ -817,29 +844,31 @@ onMounted(() => { ...@@ -817,29 +844,31 @@ onMounted(() => {
personalProduction: 4.2, personalProduction: 4.2,
excellentStoreAvgDeal: 12500, excellentStoreAvgDeal: 12500,
thisStoreKdj: 10800, thisStoreKdj: 10800,
personalKdj: 9500 personalKdj: 9500,
targetProduction: 199,
productionContribution: 100,
} as UTSJSONObject } as UTSJSONObject
// 暂时注释接口请求,使用硬编码模拟数据 // 暂时注释接口请求,使用硬编码模拟数据
// getCustomerFileList(getDefaultCustomerFileParams()).then((res) => { getCustomerFileList(getDefaultCustomerFileParams()).then((res) => {
// const resObj = res as UTSJSONObject const resObj = res as UTSJSONObject
// const bizData = resObj['data'] as UTSJSONObject | null const bizData = resObj['data'] as UTSJSONObject | null
// if (bizData != null) { if (bizData != null) {
// const list = bizData['list'] const list = bizData['list']
// if (list != null && list instanceof Array) { if (list != null && list instanceof Array) {
// const arr: UTSJSONObject[] = [] const arr: UTSJSONObject[] = []
// let i = 0 let i = 0
// while (i < list.length) { while (i < list.length) {
// const item = list[i] as UTSJSONObject const item = list[i] as UTSJSONObject
// arr.push(item) arr.push(item)
// i++ i++
// } }
// customerList.value = arr customerList.value = arr
// } }
// } }
// }).catch((err) => { }).catch((err) => {
// console.error("获取客户档案列表失败:", err) console.error("获取客户档案列表失败:", err)
// }) })
customerList.value = MOCK_CUSTOMER_LIST customerList.value = MOCK_CUSTOMER_LIST
}) })
</script> </script>
...@@ -932,9 +961,10 @@ onMounted(() => { ...@@ -932,9 +961,10 @@ onMounted(() => {
margin-left: 4px; margin-left: 4px;
} }
/* Progress */ /* Progress:一行展示,子项垂直居中对齐 */
.progress-section { .progress-section {
flex-direction: column; flex-direction: row;
align-items: center;
} }
.progress-labels { .progress-labels {
...@@ -944,12 +974,15 @@ onMounted(() => { ...@@ -944,12 +974,15 @@ onMounted(() => {
} }
.progress-label { .progress-label {
font-size: 10px; font-size: 12px;
color: #94A3B8; color: #94A3B8;
} }
.progress-bar-bg { .progress-bar-bg {
flex: 1;
height: 6px; height: 6px;
margin-left: 8px;
margin-right: 8px;
background-color: rgba(255, 255, 255, 0.5); background-color: rgba(255, 255, 255, 0.5);
border-radius: 999px; border-radius: 999px;
overflow: hidden; overflow: hidden;
......
<template>
<view class="data-container">
</view>
</template>
<script setup lang="uts">
</script>
<style scoped lang="scss">
.error-tip {
font-size: toRpx(28);
padding: toRpx(32) toRpx(60) toRpx(24);
margin-top: toRpx(100);
margin-bottom: toMinusRpx(80);
text-align: center;
background-color: rgb(254, 237, 234);
color: #f45c3d;
}
.data-container {
background: #ffffff59;
border-radius: toRpx(48);
margin: toRpx(80) toRpx(66) toRpx(80) 0;
height: calc(100% - #{toRpx(160)});
box-shadow: inset 0 0 toRpx(16) 0 #ffffff;
border: toRpx(2) solid #fff;
box-sizing: border-box;
position: relative;
.nav-bar {
position: absolute;
width: 100%;
height: toRpx(96);
left: 0;
top: toRpx(28);
z-index: 9;
text-align: center;
font-weight: 700;
font-size: toRpx(32);
color: #1a1a1a;
line-height: toRpx(96);
.back {
position: absolute;
left: 0;
top: 0;
height: 100%;
aspect-ratio: 1/1;
display: flex;
align-items: center;
justify-content: center;
}
}
.form {
display: flex;
flex-wrap: wrap;
gap: toRpx(80) toRpx(160);
padding: toRpx(80);
margin-top: toRpx(60);
&-item {
width: calc(50% - #{toRpx(80)});
display: flex;
align-items: center;
color: #6c6c70;
font-size: toRpx(30);
height: toRpx(80);
box-sizing: border-box;
.label {
position: relative;
margin-left: auto;
flex-shrink: 0;
width: toRpx(124);
margin-right: toRpx(30);
}
.required {
&::before {
content: '*';
color: #ff0000;
position: absolute;
left: toMinusRpx(20);
top: 50%;
transform: translate(0, -50%);
}
}
.value {
height: toRpx(80);
flex: 1;
border: toRpx(2) solid #e8e8ea;
background: #ffffff;
margin-left: toRpx(32);
box-sizing: border-box;
padding: 0 toRpx(40);
border-radius: toRpx(8);
&.error {
border: toRpx(2) solid #f24724;
border-radius: toRpx(8);
}
.input,
.select {
width: 100%;
height: 100%;
border: none !important;
outline: none;
padding: 0 !important;
font-size: toRpx(30);
color: #333;
&::placeholder {
color: #c9c9c9;
}
}
.placeholderStyle {
color: #999999;
}
.arrow {
color: #999 !important;
margin-left: auto;
flex-shrink: 0;
}
}
}
}
.footer-box {
display: flex;
align-items: center;
justify-content: center;
gap: toRpx(34);
padding: 0 toRpx(280);
.cancel-btn {
height: toRpx(80);
background: #dae9ff;
border-radius: toRpx(48);
line-height: toRpx(80);
text-align: center;
color: #2c66f7;
flex: 1;
}
.submit-btn {
height: toRpx(80);
background-image: linear-gradient(0deg, #2c66f7 0%, #48a6ff 100%);
border-radius: toRpx(48);
line-height: toRpx(80);
text-align: center;
flex: 1;
color: #ffffff;
}
}
}
.select-box {
margin: toRpx(40) 0;
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: toRpx(20);
overflow-y: scroll;
max-height: 50vh;
padding-bottom: toRpx(60);
.select-item {
text-align: center;
height: toRpx(68);
line-height: toRpx(68);
opacity: 1;
border: toRpx(2) solid #dce0e6;
color: #292d33;
font-size: toRpx(28);
border-radius: toRpx(8);
&.checked {
border: toRpx(2) solid #292d33;
}
}
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!